本文整理汇总了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)
#.........这里部分代码省略.........