瀏覽代碼

Work towards porting FD1D over to the new build. Also cleaning up the air layer stuff, so that things are more explicit and clear.

enhancement_3
Trevor Irons 8 年之前
父節點
當前提交
137f9f6b8d

+ 2
- 0
LemmaCore/include/LayeredEarth.h 查看文件

@@ -26,6 +26,8 @@ namespace Lemma {
26 26
 	// =======================================================================
27 27
 	class LayeredEarth : public EarthModel {
28 28
 
29
+        friend class LayeredEarthEM;
30
+
29 31
 		public:
30 32
 
31 33
 			// ====================    FRIENDS     ===========================

+ 2
- 1
LemmaCore/include/LemmaObject.h 查看文件

@@ -94,7 +94,8 @@ class LemmaObject {
94 94
         LemmaObject (const YAML::Node& node);
95 95
 
96 96
         /** Protected default destructor. This is an abstract class and
97
-         *  cannot be instantiated.
97
+         *  cannot be instantiated. Virtual is necessary so that if base class destructor is
98
+         *  called, we get the right behaviour.
98 99
          */
99 100
         virtual ~LemmaObject();
100 101
 

+ 19
- 0
Modules/FDEM1D/CMakeLists.txt 查看文件

@@ -0,0 +1,19 @@
1
+include_directories(${CMAKE_INSTALL_PREFIX}/include)
2
+
3
+include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" )
4
+add_subdirectory("src")
5
+
6
+add_library( fdem1d ${FEM1DSOURCE} )  
7
+target_link_libraries(fdem1d "lemmacore")
8
+
9
+install ( TARGETS fdem1d DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
10
+
11
+if (LEMMA_BUILD_EXAMPLES)
12
+	add_subdirectory(examples)
13
+endif()
14
+	
15
+if (LEMMA_ENABLE_TESTING)
16
+	add_subdirectory(testing)
17
+endif()
18
+
19
+install ( TARGETS fdem1d DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )

+ 6
- 0
Modules/FDEM1D/examples/CMakeLists.txt 查看文件

@@ -0,0 +1,6 @@
1
+add_executable( LayeredEarthEM LayeredEarthEM.cpp  )
2
+target_link_libraries(  LayeredEarthEM  "lemmacore" "fdem1d")
3
+
4
+INSTALL_TARGETS( "/share/FEM1D/"
5
+	LayeredEarthEM 
6
+)

+ 32
- 0
Modules/FDEM1D/examples/LayeredEarthEM.cpp 查看文件

@@ -0,0 +1,32 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API.
2
+ * More information is available at http://lemmasoftware.org
3
+ */
4
+
5
+/* This Source Code Form is subject to the terms of the Mozilla Public
6
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
7
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
+ */
9
+
10
+/**
11
+ * @file
12
+ * @date      07/14/2016 03:14:50 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Lemma Software, LLC
18
+ */
19
+
20
+#include "FEM1D"
21
+
22
+using namespace Lemma;
23
+
24
+int main() {
25
+
26
+    auto model = LayeredEarthEM::NewSP();
27
+        model->SetNumberOfLayers(6);
28
+        model->SetLayerThickness( (VectorXr(4) << 10,10,10,10).finished() );
29
+        model->SetLayerConductivity( (VectorXcr(6) << .1, .10,.10,.10,.10,.10).finished() );
30
+    std::cout << *model << std::endl;
31
+}
32
+

Modules/FDEM1D/AEMSurvey.h → Modules/FDEM1D/include/AEMSurvey.h 查看文件


Modules/FDEM1D/AEMSurveyReader.h → Modules/FDEM1D/include/AEMSurveyReader.h 查看文件


+ 4
- 0
Modules/FDEM1D/include/FEM1D 查看文件

@@ -0,0 +1,4 @@
1
+#include "LayeredEarthEM.h"
2
+
3
+/* vim: set tabstop=4 expandtab: */
4
+/* vim: set filetype=cpp: */

Modules/FDEM1D/include/layeredearthem.h → Modules/FDEM1D/include/LayeredEarthEM.h 查看文件

@@ -14,7 +14,7 @@
14 14
 #ifndef __LAYEREDEARTHEM_H
15 15
 #define __LAYEREDEARTHEM_H
16 16
 
17
-#include "layeredearth.h"
17
+#include "LayeredEarth.h"
18 18
 #include <iomanip>
19 19
 
20 20
 namespace Lemma {
@@ -38,29 +38,23 @@ namespace Lemma {
38 38
             // ====================  LIFECYCLE     ===========================
39 39
 
40 40
             /**
41
-             *  Public constructor. Creates a new instance of the class and
42
-             *  assigns a reference to the thrown pointer.
41
+             *  Factory method for generating concrete class.
42
+             *  @return a std::shared_ptr of type LayeredEarthEM
43 43
              */
44
-            static LayeredEarthEM* New();
44
+            static std::shared_ptr<LayeredEarthEM> NewSP();
45 45
 
46
-            /**
47
-             * @copybrief LemmaObject::Delete()
48
-             * @copydetails LemmaObject::Delete()
49
-             */
50
-            void Delete();
51
-
52
-            #ifdef HAVE_YAMLCPP
53 46
             /** YAML Serializing method
54 47
              */
55 48
             YAML::Node Serialize() const;
56 49
 
57
-
58
-            //static LayeredEarthEM* DeSerialize(const YAML::Node& node);
59
-            #endif
50
+            /**
51
+             *   Constructs an object from a YAML::Node.
52
+             */
53
+            static std::shared_ptr< LayeredEarthEM > DeSerialize(const YAML::Node& node);
60 54
 
61 55
             /** @return a deep copy
62 56
              */
63
-			LayeredEarthEM* Clone();
57
+			std::shared_ptr<LayeredEarthEM> Clone();
64 58
 
65 59
             // ====================  OPERATORS     ===========================
66 60
 
@@ -243,12 +237,10 @@ namespace Lemma {
243 237
             // ====================  LIFECYCLE     ===========================
244 238
 
245 239
             /** Default protected constructor. */
246
-            LayeredEarthEM (const std::string &name);
240
+            LayeredEarthEM ( );
247 241
 
248
-            #ifdef HAVE_YAMLCPP
249 242
             /** Default protected constructor. */
250 243
 			LayeredEarthEM (const YAML::Node& node);
251
-            #endif
252 244
 
253 245
             /** Default protected constructor. */
254 246
             ~LayeredEarthEM ();
@@ -306,9 +298,17 @@ namespace Lemma {
306 298
             /** Relaxation breath for each layer */
307 299
             VectorXr          LayerBreathPermitivity;
308 300
 
301
+            private:
302
+
303
+            /** ASCII string representation of the class name */
304
+            static constexpr auto CName = "LayeredEarthEM";
305
+
309 306
     }; // -----  end of class  LayeredEarthEM  -----
310 307
 
311 308
 
312 309
 } // namespace Lemma
313 310
 
314 311
 #endif // __LAYEREDEARTHEM_H
312
+
313
+/* vim: set tabstop=4 expandtab: */
314
+/* vim: set filetype=cpp: */

+ 6
- 0
Modules/FDEM1D/src/CMakeLists.txt 查看文件

@@ -0,0 +1,6 @@
1
+set (FEM1DSOURCE
2
+	${FEM1DSOURCE}
3
+	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEM.cpp
4
+	#${CMAKE_CURRENT_SOURCE_DIR}/UngroundedElectricDipole.cpp
5
+	PARENT_SCOPE
6
+)

Modules/FDEM1D/src/layeredearthem.cpp → Modules/FDEM1D/src/LayeredEarthEM.cpp 查看文件

@@ -11,75 +11,31 @@
11 11
   @version  $Id: layeredearthem.cpp 216 2015-03-09 02:26:49Z tirons $
12 12
  **/
13 13
 
14
-#include "layeredearthem.h"
14
+#include "LayeredEarthEM.h"
15 15
 
16 16
 namespace Lemma {
17 17
 
18
-#ifdef HAVE_YAMLCPP
19 18
     std::ostream &operator << (std::ostream &stream, const LayeredEarthEM &ob) {
20 19
         stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
21 20
         return stream;
22 21
     }
23
-#else
24
-    std::ostream &operator<<(std::ostream &stream,
25
-                const LayeredEarthEM &ob) {
26
-        stream << *(LayeredEarth*)(&ob);
27
-        //stream << "Class Name : "<< ob.Name  << "\n";
28
-        stream << std::setw(15) << "LayerNumber"         << "\t"
29
-               << std::setw(15) << "Thickness"           << "\t"
30
-               << std::setw(15) << "BottomInterface"     << "\t"
31
-               << std::setw(15) << "Conductivity"        << "\t"
32
-               << std::setw(15) << "Susceptibility"      << "\t"
33
-               << std::setw(15) << "Permitivity"         << "\n";
34
-        stream << std::setw(15) << " "                   << "\t"
35
-               << std::setw(15) << "[m]"                 << "\t"
36
-               << std::setw(15) << "[m]"                 << "\t"
37
-               << std::setw(15) << "[Sm^-1]"             << "\t"
38
-               << std::setw(15) << "[]"                  << "\t"
39
-               << std::setw(15) << "[F/m]"               << "\n";
40
-        for (int i=0; i< ob.NumberOfLayers; ++i) {
41
-            stream << std::setw(15) <<  i << "\t"
42
-                   << std::setw(15) << ((LayeredEarth*)(&ob))->GetLayerThickness(i) << "\t"
43
-                   << std::setw(15) << ((LayeredEarth*)(&ob))->GetLayerDepth(i) << "\t"
44
-                   << std::setw(15) << ob.LayerConductivity(i)     << "\t"
45
-                   << std::setw(15) << ob.LayerSusceptibility(i)   << "\t"
46
-                   << std::setw(15) << ob.LayerPermitivity(i)      << "\n";
47
-        }
48
-
49
-        return stream;
50
-    }
51
-#endif
52 22
 
53 23
     // ====================  LIFECYCLE     ===================================
54 24
 
55
-    LayeredEarthEM::LayeredEarthEM(const std::string &name) :
56
-        LayeredEarth(name) {
25
+    LayeredEarthEM::LayeredEarthEM( ) : LayeredEarth() {
57 26
     }
58 27
 
59 28
     LayeredEarthEM::~LayeredEarthEM() {
60
-        if (NumberOfReferences != 0) {
61
-            throw DeleteObjectWithReferences(this);
62
-        }
63
-    }
64
-
65
-    LayeredEarthEM* LayeredEarthEM::New() {
66
-        LayeredEarthEM* Obj = new LayeredEarthEM("LayeredEarthEM");
67
-        Obj->AttachTo(Obj);
68
-        return Obj;
69 29
     }
70 30
 
71
-    void LayeredEarthEM::Delete() {
72
-        this->DetachFrom(this);
31
+    std::shared_ptr<LayeredEarthEM> LayeredEarthEM::NewSP() {
32
+        std::shared_ptr<LayeredEarthEM> sp(new  LayeredEarthEM( ), LemmaObjectDeleter() );
33
+        return sp;
73 34
     }
74 35
 
75
-    void LayeredEarthEM::Release() {
76
-        delete this;
77
-    }
78
-
79
-    #ifdef HAVE_YAMLCPP
80 36
     YAML::Node LayeredEarthEM::Serialize() const {
81 37
         YAML::Node node = LayeredEarth::Serialize();
82
-        node.SetTag( this->Name );
38
+        node.SetTag( GetName() );
83 39
         node["LayerConductivity"] = LayerConductivity;
84 40
         node["LayerSusceptibility"] = LayerSusceptibility;
85 41
         node["LayerLowFreqSusceptibility"] = LayerLowFreqSusceptibility;
@@ -93,12 +49,11 @@ namespace Lemma {
93 49
         node["LayerBreathPermitivity"] = LayerBreathPermitivity;
94 50
         return node;
95 51
     }
96
-    #endif
97 52
 
98 53
     // ====================  OPERATIONS    ===================================
99 54
     void LayeredEarthEM::EvaluateColeColeModel(const Real& omega) {
100 55
 
101
-        for (int ilay=0; ilay<NumberOfLayers; ++ilay) {
56
+        for (int ilay=0; ilay<GetNumberOfLayers(); ++ilay) {
102 57
             if ( LayerTauSusceptibility(ilay) > 1e-10) {
103 58
                 LayerSusceptibility(ilay) = LayerHighFreqSusceptibility(ilay) + (LayerLowFreqSusceptibility(ilay) -
104 59
                      LayerHighFreqSusceptibility(ilay)) /
@@ -122,9 +77,8 @@ namespace Lemma {
122 77
         }
123 78
     }
124 79
 
125
-	LayeredEarthEM* LayeredEarthEM::Clone() {
126
-		LayeredEarthEM* copy = LayeredEarthEM::New();
127
-
80
+	std::shared_ptr<LayeredEarthEM> LayeredEarthEM::Clone() {
81
+		auto copy = LayeredEarthEM::NewSP();
128 82
 		copy->LayerConductivity = this->LayerConductivity;
129 83
 		copy->LayerSusceptibility = this->LayerSusceptibility;
130 84
 		copy->LayerLowFreqSusceptibility = this->LayerLowFreqSusceptibility;
@@ -136,24 +90,22 @@ namespace Lemma {
136 90
 		copy->LayerHighFreqPermitivity = this->LayerHighFreqPermitivity;
137 91
 		copy->LayerTauPermitivity = this->LayerTauPermitivity;
138 92
 		copy->LayerBreathPermitivity = this->LayerBreathPermitivity;
139
-		copy->NumberOfLayers = this->NumberOfLayers;
93
+		copy->SetNumberOfLayers( this->GetNumberOfLayers() );
140 94
 		copy->NumberOfInterfaces = this->NumberOfInterfaces;
141 95
 		copy->LayerThickness = this->LayerThickness;
142
-
143 96
 		return copy;
144
-
145 97
 	}
146 98
 
147 99
     // ====================  ACCESS        ==================================
148 100
 
149 101
     void LayeredEarthEM::SetLayerConductivity(const VectorXcr &sig) {
150
-        if (sig.size() != this->NumberOfLayers )
102
+        if (sig.size() != this->GetNumberOfLayers() )
151 103
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
152 104
         LayerConductivity = sig;
153 105
     }
154 106
 
155 107
     void LayeredEarthEM::SetLayerConductivity(const int& ilay, const Complex &sig) {
156
-        if (ilay > this->NumberOfLayers || ilay < 1 )
108
+        if (ilay > this->GetNumberOfLayers() || ilay < 1 )
157 109
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
158 110
         LayerConductivity[ilay] = sig;
159 111
     }
@@ -167,55 +119,55 @@ namespace Lemma {
167 119
 */
168 120
 
169 121
     void LayeredEarthEM::SetLayerHighFreqSusceptibility(const VectorXr &sus) {
170
-        if (sus.size() != this->NumberOfLayers )
122
+        if (sus.size() != this->GetNumberOfLayers() )
171 123
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
172 124
         LayerHighFreqSusceptibility = sus;
173 125
     }
174 126
 
175 127
     void LayeredEarthEM::SetLayerLowFreqSusceptibility(const VectorXr &sus) {
176
-        if (sus.size() != this->NumberOfLayers )
128
+        if (sus.size() != this->GetNumberOfLayers() )
177 129
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
178 130
         LayerLowFreqSusceptibility = sus;
179 131
     }
180 132
 
181 133
     void LayeredEarthEM::SetLayerBreathSusceptibility(const VectorXr &sus) {
182
-        if (sus.size() != this->NumberOfLayers )
134
+        if (sus.size() != this->GetNumberOfLayers() )
183 135
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
184 136
         LayerBreathSusceptibility = sus;
185 137
     }
186 138
 
187 139
     void LayeredEarthEM::SetLayerTauSusceptibility(const VectorXr &sus) {
188
-        if (sus.size() != this->NumberOfLayers )
140
+        if (sus.size() != this->GetNumberOfLayers() )
189 141
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
190 142
         LayerTauSusceptibility = sus;
191 143
     }
192 144
 
193 145
     void LayeredEarthEM::SetLayerHighFreqPermitivity(const VectorXr &per) {
194
-        if (per.size() != this->NumberOfLayers )
146
+        if (per.size() != this->GetNumberOfLayers() )
195 147
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
196 148
         LayerHighFreqPermitivity = per;
197 149
     }
198 150
 
199 151
     void LayeredEarthEM::SetLayerLowFreqPermitivity(const VectorXr &per) {
200
-        if (per.size() != this->NumberOfLayers )
152
+        if (per.size() != this->GetNumberOfLayers() )
201 153
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
202 154
         LayerLowFreqPermitivity = per;
203 155
     }
204 156
 
205 157
     void LayeredEarthEM::SetLayerBreathPermitivity(const VectorXr &per) {
206
-        if (per.size() != this->NumberOfLayers )
158
+        if (per.size() != this->GetNumberOfLayers() )
207 159
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
208 160
         LayerBreathPermitivity = per;
209 161
     }
210 162
 
211 163
     void LayeredEarthEM::SetLayerTauPermitivity(const VectorXr &per) {
212
-        if (per.size() != this->NumberOfLayers )
164
+        if (per.size() != this->GetNumberOfLayers() )
213 165
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
214 166
         LayerTauPermitivity = per;
215 167
     }
216 168
 
217 169
     void LayeredEarthEM::SetLayerThickness(const VectorXr &thick) {
218
-        if (thick.size() != this->NumberOfLayers - 2)
170
+        if (thick.size() != this->GetNumberOfLayers() - 2)
219 171
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
220 172
         LayerThickness = thick;
221 173
     }
@@ -231,7 +183,7 @@ namespace Lemma {
231 183
 
232 184
         // Otherwise
233 185
         this->NumberOfLayers = nlay;
234
-
186
+        this->NumberOfInterfaces = nlay-1;
235 187
 
236 188
         // Resize all layers
237 189
 
@@ -244,7 +196,6 @@ namespace Lemma {
244 196
         // Conducitivy set to zero
245 197
         LayerConductivity = VectorXcr::Zero(NumberOfLayers);
246 198
 
247
-
248 199
         ////////////////////////////////////
249 200
         // Susceptibility set to One (free space)
250 201
         LayerSusceptibility = VectorXcr::Ones(NumberOfLayers);
@@ -359,3 +310,6 @@ namespace Lemma {
359 310
         return this->LayerBreathPermitivity;
360 311
     }
361 312
 }
313
+
314
+/* vim: set tabstop=4 expandtab: */
315
+/* vim: set filetype=cpp: */

+ 3
- 0
Modules/FDEM1D/testing/CMakeLists.txt 查看文件

@@ -0,0 +1,3 @@
1
+
2
+CXXTEST_ADD_TEST(unittestFEM1D_GetNameCheck GetNameCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/GetNameCheck.h)
3
+target_link_libraries(unittestFEM1D_GetNameCheck "lemmacore" "fdem1d")

+ 37
- 0
Modules/FDEM1D/testing/GetNameCheck.h 查看文件

@@ -0,0 +1,37 @@
1
+/* This file is part of Lemma, a geophysical modelling and inversion API.
2
+ * More information is available at http://lemmasoftware.org
3
+ */
4
+
5
+/* This Source Code Form is subject to the terms of the Mozilla Public
6
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
7
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
+ */
9
+
10
+/**
11
+ * @file
12
+ * @date      06/23/2016 01:26:46 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Lemma Software, LLC
18
+ */
19
+
20
+#include <cxxtest/TestSuite.h>
21
+#include <LemmaCore>
22
+#include <FEM1D>
23
+
24
+using namespace Lemma;
25
+
26
+class MyTestSuite : public CxxTest::TestSuite
27
+{
28
+    public:
29
+
30
+    void testLayeredEarthEM( void )
31
+    {
32
+        auto Obj = LayeredEarthEM::NewSP();
33
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("LayeredEarthEM") );
34
+    }
35
+
36
+};
37
+

Loading…
取消
儲存