Innerproduct work. Testing, visualization, and 2D - NOTE there are bugs in anything but a uniform LOM

Not very helpful yet!
This commit is contained in:
Rowan Cockett
2013-08-05 11:51:03 -07:00
parent e2e38074fc
commit e073eaeb8b
9 changed files with 465 additions and 116 deletions
+87 -3
View File
@@ -32,9 +32,9 @@ from OrderTest import OrderTest
class TestInnerProducts(OrderTest):
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
meshType = 'rotateLOM'
meshDimension = 2
meshSizes = [16, 32, 64]
meshTypes = ['uniformTensorMesh', 'uniformLOM']
meshDimension = 3
meshSizes = [16, 32]
def getError(self):
@@ -118,5 +118,89 @@ class TestInnerProducts(OrderTest):
self.orderTest()
class TestInnerProducts2D(OrderTest):
"""Integrate an function over a unit cube domain using edgeInnerProducts and faceInnerProducts."""
meshTypes = ['uniformTensorMesh', 'uniformLOM', 'rotateLOM']
meshDimension = 2
meshSizes = [4, 8, 16, 32, 64, 128]
def getError(self):
z = 5 # Because 5 is just such a great number.
call = lambda fun, xy: fun(xy[:, 0], xy[:, 1])
ex = lambda x, y: x**2+y*z
ey = lambda x, y: (z**2)*x+y*z
sigma1 = lambda x, y: x*y+1
sigma2 = lambda x, y: x*z+2
sigma3 = lambda x, y: 3+z*y
Gc = self.M.gridCC
if self.sigmaTest == 1:
sigma = np.c_[call(sigma1, Gc)]
analytic = 144877./360 # Found using matlab symbolic toolbox. z=5
elif self.sigmaTest == 2:
sigma = np.c_[call(sigma1, Gc), call(sigma2, Gc)]
analytic = 189959./120 # Found using matlab symbolic toolbox. z=5
elif self.sigmaTest == 3:
sigma = np.c_[call(sigma1, Gc), call(sigma2, Gc), call(sigma3, Gc)]
analytic = 781427./360 # Found using matlab symbolic toolbox. z=5
if self.location == 'edges':
Ex = call(ex, self.M.gridEx)
Ey = call(ey, self.M.gridEy)
E = np.matrix(np.r_[Ex, Ey]).T
A = self.M.getEdgeInnerProduct(sigma)
numeric = E.T*A*E
elif self.location == 'faces':
Fx = call(ex, self.M.gridFx)
Fy = call(ey, self.M.gridFy)
F = np.matrix(np.r_[Fx, Fy]).T
A = self.M.getFaceInnerProduct(sigma)
numeric = F.T*A*F
err = np.abs(numeric - analytic)
return err
# def test_order1_edges(self):
# self.name = "2D Edge Inner Product - Isotropic"
# self.location = 'edges'
# self.sigmaTest = 1
# self.orderTest()
# def test_order3_edges(self):
# self.name = "2D Edge Inner Product - Anisotropic"
# self.location = 'edges'
# self.sigmaTest = 2
# self.orderTest()
# def test_order6_edges(self):
# self.name = "2D Edge Inner Product - Full Tensor"
# self.location = 'edges'
# self.sigmaTest = 3
# self.orderTest()
def test_order1_faces(self):
self.name = "2D Face Inner Product - Isotropic"
self.location = 'faces'
self.sigmaTest = 1
self.orderTest()
def test_order3_faces(self):
self.name = "2D Face Inner Product - Anisotropic"
self.location = 'faces'
self.sigmaTest = 2
self.orderTest()
def test_order6_faces(self):
self.name = "2D Face Inner Product - Full Tensor"
self.location = 'faces'
self.sigmaTest = 3
self.orderTest()
if __name__ == '__main__':
unittest.main()