Change innerProduct to take sigma not tensorType.

This commit is contained in:
rowanc1
2014-07-03 10:08:39 -07:00
parent 9d048f2884
commit 8c65ddacae
2 changed files with 11 additions and 11 deletions
+9 -9
View File
@@ -109,9 +109,9 @@ class InnerProducts(object):
return [V*proj(*locs[node][d-1]) for node in nodes]
def getFaceInnerProductDeriv(self, tensorType, doFast=True):
def getFaceInnerProductDeriv(self, prop, doFast=True):
"""
:param TensorType tensorType: type of the tensor: TensorType(mesh, sigma)
:param numpy.array prop: material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
:param bool doFast: do a faster implementation if available.
:rtype: function
:return: dMdmu(u), the derivative of the inner product matrix (u)
@@ -122,27 +122,27 @@ class InnerProducts(object):
:rtype: scipy.csr_matrix
:return: dMdmu, the derivative of the inner product matrix for a certain u
"""
return self._getInnerProductDeriv(tensorType, 'F', doFast=doFast)
return self._getInnerProductDeriv(prop, 'F', doFast=doFast)
def getEdgeInnerProductDeriv(self, tensorType, doFast=True):
def getEdgeInnerProductDeriv(self, prop, doFast=True):
"""
:param TensorType tensorType: type of the tensor: TensorType(mesh, sigma)
:param numpy.array prop: material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
:param bool doFast: do a faster implementation if available.
:rtype: scipy.csr_matrix
:return: dMdm, the derivative of the inner product matrix (nE, nC*nA)
"""
return self._getInnerProductDeriv(tensorType, 'E', doFast=doFast)
return self._getInnerProductDeriv(prop, 'E', doFast=doFast)
def _getInnerProductDeriv(self, tensorType, projType, doFast=True):
def _getInnerProductDeriv(self, prop, projType, doFast=True):
"""
:param TensorType tensorType: type of the tensor: TensorType(mesh, sigma)
:param numpy.array prop: material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
:param str projType: 'F' for faces 'E' for edges
:param bool doFast: do a faster implementation if available.
:rtype: scipy.csr_matrix
:return: dMdm, the derivative of the inner product matrix (nE, nC*nA)
"""
assert isinstance(tensorType, TensorType), 'tensorType must be an instance of TensorType.'
tensorType = TensorType(self, prop)
fast = None
if hasattr(self, '_fastInnerProductDeriv') and doFast:
+2 -2
View File
@@ -16,7 +16,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
mesh = Mesh.TensorMesh(h)
v = np.random.rand(mesh.nF)
sig = np.random.rand(1) if rep is 0 else np.random.rand(mesh.nC*rep)
Md = mesh.getFaceInnerProductDeriv(Utils.TensorType(mesh, sig), doFast=fast)
Md = mesh.getFaceInnerProductDeriv(sig, doFast=fast)
def fun(sig):
M = mesh.getFaceInnerProduct(sig)
return M*v, Md(v)
@@ -33,7 +33,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
mesh = Mesh.TensorMesh(h)
v = np.random.rand(mesh.nE)
sig = np.random.rand(1) if rep is 0 else np.random.rand(mesh.nC*rep)
Md = mesh.getEdgeInnerProductDeriv(Utils.TensorType(mesh, sig), doFast=fast)
Md = mesh.getEdgeInnerProductDeriv(sig, doFast=fast)
def fun(sig):
M = mesh.getEdgeInnerProduct(sig)
return M*v, Md(v)