diff --git a/SimPEG/Mesh/InnerProducts.py b/SimPEG/Mesh/InnerProducts.py index 11f5d496..f8bcee46 100644 --- a/SimPEG/Mesh/InnerProducts.py +++ b/SimPEG/Mesh/InnerProducts.py @@ -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: diff --git a/SimPEG/Tests/test_massMatricesDerivs.py b/SimPEG/Tests/test_massMatricesDerivs.py index dd208c68..21ac8c41 100644 --- a/SimPEG/Tests/test_massMatricesDerivs.py +++ b/SimPEG/Tests/test_massMatricesDerivs.py @@ -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)