def _explicitBuildMatrix(self, SparseMatrix, oldArray, id1, id2, b, weight, mesh, boundaryConditions, interiorFaces, dt): coeffMatrix = self._getCoeffMatrix(mesh, weight) inline._optionalInline(self._explicitBuildMatrixIn, self._explicitBuildMatrixPy, oldArray, id1, id2, b, coeffMatrix, mesh, interiorFaces, dt, weight) N = mesh.getNumberOfCells() M = mesh._getMaxFacesPerCell() for boundaryCondition in boundaryConditions: LL,bb = boundaryCondition._buildMatrix(SparseMatrix, N, M, coeffMatrix) if LL != 0: ## b -= LL.takeDiagonal() * numerix.array(oldArray) b -= LL * numerix.array(oldArray) b += bb
def _buildMatrix(self, var, SparseMatrix, boundaryConditions=(), dt=1., equation=None): N = len(var) b = numerix.zeros((N),'d') L = SparseMatrix(size=N) # The sign of the matrix diagonal doesn't seem likely to change # after initialization, but who knows? if equation is not None: from fipy.tools.numerix import sign, add self._diagonalSign.setValue(sign(add.reduce(equation.matrix.takeDiagonal()))) else: self._diagonalSign.setValue(1) coeffVectors = self._getCoeffVectors(var=var) inline._optionalInline(self._buildMatrixIn, self._buildMatrixPy, L, var.getOld(), b, dt, coeffVectors) return (L, b)
def _calcValue(self): N = self.mesh.getNumberOfCells() M = self.mesh._getMaxFacesPerCell() ids = self.mesh._getCellFaceIDs() orientations = self.mesh._getCellFaceOrientations() volumes = self.mesh.getCellVolumes() return inline._optionalInline(self._calcValueIn, self._calcValuePy, N, M, ids, orientations, volumes)
def _createCells(self): """ cells = (f1, f2, f3, f4) going anticlock wise. f1 etc. refer to the faces """ return inline._optionalInline(self._createCellsIn, self._createCellsPy)
def _calcValue(self): P = self.P.getNumericValue() return inline._optionalInline(self._calcValueIn, self._calcValuePy, P)
def _calcValue(self): alpha = self.mesh._getFaceToCellDistanceRatio() id1, id2 = self.mesh._getAdjacentCellIDs() return inline._optionalInline(self._calcValueIn, self._calcValuePy, alpha, id1, id2)
def _calcValue(self): from fipy.tools import inline return inline._optionalInline(self._calcValueInline, self._calcValuePy)
def _calcValue(self): return inline._optionalInline(self._calcValueInline, self._calcValuePy)
def putAdd(vector, ids, additionVector): """ This is a temporary replacement for Numeric.put as it was not doing what we thought it was doing. """ from fipy.tools import inline inline._optionalInline(_putAddIn, _putAddPy, vector, ids, additionVector)
def _calcValue(self): if not self.canInline: return self._calcValuePy() else: from fipy.tools import inline return inline._optionalInline(self._calcValueIn, self._calcValuePy)
def _getAreaProjections(self): return inline._optionalInline(self._getAreaProjectionsIn, self._getAreaProjectionsPy)
def getFaceCellIDs(self): return inline._optionalInline(self._getFaceCellIDsIn, self._getFaceCellIDsPy)
def _getAdjacentCellIDs(self): return inline._optionalInline(self._getAdjacentCellIDsIn, self._getAdjacentCellIDsPy)