Raise exceptions when trying to interpolate fields that don't exist in the CylMesh

This commit is contained in:
rowanc1
2014-05-02 15:05:31 -07:00
parent f31caf2d61
commit d6210072cd
2 changed files with 8 additions and 0 deletions
+2
View File
@@ -229,6 +229,8 @@ class BaseTensorMesh(BaseRectangularMesh):
'N' -> scalar field defined on nodes
'CC' -> scalar field defined on cell centers
"""
if self._meshType == 'CYL' and self.isSymmetric and locType in ['Ex','Ez','Fy']:
raise Exception('Symmetric CylMesh does not support %s interpolation, as this variable does not exist.' % locType)
loc = Utils.asArray_N_x_Dim(loc, self.dim)
+6
View File
@@ -144,6 +144,12 @@ class TestInterpolation2dCyl_Simple(unittest.TestCase):
fz = np.array([[ 0., 0., 0., 0., 0.5, 0., 0., 0., 0.5, 0., 0., 0.]])
self.assertTrue( np.all(fz == M.getInterpolationMat(locs, 'Fz').todense()) )
def test_exceptions(self):
M = Mesh.CylMesh([4,1,1])
locs = np.r_[0,0,0.5]
self.assertRaises(Exception,lambda:M.getInterpolationMat(locs, 'Fy'))
self.assertRaises(Exception,lambda:M.getInterpolationMat(locs, 'Ex'))
self.assertRaises(Exception,lambda:M.getInterpolationMat(locs, 'Ez'))
class TestInterpolation2dCyl(OrderTest):