Skip to content

Commit

Permalink
Merge branch 'main' into convection
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Nov 8, 2024
2 parents 238e7bb + b0dc9c3 commit a2c7d61
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pyro/compressible/derives.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def derive_primitives(myd, varnames):
gamma = myd.get_aux("gamma")
p = eos.pres(gamma, dens, e)

myg = myd.grid
vort = myg.scratch_array()

vort.v()[:, :] = \
0.5*(v.ip(1) - v.ip(-1))/myg.dx - \
0.5*(u.jp(1) - u.jp(-1))/myg.dy

if isinstance(varnames, str):
wanted = [varnames]
else:
Expand All @@ -50,6 +57,9 @@ def derive_primitives(myd, varnames):
elif var == "soundspeed":
derived_vars.append(np.sqrt(gamma*p/dens))

elif var == "vorticity":
derived_vars.append(vort)

if len(derived_vars) > 1:
return derived_vars

Expand Down
8 changes: 8 additions & 0 deletions pyro/util/io_pyro.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ def read(filename):

sim.read_extras(f)

# check if there are derived variables
try:
derives = importlib.import_module(f"pyro.{solver_name}.derives")
sim.cc_data.add_derived(derives.derive_primitives)

except ModuleNotFoundError:
pass

if solver_name is not None:
return sim

Expand Down

0 comments on commit a2c7d61

Please sign in to comment.