curModel in problem and combo maps no longer takes a mesh.

This commit is contained in:
rowanc1
2014-05-18 16:09:47 -07:00
parent 907e0eed47
commit be0be1e986
3 changed files with 23 additions and 4 deletions
+3 -3
View File
@@ -99,7 +99,7 @@ class IdentityMap(object):
if isinstance(val, IdentityMap):
if not self.shape[1] == val.shape[0]:
raise ValueError('Dimension mismatch in %s and %s.' % (str(self), str(val)))
return ComboMap(self.mesh, [self, val])
return ComboMap([self, val])
elif isinstance(val, np.ndarray):
if not self.shape[1] == val.shape[0]:
raise ValueError('Dimension mismatch in %s and np.ndarray%s.' % (str(self), str(val.shape)))
@@ -112,8 +112,8 @@ class IdentityMap(object):
class ComboMap(IdentityMap):
"""Combination of various maps."""
def __init__(self, mesh, maps, **kwargs):
IdentityMap.__init__(self, mesh, **kwargs)
def __init__(self, maps, **kwargs):
IdentityMap.__init__(self, None, **kwargs)
self.maps = []
for ii, m in enumerate(maps):
+2
View File
@@ -6,6 +6,8 @@ class Model(np.ndarray):
def __new__(cls, input_array, mapping=None):
assert isinstance(mapping, IdentityMap), 'mapping must be a SimPEG.Mapping'
assert isinstance(input_array, np.ndarray), 'input_array must be a numpy array'
assert len(input_array.shape) == 1, 'input_array must be a 1D vector'
obj = np.asarray(input_array).view(cls)
obj._mapping = mapping
if not obj.size == mapping.nP:
+18 -1
View File
@@ -1,4 +1,4 @@
import Utils, Survey, numpy as np, scipy.sparse as sp
import Utils, Survey, Models, numpy as np, scipy.sparse as sp
import Maps, Mesh
class BaseProblem(object):
@@ -44,6 +44,23 @@ class BaseProblem(object):
self.survey._prob = None
self._survey = None
deleteTheseOnModelUpdate = [] # List of strings, e.g. ['_MeSigma', '_MeSigmaI']
@property
def curModel(self):
"""
Sets the current model, and removes dependent mass matrices.
"""
return getattr(self, '_curModel', None)
@curModel.setter
def curModel(self, value):
if value is self.curModel:
return # it is the same!
self._curModel = Models.Model(value, self.mapping)
for prop in self.deleteTheseOnModelUpdate:
if hasattr(self, prop):
delattr(self, prop)
@property
def ispaired(self):
"""True if the problem is paired to a survey."""