mirror of
https://github.com/wassname/simpeg.git
synced 2026-08-19 12:40:13 +08:00
Change innerProduct to take sigma not tensorType.
This commit is contained in:
@@ -109,9 +109,9 @@ class InnerProducts(object):
|
|||||||
return [V*proj(*locs[node][d-1]) for node in nodes]
|
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.
|
:param bool doFast: do a faster implementation if available.
|
||||||
:rtype: function
|
:rtype: function
|
||||||
:return: dMdmu(u), the derivative of the inner product matrix (u)
|
:return: dMdmu(u), the derivative of the inner product matrix (u)
|
||||||
@@ -122,27 +122,27 @@ class InnerProducts(object):
|
|||||||
:rtype: scipy.csr_matrix
|
:rtype: scipy.csr_matrix
|
||||||
:return: dMdmu, the derivative of the inner product matrix for a certain u
|
: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.
|
:param bool doFast: do a faster implementation if available.
|
||||||
:rtype: scipy.csr_matrix
|
:rtype: scipy.csr_matrix
|
||||||
:return: dMdm, the derivative of the inner product matrix (nE, nC*nA)
|
: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 str projType: 'F' for faces 'E' for edges
|
||||||
:param bool doFast: do a faster implementation if available.
|
:param bool doFast: do a faster implementation if available.
|
||||||
:rtype: scipy.csr_matrix
|
:rtype: scipy.csr_matrix
|
||||||
:return: dMdm, the derivative of the inner product matrix (nE, nC*nA)
|
: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
|
fast = None
|
||||||
|
|
||||||
if hasattr(self, '_fastInnerProductDeriv') and doFast:
|
if hasattr(self, '_fastInnerProductDeriv') and doFast:
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
|
|||||||
mesh = Mesh.TensorMesh(h)
|
mesh = Mesh.TensorMesh(h)
|
||||||
v = np.random.rand(mesh.nF)
|
v = np.random.rand(mesh.nF)
|
||||||
sig = np.random.rand(1) if rep is 0 else np.random.rand(mesh.nC*rep)
|
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):
|
def fun(sig):
|
||||||
M = mesh.getFaceInnerProduct(sig)
|
M = mesh.getFaceInnerProduct(sig)
|
||||||
return M*v, Md(v)
|
return M*v, Md(v)
|
||||||
@@ -33,7 +33,7 @@ class TestInnerProductsDerivs(unittest.TestCase):
|
|||||||
mesh = Mesh.TensorMesh(h)
|
mesh = Mesh.TensorMesh(h)
|
||||||
v = np.random.rand(mesh.nE)
|
v = np.random.rand(mesh.nE)
|
||||||
sig = np.random.rand(1) if rep is 0 else np.random.rand(mesh.nC*rep)
|
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):
|
def fun(sig):
|
||||||
M = mesh.getEdgeInnerProduct(sig)
|
M = mesh.getEdgeInnerProduct(sig)
|
||||||
return M*v, Md(v)
|
return M*v, Md(v)
|
||||||
|
|||||||
Reference in New Issue
Block a user