mirror of
https://github.com/wassname/simpeg.git
synced 2026-08-04 13:13:40 +08:00
Remove the Meshless Identity Map.
- This is now default functionality in the IdentityMap.
This commit is contained in:
+14
-35
@@ -10,21 +10,25 @@ class IdentityMap(object):
|
|||||||
SimPEG Map
|
SimPEG Map
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__metaclass__ = Utils.SimPEGMetaClass
|
__metaclass__ = Utils.SimPEGMetaClass
|
||||||
|
|
||||||
mesh = None #: A SimPEG Mesh
|
def __init__(self, mesh=None, nP=None, **kwargs):
|
||||||
|
|
||||||
def __init__(self, mesh, **kwargs):
|
|
||||||
Utils.setKwargs(self, **kwargs)
|
Utils.setKwargs(self, **kwargs)
|
||||||
|
|
||||||
|
if nP is not None:
|
||||||
|
assert type(nP) in [int, long], ' Number of parameters must be an integer.'
|
||||||
|
|
||||||
self.mesh = mesh
|
self.mesh = mesh
|
||||||
|
self._nP = nP
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def nP(self):
|
def nP(self):
|
||||||
"""
|
"""
|
||||||
:rtype: int
|
:rtype: int
|
||||||
:return: number of parameters in the model
|
:return: number of parameters that the mapping accepts
|
||||||
"""
|
"""
|
||||||
|
if self._nP is not None:
|
||||||
|
return self._nP
|
||||||
if self.mesh is None:
|
if self.mesh is None:
|
||||||
return '*'
|
return '*'
|
||||||
return self.mesh.nC
|
return self.mesh.nC
|
||||||
@@ -32,11 +36,15 @@ class IdentityMap(object):
|
|||||||
@property
|
@property
|
||||||
def shape(self):
|
def shape(self):
|
||||||
"""
|
"""
|
||||||
The default shape is (mesh.nC, nP).
|
The default shape is (mesh.nC, nP) if the mesh is defined.
|
||||||
|
If this is a meshless mapping (i.e. nP is defined independently)
|
||||||
|
the shape will be the the shape (nP,nP).
|
||||||
|
|
||||||
:rtype: (int,int)
|
:rtype: (int,int)
|
||||||
:return: shape of the operator as a tuple
|
:return: shape of the operator as a tuple
|
||||||
"""
|
"""
|
||||||
|
if self._nP is not None:
|
||||||
|
return (self.nP, self.nP)
|
||||||
if self.mesh is None:
|
if self.mesh is None:
|
||||||
return ('*', self.nP)
|
return ('*', self.nP)
|
||||||
return (self.mesh.nC, self.nP)
|
return (self.mesh.nC, self.nP)
|
||||||
@@ -119,35 +127,6 @@ class IdentityMap(object):
|
|||||||
return "%s(%s,%s)" % (self.__class__.__name__, self.shape[0], self.shape[1])
|
return "%s(%s,%s)" % (self.__class__.__name__, self.shape[0], self.shape[1])
|
||||||
|
|
||||||
|
|
||||||
class IdentityMap_Meshless(IdentityMap):
|
|
||||||
|
|
||||||
def __init__(self, nP=None, **kwargs):
|
|
||||||
IdentityMap.__init__(self, None, **kwargs)
|
|
||||||
self._nP = nP
|
|
||||||
|
|
||||||
@property
|
|
||||||
def nP(self):
|
|
||||||
"""
|
|
||||||
:rtype: int
|
|
||||||
:return: number of parameters in the model
|
|
||||||
"""
|
|
||||||
if self._nP is None:
|
|
||||||
return '*'
|
|
||||||
return self._nP
|
|
||||||
|
|
||||||
@property
|
|
||||||
def shape(self):
|
|
||||||
"""
|
|
||||||
The default shape is (mesh.nC, nP).
|
|
||||||
|
|
||||||
:rtype: (int,int)
|
|
||||||
:return: shape of the operator as a tuple
|
|
||||||
"""
|
|
||||||
if self._nP is None:
|
|
||||||
return ('*', '*')
|
|
||||||
return (self.nP, self.nP)
|
|
||||||
|
|
||||||
|
|
||||||
class ComboMap(IdentityMap):
|
class ComboMap(IdentityMap):
|
||||||
"""Combination of various maps."""
|
"""Combination of various maps."""
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class RegularizationTests(unittest.TestCase):
|
|||||||
elif mesh.dim == 3:
|
elif mesh.dim == 3:
|
||||||
indAct = Utils.mkvc(mesh.gridCC[:,-1] <= 2*np.sin(2*np.pi*mesh.gridCC[:,0])+0.5 * 2*np.sin(2*np.pi*mesh.gridCC[:,1])+0.5)
|
indAct = Utils.mkvc(mesh.gridCC[:,-1] <= 2*np.sin(2*np.pi*mesh.gridCC[:,0])+0.5 * 2*np.sin(2*np.pi*mesh.gridCC[:,1])+0.5)
|
||||||
|
|
||||||
mapping = Maps.IdentityMap_Meshless(nP=indAct.nonzero()[0].size)
|
mapping = Maps.IdentityMap(nP=indAct.nonzero()[0].size)
|
||||||
|
|
||||||
reg = r(mesh, mapping=mapping, indActive=indAct)
|
reg = r(mesh, mapping=mapping, indActive=indAct)
|
||||||
m = np.random.rand(mesh.nC)[indAct]
|
m = np.random.rand(mesh.nC)[indAct]
|
||||||
|
|||||||
Reference in New Issue
Block a user