From 49cdba2fbc5fca4a44cfd25248d565f3cae6005b Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 22 Nov 2024 11:56:25 -0500 Subject: [PATCH 1/2] move the 4th order reconstruction into mesh/ this is consistent with the other reconstruction routines --- pyro/advection_fv4/fluxes.py | 6 +++--- pyro/compressible_fv4/fluxes.py | 5 ++--- pyro/{advection_fv4/interface.py => mesh/fourth_order.py} | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) rename pyro/{advection_fv4/interface.py => mesh/fourth_order.py} (98%) diff --git a/pyro/advection_fv4/fluxes.py b/pyro/advection_fv4/fluxes.py index 8b902cf1f..a23b66dce 100644 --- a/pyro/advection_fv4/fluxes.py +++ b/pyro/advection_fv4/fluxes.py @@ -1,5 +1,5 @@ import pyro.mesh.array_indexer as ai -from pyro.advection_fv4 import interface +from pyro.mesh import fourth_order def fluxes(my_data, rp): @@ -72,13 +72,13 @@ def fluxes(my_data, rp): 1./12.*(a.jp(-2, buf=1) + a.jp(1, buf=1)) else: - a_l, a_r = interface.states(a, myg.ng, 1) + a_l, a_r = fourth_order.states(a, myg.ng, 1) if u > 0: a_x = ai.ArrayIndexer(d=a_l, grid=myg) else: a_x = ai.ArrayIndexer(d=a_r, grid=myg) - a_l, a_r = interface.states(a, myg.ng, 2) + a_l, a_r = fourth_order.states(a, myg.ng, 2) if v > 0: a_y = ai.ArrayIndexer(d=a_l, grid=myg) else: diff --git a/pyro/compressible_fv4/fluxes.py b/pyro/compressible_fv4/fluxes.py index 25a1439fa..6b3d67528 100644 --- a/pyro/compressible_fv4/fluxes.py +++ b/pyro/compressible_fv4/fluxes.py @@ -4,9 +4,8 @@ import pyro.compressible as comp import pyro.mesh.array_indexer as ai -from pyro.advection_fv4 import interface from pyro.compressible import riemann -from pyro.mesh import reconstruction +from pyro.mesh import fourth_order, reconstruction def flux_cons(ivars, idir, gamma, q): @@ -104,7 +103,7 @@ def fluxes(myd, rp, ivars): else: for n in range(ivars.nq): - q_l[:, :, n], q_r[:, :, n] = interface.states(q_avg[:, :, n], myg.ng, idir) + q_l[:, :, n], q_r[:, :, n] = fourth_order.states(q_avg[:, :, n], myg.ng, idir) # apply flattening for n in range(ivars.nq): diff --git a/pyro/advection_fv4/interface.py b/pyro/mesh/fourth_order.py similarity index 98% rename from pyro/advection_fv4/interface.py rename to pyro/mesh/fourth_order.py index c9f355077..feaff0838 100644 --- a/pyro/advection_fv4/interface.py +++ b/pyro/mesh/fourth_order.py @@ -1,3 +1,5 @@ +"""Reconstruction routines for 4th order finite-volume methods""" + import numpy as np from numba import njit @@ -84,7 +86,7 @@ def states(a, ng, idir): # this lives on the interface d3a[i, j] = d2ac[i, j] - d2ac[i - 1, j] - # this is a look over cell centers, affecting + # this is a loop over cell centers, affecting # i-1/2,R and i+1/2,L for i in range(ilo - 1, ihi + 1): for j in range(jlo - 1, jhi + 1): From ce67a64016499428709e493996b8397951b7268e Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Fri, 22 Nov 2024 12:22:38 -0500 Subject: [PATCH 2/2] a few more fixes --- examples/mesh/bc_demo.py | 3 ++- pyro/mesh/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/mesh/bc_demo.py b/examples/mesh/bc_demo.py index 7ce80fe72..6c5dc5524 100644 --- a/examples/mesh/bc_demo.py +++ b/examples/mesh/bc_demo.py @@ -1,9 +1,10 @@ # test the boundary fill routine +import numpy as np + import pyro.mesh.boundary as bnd import pyro.mesh.patch as patch -import numpy as np def doit(): diff --git a/pyro/mesh/__init__.py b/pyro/mesh/__init__.py index 5f6f0e1ae..2a8a3c0e8 100644 --- a/pyro/mesh/__init__.py +++ b/pyro/mesh/__init__.py @@ -3,7 +3,7 @@ necessary to work with finite-volume data. """ -__all__ = ['patch', 'integration', 'reconstruction'] +__all__ = ['patch', 'fourth_order', 'integration', 'reconstruction'] from .array_indexer import ArrayIndexer, ArrayIndexerFC from .boundary import BC, bc_is_solid, define_bc