Breaking of a dam (fluidsimfoam-dam solver)#

We created a solver fluidsimfoam-dam to reproduce the OpenFOAM tutorial Breaking of a dam.

from fluidsimfoam_dam import Simul

To run a sequential simulation:

params = Simul.create_default_params()
params.output.sub_directory = "doc_fluidsimfoam/dam"
params.control_dict.end_time = 1.0
sim = Simul(params)
pyvista is not importable so it cannot be used. You could install it (`pip install pyvista`) and retry.
path_run: /home/docs/Sim_data/doc_fluidsimfoam/dam/dam_run_2023-06-27_21-21-43
INFO     sim:                        <class 'fluidsimfoam_dam.Simul'>                                              
         sim.output.log:             <class 'fluidsimfoam.output.log.Log'>                                         
         sim.output.fields:          <class 'fluidsimfoam.output.fields.Fields'>                                   
         input_files:                                                                                              
           - in 0:          U alpha_water p_rgh                                                                    
           - in constant:   g transportProperties turbulenceProperties                                             
           - in system:     blockMeshDict controlDict decomposeParDict fvSchemes fvSolution sampling setFieldsDict 
         sim.output:                 <class 'fluidsimfoam_dam.output.OutputDam'>                                   
         sim.oper:                   <class 'fluidsimfoam.operators.Operators'>                                    
         sim.init_fields:            <class 'fluidsimfoam.init_fields.InitFields'>                                 
         sim.make:                   <class 'fluidsimfoam.make.MakeInvoke'>                                        
                                                                                                                   
sim.make.exec("polymesh")
Hide code cell output
blockMesh
sim.make.exec("run")
1
setFields
Starting simulation in 
/home/docs/Sim_data/doc_fluidsimfoam/dam/dam_run_2023-06-27_21-21-43
end_time = 1.0
Simulation done. path_run:
/home/docs/Sim_data/doc_fluidsimfoam/dam/dam_run_2023-06-27_21-21-43
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
Cell In[4], line 1
----> 1 sim.make.exec("run")

File ~/checkouts/readthedocs.org/user_builds/fluidsimfoam/checkouts/stable/src/fluidsimfoam/make.py:18, in MakeInvoke.exec(self, task_name, stdout)
     14 def exec(self, task_name, stdout=None):
     15     self.process = run(
     16         ["inv", task_name], cwd=self.sim.path_run, stdout=stdout
     17     )
---> 18     self.process.check_returncode()

File ~/.asdf/installs/python/3.10.12/lib/python3.10/subprocess.py:457, in CompletedProcess.check_returncode(self)
    455 """Raise CalledProcessError if the exit code is non-zero."""
    456 if self.returncode:
--> 457     raise CalledProcessError(self.returncode, self.args, self.stdout,
    458                              self.stderr)

CalledProcessError: Command '['inv', 'run']' returned non-zero exit status 1.

To run a parallel simulation:

params = Simul.create_default_params()
params.output.sub_directory = "doc_fluidsimfoam/dam"
params.control_dict.end_time = 1.0

params.parallel.method = "simple"
params.parallel.nsubdoms = 4
params.parallel.nsubdoms_xyz = [2, 2, 1]

sim = Simul(params)
sim.make.exec("run")

One can also try with a higher dam:

params.block_mesh_dict.height_dam *= 2
sim = Simul(params)
sim.make.exec("run")