diff --git a/SimPEG/Mesh/CylMesh.py b/SimPEG/Mesh/CylMesh.py index da0927e5..376cb789 100644 --- a/SimPEG/Mesh/CylMesh.py +++ b/SimPEG/Mesh/CylMesh.py @@ -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 diff --git a/SimPEG/Tests/test_cylMesh.py b/SimPEG/Tests/test_cylMesh.py index 584bcc2d..ebde658c 100644 --- a/SimPEG/Tests/test_cylMesh.py +++ b/SimPEG/Tests/test_cylMesh.py @@ -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