Make tensor mesh copy the h and list so that the outside h is not affected.

This commit is contained in:
rowanc1
2013-11-25 14:59:52 -08:00
parent 4ca6f090f6
commit facd291bea
+5 -3
View File
@@ -33,14 +33,16 @@ class TensorMesh(BaseMesh, TensorView, DiffOperators, InnerProducts):
"""
_meshType = 'TENSOR'
def __init__(self, h, x0=None):
for i, h_i in enumerate(h):
def __init__(self, h_in, x0=None):
assert type(h_in) is list, 'h_in must be a list'
h = range(len(h_in))
for i, h_i in enumerate(h_in):
if type(h_i) in [int, long, float]:
# This gives you something over the unit cube.
h_i = np.ones(int(h_i))/int(h_i)
h[i] = h_i
assert type(h_i) == np.ndarray, ("h[%i] is not a numpy array." % i)
assert len(h_i.shape) == 1, ("h[%i] must be a 1D numpy array." % i)
h[i] = h_i[:] # make a copy.
BaseMesh.__init__(self, np.array([x.size for x in h]), x0)
assert len(h) == len(self.x0), "Dimension mismatch. x0 != len(h)"