mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-01 02:32:33 +08:00
updated where cell centers are and how I count the first h in 2D case
This commit is contained in:
@@ -116,7 +116,7 @@ class CylMesh(BaseTensorMesh):
|
||||
def vectorCCx(self):
|
||||
"""Cell-centered grid vector (1D) in the x direction."""
|
||||
if self.nCy == 1:
|
||||
return np.r_[0, self.hx[:-1].cumsum()] + self.hx*0.5 - self.hx[0]/2
|
||||
return np.r_[-self.hx[0]*0.5, self.hx[:-1].cumsum()] + self.hx*0.5 # - self.hx[0]/2
|
||||
return np.r_[0, self.hx[:-1].cumsum()] + self.hx*0.5
|
||||
|
||||
@property
|
||||
@@ -128,12 +128,14 @@ class CylMesh(BaseTensorMesh):
|
||||
def vectorNx(self):
|
||||
"""Nodal grid vector (1D) in the x direction."""
|
||||
if self.nCy == 1:
|
||||
return self.hx.cumsum() - self.hx[0]/2
|
||||
return self.hx.cumsum()# - self.hx[0]/2
|
||||
return np.r_[0, self.hx].cumsum()
|
||||
|
||||
@property
|
||||
def vectorNy(self):
|
||||
"""Nodal grid vector (1D) in the y direction."""
|
||||
if self.nCy == 1:
|
||||
return np.r_[0]
|
||||
return np.r_[0, self.hy[:-1].cumsum()] + self.hy[0]*0.5
|
||||
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestCyl2DMesh(unittest.TestCase):
|
||||
self.assertTrue(np.all(self.mesh.vnE == [0, 9, 0]))
|
||||
|
||||
def test_vectorsCC(self):
|
||||
v = np.r_[0, 1, 1.75]
|
||||
v = np.r_[0, 1.5, 2.25]
|
||||
self.assertTrue(np.linalg.norm((v-self.mesh.vectorCCx)) == 0)
|
||||
v = np.r_[0]
|
||||
self.assertTrue(np.linalg.norm((v-self.mesh.vectorCCy)) == 0)
|
||||
@@ -53,18 +53,18 @@ class TestCyl2DMesh(unittest.TestCase):
|
||||
self.assertTrue(np.linalg.norm((v-self.mesh.vectorCCz)) == 0)
|
||||
|
||||
def test_vectorsN(self):
|
||||
v = np.r_[0.5, 1.5, 2]
|
||||
v = np.r_[1, 2, 2.5]
|
||||
self.assertTrue(np.linalg.norm((v-self.mesh.vectorNx)) == 0)
|
||||
v = np.r_[np.pi] #This is kinda a fake. But it is where it would be if there was a radial connection
|
||||
v = np.r_[0]
|
||||
self.assertTrue(np.linalg.norm((v-self.mesh.vectorNy)) == 0)
|
||||
v = np.r_[0, 2, 3.]
|
||||
self.assertTrue(np.linalg.norm((v-self.mesh.vectorNz)) == 0)
|
||||
|
||||
def test_dimensions(self):
|
||||
edge = np.r_[0.5, 1.5, 2, 0.5, 1.5, 2, 0.5, 1.5, 2] * 2 * np.pi
|
||||
edge = np.r_[1, 2, 2.5, 1, 2, 2.5, 1, 2, 2.5] * 2 * np.pi
|
||||
self.assertTrue(np.linalg.norm((edge-self.mesh.edge)) == 0)
|
||||
|
||||
r = np.r_[0, 0.5, 1.5, 2]
|
||||
r = np.r_[0, 1, 2, 2.5]
|
||||
a = r[1:]*2*np.pi
|
||||
areaX = np.r_[2*a,a]
|
||||
a = (r[1:]**2 - r[:-1]**2)*np.pi
|
||||
|
||||
Reference in New Issue
Block a user