本文整理汇总了Python中esys.escript.linearPDEs.LinearPDE.getFunctionSpaceForCoefficient方法的典型用法代码示例。如果您正苦于以下问题:Python LinearPDE.getFunctionSpaceForCoefficient方法的具体用法?Python LinearPDE.getFunctionSpaceForCoefficient怎么用?Python LinearPDE.getFunctionSpaceForCoefficient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类esys.escript.linearPDEs.LinearPDE
的用法示例。
在下文中一共展示了LinearPDE.getFunctionSpaceForCoefficient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SplitRegularization
# 需要导入模块: from esys.escript.linearPDEs import LinearPDE [as 别名]
# 或者: from esys.escript.linearPDEs.LinearPDE import getFunctionSpaceForCoefficient [as 别名]
#.........这里部分代码省略.........
# =========== check the shape of the scales: ========================
if scale is None:
if numLevelSets == 1:
scale = 1.0
else:
scale = np.ones((numLevelSets,))
else:
scale = np.asarray(scale)
if numLevelSets == 1:
if scale.shape == ():
if not scale > 0:
raise ValueError("Value for scale must be positive.")
else:
raise ValueError("Unexpected shape %s for scale." % scale.shape)
else:
if scale.shape is (numLevelSets,):
if not min(scale) > 0:
raise ValueError("All values for scale must be positive.")
else:
raise ValueError("Unexpected shape %s for scale." % scale.shape)
if scale_c is None or numLevelSets < 2:
scale_c = np.ones((numLevelSets, numLevelSets))
else:
scale_c = np.asarray(scale_c)
if scale_c.shape == (numLevelSets, numLevelSets):
if not all([[scale_c[l, k] > 0.0 for l in range(k)] for k in range(1, numLevelSets)]):
raise ValueError("All values in the lower triangle of scale_c must be positive.")
else:
raise ValueError("Unexpected shape %s for scale." % scale_c.shape)
# ===== check the shape of the weights: =============================
if w0 is not None:
w0 = interpolate(w0, self.__pde.getFunctionSpaceForCoefficient("D"))
s0 = w0.getShape()
if numLevelSets == 1:
if not s0 == ():
raise ValueError("Unexpected shape %s for weight w0." % (s0,))
else:
if not s0 == (numLevelSets,):
raise ValueError("Unexpected shape %s for weight w0." % (s0,))
if not self.__trafo.isCartesian():
w0 *= self.__trafo.getVolumeFactor()
if not w1 is None:
w1 = interpolate(w1, self.__pde.getFunctionSpaceForCoefficient("A"))
s1 = w1.getShape()
if numLevelSets == 1:
if not s1 == (DIM,):
raise ValueError("Unexpected shape %s for weight w1." % (s1,))
else:
if not s1 == (numLevelSets, DIM):
raise ValueError("Unexpected shape %s for weight w1." % (s1,))
if not self.__trafo.isCartesian():
f = self.__trafo.getScalingFactors() ** 2 * self.__trafo.getVolumeFactor()
if numLevelSets == 1:
w1 *= f
else:
for i in range(numLevelSets):
w1[i, :] *= f
if numLevelSets == 1:
wc = None
else:
wc = interpolate(wc, self.__pde.getFunctionSpaceForCoefficient("A"))
sc = wc.getShape()
if not sc == (numLevelSets, numLevelSets):