vol and area tests passing

This commit is contained in:
rowanc1
2014-02-15 14:08:41 -08:00
parent 1129fc1c66
commit 9bea954dff
3 changed files with 27 additions and 7 deletions
+9 -5
View File
@@ -157,15 +157,17 @@ class CylMesh(TensorMesh):
if self.nCy == 1:
self._edge = 2*pi*self.gridN[:,0]
else:
raise NotImplementedError('edges not implemented for 3D cyl mesh')
raise NotImplementedError('edges not yet implemented for 3D cyl mesh')
return self._edge
@property
def area(self):
"""Face areas"""
if getattr(self, '_area', None) is None:
areaR = np.kron(self.hz, 2*pi*self.vectorNr)
areaZ = np.kron(np.ones_like(self.vectorNz),pi*(self.vectorNr**2 - np.r_[0, self.vectorNr[:-1]]**2))
if self.nCy > 1:
raise NotImplementedError('area not yet implemented for 3D cyl mesh')
areaR = np.kron(self.hz, 2*pi*self.vectorNx)
areaZ = np.kron(np.ones_like(self.vectorNz),pi*(self.vectorNx**2 - np.r_[0, self.vectorNx[:-1]]**2))
self._area = np.r_[areaR, areaZ]
return self._area
@@ -173,7 +175,9 @@ class CylMesh(TensorMesh):
def vol(self):
"""Volume of each cell"""
if getattr(self, '_vol', None) is None:
az = pi*(self.vectorNr**2 - np.r_[0, self.vectorNr[:-1]]**2)
if self.nCy > 1:
raise NotImplementedError('vol not yet implemented for 3D cyl mesh')
az = pi*(self.vectorNx**2 - np.r_[0, self.vectorNx[:-1]]**2)
self._vol = np.kron(self.hz,az)
return self._vol
@@ -295,7 +299,7 @@ class CylMesh(TensorMesh):
loc = np.atleast_2d(loc)
assert np.all(loc[:,0]<=self.vectorNr.max()) & \
assert np.all(loc[:,0]<=self.vectorNx.max()) & \
np.all(loc[:,1]>=self.vectorNz.min()) & \
np.all(loc[:,1]<=self.vectorNz.max()), \
"Points outside of mesh"
+2
View File
@@ -303,6 +303,8 @@ class InnerProducts(object):
def _makeTensor(M, sigma):
if sigma is None: # default is ones
sigma = np.ones((M.nC, 1))
elif type(sigma) is float:
sigma = np.ones(self.nC)*sigma
if M.dim == 2:
if sigma.size == M.nC: # Isotropic!