Skip to content

Commit

Permalink
Merge upstream again
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinvis committed Jan 8, 2019
2 parents 8898dba + 16451b2 commit ded3a7d
Show file tree
Hide file tree
Showing 120 changed files with 772 additions and 475 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cache:
install:
- pip install -U pip setuptools wheel six colorlog
- pip install -U pipenv tox-pipenv coverage fluiddevops
- pip install -U numpy cython mako mpi4py "fluidpythran>=0.1.4" # To be removed when pip==10 is out and this step can be bootstrapped
- pip install -U numpy cython mako mpi4py fluidpythran # To be removed when pip==10 is out and this step can be bootstrapped

before_script:
- |
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ tests_mpi:
_tests_coverage:
mkdir -p .coverage
coverage run -p -m fluidsim.util.testing -v
mpirun -np 2 coverage run -p -m fluidsim.util.testing -v
FLUIDPYTHRAN_NO_REPLACE=1 coverage run -p -m fluidsim.util.testing -v
FLUIDPYTHRAN_NO_REPLACE=1 mpirun -np 2 coverage run -p -m fluidsim.util.testing -v

_report_coverage:
coverage combine
Expand All @@ -44,6 +45,11 @@ _report_coverage:

coverage: _tests_coverage _report_coverage

coverage_short:
mkdir -p .coverage
FLUIDPYTHRAN_NO_REPLACE=1 coverage run -p -m fluidsim.util.testing -v
make _report_coverage

lint:
pylint -rn --rcfile=pylintrc --jobs=$(shell nproc) fluidsim --exit-zero

Expand Down
1 change: 0 additions & 1 deletion bench/spectraldns/bench_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
mpirun -np 2 fluidsim-bench 128 -d 3 -s ns3d -it 10
"""
from __future__ import print_function
import time
import numpy as np
from numpy import zeros, sum, float64, sin, cos, prod, asscalar
Expand Down
1 change: 0 additions & 1 deletion bench/spectraldns/profile_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
fluidsim-bench 128 -d 3 -s ns3d -it 10
"""
from __future__ import print_function
import time
import numpy as np
from numpy import zeros, sum, float64, sin, cos, prod, asscalar
Expand Down
2 changes: 1 addition & 1 deletion bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ pipelines:
caches:
- pip
script:
- pip install -U tox "fluidpythran>=0.1.4" --user
- pip install -U tox fluidpythran --user
- tox -e py36,codecov
3 changes: 0 additions & 3 deletions doc/example_from_numpy_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
a line by itself, preferably preceeded by a blank line.
"""
from __future__ import division, absolute_import, print_function

import os # standard library imports first

Expand Down Expand Up @@ -121,5 +120,3 @@ def foo(var1, var2, long_var_name='hi') :
"""

pass


53 changes: 28 additions & 25 deletions doc/examples/simul_ns3dbouss_initfields_in_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@

params = Simul.create_default_params()

params.output.sub_directory = 'examples'
params.output.sub_directory = "examples"

nx = 48//2
ny = 64//2
nz = 96//2
nx = 48 // 2
ny = 64 // 2
nz = 96 // 2
Lx = 3
params.oper.nx = nx
params.oper.ny = ny
params.oper.nz = nz
params.oper.Lx = Lx
params.oper.Ly = Ly = Lx/nx*ny
params.oper.Lz = Lz = Lx/nx*nz
fft = 'fftwmpi3d'
params.oper.Ly = Ly = Lx / nx * ny
params.oper.Lz = Lz = Lx / nx * nz
fft = "fftwmpi3d"
# fft = 'fftw1d'
# fft = 'pfft'
# fft = 'p3dfft'

# for sequential runs, just comment these 2 lines
params.oper.type_fft = 'fluidfft.fft3d.mpi_with_' + fft
params.oper.type_fft = "fluidfft.fft3d.mpi_with_" + fft
params.short_name_type_run = fft


Expand Down Expand Up @@ -62,19 +62,19 @@
"""
n = 8
C = 1.
dx = Lx/nx
C = 1.0
dx = Lx / nx
B = 1
D = 1
eps = 1e-2*B**(3/2)*D**(1/2)
params.nu_8 = (dx/C)**((3*n-2)/3) * eps**(1/3)
eps = 1e-2 * B ** (3 / 2) * D ** (1 / 2)
params.nu_8 = (dx / C) ** ((3 * n - 2) / 3) * eps ** (1 / 3)

printby0(f'nu_8 = {params.nu_8:.3e}')
printby0(f"nu_8 = {params.nu_8:.3e}")

params.time_stepping.USE_T_END = True
params.time_stepping.t_end = 10.
params.time_stepping.t_end = 10.0

params.init_fields.type = 'in_script'
params.init_fields.type = "in_script"

params.output.periods_print.print_stdout = 1e-1

Expand All @@ -86,18 +86,19 @@

# here we have to initialize the flow fields

variables = {k: 1e-2 * sim.oper.create_arrayX_random()
for k in ('vx', 'vy', 'vz')}
variables = {
k: 1e-2 * sim.oper.create_arrayX_random() for k in ("vx", "vy", "vz")
}

X, Y, Z = sim.oper.get_XYZ_loc()

x0 = Lx/2.
y0 = Ly/2.
z0 = Lz/2.
R2 = (X-x0)**2 + (Y-y0)**2 + (Z-z0)**2
x0 = Lx / 2.0
y0 = Ly / 2.0
z0 = Lz / 2.0
R2 = (X - x0) ** 2 + (Y - y0) ** 2 + (Z - z0) ** 2
r0 = 0.5
b = -0.5*(1-np.tanh((R2 - r0**2)/0.2**2))
variables['b'] = b
b = -0.5 * (1 - np.tanh((R2 - r0 ** 2) / 0.2 ** 2))
variables["b"] = b

sim.state.init_statephys_from(**variables)

Expand All @@ -106,9 +107,11 @@

sim.time_stepping.start()

printby0(f"""
printby0(
f"""
To visualize the output with Paraview, create a file states_phys.xmf with:
fluidsim-create-xml-description {sim.output.path_run}
""")
"""
)
79 changes: 79 additions & 0 deletions doc/test_cases/Taylor_Green_vortices/run_simul.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""Taylor-Green Vortex at Re = 1600
===================================
https://www.grc.nasa.gov/hiocfd/wp-content/uploads/sites/22/case_c3.3.pdf
"""

