Sfoglia il codice sorgente

Missing file added

enhancement_3
Trevor Irons 8 anni fa
parent
commit
2ba7e19435
1 ha cambiato i file con 244 aggiunte e 0 eliminazioni
  1. 244
    0
      Modules/FDEM1D/include/KernelEM1DReflBase.h

+ 244
- 0
Modules/FDEM1D/include/KernelEM1DReflBase.h Vedi File

@@ -0,0 +1,244 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API */
2
+
3
+/* This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
+
7
+/**
8
+  @file
9
+  @author   Trevor Irons
10
+  @date     05/18/2012
11
+ **/
12
+
13
+#ifndef  KERNELEM1DREFLBASE_INC
14
+#define  KERNELEM1DREFLBASE_INC
15
+
16
+#include "KernelEM1DBase.h"
17
+#include "DipoleSource.h"
18
+#include "LayeredEarthEM.h"
19
+
20
+namespace Lemma {
21
+
22
+    enum DIPOLE_LOCATION { INAIR, INGROUND };
23
+
24
+    // forward declaration for friend
25
+    template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
26
+    class KernelEM1DSpec;
27
+
28
+
29
+    // ===================================================================
30
+    //  Class:  KernelEM1DReflBase
31
+    /**
32
+      @class
33
+      \brief   Abstract class defining EM1DRefl class.
34
+      \details Derived classes are template specialized for optimal performance.
35
+     */
36
+    // ===================================================================
37
+    class KernelEM1DReflBase : public LemmaObject {
38
+
39
+        template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
40
+        friend class KernelEM1DSpec;
41
+        friend class KernelEM1DManager;
42
+        //friend class DipoleSource;
43
+
44
+        public:
45
+
46
+            // ====================  LIFECYCLE     =======================
47
+
48
+            // ====================  OPERATORS     =======================
49
+
50
+            // ====================  OPERATIONS    =======================
51
+
52
+            void Initialise( std::shared_ptr<LayeredEarthEM> EarthIn) {
53
+
54
+                nlay = EarthIn->GetNumberOfLayers();
55
+                zh = VectorXcr::Zero(nlay);
56
+                yh = VectorXcr::Zero(nlay);
57
+                u = VectorXcr::Zero(nlay);
58
+                cf = VectorXcr::Zero(nlay);    // nlay -1 (lay 0 empty)
59
+                rtu = VectorXcr::Zero(nlay);   // nlay -1 Interfaces only
60
+                rtd = VectorXcr::Zero(nlay);   // nlay -1 Interfaces only
61
+                kk = VectorXcr::Zero(nlay);
62
+                Zyu = VectorXcr::Zero(nlay);
63
+                Zyd = VectorXcr::Zero(nlay);
64
+                Zyi = VectorXcr::Zero(nlay);
65
+                th = VectorXcr::Zero(nlay);
66
+
67
+                // Don't attach Earth, because this is performance critical.
68
+                // Everying is internal, it's OK relax Frankie
69
+                //if (Earth != NULL) {
70
+                //    Earth->DetachFrom(this);
71
+                //    Earth = NULL;
72
+                //}
73
+                //EarthIn->AttachTo(this);
74
+                Earth = EarthIn;
75
+
76
+                LayerThickness.resize(nlay);
77
+                for (int ilay=0; ilay<nlay; ++ilay) {
78
+                    LayerThickness(ilay) =  Earth->GetLayerThickness(ilay);
79
+                }
80
+
81
+                LayerDepth.resize(nlay);
82
+                for (int ilay=0; ilay<nlay; ++ilay) {
83
+                    LayerDepth(ilay) =  Earth->GetLayerDepth(ilay);
84
+                }
85
+
86
+            }
87
+
88
+            void SetUpSource( std::shared_ptr<DipoleSource> Dipole, const int &ifreq ) {
89
+
90
+                zh(0) = Complex(0, Dipole->GetAngularFrequency(ifreq)*MU0);
91
+                yh(0) = Complex(0, Dipole->GetAngularFrequency(ifreq)*EPSILON0);
92
+                kk(0) = -zh(0) * yh(0);
93
+
94
+                Earth->EvaluateColeColeModel(Dipole->GetAngularFrequency(ifreq));
95
+
96
+                for (int ilay=1; ilay<Earth->GetNumberOfLayers(); ++ilay) {
97
+                    zh(ilay) = zh(0) * Earth->GetLayerSusceptibility(ilay);
98
+                    yh(ilay) = Earth->GetLayerConductivity(ilay) +
99
+                            yh(0)*Earth->GetLayerPermitivity(ilay);
100
+                    kk(ilay)   = -zh(ilay)*yh(ilay);
101
+                }
102
+
103
+                tx_z = Dipole->GetLocation(2);
104
+                lays = 0;
105
+                Real Depth(0);
106
+                for (int ilay=1; ilay<nlay; ++ilay) {
107
+                    if (tx_z > Depth) {
108
+                        lays = ilay;
109
+                    }
110
+                    Depth += LayerThickness(ilay);
111
+                }
112
+            }
113
+
114
+            void SetUpReceiver(const Real &rz) {
115
+                rx_z = rz;
116
+                Real Depth(0.);
117
+                layr = 0;
118
+                for (int ilay=1; ilay<Earth->GetNumberOfLayers(); ++ilay) {
119
+                    if (rx_z > Depth) {
120
+                        layr = ilay;
121
+                    }
122
+                    Depth += LayerThickness(ilay);
123
+                }
124
+            }
125
+
126
+            // ====================  ACCESS        =======================
127
+            Complex GetYm() {
128
+                return yh(layr);
129
+            }
130
+
131
+            Complex GetZm() {
132
+                return zh(layr);
133
+            }
134
+
135
+            Complex GetZs() {
136
+                return zh(lays);
137
+            }
138
+
139
+            Complex GetKs() {
140
+                return kk(lays);
141
+            }
142
+
143
+            // ====================  INQUIRY       =======================
144
+
145
+        protected:
146
+
147
+            // ====================  LIFECYCLE     =======================
148
+
149
+            /// Default protected constructor.
150
+            KernelEM1DReflBase ( ) : LemmaObject( )
151
+            {
152
+            }
153
+
154
+            /// Default protected constructor.
155
+            ~KernelEM1DReflBase () {
156
+            }
157
+
158
+            // ====================  OPERATIONS    =======================
159
+
160
+            /** Computes reflection coefficients. Depending on the
161
+             * specialisation, this will either be TM or TE mode.
162
+             */
163
+            virtual void ComputeReflectionCoeffs(const Real& lambda)=0;
164
+
165
+            /** Precomputes expensive calculations that are reused by insances
166
+             * of KernelEM1DSpec in the calculation of Related potentials.
167
+             */
168
+            virtual void PreComputePotentialTerms()=0;
169
+
170
+            // ====================  DATA MEMBERS  =========================
171
+
172
+			/// Bessel order, only 0 or 1 supported
173
+			int id; // Needs to be dim nRel, or separate
174
+
175
+            /// Layer the source is in
176
+			int lays;
177
+
178
+			/// Layer the receiver is in
179
+			int layr;
180
+
181
+			/// Number of Layers
182
+			int nlay;
183
+
184
+            /// Number of Related kernels to be computed
185
+            int nRelated;
186
+
187
+            /// Used in related kernel precompute calls
188
+            int relIud;
189
+
190
+			/// Receiver z position
191
+			Real rx_z;
192
+
193
+			/// Transmitter z position
194
+			Real tx_z;
195
+
196
+            /// bessel arg squared
197
+            Real rams;
198
+
199
+            /** Related part of con term */
200
+            Complex  relCon;
201
+
202
+            Complex  relenukadz;
203
+
204
+            Complex  relexp_pbs1;
205
+
206
+            Complex  relexp_pbs2;
207
+
208
+            Complex  rel_a;
209
+
210
+			/// TM or TE mode
211
+			EMMODE mode;
212
+
213
+            /// Pointer to layered earth
214
+            std::shared_ptr<LayeredEarthEM> Earth;
215
+
216
+			Complex       uk;
217
+			Complex       um;
218
+			VectorXcr     cf;  // nlay
219
+			VectorXcr      u;  // nlay
220
+			VectorXcr     yh;  // nlay
221
+			VectorXcr     zh;  // nlay
222
+			VectorXcr     kk;  // nlay
223
+			VectorXcr    Zyu;  //(nlay); //Zyu.setZero();
224
+			VectorXcr    Zyd;  //(nlay); //Zyd.setZero();
225
+			VectorXcr    Zyi;  //(nlay); //Zyi.setZero();
226
+			VectorXcr     th;  //(nlay);
227
+			VectorXr     LayerThickness;
228
+			VectorXr     LayerDepth;
229
+
230
+			/// Reflection/Transmission coeffients for upgoing waves in a
231
+			/// layered earth model
232
+			VectorXcr    rtu;
233
+
234
+			/// Reflection/Transmission coeffients for downgoing waves in
235
+			/// a layered earth model
236
+			VectorXcr    rtd;
237
+
238
+        private:
239
+
240
+    }; // -----  end of class  KernelEM1DReflBase  -----
241
+
242
+}		// -----  end of Lemma  name  -----
243
+
244
+#endif   // ----- #ifndef KERNELEM1DREFLBASE_INC  -----

Loading…
Annulla
Salva