mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-27 19:48:52 +08:00
Edge inner products updates for 1D
This commit is contained in:
@@ -620,7 +620,7 @@ class DiffOperators(object):
|
||||
# The number of cell centers in each direction
|
||||
n = self.vnC
|
||||
if(self.dim == 1):
|
||||
raise Exception('Edge Averaging does not make sense in 1D: Use Identity?')
|
||||
self._aveE2CC = speye(n[0])
|
||||
elif(self.dim == 2):
|
||||
self._aveE2CC = 0.5*sp.hstack((sp.kron(av(n[1]), speye(n[0])),
|
||||
sp.kron(speye(n[1]), av(n[0]))), format="csr")
|
||||
|
||||
@@ -102,8 +102,8 @@ class InnerProducts(object):
|
||||
|
||||
elif projType == 'E':
|
||||
locs = {
|
||||
'000': [ None , ('eX0', 'eY0'), ('eX0', 'eY0', 'eZ0')],
|
||||
'100': [ None , ('eX0', 'eY1'), ('eX0', 'eY1', 'eZ1')],
|
||||
'000': [('eX0',), ('eX0', 'eY0'), ('eX0', 'eY0', 'eZ0')],
|
||||
'100': [('eX0',), ('eX0', 'eY1'), ('eX0', 'eY1', 'eZ1')],
|
||||
'010': [ None , ('eX1', 'eY0'), ('eX1', 'eY0', 'eZ2')],
|
||||
'110': [ None , ('eX1', 'eY1'), ('eX1', 'eY1', 'eZ3')],
|
||||
'001': [ None , None , ('eX2', 'eY2', 'eZ0')],
|
||||
@@ -112,7 +112,7 @@ class InnerProducts(object):
|
||||
'111': [ None , None , ('eX3', 'eY3', 'eZ3')]
|
||||
}
|
||||
if d == 1:
|
||||
raise NotImplementedError('getEdgeInnerProduct not implemented for 1D')
|
||||
proj = _getEdgePx(self)
|
||||
elif d == 2:
|
||||
proj = _getEdgePxx(self)
|
||||
elif d == 3:
|
||||
@@ -295,6 +295,10 @@ def _getFacePxxx(M):
|
||||
|
||||
return _getFacePxxx_Rectangular(M)
|
||||
|
||||
def _getEdgePx(M):
|
||||
assert M._meshType == 'TENSOR', 'Only supported for a tensor mesh'
|
||||
return _getEdgePx_Rectangular(M)
|
||||
|
||||
def _getEdgePxx(M):
|
||||
if M._meshType == 'TREE':
|
||||
return M._getEdgePxx
|
||||
@@ -449,6 +453,13 @@ def _getFacePxxx_Rectangular(M):
|
||||
return PXXX
|
||||
return Pxxx
|
||||
|
||||
def _getEdgePx_Rectangular(M):
|
||||
"""Returns a function for creating projection matrices"""
|
||||
def Px(xEdge):
|
||||
assert xEdge == 'eX0', 'xEdge = %s, not eX0' % xEdge
|
||||
return sp.identity(M.nC)
|
||||
return Px
|
||||
|
||||
def _getEdgePxx_Rectangular(M):
|
||||
i, j = np.int64(range(M.nCx)), np.int64(range(M.nCy))
|
||||
|
||||
|
||||
@@ -64,10 +64,14 @@ class TestInnerProductsDerivs(unittest.TestCase):
|
||||
def test_FaceIP_3D_anisotropic_fast(self):
|
||||
self.assertTrue(self.doTestFace([10, 4, 5],3, True))
|
||||
|
||||
def test_EdgeIP_1D_float(self):
|
||||
self.assertTrue(self.doTestEdge([10],0, False))
|
||||
def test_EdgeIP_2D_float(self):
|
||||
self.assertTrue(self.doTestEdge([10, 4],0, False))
|
||||
def test_EdgeIP_3D_float(self):
|
||||
self.assertTrue(self.doTestEdge([10, 4, 5],0, False))
|
||||
def test_EdgeIP_1D_isotropic(self):
|
||||
self.assertTrue(self.doTestEdge([10],1, False))
|
||||
def test_EdgeIP_2D_isotropic(self):
|
||||
self.assertTrue(self.doTestEdge([10, 4],1, False))
|
||||
def test_EdgeIP_3D_isotropic(self):
|
||||
@@ -81,10 +85,14 @@ class TestInnerProductsDerivs(unittest.TestCase):
|
||||
def test_EdgeIP_3D_tensor(self):
|
||||
self.assertTrue(self.doTestEdge([10, 4, 5],6, False))
|
||||
|
||||
def test_EdgeIP_1D_float_fast(self):
|
||||
self.assertTrue(self.doTestEdge([10],0, True))
|
||||
def test_EdgeIP_2D_float_fast(self):
|
||||
self.assertTrue(self.doTestEdge([10, 4],0, True))
|
||||
def test_EdgeIP_3D_float_fast(self):
|
||||
self.assertTrue(self.doTestEdge([10, 4, 5],0, True))
|
||||
def test_EdgeIP_1D_isotropic_fast(self):
|
||||
self.assertTrue(self.doTestEdge([10],1, True))
|
||||
def test_EdgeIP_2D_isotropic_fast(self):
|
||||
self.assertTrue(self.doTestEdge([10, 4],1, True))
|
||||
def test_EdgeIP_3D_isotropic_fast(self):
|
||||
|
||||
Reference in New Issue
Block a user