Sfoglia il codice sorgente

Work on TEM module

add-code-of-conduct-1
Trevor Irons 6 anni fa
parent
commit
c79829d670

+ 33
- 0
Modules/TEM1D/CMakeLists.txt Vedi File

@@ -0,0 +1,33 @@
1
+add_subdirectory("src")
2
+add_library( tem1d ${TEM1DSOURCE} )  
3
+target_include_directories( tem1d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
4
+
5
+set_target_properties(tem1d PROPERTIES 
6
+	VERSION  "${LEMMA_VERSION_NOQUOTES}"
7
+	SOVERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}"
8
+	PROJECT_LABEL "TEM1D ${LABEL_SUFFIX}"
9
+    CXX_STANDARD 14
10
+    CXX_STANDARD_REQUIRED ON
11
+)
12
+
13
+# Linking
14
+target_link_libraries(tem1d "lemmacore")
15
+target_link_libraries(tem1d "fdem1d")
16
+
17
+# Testing
18
+if (LEMMA_ENABLE_TESTING)
19
+	add_subdirectory(testing)
20
+endif()
21
+
22
+# Install
23
+install ( TARGETS tem1d DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
24
+install ( FILES include/TEM1D  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 
25
+install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma  FILES_MATCHING PATTERN "*.h")
26
+
27
+#install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")
28
+#install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/FDEM1D  FILES_MATCHING PATTERN "*.h")
29
+
30
+# Examples
31
+if (LEMMA_BUILD_EXAMPLES)
32
+	add_subdirectory(examples)
33
+endif()

+ 0
- 0
Modules/TEM1D/examples/CMakeLists.txt Vedi File


+ 30
- 32
Modules/TEM1D/include/TEMReceiver.h Vedi File

@@ -10,58 +10,66 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      10/08/2014 02:36:47 PM
13
- * @version   $Id$
14 13
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
16
- * @copyright Copyright (c) 2014, XRI Geophysics, LLC
14
+ * @email     Trevor.Irons@Utah.edu
17 15
  * @copyright Copyright (c) 2014, Trevor Irons
18 16
  */
17
+#pragma once
19 18
 
20 19
 #ifndef  TEMRECEIVER_INC
21 20
 #define  TEMRECEIVER_INC
22 21
 
23
-#include "receiverpoints.h"
22
+#include <random>
23
+//#include "yaml-cpp/yaml.h"
24
+#include <LemmaCore>
25
+#include <FDEM1D>
24 26
 
25 27
 //#include <boost/random.hpp>
26 28
 //#include <boost/random/normal_distribution.hpp>
27
-#include <random>
28 29
 
29 30
 namespace Lemma {
30 31
 
31
-#ifdef HAVE_YAMLCPP
32
-#include "yaml-cpp/yaml.h"
33
-#endif
34
-
35
-
36 32
 /**
37 33
   \brief
38 34
   \details
39 35
  */
40
-class TEMReceiver : public ReceiverPoints {
36
+class TEMReceiver : public FieldPoints {
41 37
 
42
-    friend std::ostream &operator<<(std::ostream &stream,
43
-            const TEMReceiver &ob);
38
+    friend std::ostream &operator<<(std::ostream &stream, const TEMReceiver &ob);
44 39
 
45 40
     public:
46 41
 
47 42
     // ====================  LIFECYCLE     =======================
48 43
 
44
+    /** Default locked constructor. */
45
+    explicit TEMReceiver ( const ctor_key& );
46
+
47
+    /** Locked deserializing constructor. */
48
+    TEMReceiver (const YAML::Node& node, const ctor_key&);
49
+
50
+    /** Default destructor. */
51
+    ~TEMReceiver ();
52
+
49 53
     /**
50
-     * @copybrief LemmaObject::New()
51
-     * @copydetails LemmaObject::New()
54
+     *  Factory method for generating concrete class.
55
+     *  @return a std::shared_ptr of type TEMReceiver
52 56
      */
53
-    static TEMReceiver* New();
57
+    static std::shared_ptr<TEMReceiver> NewSP();
54 58
 
55 59
     /**
56
-     *   @return a deep copy of this
60
+     *  Uses YAML to serialize this object.
61
+     *  @note The actual calculation results are not serialized, currently.
62
+     *  @return a YAML::Node
57 63
      */
58
-    TEMReceiver* Clone();
64
+    YAML::Node Serialize() const;
59 65
 
60 66
     /**
61
-     *  @copybrief   LemmaObject::Delete()
62
-     *  @copydetails LemmaObject::Delete()
67
+     *   Constructs an object from a YAML::Node.
68
+     *   @param[in] node is a YAML node containing the serialized class information
69
+     *   @return a std::shared_ptr object of TEMReceiver
63 70
      */
64
-    void Delete();
71
+    static std::shared_ptr<TEMReceiver> DeSerialize(const YAML::Node& node);
72
+
65 73
 
66 74
     // ====================  OPERATORS     =======================
67 75
 
@@ -141,21 +149,11 @@ class TEMReceiver : public ReceiverPoints {
141 149
      *  @return the reference time
142 150
      */
143 151
     Real    GetReferenceTime();
152
+
144 153
     protected:
145 154
 
146 155
     // ====================  LIFECYCLE     =======================
147 156
 
148
-    /** Default protected constructor, use New */
149
-    TEMReceiver (const std::string& name);
150
-
151
-     #ifdef HAVE_YAMLCPP
152
-    /** Default protected de-serializing constructor, use factory DeSerialize */
153
-    TEMReceiver (const YAML::Node& node);
154
-    #endif
155
-
156
-    /** Default protected destructor, use Delete */
157
-    ~TEMReceiver ();
158
-
159 157
     /**
160 158
      *  @copybrief   LemmaObject::Release()
161 159
      *  @copydetails LemmaObject::Release()

+ 50
- 0
Modules/TEM1D/src/CMakeLists.txt Vedi File

@@ -0,0 +1,50 @@
1
+set (TEM1DSOURCE
2
+	${TEM1DSOURCE}
3
+
4
+
5
+	${CMAKE_CURRENT_SOURCE_DIR}/TEMReceiver.cpp
6
+#	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEMReader.cpp
7
+	
8
+	# Calculation points
9
+#	${CMAKE_CURRENT_SOURCE_DIR}/FieldPoints.cpp
10
+
11
+	# Sources	
12
+#	${CMAKE_CURRENT_SOURCE_DIR}/CompactSupportEMSource.cpp
13
+#	${CMAKE_CURRENT_SOURCE_DIR}/CircularLoop.cpp
14
+
15
+#	${CMAKE_CURRENT_SOURCE_DIR}/DipoleSource.cpp
16
+#	${CMAKE_CURRENT_SOURCE_DIR}/WireAntenna.cpp
17
+#	${CMAKE_CURRENT_SOURCE_DIR}/PolygonalWireAntenna.cpp
18
+
19
+	# Kernel management	
20
+#	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DManager.cpp
21
+#	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DSpec.cpp
22
+#	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DReflSpec.cpp
23
+
24
+	#####################
25
+	# Hankel transforms #
26
+	#####################
27
+	# FHT
28
+#	${CMAKE_CURRENT_SOURCE_DIR}/HankelTransform.cpp
29
+#	${CMAKE_CURRENT_SOURCE_DIR}/FHTAnderson801.cpp
30
+#	${CMAKE_CURRENT_SOURCE_DIR}/FHTKey201.cpp
31
+#	${CMAKE_CURRENT_SOURCE_DIR}/FHTKey101.cpp
32
+#	${CMAKE_CURRENT_SOURCE_DIR}/FHTKey51.cpp
33
+
34
+	# Templated FHT
35
+#	${CMAKE_CURRENT_SOURCE_DIR}/FHT.cpp
36
+
37
+	# Gaussian Quadrature
38
+#	${CMAKE_CURRENT_SOURCE_DIR}/GQChave.cpp
39
+#	${CMAKE_CURRENT_SOURCE_DIR}/QWEKey.cpp
40
+	
41
+	# Calculation
42
+#	${CMAKE_CURRENT_SOURCE_DIR}/EMEarth1D.cpp
43
+
44
+	# AEM 
45
+#	${CMAKE_CURRENT_SOURCE_DIR}/AEMSurvey.cpp
46
+#	${CMAKE_CURRENT_SOURCE_DIR}/AEMSurveyReader.cpp
47
+	
48
+	#${CMAKE_CURRENT_SOURCE_DIR}/UngroundedElectricDipole.cpp
49
+	PARENT_SCOPE
50
+)

+ 22
- 54
Modules/TEM1D/src/TEMReceiver.cpp Vedi File

@@ -10,11 +10,9 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      10/08/2014 03:04:56 PM
13
- * @version   $Id$
14 13
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
16
- * @copyright Copyright (c) 2014, XRI Geophysics, LLC
17
- * @copyright Copyright (c) 2014, Trevor Irons
14
+ * @email     Trevor.Irons@utah.edu
15
+ * @copyright Copyright (c) 2014, 2018 Trevor Irons
18 16
  */
19 17
 
20 18
 #include "TEMReceiver.h"
@@ -23,36 +21,29 @@ namespace Lemma {
23 21
 
24 22
 
25 23
     // ====================  FRIEND METHODS  =====================
26
-#ifdef HAVE_YAMLCPP
24
+
27 25
     std::ostream &operator << (std::ostream &stream, const TEMReceiver &ob) {
28
-        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
29
-        return stream;
30
-    }
31
-#else
32
-    std::ostream &operator<<(std::ostream &stream, const TEMReceiver& ob) {
33
-        stream << *(ReceiverPoints*)(&ob);
26
+        stream << ob.Serialize()  << "\n";
34 27
         return stream;
35 28
     }
36
-#endif
37 29
 
38 30
     // ====================  LIFECYCLE     =======================
39 31
 
40 32
     //--------------------------------------------------------------------------------------
41 33
     //       Class:  TEMReceiver
42 34
     //      Method:  TEMReceiver
43
-    // Description:  constructor (protected)
35
+    // Description:  constructor (locked)
44 36
     //--------------------------------------------------------------------------------------
45
-    TEMReceiver::TEMReceiver (const std::string& name) : ReceiverPoints(name), moment(1), referenceTime(0) {
37
+    TEMReceiver::TEMReceiver ( const ctor_key& key ) : FieldPoints(key), moment(1), referenceTime(0) {
46 38
 
47 39
     }  // -----  end of method TEMReceiver::TEMReceiver  (constructor)  -----
48 40
 
49
-#ifdef HAVE_YAMLCPP
50 41
     //--------------------------------------------------------------------------------------
51 42
     //       Class:  TEMReceiver
52 43
     //      Method:  TEMReceiver
53 44
     // Description:  constructor (protected)
54 45
     //--------------------------------------------------------------------------------------
55
-    TEMReceiver::TEMReceiver (const YAML::Node& node) : ReceiverPoints(node) {
46
+    TEMReceiver::TEMReceiver (const YAML::Node& node, const ctor_key& key) : FieldPoints(node, key) {
56 47
 
57 48
         moment = node["moment"].as<Real>();
58 49
         referenceTime = node["referenceTime"].as<Real>();
@@ -63,17 +54,14 @@ namespace Lemma {
63 54
         noiseSTD      = node["noiseSTD"].as<VectorXr>();
64 55
         //location = node["location"].as<Vector3r>();
65 56
     }  // -----  end of method TEMReceiver::TEMReceiver  (constructor)  -----
66
-#endif
67 57
 
68 58
     //--------------------------------------------------------------------------------------
69 59
     //       Class:  TEMReceiver
70 60
     //      Method:  New()
71 61
     // Description:  public constructor
72 62
     //--------------------------------------------------------------------------------------
73
-    TEMReceiver* TEMReceiver::New() {
74
-        TEMReceiver*  Obj = new TEMReceiver("TEMReceiver");
75
-        Obj->AttachTo(Obj);
76
-        return Obj;
63
+    std::shared_ptr<TEMReceiver> TEMReceiver::NewSP() {
64
+        return std::make_shared<TEMReceiver> ( ctor_key() );
77 65
     }
78 66
 
79 67
 
@@ -81,6 +69,7 @@ namespace Lemma {
81 69
     //       Class:  TEMReceiver
82 70
     //      Method:  Clone
83 71
     //--------------------------------------------------------------------------------------
72
+/*
84 73
     TEMReceiver* TEMReceiver::Clone() {
85 74
         TEMReceiver* Copy = TEMReceiver::New();
86 75
             Copy->SetNumberOfReceivers( this->NumberOfReceivers );
@@ -96,6 +85,7 @@ namespace Lemma {
96 85
             Copy->noiseSTD = this->noiseSTD;
97 86
         return Copy;
98 87
     }		// -----  end of method TEMReceiver::Clone  -----
88
+*/
99 89
 
100 90
     //--------------------------------------------------------------------------------------
101 91
     //       Class:  TEMReceiver
@@ -108,25 +98,6 @@ namespace Lemma {
108 98
 
109 99
     //--------------------------------------------------------------------------------------
110 100
     //       Class:  TEMReceiver
111
-    //      Method:  Delete
112
-    // Description:  public destructor
113
-    //--------------------------------------------------------------------------------------
114
-    void TEMReceiver::Delete() {
115
-        this->DetachFrom(this);
116
-    }
117
-
118
-    //--------------------------------------------------------------------------------------
119
-    //       Class:  TEMReceiver
120
-    //      Method:  Release
121
-    // Description:  destructor (protected)
122
-    //--------------------------------------------------------------------------------------
123
-    void TEMReceiver::Release() {
124
-        delete this;
125
-    }
126
-
127
-
128
-    //--------------------------------------------------------------------------------------
129
-    //       Class:  TEMReceiver
130 101
     //      Method:  SetWindows
131 102
     //--------------------------------------------------------------------------------------
132 103
     void TEMReceiver::SetWindows ( const VectorXr& centres, const VectorXr& widths, const TIMEUNITS& Units ) {
@@ -185,15 +156,15 @@ namespace Lemma {
185 156
     //      Method:  SampleNoise
186 157
     //--------------------------------------------------------------------------------------
187 158
     VectorXr TEMReceiver::SampleNoise (  ) {
188
-        
189
-	/* we have C++-11 now! No Boost! 
159
+
160
+	/* we have C++-11 now! No Boost!
190 161
         boost::mt19937 rng(time(0));
191 162
         boost::normal_distribution<> nd(0.0, 1.0);
192 163
         boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(rng, nd);
193 164
 	*/
194 165
 
195 166
         std::random_device rd;
196
-        std::mt19937 gen(rd()); 
167
+        std::mt19937 gen(rd());
197 168
         std::normal_distribution<> d(0.0, 1.00);
198 169
 
199 170
         VectorXr noise = VectorXr::Zero( windowCentres.size() );
@@ -251,7 +222,7 @@ namespace Lemma {
251 222
     //      Method:  SetLocation
252 223
     //--------------------------------------------------------------------------------------
253 224
     void TEMReceiver::SetRxLocation ( const Vector3r& loc ) {
254
-        this->SetNumberOfReceivers(1); // Valgrind doesn't like??
225
+        this->SetNumberOfPoints(1); // Valgrind doesn't like??
255 226
         this->SetLocation(0, loc);
256 227
         //location = loc;
257 228
         return ;
@@ -296,14 +267,13 @@ namespace Lemma {
296 267
     }		// -----  end of method TEMReceiver::GetReferenceTime  -----
297 268
 
298 269
 
299
-#ifdef HAVE_YAMLCPP
300 270
     //--------------------------------------------------------------------------------------
301 271
     //       Class:  TEMReceiver
302 272
     //      Method:  Serialize
303 273
     //--------------------------------------------------------------------------------------
304 274
     YAML::Node  TEMReceiver::Serialize (  ) const {
305
-        YAML::Node node = ReceiverPoints::Serialize();
306
-        node.SetTag( this->Name );
275
+        YAML::Node node = FieldPoints::Serialize();
276
+        node.SetTag( GetName() );
307 277
         node["moment"] = moment;
308 278
         node["referenceTime"] = referenceTime;
309 279
         node["component"] = enum2String(component);
@@ -320,14 +290,12 @@ namespace Lemma {
320 290
     //       Class:  TEMReceiver
321 291
     //      Method:  DeSerialize
322 292
     //--------------------------------------------------------------------------------------
323
-    TEMReceiver* TEMReceiver::DeSerialize ( const YAML::Node& node  ) {
324
-        TEMReceiver* Object = new TEMReceiver(node);
325
-        Object->AttachTo(Object);
326
-        DESERIALIZECHECK( node, Object )
327
-        return Object ;
328
-
293
+    std::shared_ptr<TEMReceiver> TEMReceiver::DeSerialize ( const YAML::Node& node  ) {
294
+        if (node.Tag() != "TEMReceiver") {
295
+            throw  DeSerializeTypeMismatch( "TEMReceiver", node.Tag());
296
+        }
297
+        return std::make_shared<TEMReceiver> ( node, ctor_key() );
329 298
     }		// -----  end of method TEMReceiver::DeSerialize  -----
330
-#endif
331 299
 
332 300
 }		// -----  end of Lemma  name  -----
333 301
 

+ 0
- 0
Modules/TEM1D/testing/CMakeLists.txt Vedi File


Loading…
Annulla
Salva