本文整理匯總了Python中fipy.variables.variable.Variable.getArithmeticFaceValue方法的典型用法代碼示例。如果您正苦於以下問題:Python Variable.getArithmeticFaceValue方法的具體用法?Python Variable.getArithmeticFaceValue怎麽用?Python Variable.getArithmeticFaceValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fipy.variables.variable.Variable
的用法示例。
在下文中一共展示了Variable.getArithmeticFaceValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DiffusionTerm
# 需要導入模塊: from fipy.variables.variable import Variable [as 別名]
# 或者: from fipy.variables.variable.Variable import getArithmeticFaceValue [as 別名]
class DiffusionTerm(Term):
r"""
This term represents a higher order diffusion term. The order of the term is determined
by the number of `coeffs`, such that::
DiffusionTerm(D1)
represents a typical 2nd-order diffusion term of the form
.. math::
\nabla\cdot\left(D_1 \nabla \phi\right)
and::
DiffusionTerm((D1,D2))
represents a 4th-order Cahn-Hilliard term of the form
.. math::
\nabla \cdot \left\{ D_1 \nabla \left[ \nabla\cdot\left( D_2 \nabla \phi\right) \right] \right\}
and so on.
"""
def __init__(self, coeff = (1.,)):
"""
Create a `DiffusionTerm`.
:Parameters:
- `coeff`: `Tuple` or `list` of `FaceVariables` or numbers.
"""
if type(coeff) not in (type(()), type([])):
coeff = (coeff,)
self.order = len(coeff) * 2
if len(coeff) > 0:
self.nthCoeff = coeff[0]
from fipy.variables.variable import Variable
if not isinstance(self.nthCoeff, Variable):
self.nthCoeff = Variable(value = self.nthCoeff)
from fipy.variables.cellVariable import CellVariable
if isinstance(self.nthCoeff, CellVariable):
self.nthCoeff = self.nthCoeff.getArithmeticFaceValue()
else:
self.nthCoeff = None
Term.__init__(self, coeff = coeff)
if self.order > 0:
self.lowerOrderDiffusionTerm = DiffusionTerm(coeff = coeff[1:])
def __neg__(self):
"""
Negate the term.
>>> -DiffusionTerm(coeff=[1.])
DiffusionTerm(coeff=[-1.0])
>>> -DiffusionTerm()
DiffusionTerm(coeff=[-1.0])
"""
negatedCoeff = list(self.coeff)
negatedCoeff[0] = -negatedCoeff[0]
return self.__class__(coeff = negatedCoeff)
def _getBoundaryConditions(self, boundaryConditions):
higherOrderBCs = []
lowerOrderBCs = []
for bc in boundaryConditions:
bcDeriv = bc._getDerivative(self.order - 2)
if bcDeriv:
higherOrderBCs.append(bcDeriv)
else:
lowerOrderBCs.append(bc)
return higherOrderBCs, lowerOrderBCs
def _getNormals(self, mesh):
return mesh._getFaceCellToCellNormals()
def _getRotationTensor(self, mesh):
if not hasattr(self, 'rotationTensor'):
from fipy.variables.faceVariable import FaceVariable
rotationTensor = FaceVariable(mesh=mesh, rank=2)
rotationTensor[:, 0] = self._getNormals(mesh)
#.........這裏部分代碼省略.........