mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-28 15:23:20 +08:00
add a projection map (for re-arranging models)
use current sigmaModel in src
This commit is contained in:
@@ -719,7 +719,7 @@ class PrimSecMappedSigma(BaseSrc):
|
||||
def _primaryFields(self, prob):
|
||||
|
||||
# TODO: cache and check if prob.curModel has changed
|
||||
return self.primaryProblem.fields(prob.curModel)
|
||||
return self.primaryProblem.fields(prob.curModel.sigmaModel)
|
||||
|
||||
def _primaryFieldsDeriv(self, prob, v, adjoint=False):
|
||||
if adjoint:
|
||||
@@ -774,7 +774,7 @@ class PrimSecMappedSigma(BaseSrc):
|
||||
|
||||
|
||||
def s_e(self, prob):
|
||||
sigmaPrimary = self.map2meshs * prob.curModel
|
||||
sigmaPrimary = self.map2meshs * prob.curModel.sigmaModel
|
||||
return (prob.MeSigma - prob.mesh.getEdgeInnerProduct(sigmaPrimary)) * self.ePrimary(prob)
|
||||
|
||||
|
||||
@@ -783,8 +783,8 @@ class PrimSecMappedSigma(BaseSrc):
|
||||
raise NotImplementedError
|
||||
return prob.MeSigmaDeriv(self.ePrimary(prob)).T * v
|
||||
|
||||
sigmaPrimary = self.map2meshs * prob.curModel
|
||||
sigmaPrimaryDeriv = self.map2meshs.deriv(prob.curModel)
|
||||
sigmaPrimary = self.map2meshs * prob.curModel.sigmaModel
|
||||
sigmaPrimaryDeriv = self.map2meshs.deriv(prob.curModel.sigmaModel)
|
||||
return (prob.MeSigmaDeriv(self.ePrimary(prob)) * v
|
||||
- prob.mesh.getEdgeInnerProductDeriv(sigmaPrimary)(self.ePrimary(prob)) * sigmaPrimaryDeriv * v
|
||||
+ (prob.MeSigma - prob.mesh.getEdgeInnerProduct(sigmaPrimary)) * self.ePrimaryDeriv(prob, v)
|
||||
|
||||
@@ -616,6 +616,37 @@ class Weighting(IdentityMap):
|
||||
def deriv(self, m):
|
||||
return self.P
|
||||
|
||||
class Projection(IdentityMap):
|
||||
"""
|
||||
A map to rearrange parameters
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, indTo, indFrom, shape, mesh=None, **kwargs):
|
||||
|
||||
assert len(indTo) == len(indFrom)
|
||||
|
||||
self.P = sp.csr_matrix((np.ones(len(indTo)), (indTo, indFrom)), shape=shape)
|
||||
self._shape = shape
|
||||
|
||||
super(Projection, self).__init__(mesh, **kwargs)
|
||||
|
||||
@property
|
||||
def shape(self):
|
||||
return self._shape
|
||||
|
||||
@property
|
||||
def nP(self):
|
||||
"""Number of parameters in the model."""
|
||||
return self.shape[1]
|
||||
|
||||
def _transform(self, m):
|
||||
return self.P*m
|
||||
|
||||
def deriv(self, m):
|
||||
return self.P
|
||||
|
||||
|
||||
class ComplexMap(IdentityMap):
|
||||
"""ComplexMap
|
||||
|
||||
Reference in New Issue
Block a user