Skip to content

Commit

Permalink
Account for ghost cells and element shape in preallocation
Browse files Browse the repository at this point in the history
  • Loading branch information
guyer committed Dec 1, 2023
1 parent 333df13 commit bdaa4b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fipy/matrices/offsetSparseMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, mesh, nonZerosPerRow=1, exactNonZeros=False,
# can't compare to collections.abc.Iterable because PySparse.
before = self.equationIndex
after = numberOfEquations - self.equationIndex - 1
N = mesh.numberOfCells
N = len(nonZerosPerRow)
nonZerosPerRow = numerix.concatenate([[0] * N * before,
nonZerosPerRow,
[0] * N * after])
Expand Down
3 changes: 2 additions & 1 deletion fipy/terms/abstractDiffusionTerm.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def __getCoefficientMatrix(self, SparseMatrix, var, coeff):
## print 'id1',id1
## print 'id2',id2

coefficientMatrix = SparseMatrix(mesh=mesh, nonZerosPerRow=mesh._facesPerCell + 1)
facesPerCell = mesh._facesPerCell[..., mesh._localNonOverlappingCellIDs]
coefficientMatrix = SparseMatrix(mesh=mesh, nonZerosPerRow=facesPerCell + 1)
interiorCoeff = numerix.take(coeff, interiorFaces, axis=-1).ravel()
coefficientMatrix.addAt(interiorCoeff, id1.ravel(), id1.swapaxes(0, 1).ravel())
coefficientMatrix.addAt(-interiorCoeff, id1.ravel(), id2.swapaxes(0, 1).ravel())
Expand Down
3 changes: 2 additions & 1 deletion fipy/terms/faceTerm.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def _buildMatrix(self, var, SparseMatrix, boundaryConditions=(), dt=None, transi
id2 = numerix.take(id2, interiorFaces)

b = numerix.zeros(var.shape, 'd').ravel()
L = SparseMatrix(mesh=mesh, nonZerosPerRow=mesh._facesPerCell + 1)
facesPerCell = mesh._facesPerCell[..., mesh._localNonOverlappingCellIDs]
L = SparseMatrix(mesh=mesh, nonZerosPerRow=facesPerCell + 1)

weight = self._getWeight(var, transientGeomCoeff, diffusionGeomCoeff)

Expand Down

0 comments on commit bdaa4b8

Please sign in to comment.