Skip to content

Commit 4227788

Browse files
committed
FLUIDSIM_TYPE_FFT2D and FLUIDSIM_TYPE_FFT3D
1 parent 52a98ca commit 4227788

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pytest_cov_html_full:
103103

104104
define _pytest_mpi_operators3d
105105
$(call _init_coverage)
106-
FLUIDSIM_TYPE_FFT=$(1) TRANSONIC_NO_REPLACE=1 mpirun -np $(MPI_NUM_PROCS) coverage run -p -m pytest -v --exitfirst fluidsim/operators/test/test_operators3d.py -p no:warnings
106+
FLUIDSIM_TYPE_FFT3D=$(1) TRANSONIC_NO_REPLACE=1 mpirun -np $(MPI_NUM_PROCS) coverage run -p -m pytest -v --exitfirst fluidsim/operators/test/test_operators3d.py -p no:warnings
107107
$(call _end_coverage_combine)
108108
endef
109109

@@ -118,8 +118,8 @@ pytest_mpi_with_pfft:
118118

119119
pytest_mpi_with_p3dfft:
120120
$(call _init_coverage)
121-
FLUIDSIM_TYPE_FFT=fft3d.mpi_with_p3dfft TRANSONIC_NO_REPLACE=1 mpirun -np $(MPI_NUM_PROCS) \
121+
FLUIDSIM_TYPE_FFT3D=fft3d.mpi_with_p3dfft TRANSONIC_NO_REPLACE=1 mpirun -np $(MPI_NUM_PROCS) \
122122
coverage run -p -m pytest -v --exitfirst fluidsim/operators/test/test_operators3d.py::TestCoarse
123-
FLUIDSIM_TYPE_FFT=fft3d.mpi_with_p3dfft TRANSONIC_NO_REPLACE=1 mpirun -np $(MPI_NUM_PROCS) \
123+
FLUIDSIM_TYPE_FFT3D=fft3d.mpi_with_p3dfft TRANSONIC_NO_REPLACE=1 mpirun -np $(MPI_NUM_PROCS) \
124124
coverage run -p -m pytest -v --exitfirst fluidsim/operators/test/test_operators3d.py -k "not TestCoarse"
125125
$(call _end_coverage_combine)

doc/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ Fluidsim is sensitive to environment variables:
142142

143143
- `FLUIDDYN_PATH_SCRATCH`: working directory (can be useful on some clusters).
144144

145-
- `FLUIDSIM_TYPE_FFT`: set the Fluidfft method (see
146-
<https://fluidfft.readthedocs.io/en/latest/plugins.html>).
145+
- `FLUIDSIM_TYPE_FFT2D` and `FLUIDSIM_TYPE_FFT3D`: set the Fluidfft method
146+
(see <https://fluidfft.readthedocs.io/en/latest/plugins.html>).
147147

148148
## Dependencies with different flavours
149149

fluidsim/operators/base.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,23 @@
1717

1818
import os
1919

20+
from warnings import warn
21+
2022
import numpy as np
2123

2224
from fluiddyn.util import mpi
2325

2426

25-
def _get_type_fft_from_params_and_env(params):
26-
if "FLUIDSIM_TYPE_FFT" in os.environ:
27-
if params.oper.type_fft != "default":
28-
raise ValueError(
29-
"FLUIDSIM_TYPE_FFT is set and params.oper.type_fft != 'default'"
30-
)
31-
type_fft = os.environ["FLUIDSIM_TYPE_FFT"]
32-
print(f"Using FLUIDSIM_TYPE_FFT={type_fft}")
33-
return type_fft
27+
def _get_type_fft_from_params_and_env(params, dim: str):
28+
var_name = "FLUIDSIM_TYPE_FFT" + dim
29+
if var_name in os.environ:
30+
if params.oper.type_fft == "default":
31+
type_fft = os.environ[var_name]
32+
print(f"Using {var_name}={type_fft}")
33+
return type_fft
34+
elif params.oper.type_fft != "sequential":
35+
warn(f"not using {var_name} since params.oper.type_fft != 'default'")
36+
return params.oper.type_fft
3437
else:
3538
return params.oper.type_fft
3639

fluidsim/operators/operators2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self, params):
140140
ny,
141141
params.oper.Lx,
142142
params.oper.Ly,
143-
fft=_get_type_fft_from_params_and_env(params),
143+
fft=_get_type_fft_from_params_and_env(params, "2D"),
144144
coef_dealiasing=params.oper.coef_dealiasing,
145145
)
146146

fluidsim/operators/operators3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def __init__(self, params=None):
226226
params.oper.Lx,
227227
params.oper.Ly,
228228
params.oper.Lz,
229-
fft=_get_type_fft_from_params_and_env(params),
229+
fft=_get_type_fft_from_params_and_env(params, "3D"),
230230
coef_dealiasing=params.oper.coef_dealiasing,
231231
)
232232

fluidsim/operators/test/test_operators3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515

1616
def xfail_if_fluidfft_class_not_importable(func):
17-
if not FLUIDFFT_INSTALLED or "FLUIDSIM_TYPE_FFT" not in os.environ:
17+
if not FLUIDFFT_INSTALLED or "FLUIDSIM_TYPE_FFT3D" not in os.environ:
1818
return func
1919

2020
from fluidfft import import_fft_class
2121

2222
try:
23-
import_fft_class(os.environ["FLUIDSIM_TYPE_FFT"])
23+
import_fft_class(os.environ["FLUIDSIM_TYPE_FFT3D"])
2424
except ImportError:
2525
ImportError_fft_class = True
2626
else:

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_mpi_fft_lib(session, method_fft, nprocs=2, _k_expr=None, env=None):
3030
env = {}
3131
else:
3232
env = env.copy()
33-
env.update({"TRANSONIC_NO_REPLACE": "1", "FLUIDSIM_TYPE_FFT": method_fft})
33+
env.update({"TRANSONIC_NO_REPLACE": "1", "FLUIDSIM_TYPE_FFT3D": method_fft})
3434

3535
print(f"test for method {method_fft}")
3636
session.run(*cmd, external=True, env=env)

0 commit comments

Comments
 (0)