import numpy as np

from fluidsim.solvers.ns3d.solver import Simul

params = Simul.create_default_params()

Re = 1600
V0 = 1.0
L = 1
params.nu_2 = V0 * L / Re

params.init_fields.type = "in_script"

params.time_stepping.t_end = 20.0 * L / V0

nx = 128 // 4
params.oper.nx = params.oper.ny = params.oper.nz = nx
lx = params.oper.Lx = params.oper.Ly = params.oper.Lz = 2 * np.pi * L

params.output.periods_save.phys_fields = 4
params.output.periods_save.spatial_means = 0.2
params.output.periods_save.spectra = 0.5

sim = Simul(params)

X, Y, Z = sim.oper.get_XYZ_loc()

vx = V0 * np.sin(X / L) * np.cos(Y / L) * np.cos(Z / L)
vy = -V0 * np.cos(X / L) * np.sin(Y / L) * np.cos(Z / L)
vz = sim.oper.create_arrayX(value=0)

sim.state.init_statephys_from(vx=vx, vy=vy, vz=vz)

sim.state.statespect_from_statephys()
sim.state.statephys_from_statespect()

# only useful to plot fields before time_stepping
# sim.output.init_with_initialized_state()

if __name__ == "__main__":

sim.time_stepping.start()

from fluiddyn.util.mpi import printby0

printby0(
f"""
To visualize the output with Paraview, create a file states_phys.xmf with:
fluidsim-create-xml-description {sim.output.path_run}
# To visualize with fluidsim:
cd {sim.output.path_run}
ipython
# in ipython:
from fluidsim import load_sim_for_plot
sim = load_sim_for_plot()
sim.output.phys_fields.set_equation_crosssection(f'x={{sim.oper.Lx/4}}')
sim.output.phys_fields.animate('vx')
sim.output.phys_fields.plot(field="vx", time=10)
sim.output.spatial_means.plot()
sim.output.spectra.plot1d(tmin=12, tmax=16, coef_compensate=5/3)
"""
)
5 changes: 4 additions & 1 deletion fluidsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
Path(os.environ["FLUIDSIM_PATH"]) / ".fluidpythran"
)

_is_testing = False

if any(
any(test_tool in arg for arg in sys.argv)
for test_tool in ("pytest", "unittest", "fluidsim-test")
for test_tool in ("pytest", "unittest", "fluidsim-test", "coverage")
):
_is_testing = True
from fluiddyn.util import mpi

mpi.printby0(
Expand Down
3 changes: 0 additions & 3 deletions fluidsim/base/basilisk/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
:private-members:
"""
from __future__ import division

from builtins import object

import numpy as np

Expand Down
2 changes: 0 additions & 2 deletions fluidsim/base/forcing/anisotropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
:private-members:
"""
from __future__ import division
from __future__ import print_function

from math import degrees

Expand Down
5 changes: 4 additions & 1 deletion fluidsim/base/forcing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def __init__(self, sim):
ClassForcing = dict_classes[self.type_forcing]

self.sim = sim
self.forcing_maker = ClassForcing(sim)
if not sim.params.ONLY_COARSE_OPER:
self.forcing_maker = ClassForcing(sim)
else:
self.forcing_maker = None

self._t_last_computed = -np.inf

Expand Down
8 changes: 4 additions & 4 deletions fluidsim/base/forcing/specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
:private-members:
"""
from __future__ import division
from __future__ import print_function

from builtins import object, str

from copy import deepcopy
from math import radians
Expand Down Expand Up @@ -89,6 +85,8 @@ def compute(self):
if isinstance(obj, dict):
kwargs = obj
else:
if self.sim.params.forcing.key_forced is None:
raise ValueError("params.forcing.key_forced must be initialized.")
kwargs = {self.sim.params.forcing.key_forced: obj}
self.fstate.init_statespect_from(**kwargs)

Expand All @@ -115,6 +113,8 @@ def compute_forcing_fft_each_time(self):
if isinstance(obj, dict):
kwargs = {key: self.sim.oper.fft(value) for key, value in obj.items()}
else:
if self.sim.params.forcing.key_forced is None:
raise ValueError("params.forcing.key_forced must be initialized.")
kwargs = {self.sim.params.forcing.key_forced: self.sim.oper.fft(obj)}
return kwargs

Expand Down
4 changes: 0 additions & 4 deletions fluidsim/base/init_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
:private-members:
"""
from __future__ import division
from __future__ import print_function

from builtins import range
from builtins import object
import os
from copy import deepcopy

Expand Down
Loading

0 comments on commit ded3a7d

Please sign in to comment.