Skip to content

Commit

Permalink
disable verbosity by default when directly using Pyro() (#231)
Browse files Browse the repository at this point in the history
Now in a notebook, we don't get the "pyro..." message or the message from the initial conditions. This can still
be overridden by passing a verbosity into Pyro() via the parameters dictionary.
  • Loading branch information
zingale authored Sep 1, 2024
1 parent 5834466 commit 0e34de9
Show file tree
Hide file tree
Showing 35 changed files with 146 additions and 184 deletions.
210 changes: 74 additions & 136 deletions examples/examples.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyro/advection/problems/smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

def init_data(my_data, rp):
""" initialize the smooth advection problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the smooth advection problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the smooth advection problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/advection/problems/tophat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

def init_data(myd, rp):
""" initialize the tophat advection problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the tophat advection problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the tophat advection problem...")

# make sure that we are passed a valid patch object
if not isinstance(myd, patch.CellCenterData2d):
Expand Down
4 changes: 3 additions & 1 deletion pyro/advection_nonuniform/problems/slotted.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

def init_data(my_data, rp):
""" initialize the slotted advection problem """
msg.bold("initializing the slotted advection problem...")

if rp.get_param("driver.verbose"):
msg.bold("initializing the slotted advection problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/burgers/problems/converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

def init_data(my_data, rp):
""" initialize the smooth burgers convergence problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the smooth burgers convergence problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the smooth burgers convergence problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/burgers/problems/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

def init_data(myd, rp):
""" initialize the burgers test problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the burgers test problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the burgers test problem...")

# make sure that we are passed a valid patch object
if not isinstance(myd, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/burgers/problems/tophat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

def init_data(myd, rp):
""" initialize the tophat burgers problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the tophat burgers problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the tophat burgers problem...")

# make sure that we are passed a valid patch object
if not isinstance(myd, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/acoustic_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def init_data(myd, rp):
"""initialize the acoustic_pulse problem. This comes from
McCourquodale & Coella 2011"""

msg.bold("initializing the acoustic pulse problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the acoustic pulse problem...")

# make sure that we are passed a valid patch object
if not isinstance(myd, (patch.CellCenterData2d, fv.FV2d)):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/advect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize a smooth advection problem for testing convergence """

msg.bold("initializing the advect problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the advect problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize the bubble problem """

msg.bold("initializing the bubble problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the bubble problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/gresho.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize the Gresho vortex problem """

msg.bold("initializing the Gresho vortex problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the Gresho vortex problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/hse.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize the HSE problem """

msg.bold("initializing the HSE problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the HSE problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/kh.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
def init_data(my_data, rp):
""" initialize the Kelvin-Helmholtz problem """

msg.bold("initializing the Kelvin-Helmholtz problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the Kelvin-Helmholtz problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
def init_data(my_data, rp):
""" initialize the logo problem """

msg.bold("initializing the logo problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the logo problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/quad.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize the quadrant problem """

msg.bold("initializing the quadrant problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the quadrant problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/ramp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
def init_data(my_data, rp):
""" initialize the double Mach reflection problem """

msg.bold("initializing the double Mach reflection problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the double Mach reflection problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize the rt problem """

msg.bold("initializing the rt problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the rt problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/compressible/problems/rt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@


def init_data(my_data, rp):

""" initialize the rt problem """

msg.bold("initializing the rt problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the rt problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/sedov.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
def init_data(my_data, rp):
""" initialize the sedov problem """

msg.bold("initializing the sedov problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the sedov problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/compressible/problems/sod.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
def init_data(my_data, rp):
""" initialize the sod problem """

msg.bold("initializing the sod problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the sod problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/diffusion/problems/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def phi_analytic(dist, t, t_0, k, phi_1, phi_2):
def init_data(my_data, rp):
""" initialize the Gaussian diffusion problem """

msg.bold("initializing the Gaussian diffusion problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the Gaussian diffusion problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/incompressible/problems/converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

def init_data(my_data, rp):
""" initialize the incompressible converge problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the incompressible converge problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the incompressible converge problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/incompressible/problems/shear.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
def init_data(my_data, rp):
""" initialize the incompressible shear problem """

msg.bold("initializing the incompressible shear problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the incompressible shear problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/incompressible_viscous/problems/cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

def init_data(my_data, rp):
""" initialize the lid-driven cavity """
del rp # this problem doesn't use runtime params

msg.bold("initializing the lid-driven cavity problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the lid-driven cavity problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/incompressible_viscous/problems/converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

def init_data(my_data, rp):
""" initialize the incompressible viscous converge problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the incompressible viscous converge problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the incompressible viscous converge problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/incompressible_viscous/problems/shear.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
def init_data(my_data, rp):
""" initialize the incompressible shear problem """

msg.bold("initializing the incompressible shear problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the incompressible shear problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/lm_atm/problems/bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, base, rp):
""" initialize the bubble problem """

msg.bold("initializing the bubble problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the bubble problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/lm_atm/problems/gresho.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, base, rp):
""" initialize the Gresho vortex problem """

msg.bold("initializing the Gresho vortex problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the Gresho vortex problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
10 changes: 5 additions & 5 deletions pyro/pyro_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def __init__(self, solver_name, from_commandline=False):
runtime vis by default.
"""

msg.bold('pyro ...')
if from_commandline:
msg.bold('pyro ...')

if solver_name not in valid_solvers:
msg.fail(f"ERROR: {solver_name} is not a valid solver")
Expand Down Expand Up @@ -118,12 +119,11 @@ def initialize_problem(self, problem_name, inputs_file=None, inputs_dict=None,

self.rp.load_params(inputs_file, no_new=1)

# manually override the dovis default
# manually override the dovis and verbose defaults
# for Jupyter, we want runtime vis disabled by default
if self.from_commandline:
self.rp.set_param("vis.dovis", 1)
else:
if not self.from_commandline:
self.rp.set_param("vis.dovis", 0)
self.rp.set_param("driver.verbose", 0)

if inputs_dict is not None:
for k, v in inputs_dict.items():
Expand Down
3 changes: 2 additions & 1 deletion pyro/swe/problems/acoustic_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def init_data(myd, rp):
"""initialize the acoustic_pulse problem. This comes from
McCourquodale & Coella 2011"""

msg.bold("initializing the acoustic pulse problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the acoustic pulse problem...")

# make sure that we are passed a valid patch object
if not isinstance(myd, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/swe/problems/advect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize a smooth advection problem for testing convergence """

msg.bold("initializing the advect problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the advect problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/swe/problems/dam.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
def init_data(my_data, rp):
""" initialize the dam problem """

msg.bold("initializing the dam problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the dam problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/swe/problems/kh.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
def init_data(my_data, rp):
""" initialize the Kelvin-Helmholtz problem """

msg.bold("initializing the Kelvin-Helmholtz problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the Kelvin-Helmholtz problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
4 changes: 2 additions & 2 deletions pyro/swe/problems/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

def init_data(my_data, rp):
""" initialize the sedov problem """
del rp # this problem doesn't use runtime params

msg.bold("initializing the logo problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the logo problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down
3 changes: 2 additions & 1 deletion pyro/swe/problems/quad.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
def init_data(my_data, rp):
""" initialize the quadrant problem """

msg.bold("initializing the quadrant problem...")
if rp.get_param("driver.verbose"):
msg.bold("initializing the quadrant problem...")

# make sure that we are passed a valid patch object
if not isinstance(my_data, patch.CellCenterData2d):
Expand Down

0 comments on commit 0e34de9

Please sign in to comment.