Skip to content

Commit

Permalink
Moved to single equation model and system uses 2D numpy array
Browse files Browse the repository at this point in the history
  • Loading branch information
gpavanb1 committed Oct 2, 2024
1 parent e45375d commit 3e6b003
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions splitfxm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ def __init__(self):
"""
Initialize a Model object.
"""
self._equations = []
self._equation = None

def equations(self):
def equation(self):
"""
Get the list of equations associated with this Model.
Get the equation associated with this model
Returns
-------
list
The list of equations
"""
return self._equations
return self._equation
23 changes: 13 additions & 10 deletions splitfxm/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ def residuals(self, d: Domain):
nb_left = d.nb(btype.LEFT)
nb_right = d.nb(btype.RIGHT)

# Fetch equation for model
eq = self._model.equation()

rhs_list = []

for i in range(ilo, ihi + 1):
rhs = np.array([])
# Append residuals from each equation
for eq in self._model.equations():
# Send two-sided stencil
# Let model decide computation
cell_sub = [cells[i + offset]
for offset in range(-nb_left, nb_right + 1)]
rhs = np.concatenate(
(rhs, eq.residuals(cell_sub, self._scheme, self._scheme_opts)))
# Define the neighborhood and band around the current cell
cell_sub = [cells[i + offset]
for offset in range(-nb_left, nb_right + 1)]
# Send two-sided stencil
# Let model decide computation
rhs = eq.residuals(cell_sub, self._scheme, self._scheme_opts)
rhs_list.append(rhs)

return rhs_list
# Stack the residuals to form a 2D array
rhs_array = np.vstack(rhs_list)

return rhs_array

0 comments on commit 3e6b003

Please sign in to comment.