Enhance modularity for inheriting FluidSim
Created originally on Bitbucket by avmo (Ashwin Vishnu)
I am in the process of using a FluidSim framework to create a package eturb
to script compilation and run of Nek5000 files. How I approached it would be a long story, but to put it briefly,
- I use
snakemake
package to enable scripting and launching the solver (sim.make
). - I will use
paraview
’s python interface to handle output files (sim.output.phys_fields
)
I started borrowing parts of fluidsim
to make a “solver” which does nothing more than managing parameters, copying fortran source files, compiling and executing them. See a sample of what I have below:
In [1]: from eturb.solvers.abl import Simul
In [2]: params = Simul.create_default_params()
In [3]: sim = Simul(params)
INFO Copying with shutil.copytree ...
WARNING Python < 3.8: shutil.copytree may not proceed if directories exist.
WARNING [Errno 17] File exists: '/home/avmo/.local/scratch/tmp/abl_run_L=2pix2pix2pi_48x48x48_2020-01-22_16-42-57'
INFO Copying with shutil.copy2 ...
INFO Copied: /home/avmo/src/exabl/eturb/src/abl -> /home/avmo/.local/scratch/tmp/abl_run_L=2pix2pix2pi_48x48x48_2020-01-22_16-42-57
INFO ******************************************
INFO solver: <class 'eturb.solvers.abl.SimulABL'>
INFO path_run: /home/avmo/.local/scratch/tmp/abl_run_L=2pix2pix2pi_48x48x48_2020-01-22_16-42-57
INFO ******************************************
In [4]: sim.info
Out[4]:
<fluiddyn.util.paramcontainer.ParamContainer object at 0x7fde78059990>
<info_simul>
<solver class_name="SimulNek" module_name="eturb.solvers.base"
short_name="abl">
<classes>
<Oper class_name="Operators" module_name="eturb.operators"/>
<Output class_name="Output" module_name="abl">
<classes>
<PrintStdOut class_name="PrintStdOut"
module_name="eturb.output.print_stdout"/>
<PhysFields class_name="PhysFields"
module_name="eturb.output.phys_fields"/>
</classes>
</Output>
<Make class_name="Make" module_name="eturb.make"/>
</classes>
</solver>
<params NEW_DIR_RESULTS="True"
path_run="/home/avmo/.local/scratch/tmp/abl_run_L=2pix2pix2pi_48x48x48_2020-01-22_16-42-57"
short_name_type_run="run">
<oper Lx="6.283185307179586" Ly="6.283185307179586" Lz="6.283185307179586"
coef_dealiasing="0.6666666666666666" nx="48" ny="48" nz="48"/>
<output HAS_TO_SAVE="True" ONLINE_PLOT_OK="True" period_refresh_plots="1"
sub_directory=""/>
<nek>
<GENERAL _enabled="True" dealiasing="True" dt="nan" endTime="nan"
extrapolation="standard" filterCutoffRatio="0.65"
filterWeight="12.0" filtering="None" loglevel="2" numSteps="1"
optLevel="2" startFrom="" stopAt="numSteps" targetCFL="0.5"
timeStepper="BDF2" userParam03="1" variableDT="True"
writeControl="timeStep" writeDoublePrecision="True"
writeInterval="10"/>
<PROBLEMTYPE _enabled="True" equation="incompNS" stressFormulation="False"
variableProperties="False"/>
<VELOCITY _enabled="True" density="nan" residualProj="False"
residualTol="nan" viscosity="nan"/>
<PRESSURE _enabled="True" preconditioner="semg_xxt" residualProj="False"
residualTol="nan"/>
<MESH _enabled="False"/>
<TEMPERATURE _enabled="False" residualProj="False" residualTol="nan"/>
<SCALAR01 _enabled="False" residualProj="False" residualTol="nan"/>
<CVODE _enabled="False"/>
</nek>
</params>
The monolithic nature of Nek5000 means, I may not be able to interface the subroutines directly. Which in turn means, I cannot have access to runtime states. But this approach seems better than nothing! During this endeavour, I had to copy certain parts and create some dummy classes, which I outline below:
-
fluidsim.base.output.base.OutputBase
does some cool `path_run` management, but it is hard to get rid of print_stdout and phys_fields classes. It would be nice to make a lighter version of this class -
fluidsim.base.params.create_params
had to be copied and modified, since it does not allow even child classes of `Parameters` class to be created! Ineturb
I have a derived class fromParameters
to provide special methods for Nek5000 parameters format. - I wanted to print some initialization messages, as done by
init_with_oper_and_state
but the method relies on too many dependents liketime_stepping
,init_fields
, andstate
which I do not intend on creating. - No way to inherit a bare
Operators
class without having thefluidfft
dependency. It would be useful to have 1D, 2D and 3D Operator base classes with parameters likenx
.. andLx
initialized and toproduce_str_describing_oper
from them!