Skip to content

Commit

Permalink
implement a clean_state routine for compressible (#329)
Browse files Browse the repository at this point in the history
this will enforce small_dens
  • Loading branch information
zingale authored Jan 25, 2025
1 parent 7ee23e1 commit c2ecf50
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyro/compressible/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ grav = 0.0 ; gravitational acceleration (in y-direction)

riemann = HLLC ; HLLC or CGF

small_dens = -1.e200 ; minimum allowed density
small_eint = -1.e200 ; minimum allowed specific internal energy

[sponge]
do_sponge = 0 ; do we include a sponge source term
Expand Down
8 changes: 8 additions & 0 deletions pyro/compressible/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ def evolve(self):
timestep dt.
"""

self.clean_state(self.cc_data.data)

tm_evolve = self.tc.timer("evolve")
tm_evolve.begin()

Expand Down Expand Up @@ -437,6 +439,12 @@ def evolve(self):

tm_evolve.end()

def clean_state(self, U):
"""enforce minimum density and eint on the conserved state U"""

U.v(n=self.ivars.idens)[:, :] = np.maximum(U.v(n=self.ivars.idens),
self.rp.get_param("compressible.small_dens"))

def dovis(self):
"""
Do runtime visualization.
Expand Down
1 change: 1 addition & 0 deletions pyro/compressible_fv4/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ grav = 0.0 ; gravitational acceleration (in y-direction)

riemann = CGF

small_dens = -1.e200 ; minimum allowed density

[sponge]
do_sponge = 0 ; do we include a sponge source term
Expand Down
2 changes: 2 additions & 0 deletions pyro/compressible_fv4/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def substep(self, myd):
compute the advective source term for the given state
"""

self.clean_state(myd.data)

myg = myd.grid

# compute the source terms -- we need to do this first
Expand Down
1 change: 1 addition & 0 deletions pyro/compressible_rk/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ riemann = HLLC ; HLLC or CGF

well_balanced = 0 ; use a well-balanced scheme to keep the model in hydrostatic equilibrium

small_dens = -1.e200 ; minimum allowed density

[sponge]
do_sponge = 0 ; do we include a sponge source term
Expand Down
2 changes: 2 additions & 0 deletions pyro/compressible_rk/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def substep(self, myd):
conservative state defined as part of myd
"""

self.clean_state(myd.data)

myg = myd.grid

# source terms -- note: this dt is the entire dt, not the
Expand Down
1 change: 1 addition & 0 deletions pyro/compressible_sdc/_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ grav = 0.0 ; gravitational acceleration (in y-direction)

riemann = CGF

small_dens = -1.e200 ; minimum allowed density

[sponge]
do_sponge = 0 ; do we include a sponge source term
Expand Down

0 comments on commit c2ecf50

Please sign in to comment.