|
@@ -11,89 +11,52 @@
|
11
|
11
|
@version $Id: kernelem1dmanager.cpp 193 2014-11-10 23:51:41Z tirons $
|
12
|
12
|
**/
|
13
|
13
|
|
14
|
|
-#include "kernelem1dmanager.h"
|
15
|
|
-
|
|
14
|
+#include "KernelEM1DManager.h"
|
16
|
15
|
|
17
|
16
|
namespace Lemma {
|
18
|
17
|
|
19
|
|
- std::ostream &operator<<(std::ostream &stream,
|
20
|
|
- const KernelEM1DManager &ob) {
|
21
|
|
- stream << *(LemmaObject*)(&ob);
|
|
18
|
+ std::ostream &operator<<(std::ostream &stream, const KernelEM1DManager &ob) {
|
|
19
|
+ stream << ob.Serialize() << "\n---\n";
|
22
|
20
|
return stream;
|
23
|
21
|
}
|
24
|
22
|
|
25
|
23
|
|
26
|
24
|
// ==================== LIFECYCLE =======================
|
27
|
25
|
|
28
|
|
- KernelEM1DManager::KernelEM1DManager(const std::string& name) :
|
29
|
|
- LemmaObject(name), TEReflBase(NULL), TMReflBase(NULL), Earth(NULL), Dipole(NULL) {
|
|
26
|
+ KernelEM1DManager::KernelEM1DManager( const ctor_key& ) : LemmaObject( ), TEReflBase(nullptr),
|
|
27
|
+ TMReflBase(nullptr), Earth(nullptr), Dipole(nullptr) {
|
30
|
28
|
}
|
31
|
29
|
|
32
|
30
|
KernelEM1DManager::~KernelEM1DManager() {
|
33
|
31
|
|
34
|
|
- if (this->NumberOfReferences != 0)
|
35
|
|
- throw DeleteObjectWithReferences(this);
|
36
|
|
-
|
37
|
|
-// if (Earth != NULL) {
|
38
|
|
-// Earth->DetachFrom(this);
|
39
|
|
-// }
|
40
|
|
-//
|
41
|
|
-// if (Dipole != NULL) {
|
42
|
|
-// Dipole->DetachFrom(this);
|
43
|
|
-// }
|
44
|
|
-
|
45
|
|
- for (unsigned int ik=0; ik<KernelVec.size(); ++ik) {
|
46
|
|
- KernelVec[ik]->Delete();
|
47
|
|
- }
|
48
|
|
-
|
49
|
|
- if (TEReflBase != NULL) TEReflBase->Delete();
|
50
|
|
- if (TMReflBase != NULL) TMReflBase->Delete();
|
51
|
|
-
|
52
|
|
- }
|
53
|
|
-
|
54
|
|
- KernelEM1DManager* KernelEM1DManager::New() {
|
55
|
|
- KernelEM1DManager* Obj = new KernelEM1DManager("KernelEM1DManager");
|
56
|
|
- Obj->AttachTo(Obj);
|
57
|
|
- return Obj;
|
58
|
32
|
}
|
59
|
33
|
|
60
|
|
- void KernelEM1DManager::Delete() {
|
61
|
|
- this->DetachFrom(this);
|
|
34
|
+ std::shared_ptr<KernelEM1DManager> KernelEM1DManager::NewSP() {
|
|
35
|
+ return std::make_shared<KernelEM1DManager>( ctor_key() );
|
62
|
36
|
}
|
63
|
37
|
|
64
|
|
- void KernelEM1DManager::Release() {
|
65
|
|
- delete this;
|
66
|
|
- }
|
67
|
38
|
|
68
|
39
|
// ==================== ACCESS =======================
|
69
|
40
|
|
70
|
41
|
// A race condition can develop with these. It's OK to not attach, since this is an internal class, and
|
71
|
42
|
// we know what is going on.
|
72
|
|
- void KernelEM1DManager::SetEarth(LayeredEarthEM* Earthin) {
|
73
|
|
- //if (Earth != NULL) {
|
74
|
|
- // Earth->DetachFrom(this);
|
75
|
|
- //}
|
76
|
|
- //Earthin->AttachTo(this);
|
|
43
|
+ void KernelEM1DManager::SetEarth( std::shared_ptr<LayeredEarthEM> Earthin) {
|
77
|
44
|
Earth = Earthin;
|
78
|
45
|
}
|
79
|
46
|
|
80
|
|
- void KernelEM1DManager::SetDipoleSource(DipoleSource* DipoleIn, const int& ifreqin,
|
|
47
|
+ void KernelEM1DManager::SetDipoleSource( std::shared_ptr<DipoleSource> DipoleIn, const int& ifreqin,
|
81
|
48
|
const Real& rx_zin) {
|
82
|
|
- //if (Dipole != NULL) {
|
83
|
|
- // Dipole->DetachFrom(this);
|
84
|
|
- //}
|
85
|
|
- //DipoleIn->AttachTo(this);
|
86
|
49
|
Dipole = DipoleIn;
|
87
|
50
|
|
88
|
51
|
ifreq = ifreqin;
|
89
|
52
|
rx_z = rx_zin;
|
90
|
53
|
}
|
91
|
54
|
|
92
|
|
- KernelEm1DBase* KernelEM1DManager::GetKernel(const unsigned int& ik) {
|
|
55
|
+ std::shared_ptr<KernelEm1DBase> KernelEM1DManager::GetKernel(const unsigned int& ik) {
|
93
|
56
|
return KernelVec[ik];
|
94
|
57
|
}
|
95
|
58
|
|
96
|
|
- DipoleSource* KernelEM1DManager::GetDipole( ) {
|
|
59
|
+ std::shared_ptr<DipoleSource> KernelEM1DManager::GetDipole( ) {
|
97
|
60
|
return Dipole;
|
98
|
61
|
}
|
99
|
62
|
|
|
@@ -101,12 +64,12 @@ namespace Lemma {
|
101
|
64
|
|
102
|
65
|
void KernelEM1DManager::ComputeReflectionCoeffs(const Real& lambda, const int& idx, const Real& rho0) {
|
103
|
66
|
|
104
|
|
- if (TEReflBase != NULL) {
|
|
67
|
+ if (TEReflBase != nullptr) {
|
105
|
68
|
TEReflBase->ComputeReflectionCoeffs(lambda);
|
106
|
69
|
TEReflBase->PreComputePotentialTerms( );
|
107
|
70
|
}
|
108
|
71
|
|
109
|
|
- if (TMReflBase != NULL) {
|
|
72
|
+ if (TMReflBase != nullptr) {
|
110
|
73
|
TMReflBase->ComputeReflectionCoeffs(lambda);
|
111
|
74
|
TMReflBase->PreComputePotentialTerms( );
|
112
|
75
|
}
|
|
@@ -115,11 +78,11 @@ namespace Lemma {
|
115
|
78
|
|
116
|
79
|
void KernelEM1DManager::ResetSource(const int& ifreq) {
|
117
|
80
|
|
118
|
|
- if (TEReflBase != NULL) {
|
|
81
|
+ if (TEReflBase != nullptr) {
|
119
|
82
|
TEReflBase->SetUpSource(Dipole, ifreq);
|
120
|
83
|
}
|
121
|
84
|
|
122
|
|
- if (TMReflBase != NULL) {
|
|
85
|
+ if (TMReflBase != nullptr) {
|
123
|
86
|
TMReflBase->SetUpSource(Dipole, ifreq);
|
124
|
87
|
|
125
|
88
|
}
|