diff --git a/docs/pygeos_tools_docs/example.rst b/docs/pygeos_tools_docs/example.rst index a217eb8be..dda8cb9e8 100644 --- a/docs/pygeos_tools_docs/example.rst +++ b/docs/pygeos_tools_docs/example.rst @@ -117,12 +117,12 @@ This block contains a ``forceDt`` attribute that will be used later to choose as The "outputs" event triggers the output of the vtk files. The attribute "timeFrequency" has the same value as "forceDt" so we can use the same timestep for the solver and the outputs. -To start, we will set the time to 0.0 and trigger one output of the vtk files. +To start, we will set the time to 0.0 and the cycle number to 0. .. code-block:: python time = 0.0 - solver.outputVtk( time ) + cycle = 0 ------------------------------------------------------------------ @@ -135,9 +135,12 @@ Once done, the simulation is ended by calling the ``cleanup`` method. .. code-block:: python while time < solver.maxTime: - solver.execute( time ) - solver.outputVtk( time ) + solver.outputVtk( time, cycle ) + solver.execute( time, cycle ) time += solver.dt + cycle += 1 + + solver.outputVtk( time, cycle ) solver.cleanup( time ) diff --git a/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/input_file_adaptive.xml b/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/input_file_adaptive.xml index ec4e1ea22..a664970c3 100644 --- a/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/input_file_adaptive.xml +++ b/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/input_file_adaptive.xml @@ -16,7 +16,9 @@ newtonTol="0.0001" newtonMaxIter="25"/> + solverType="fgmres" + preconditionerType="mgr" + krylovTol="1.0e-5"/> diff --git a/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/main.py b/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/main.py index 2cf7cc7ef..c33a47802 100644 --- a/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/main.py +++ b/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/2ph_comp/main.py @@ -98,7 +98,7 @@ def run_darts_model( xml_name: str, darts_model=None ): cycle: int = 0 solver.setDt( 86400.0 ) - solver.outputVtk( time ) + while time < solver.maxTime: if time < 604800: solver.setDt( 86400.0 ) @@ -108,10 +108,14 @@ def run_darts_model( xml_name: str, darts_model=None ): if rank == 0: if solver.dt is not None: print( f"time = {time:.3f}s, dt = {solver.getDt():.4f}, iter = {cycle + 1}" ) - solver.execute( time ) + + solver.outputVtk( time, cycle ) + solver.execute( time, cycle ) + time += solver.getDt() - solver.outputVtk( time ) cycle += 1 + + solver.outputVtk( time, cycle ) solver.cleanup( time ) diff --git a/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/carbonated_water/1d_setup.xml b/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/carbonated_water/1d_setup.xml index a2e012dc3..9e714abc7 100644 --- a/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/carbonated_water/1d_setup.xml +++ b/pygeos-tools/examples/reactiveCompositionalMultiphaseOBL_modeling/carbonated_water/1d_setup.xml @@ -18,7 +18,9 @@ newtonTol="0.0001" newtonMaxIter="25"/> + solverType="fgmres" + preconditionerType="mgr" + krylovTol="1.0e-5"/> @@ -101,7 +103,7 @@ objectPath="ElementRegions/Region1" fieldName="globalCompFraction" component="0" - scale="0.7"/> + scale="0.276839"/> + scale="1e-11"/> + scale="1e-11"/> + scale="0.276839"/> + scale="1e-11"/> + scale="1e-11"/> None: self.solver.cleanup( time ) @required_attributes( "solver" ) - def execute( self: Self, time: float ) -> None: + def execute( self: Self, time: float, cycleNumber: int ) -> None: """ Do one solver iteration @@ -709,8 +709,10 @@ def execute( self: Self, time: float ) -> None: ---------- time : float Current time of simulation + cycleNumber : int + Current cycle number """ - self.solver.execute( time, self.dt ) + self.solver.execute( time, self.dt, cycleNumber ) @required_attributes( "solver" ) def reinitSolver( self: Self ) -> None: @@ -718,7 +720,7 @@ def reinitSolver( self: Self ) -> None: self.solver.reinit() @required_attributes( "vtkOutputs" ) - def outputVtk( self: Self, time: float ) -> None: + def outputVtk( self: Self, time: float, cycleNumber: int ) -> None: """ Trigger the VTK output @@ -726,9 +728,11 @@ def outputVtk( self: Self, time: float ) -> None: ---------- time : float Current time of simulation + cycleNumber : int + Current cycle number """ for vtkOutput in self.vtkOutputs: - vtkOutput.output( time, self.dt ) + vtkOutput.output( time, self.dt, cycleNumber ) """ Update methods when initializing or reinitializing the solver diff --git a/pygeos-tools/src/geos/pygeos_tools/solvers/WaveSolver.py b/pygeos-tools/src/geos/pygeos_tools/solvers/WaveSolver.py index 9daf59c08..2e05d06f7 100644 --- a/pygeos-tools/src/geos/pygeos_tools/solvers/WaveSolver.py +++ b/pygeos-tools/src/geos/pygeos_tools/solvers/WaveSolver.py @@ -393,7 +393,7 @@ def filterSource( self: Self, fmax: Union[ str, float ] ) -> None: self.setGeosWrapperValueByTargetKey( "Events/minTime", self.minTimeSim ) self.sourceValue = np.real( y[ max( i1 - d, 0 ):min( i4 + d, n ), : ] ) - def outputWaveField( self: Self, time: float ) -> None: + def outputWaveField( self: Self, time: float, cycleNumber: int ) -> None: """ Trigger the wavefield output @@ -401,6 +401,8 @@ def outputWaveField( self: Self, time: float ) -> None: ---------- time : float Current time of simulation + cycleNumber : int + Current cycle number """ - self.collections[ 0 ].collect( time, self.dt ) - self.hdf5Outputs[ 0 ].output( time, self.dt ) + self.collections[ 0 ].collect( time, self.dt, cycleNumber ) + self.hdf5Outputs[ 0 ].output( time, self.dt, cycleNumber )