mirror of
https://github.com/wassname/simpeg.git
synced 2026-09-12 12:51:28 +08:00
Testing differential operators (Div, Grad, Curl)
This commit is contained in:
+15
-12
@@ -5,16 +5,18 @@ sys.path.append('../')
|
||||
from TensorMesh import TensorMesh
|
||||
from getDIV import getDivMatrix, getarea, getvol
|
||||
|
||||
# Define the mesh
|
||||
|
||||
err=0.
|
||||
print '>> Test face Divergence operator'
|
||||
for i in range(4):
|
||||
icount=i+1;
|
||||
nc = 2*icount;
|
||||
h1 = np.pi/nc*np.ones((1,nc))
|
||||
h2 = np.pi/nc*np.ones((1,nc))
|
||||
h3 = np.pi/nc*np.ones((1,nc))
|
||||
icount=i+1
|
||||
nc = 2**icount
|
||||
# Define the mesh
|
||||
h1 = np.ones((1,nc))/nc
|
||||
h2 = np.ones((1,nc))/nc
|
||||
h3 = np.ones((1,nc))/nc
|
||||
h = [h1, h2, h3]
|
||||
x0 = -np.pi/2*np.ones((3, 1))
|
||||
x0 = np.zeros((3, 1))
|
||||
M = TensorMesh(h, x0)
|
||||
#n = M.plotGrid()
|
||||
|
||||
@@ -34,12 +36,13 @@ for i in range(4):
|
||||
|
||||
area = getarea(h)
|
||||
vol = getvol(h)
|
||||
err = np.linalg.norm((divF-divF_anal)*np.sqrt(vol), 2)
|
||||
#err = np.linalg.norm((divF-divF_anal)*np.sqrt(vol), 2)
|
||||
err = np.linalg.norm((divF-divF_anal), np.inf)
|
||||
|
||||
if icount == 1:
|
||||
err1 = err
|
||||
print 'h | 2 norm | error ratio'
|
||||
print 'h | inf norm | error ratio'
|
||||
print '---------------------------------------'
|
||||
print '%6.4f | %8.2e |'% (h1[0,0], err)
|
||||
else:
|
||||
print '%6.4f | %8.2e | %6.4f' % (h1[0,0], err, err1/err)
|
||||
|
||||
print '%6.4f | %8.2e | %6.4f' % (h1[0,0], err, err_old/err)
|
||||
err_old = err
|
||||
|
||||
Reference in New Issue
Block a user