19#ifndef _BERT_DCFEMMODDELING__H
20#define _BERT_DCFEMMODDELING__H
25#include <modellingbase.h>
26#include <sparsematrix.h>
35DLLEXPORT
void dcfemDomainAssembleStiffnessMatrix(RSparseMatrix & S,
const Mesh & mesh,
36 double k=0.0,
bool fix=
true);
38DLLEXPORT
void dcfemDomainAssembleStiffnessMatrix(CSparseMatrix & S,
const Mesh & mesh,
39 double k=0.0,
bool fix=
true);
44DLLEXPORT
double mixedBoundaryCondition(
const Boundary & boundary,
45 const RVector3 & sourcePos,
48DLLEXPORT
void assembleCompleteElectrodeModel(RSparseMatrix & S,
49 const std::vector < ElectrodeShape * > & elecs,
50 uint oldMatSize,
bool lastIsReferenz,
51 const RVector & contactImpedances);
70 const std::map < float, Complex > & aMap);
79 const RVector & phase);
95 const RVector & re,
const RVector & im);
107 DCMultiElectrodeModelling(
bool verbose=
false);
109 DCMultiElectrodeModelling(
Mesh & mesh,
118 virtual ~DCMultiElectrodeModelling();
136 virtual void createConstraints();
153 void mapERTModel(
const CVector & model, Complex background);
160 void mapERTModel(
const RVector & model,
double background);
168 RVector response(
const RVector & model,
double background);
170 void createCurrentPattern(std::vector < ElectrodeShape * > & eA,
171 std::vector < ElectrodeShape * > & eB,
174 virtual void calculate(
DataMap & dMap);
178 virtual void calculate(
const std::vector < ElectrodeShape * > & eA,
179 const std::vector < ElectrodeShape * > & eB);
181 virtual void calculateK(
const std::vector < ElectrodeShape * > & eA,
182 const std::vector < ElectrodeShape * > & eB,
183 RMatrix & solutionK,
int kIdx);
185 virtual void calculateK(
const std::vector < ElectrodeShape * > & eA,
186 const std::vector < ElectrodeShape * > & eB,
187 CMatrix & solutionK,
int kIdx);
189 template <
class ValueType >
190 void calculateKAnalyt(
const std::vector < ElectrodeShape * > & eA,
191 const std::vector < ElectrodeShape * > & eB,
192 Matrix < ValueType > & solutionK,
193 double k,
int kIdx)
const;
195 void setTopography(
bool topography) { topography_=topography; }
196 bool topography()
const {
return topography_; }
198 bool neumann()
const {
return neumannDomain_; }
201 void setComplex(
bool c);
218 inline bool analytical()
const {
return analytical_; }
220 void collectSubPotentials(RMatrix & subSolutions){
221 subSolutions_=& subSolutions;
227 return currentPatternIdxMap_;
236 byPassFile_=fileName;
239 inline void setkValues(
const RVector & v) { kValues_=v; }
240 inline const RVector & kValues()
const {
return kValues_; }
242 inline void setWeights(
const RVector & v) { weights_=v; }
243 inline const RVector & weights()
const {
return weights_; }
245 inline const std::vector< ElectrodeShape * > & electrodes()
const {
249 void setContactImpedances(
const RVector & zi);
251 virtual RVector calcGeometricFactor(
const DataContainerERT & data,
254 virtual void preCalculate(
const std::vector < ElectrodeShape * > & eA,
255 const std::vector < ElectrodeShape * > & eB){
273 template <
class ValueType >
274 void calculateK_(
const std::vector < ElectrodeShape * > & eA,
275 const std::vector < ElectrodeShape * > & eB,
276 Matrix < ValueType > & solutionK,
int kIdx);
278 template <
class ValueType >
279 void assembleStiffnessMatrixDCFEMByPass_(SparseMatrix < ValueType > & S);
281 template <
class ValueType >
282 DataMap response_(
const Vector < ValueType > & model,
283 ValueType background);
285 template <
class ValueType >
288 RMatrix * prepareJacobian_(
const RVector & model);
289 CMatrix * prepareJacobian_(
const CVector & model);
291 void createJacobian_(
const RVector & model,
const RMatrix & u, RMatrix * J);
292 void createJacobian_(
const CVector & model,
const CMatrix & u, CMatrix * J);
294 virtual void deleteMeshDependency_();
295 virtual void updateMeshDependency_();
296 virtual void updateDataDependency_();
298 virtual void searchElectrodes_();
311 bool lastIsReferenz_;
314 std::string byPassFile_;
321 IndexArray calibrationSourceIdx_;
322 IndexArray bypassNodeIdx_;
324 std::vector< ElectrodeShape * > electrodes_;
327 std::vector< ElectrodeShape * > passiveCEM_;
329 RVector3 sourceCenterPos_;
331 bool buildCompleteElectrodeModel_;
333 bool dipoleCurrentPattern_;
334 std::map < Index, Index > currentPatternIdxMap_;
336 RMatrix potentialsCEM_;
337 RVector vContactImpedance_;
344class DLLEXPORT DCSRMultiElectrodeModelling :
public DCMultiElectrodeModelling {
346 DCSRMultiElectrodeModelling(
bool verbose=
false)
347 : DCMultiElectrodeModelling(
verbose) {
351 DCSRMultiElectrodeModelling(
Mesh & mesh,
bool verbose=
false)
352 : DCMultiElectrodeModelling(mesh,
verbose) {
357 : DCMultiElectrodeModelling(mesh, dataContainer,
verbose){
361 virtual ~DCSRMultiElectrodeModelling(){
362 if (primPot_ && primPotOwner_)
delete primPot_;
363 if (primMesh_ && primMeshOwner_)
delete primMesh_;
366 virtual void calculateK(
const std::vector < ElectrodeShape * > & eA,
367 const std::vector < ElectrodeShape * > & eB,
368 RMatrix & solutionK,
int kIdx);
370 inline void setPrimaryPotFileBody(
const std::string & primPotFileBody){
371 primPotFileBody_=primPotFileBody;
374 inline void setPrimaryPotential(RMatrix & primPot) { primPot_=& primPot; }
376 inline RMatrix & primaryPotential() {
return *primPot_; }
378 inline void setPrimaryMesh(
Mesh & mesh){ primMesh_=&mesh; }
380 void setPrimaryMesh(
const std::string & meshname);
382 inline Mesh & primaryMesh() {
return *primMesh_; }
386 virtual void preCalculate(
const std::vector < ElectrodeShape * > & eA,
387 const std::vector < ElectrodeShape * > & eB);
391 primPotFileBody_= NOT_DEFINED;
393 primPotOwner_ =
false;
396 primMeshOwner_ =
false;
401 virtual void updateMeshDependency_();
402 virtual void updateDataDependency_();
405 const std::vector < ElectrodeShape * > & eB);
407 std::string primPotFileBody_;
Definition meshentities.h:350
void setSingValue(bool s=true)
Definition dcfemmodelling.h:260
virtual void createJacobian(const RVector &model)
Definition dcfemmodelling.cpp:1446
void setDipoleCurrentPattern(bool dipole)
Definition dcfemmodelling.h:211
bool dipoleCurrentPattern() const
Definition dcfemmodelling.h:214
void assembleStiffnessMatrixDCFEMByPass(RSparseMatrix &S)
Definition dcfemmodelling.cpp:593
void setAnalytical(bool ana)
Definition dcfemmodelling.h:217
bool isSetSingValue() const
Definition dcfemmodelling.h:263
bool complex() const
Definition dcfemmodelling.h:204
const std::map< Index, Index > & currentPatternIdxMap() const
Definition dcfemmodelling.h:226
void setBypassMapFile(const std::string &fileName)
Definition dcfemmodelling.h:235
virtual RVector createDefaultStartModel()
Definition dcfemmodelling.cpp:1075
void mapERTModel(const CVector &model, Complex background)
Definition dcfemmodelling.cpp:1199
virtual RVector response(const RVector &model)
Definition dcfemmodelling.h:164
void setSolver(SolverWrapper *solver)
Definition dcfemmodelling.h:266
void checkPrimpotentials_(const std::vector< ElectrodeShape * > &eA, const std::vector< ElectrodeShape * > &eB)
Definition dcfemmodelling.cpp:1986
virtual void preCalculate(const std::vector< ElectrodeShape * > &eA, const std::vector< ElectrodeShape * > &eB)
Definition dcfemmodelling.cpp:2143
Definition bertDataContainer.h:32
DataContainer to store, load and save data in the GIMLi unified data format.
Definition datacontainer.h:48
Abstract class for an electrode with a shape, which is required for modelling.
Definition electrode.h:58
Interface class for matrices.
Definition matrix.h:137
Definition modellingbase.h:31
bool verbose() const
Definition modellingbase.h:48
Definition solverWrapper.h:26
One dimensional array aka Vector of limited size.
Definition vector.h:186
GIMLi main namespace for the Geophyiscal Inversion and Modelling Library.
Definition baseentity.h:24
void setComplexResistivities(Mesh &mesh, const std::map< float, Complex > &aMap)
Definition dcfemmodelling.cpp:51
CVector getComplexData(const DataContainer &data)
Definition dcfemmodelling.cpp:105
CVector getComplexResistivities(const Mesh &mesh)
Definition dcfemmodelling.cpp:82
void setComplexData(DataContainer &data, const RVector &re, const RVector &im)
Definition dcfemmodelling.cpp:92