mirror of
https://github.com/wassname/simpeg.git
synced 2026-08-04 13:13:40 +08:00
NodalGrad
This commit is contained in:
@@ -69,9 +69,9 @@ class TestFaceDiv3D(Tests.OrderTest):
|
||||
|
||||
class TestCurl(Tests.OrderTest):
|
||||
name = "Curl"
|
||||
meshTypes = MESHTYPES
|
||||
meshTypes = ['notatreeTree', 'uniformTree'] #, 'randomTree']#, 'uniformTree']
|
||||
meshSizes = [8, 16]#, 32]
|
||||
expectedOrders = 1 # This is due to linear interpolation in the Re projection
|
||||
expectedOrders = [2,1] # This is due to linear interpolation in the Re projection
|
||||
|
||||
def getError(self):
|
||||
# fun: i (cos(y)) + j (cos(z)) + k (cos(x))
|
||||
@@ -102,6 +102,62 @@ class TestCurl(Tests.OrderTest):
|
||||
self.orderTest()
|
||||
|
||||
|
||||
class TestNodalGrad(Tests.OrderTest):
|
||||
name = "Nodal Gradient"
|
||||
meshTypes = ['notatreeTree', 'uniformTree'] #['randomTree', 'uniformTree']
|
||||
meshSizes = [8, 16]#, 32]
|
||||
expectedOrders = [2,1]
|
||||
|
||||
def getError(self):
|
||||
#Test function
|
||||
fun = lambda x, y, z: (np.cos(x)+np.cos(y)+np.cos(z))
|
||||
# i (sin(x)) + j (sin(y)) + k (sin(z))
|
||||
solX = lambda x, y, z: -np.sin(x)
|
||||
solY = lambda x, y, z: -np.sin(y)
|
||||
solZ = lambda x, y, z: -np.sin(z)
|
||||
|
||||
phi = call3(fun, self.M.gridN)
|
||||
gradE = self.M.nodalGrad.dot(phi)
|
||||
|
||||
Ec = cartE3(self.M, solX, solY, solZ)
|
||||
gradE_ana = self.M.projectEdgeVector(Ec)
|
||||
|
||||
err = np.linalg.norm((gradE-gradE_ana), np.inf)
|
||||
|
||||
return err
|
||||
|
||||
def test_order(self):
|
||||
self.orderTest()
|
||||
|
||||
|
||||
class TestNodalGrad2D(Tests.OrderTest):
|
||||
name = "Nodal Gradient 2D"
|
||||
meshTypes = ['notatreeTree', 'uniformTree'] #['randomTree', 'uniformTree']
|
||||
meshSizes = [8, 16]#, 32]
|
||||
expectedOrders = [2,1]
|
||||
meshDimension = 2
|
||||
|
||||
def getError(self):
|
||||
#Test function
|
||||
fun = lambda x, y: (np.cos(x)+np.cos(y))
|
||||
# i (sin(x)) + j (sin(y)) + k (sin(z))
|
||||
solX = lambda x, y: -np.sin(x)
|
||||
solY = lambda x, y: -np.sin(y)
|
||||
|
||||
phi = call2(fun, self.M.gridN)
|
||||
gradE = self.M.nodalGrad.dot(phi)
|
||||
|
||||
Ec = cartE2(self.M, solX, solY)
|
||||
gradE_ana = self.M.projectEdgeVector(Ec)
|
||||
|
||||
err = np.linalg.norm((gradE-gradE_ana), np.inf)
|
||||
|
||||
return err
|
||||
|
||||
def test_order(self):
|
||||
self.orderTest()
|
||||
|
||||
|
||||
class TestTreeInnerProducts(Tests.OrderTest):
|
||||
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
|
||||
|
||||
@@ -613,5 +669,7 @@ class TestAveraging3D(Tests.OrderTest):
|
||||
# self.expectedOrders = 1
|
||||
# self.orderTest()
|
||||
# self.expectedOrders = 2
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user