Browse Source

Added Key hankel class and polygonal wire antenna.

enhancement_3
T-bone 7 years ago
parent
commit
eb60ba70e8

+ 4
- 0
Modules/FDEM1D/examples/CMakeLists.txt View File

@@ -4,7 +4,11 @@ target_link_libraries(  LayeredEarthEM  "lemmacore" "fdem1d")
4 4
 add_executable( FieldPoints FieldPoints.cpp  )
5 5
 target_link_libraries(  FieldPoints  "lemmacore" "fdem1d")
6 6
 
7
+add_executable( PolygonalWireAntenna PolygonalWireAntenna.cpp  )
8
+target_link_libraries(  PolygonalWireAntenna  "lemmacore" "fdem1d")
9
+
7 10
 INSTALL_TARGETS( "/share/FEM1D/"
8 11
 	LayeredEarthEM 
9 12
 	FieldPoints
13
+	PolygonalWireAntenna
10 14
 )

+ 36
- 0
Modules/FDEM1D/examples/PolygonalWireAntenna.cpp View File

@@ -0,0 +1,36 @@
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      11/07/2016 12:01:34 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, Trevor Irons & Lemma Software, LLC
18
+ */
19
+
20
+#include <FDEM1D>
21
+using namespace Lemma;
22
+
23
+int main() {
24
+
25
+    auto wire = PolygonalWireAntenna::NewSP();
26
+        wire->SetNumberOfPoints(5);
27
+        wire->SetPoint(0, 0, 0, 0);
28
+        wire->SetPoint(1, 1, 0, 0);
29
+        wire->SetPoint(2, 1, 1, 0);
30
+        wire->SetPoint(3, 0, 1, 0);
31
+        wire->SetPoint(4, 0, 0, 0);
32
+    std::cout << *wire << std::endl;
33
+
34
+    auto wire2 = wire->Clone();
35
+    std::cout << *wire2 << std::endl;
36
+}

+ 4
- 0
Modules/FDEM1D/include/FDEM1D View File

@@ -1,6 +1,10 @@
1 1
 #include "LayeredEarthEM.h"
2
+
2 3
 #include "FieldPoints.h"
4
+
3 5
 #include "WireAntenna.h"
6
+#include "PolygonalWireAntenna.h"
7
+
4 8
 #include "DipoleSource.h"
5 9
 
6 10
 // internal

Modules/FDEM1D/include/FHTKey.h → Modules/FDEM1D/include/FHTKey201.h View File

@@ -10,24 +10,22 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      02/11/2014 03:33:08 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@lemmasoftware.org
17 15
  * @copyright Copyright (c) 2014, Trevor Irons
18 16
  */
19 17
 
20 18
 
21
-#ifndef  FHTKEY_INC
22
-#define  FHTKEY_INC
19
+#ifndef  FHTKEY201_INC
20
+#define  FHTKEY201_INC
23 21
 
24
-#include "hankeltransform.h"
22
+#include "HankelTransform.h"
25 23
 
26 24
 namespace Lemma {
27 25
 
28 26
     /**
29 27
       \brief   Impliments the fast Hankel transform as outlines by Key 2011
30
-      \details This filter uses 61, 121, or 201 filter points and supports both lagged and related
28
+      \details This filter uses 51, 101, or 201 filter points and supports both lagged and related
31 29
                 kernel arguments. This algorithm is a port of code carrying the following copyright and
32 30
                 restriction:
33 31
                 %------------------------------------------------------------------%
@@ -37,26 +35,39 @@ namespace Lemma {
37 35
                 % http://software.seg.org/disclaimer.txt before use.               %
38 36
                 %------------------------------------------------------------------%
39 37
      */
40
-    class FHTKey : public HankelTransform {
38
+    class FHTKey201 : public HankelTransform {
41 39
 
42
-        friend std::ostream &operator<<(std::ostream &stream,
43
-                const FHTKey &ob);
40
+        friend std::ostream &operator<<(std::ostream &stream, const FHTKey201 &ob);
41
+
42
+        struct ctor_key {};
44 43
 
45 44
         public:
46 45
 
47 46
         // ====================  LIFECYCLE     =======================
48 47
 
48
+        /** Default locked constructor, use NewSP */
49
+        FHTKey201 ( const ctor_key& );
50
+
51
+        /** DeSerializing locked constructor, use NewSP */
52
+        FHTKey201 ( const YAML::Node& node, const ctor_key& );
53
+
54
+        /** Default protected destructor, use Delete */
55
+        ~FHTKey201 ();
56
+
49 57
         /**
50 58
          * @copybrief LemmaObject::New()
51 59
          * @copydetails LemmaObject::New()
52 60
          */
53
-        static FHTKey* New();
61
+        static std::shared_ptr<FHTKey201> NewSP();
62
+
63
+        /** YAML Serializing method
64
+         */
65
+        YAML::Node Serialize() const;
54 66
 
55 67
         /**
56
-         *  @copybrief   LemmaObject::Delete()
57
-         *  @copydetails LemmaObject::Delete()
68
+         *   Constructs an object from a YAML::Node.
58 69
          */
59
-        void Delete();
70
+        static std::shared_ptr< FHTKey201 > DeSerialize(const YAML::Node& node);
60 71
 
61 72
         // ====================  OPERATORS     =======================
62 73
 
@@ -64,36 +75,29 @@ namespace Lemma {
64 75
 
65 76
         Complex Zgauss(const int &ikk, const EMMODE &imode,
66 77
                             const int &itype, const Real &rho,
67
-                            const Real &wavef, KernelEm1DBase *Kernel);
78
+                            const Real &wavef, std::shared_ptr<KernelEM1DBase> Kernel);
68 79
 
69 80
         /// Computes related kernels, if applicable, otherwise this is
70 81
         /// just a dummy function.
71
-        void ComputeRelated(const Real& rho, KernelEm1DBase* Kernel);
82
+        void ComputeRelated(const Real& rho, std::shared_ptr<KernelEM1DBase> Kernel);
72 83
 
73
-        void ComputeRelated(const Real& rho, std::vector< KernelEm1DBase* > KernelVec);
84
+        void ComputeRelated(const Real& rho, std::vector< std::shared_ptr<KernelEM1DBase> > KernelVec);
74 85
 
75
-        void ComputeRelated(const Real& rho, KernelEM1DManager* KernelManager);
86
+        void ComputeRelated(const Real& rho, std::shared_ptr<KernelEM1DManager> KernelManager);
76 87
 
77 88
         // ====================  ACCESS        =======================
78 89
 
79 90
         // ====================  INQUIRY       =======================
80 91
 
92
+        /** Returns the name of the underlying class, similiar to Python's type */
93
+        virtual inline std::string GetName() const {
94
+            return CName;
95
+        }
96
+
81 97
         protected:
82 98
 
83 99
         // ====================  LIFECYCLE     =======================
84 100
 
85
-        /** Default protected constructor, use New */
86
-        FHTKey (const std::string& name);
87
-
88
-        /** Default protected destructor, use Delete */
89
-        ~FHTKey ();
90
-
91
-        /**
92
-         *  @copybrief   LemmaObject::Release()
93
-         *  @copydetails LemmaObject::Release()
94
-         */
95
-        void Release();
96
-
97 101
         private:
98 102
 
99 103
         // ====================  DATA MEMBERS  =========================
@@ -104,9 +108,12 @@ namespace Lemma {
104 108
         /// Holds answer, dimensions are NumConv, and NumberRelated.
105 109
         Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic> Zans;
106 110
 
107
-    }; // -----  end of class  FHTKey  -----
111
+        /** ASCII string representation of the class name */
112
+        static constexpr auto CName = "FHTKey201";
113
+
114
+    }; // -----  end of class  FHTKey201  -----
108 115
 
109 116
 }		// -----  end of Lemma  name  -----
110 117
 
111
-#endif   // ----- #ifndef FHTKEY_INC  -----
118
+#endif   // ----- #ifndef FHTKEY201_INC  -----
112 119
 

+ 5
- 0
Modules/FDEM1D/include/HankelTransform.h View File

@@ -48,6 +48,8 @@ namespace Lemma {
48 48
                 /// rho is argument to integral
49 49
                 /// wavef is the propogation constant of free space
50 50
                 /// = omega * sqrt( EP*AMU )  amu = 4 pi e-7  ep = 8.85e-12
51
+                /// @note compare performance of passing Kernel, instead consider
52
+                ///       passing by reference and using Kernel.get() instead.
51 53
                 virtual Complex Zgauss(const int &ikk, const EMMODE &imode,
52 54
                             const int &itype, const Real &rho,
53 55
                             const Real &wavef, std::shared_ptr<KernelEM1DBase> Kernel)=0;
@@ -78,6 +80,9 @@ namespace Lemma {
78 80
                 HankelTransform ( );
79 81
 
80 82
                 /// Default protected constructor.
83
+                HankelTransform ( const YAML::Node& node );
84
+
85
+                /// Default protected constructor.
81 86
                 ~HankelTransform ( );
82 87
 
83 88
             private:

+ 1
- 1
Modules/FDEM1D/include/PolygonalWireAntenna.h View File

@@ -51,7 +51,7 @@ namespace Lemma {
51 51
 
52 52
             /// Makes a deep copy of this antenna with all connections except
53 53
             /// the dipole approximation.
54
-            std::shared_ptr<PolygonalWireAntenna> Clone();
54
+            std::shared_ptr<WireAntenna> Clone();
55 55
 
56 56
             /**
57 57
              *  Uses YAML to serialize this object.

+ 1
- 0
Modules/FDEM1D/include/WireAntenna.h View File

@@ -33,6 +33,7 @@ namespace Lemma {
33 33
 
34 34
         friend std::ostream &operator<<(std::ostream &stream, const WireAntenna &ob);
35 35
 
36
+        protected:
36 37
         struct ctor_key {};
37 38
 
38 39
         public:

+ 4
- 3
Modules/FDEM1D/src/CMakeLists.txt View File

@@ -1,15 +1,13 @@
1 1
 set (FDEM1DSOURCE
2 2
 	${FDEM1DSOURCE}
3 3
 
4
-
5
-
6 4
 	${CMAKE_CURRENT_SOURCE_DIR}/LayeredEarthEM.cpp
7 5
 	
8 6
 	${CMAKE_CURRENT_SOURCE_DIR}/FieldPoints.cpp
9 7
 	
10 8
 	${CMAKE_CURRENT_SOURCE_DIR}/DipoleSource.cpp
11 9
 	${CMAKE_CURRENT_SOURCE_DIR}/WireAntenna.cpp
12
-
10
+	${CMAKE_CURRENT_SOURCE_DIR}/PolygonalWireAntenna.cpp
13 11
 	
14 12
 	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DManager.cpp
15 13
 	${CMAKE_CURRENT_SOURCE_DIR}/KernelEM1DSpec.cpp
@@ -17,6 +15,9 @@ set (FDEM1DSOURCE
17 15
 
18 16
 	${CMAKE_CURRENT_SOURCE_DIR}/HankelTransform.cpp
19 17
 	${CMAKE_CURRENT_SOURCE_DIR}/FHTAnderson801.cpp
18
+	${CMAKE_CURRENT_SOURCE_DIR}/FHTKey201.cpp
19
+	#${CMAKE_CURRENT_SOURCE_DIR}/FHTKey101.cpp
20
+	#${CMAKE_CURRENT_SOURCE_DIR}/FHTKey51.cpp
20 21
 
21 22
 	#${CMAKE_CURRENT_SOURCE_DIR}/AEMSurvey.cpp
22 23
 	#${CMAKE_CURRENT_SOURCE_DIR}/AEMSurveyReader.cpp

Modules/FDEM1D/src/FHTKey.cpp → Modules/FDEM1D/src/FHTKey201.cpp View File

@@ -10,30 +10,26 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      02/11/2014 03:42:53 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@lemmasoftware.org
17 15
  * @copyright Copyright (c) 2014, Trevor Irons
18 16
  */
19 17
 
20
-#include "FHTKey.h"
18
+#include "FHTKey201.h"
21 19
 
22 20
 namespace Lemma {
23 21
 
24 22
     // ====================  FRIEND METHODS  =====================
25 23
 
26
-    std::ostream &operator<<(std::ostream &stream, const FHTKey &ob) {
27
-
28
-        stream << *(HankelTransform*)(&ob);
29
-
24
+    std::ostream &operator<<(std::ostream &stream, const FHTKey201 &ob) {
25
+        stream << ob.Serialize()  << "\n---\n"; // End of doc ---
30 26
         return stream;
31 27
     }
32 28
 
33 29
 
34 30
     // ====================  STATIC CONST MEMBERS     ============
35 31
 
36
-    const Eigen::Matrix<Real, 201, 3>  FHTKey::WT201 =
32
+    const Eigen::Matrix<Real, 201, 3>  FHTKey201::WT201 =
37 33
         ( Eigen::Matrix<Real, 201, 3>()   <<
38 34
         // Base                   J0                      J1
39 35
           4.1185887075357082e-06, 1.5020099209519960e-03, 4.7827871332506182e-10
@@ -241,86 +237,92 @@ namespace Lemma {
241 237
     // ====================  LIFECYCLE     =======================
242 238
 
243 239
     //--------------------------------------------------------------------------------------
244
-    //       Class:  FHTKey
245
-    //      Method:  FHTKey
246
-    // Description:  constructor (protected)
240
+    //       Class:  FHTKey201
241
+    //      Method:  FHTKey201
242
+    // Description:  constructor (locked)
247 243
     //--------------------------------------------------------------------------------------
248
-    FHTKey::FHTKey (const std::string& name) : HankelTransform(name) {
244
+    FHTKey201::FHTKey201 (const ctor_key& ) : HankelTransform( ) {
245
+
246
+    }  // -----  end of method FHTKey201::FHTKey201  (constructor)  -----
249 247
 
250
-    }  // -----  end of method FHTKey::FHTKey  (constructor)  -----
248
+    FHTKey201::FHTKey201( const YAML::Node& node, const ctor_key& ) : HankelTransform(node) {
251 249
 
250
+    }
252 251
 
253 252
     //--------------------------------------------------------------------------------------
254
-    //       Class:  FHTKey
255
-    //      Method:  New()
253
+    //       Class:  FHTKey201
254
+    //      Method:  NewSP()
256 255
     // Description:  public constructor
257 256
     //--------------------------------------------------------------------------------------
258
-    FHTKey* FHTKey::New() {
259
-        FHTKey*  Obj = new FHTKey("FHTKey");
260
-        Obj->AttachTo(Obj);
261
-        return Obj;
257
+    std::shared_ptr<FHTKey201> FHTKey201::NewSP() {
258
+        return std::make_shared<FHTKey201>( ctor_key() );
262 259
     }
263 260
 
264 261
     //--------------------------------------------------------------------------------------
265
-    //       Class:  FHTKey
266
-    //      Method:  ~FHTKey
267
-    // Description:  destructor (protected)
262
+    //       Class:  FHTKey201
263
+    //      Method:  ~FHTKey201
264
+    // Description:  destructor
268 265
     //--------------------------------------------------------------------------------------
269
-    FHTKey::~FHTKey () {
266
+    FHTKey201::~FHTKey201 () {
270 267
 
271
-    }  // -----  end of method FHTKey::~FHTKey  (destructor)  -----
268
+    }  // -----  end of method FHTKey201::~FHTKey201  (destructor)  -----
272 269
 
273 270
     //--------------------------------------------------------------------------------------
274
-    //       Class:  FHTKey
275
-    //      Method:  Delete
276
-    // Description:  public destructor
271
+    //       Class:  FHTKey201
272
+    //      Method:  DeSerialize
273
+    // Description:  Factory method, converts YAML node into object
277 274
     //--------------------------------------------------------------------------------------
278
-    void FHTKey::Delete() {
279
-        this->DetachFrom(this);
275
+    std::shared_ptr<FHTKey201> FHTKey201::DeSerialize( const YAML::Node& node ) {
276
+        if (node.Tag() != "FHTKey201") {
277
+            throw  DeSerializeTypeMismatch( "FHTKey201", node.Tag());
278
+        }
279
+        return std::make_shared<FHTKey201> ( node, ctor_key() );
280 280
     }
281 281
 
282 282
     //--------------------------------------------------------------------------------------
283
-    //       Class:  FHTKey
284
-    //      Method:  Release
285
-    // Description:  destructor (protected)
283
+    //       Class:  FHTKey201
284
+    //      Method:  Serialize
285
+    // Description:  Converts object into Serialized version
286 286
     //--------------------------------------------------------------------------------------
287
-    void FHTKey::Release() {
288
-        delete this;
287
+    YAML::Node FHTKey201::Serialize() const {
288
+        YAML::Node node = HankelTransform::Serialize();
289
+        node.SetTag( GetName() );
290
+        //node["LayerConductivity"] = LayerConductivity;
291
+        return node;
289 292
     }
290 293
 
291
-
292 294
     //--------------------------------------------------------------------------------------
293
-    //       Class:  FHTKey
295
+    //       Class:  FHTKey201
294 296
     //      Method:  Zgauss
295 297
     //--------------------------------------------------------------------------------------
296
-    Complex FHTKey::Zgauss ( const int &ikk, const EMMODE &imode,
298
+    Complex FHTKey201::Zgauss ( const int &ikk, const EMMODE &imode,
297 299
                             const int &itype, const Real &rho,
298
-                            const Real &wavef, KernelEm1DBase *Kernel ) {
300
+                            const Real &wavef, std::shared_ptr<KernelEM1DBase> Kernel ) {
299 301
  		return Zans(0, Kernel->GetManagerIndex());
300
-    }		// -----  end of method FHTKey::ComputeRelated  -----
302
+    }		// -----  end of method FHTKey201::ComputeRelated  -----
301 303
 
302 304
 
303 305
     //--------------------------------------------------------------------------------------
304
-    //       Class:  FHTKey
306
+    //       Class:  FHTKey201
305 307
     //      Method:  ComputeRelated
306 308
     //--------------------------------------------------------------------------------------
307
-    void FHTKey::ComputeRelated ( const Real& rho, KernelEm1DBase* Kernel ) {
309
+    void FHTKey201::ComputeRelated ( const Real& rho, std::shared_ptr<KernelEM1DBase> Kernel ) {
308 310
         return ;
309
-    }		// -----  end of method FHTKey::ComputeRelated  -----
311
+    }		// -----  end of method FHTKey201::ComputeRelated  -----
310 312
 
311 313
     //--------------------------------------------------------------------------------------
312
-    //       Class:  FHTKey
314
+    //       Class:  FHTKey201
313 315
     //      Method:  ComputeRelated
314 316
     //--------------------------------------------------------------------------------------
315
-    void FHTKey::ComputeRelated ( const Real& rho, std::vector< KernelEm1DBase* > KernelVec ) {
317
+    void FHTKey201::ComputeRelated ( const Real& rho, std::vector< std::shared_ptr<KernelEM1DBase> > KernelVec ) {
316 318
         return ;
317
-    }		// -----  end of method FHTKey::ComputeRelated  -----
319
+    }		// -----  end of method FHTKey201::ComputeRelated  -----
318 320
 
319 321
     //--------------------------------------------------------------------------------------
320
-    //       Class:  FHTKey
322
+    //       Class:  FHTKey201
321 323
     //      Method:  ComputeRelated
322 324
     //--------------------------------------------------------------------------------------
323
-    void FHTKey::ComputeRelated ( const Real& rho, KernelEM1DManager* KernelManager ) {
325
+    void FHTKey201::ComputeRelated ( const Real& rho, std::shared_ptr<KernelEM1DManager> KernelManager ) {
324 326
 
325 327
         //kernelVec = KernelManager->GetSTLVector();
326 328
         int nrel = (int)(KernelManager->GetSTLVector().size());
@@ -354,6 +356,6 @@ namespace Lemma {
354 356
         }
355 357
 
356 358
         return ;
357
-    }		// -----  end of method FHTKey::ComputeRelated  -----
359
+    }		// -----  end of method FHTKey201::ComputeRelated  -----
358 360
 
359 361
 }		// -----  end of Lemma  name  -----

+ 3
- 0
Modules/FDEM1D/src/HankelTransform.cpp View File

@@ -23,6 +23,9 @@ namespace Lemma {
23 23
 	HankelTransform::HankelTransform( ) : LemmaObject( )	{
24 24
 	}
25 25
 
26
+    HankelTransform::HankelTransform( const YAML::Node& node ) : LemmaObject( node )	{
27
+	}
28
+
26 29
 	HankelTransform::~HankelTransform( ) {
27 30
 	}
28 31
 

+ 35
- 81
Modules/FDEM1D/src/PolygonalWireAntenna.cpp View File

@@ -15,65 +15,58 @@
15 15
 
16 16
 namespace Lemma {
17 17
 
18
-#ifdef HAVE_YAMLCPP
19 18
     std::ostream &operator << (std::ostream &stream, const PolygonalWireAntenna &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 PolygonalWireAntenna &ob) {
26
-
27
-		stream << *(WireAntenna*)(&ob);
28
-		//stream << "Current: " << ob.Current << " [A]\n";
29
-		//stream << "Frequencies: " << ob.Freqs.transpose() << " [Hz]\n";
30
-		//stream << "Number of points " << ob.NumberOfPoints << "\n";
31
-		//stream << "Points:\n" << ob.Points.transpose() << "\n";
32
-		//stream << "Dipoles used to approximate " << ob.Dipoles.size();
33
-		return stream;
34
-	}
35
-#endif
22
+
36 23
 	// ====================  LIFECYCLE     =======================
37 24
 
38
-	PolygonalWireAntenna::PolygonalWireAntenna(const std::string& name)
39
-		: WireAntenna(name), minDipoleRatio(.15),
25
+	PolygonalWireAntenna::PolygonalWireAntenna( const ctor_key& key ) : WireAntenna( WireAntenna::ctor_key() ), minDipoleRatio(.15),
40 26
    		minDipoleMoment(1e-6), maxDipoleMoment(1e1), rRepeat(1e10,1e10,1e10) {
41 27
 		Points.setZero();
42 28
         //rRepeat.setOnes();
43 29
 	}
44 30
 
45
-#ifdef HAVE_YAMLCPP
46
-    PolygonalWireAntenna::PolygonalWireAntenna(const YAML::Node& node)
47
-		: WireAntenna(node) {
48
-// minDipoleRatio(.15),
49
-// minDipoleMoment(1e-4),
50
-// maxDipoleMoment(1e-0)
31
+    PolygonalWireAntenna::PolygonalWireAntenna( const YAML::Node& node, const ctor_key& ) : WireAntenna(node, WireAntenna::ctor_key() ) {
51 32
         minDipoleRatio   = node["minDipoleRatio"].as<Real>();
52 33
         maxDipoleMoment  = node["maxDipoleMoment"].as<Real>();
53 34
         minDipoleMoment  = node["minDipoleMoment"].as<Real>();
54 35
 	}
55
-#endif
56 36
 
57 37
 	PolygonalWireAntenna::~PolygonalWireAntenna() {
58
-        if (this->NumberOfReferences != 0)
59
-            throw DeleteObjectWithReferences( this );
60
-		// Taken care of in parent
61
-        //for (unsigned int id=0; id<Dipoles.size(); ++id) {
62
-		//	Dipoles[id]->Delete();
63
-		//}
64
-		//Dipoles.clear();
65 38
 	}
66 39
 
67
-	PolygonalWireAntenna* PolygonalWireAntenna::New() {
68
-		PolygonalWireAntenna* Obj = new
69
-            PolygonalWireAntenna("PolygonalWireAntenna");
70
-        Obj->AttachTo(Obj);
71
-        return Obj;
40
+    //--------------------------------------------------------------------------------------
41
+    //       Class:  PolygonalWireAntenna
42
+    //      Method:  Serialize
43
+    //--------------------------------------------------------------------------------------
44
+    YAML::Node PolygonalWireAntenna::Serialize (  ) const {
45
+        YAML::Node node = WireAntenna::Serialize();
46
+        node.SetTag( this->GetName() );
47
+        node["minDipoleRatio"]  = minDipoleRatio;
48
+        node["maxDipoleMoment"] = maxDipoleMoment;
49
+        node["minDipoleMoment"] = minDipoleMoment;
50
+        return node;
51
+    }		// -----  end of method PolygonalWireAntenna::Serialize  -----
52
+
53
+    //--------------------------------------------------------------------------------------
54
+    //       Class:  WireAntenna
55
+    //      Method:  DeSerialize
56
+    //--------------------------------------------------------------------------------------
57
+    std::shared_ptr<PolygonalWireAntenna> PolygonalWireAntenna::DeSerialize ( const YAML::Node& node ) {
58
+        if (node.Tag() != "PolygonalWireAntenna") {
59
+            throw  DeSerializeTypeMismatch( "PolygonalWireAntenna", node.Tag());
60
+        }
61
+        return std::make_shared<PolygonalWireAntenna> ( node, ctor_key() );
62
+    }		// -----  end of method WireAntenna::DeSerialize  -----
63
+
64
+	std::shared_ptr<PolygonalWireAntenna> PolygonalWireAntenna::NewSP() {
65
+        return std::make_shared<PolygonalWireAntenna>( ctor_key() );
72 66
 	}
73 67
 
74
-	PolygonalWireAntenna* PolygonalWireAntenna::Clone() {
75
-		PolygonalWireAntenna* copy = PolygonalWireAntenna::New();
76
-		//copy->AttachTo(copy); // NO! Attached above!
68
+	std::shared_ptr<WireAntenna> PolygonalWireAntenna::Clone() {
69
+		auto copy = PolygonalWireAntenna::NewSP();
77 70
         copy->minDipoleRatio = this->minDipoleRatio;
78 71
 		copy->minDipoleMoment = this->minDipoleMoment;
79 72
 		copy->maxDipoleMoment = this->maxDipoleMoment;
@@ -86,14 +79,6 @@ namespace Lemma {
86 79
 		return copy;
87 80
 	}
88 81
 
89
-	void PolygonalWireAntenna::Delete() {
90
-		this->DetachFrom(this);
91
-	}
92
-
93
-    void PolygonalWireAntenna::Release() {
94
-		delete this;
95
-	}
96
-
97 82
     void PolygonalWireAntenna::SetMinDipoleRatio (const Real& ratio) {
98 83
         minDipoleRatio = ratio;
99 84
     }
@@ -111,9 +96,6 @@ namespace Lemma {
111 96
 	void PolygonalWireAntenna::ApproximateWithElectricDipoles(const Vector3r &rp) {
112 97
         // Only resplit if necessary. Save a few cycles if repeated
113 98
         if ( (rRepeat-rp).norm() > 1e-16 ) {
114
-		    for (unsigned int id=0; id<Dipoles.size(); ++id) {
115
-			    Dipoles[id]->Delete();
116
-		    }
117 99
 		    Dipoles.clear();
118 100
 
119 101
 		    // loop over all segments
@@ -159,11 +141,11 @@ namespace Lemma {
159 141
 
160 142
 	void PolygonalWireAntenna::PushXYZDipoles(const Vector3r &step,
161 143
 				    const Vector3r &cp, const Vector3r &dir,
162
-					std::vector<DipoleSource*> &xDipoles) {
144
+					std::vector< std::shared_ptr<DipoleSource> > &xDipoles) {
163 145
 
164 146
 		Real scale = (Real)(NumberOfTurns)*Current;
165 147
 
166
-        DipoleSource *tx = DipoleSource::New();
148
+        auto tx = DipoleSource::NewSP();
167 149
 		    tx->SetLocation(cp);
168 150
 		    tx->SetType(UNGROUNDEDELECTRICDIPOLE);
169 151
 			tx->SetPolarisation(dir);
@@ -174,7 +156,7 @@ namespace Lemma {
174 156
 
175 157
 	void PolygonalWireAntenna::CorrectOverstepXYZDipoles(const Vector3r &step,
176 158
 				    const Vector3r &cp,	const Vector3r &dir,
177
-					std::vector<DipoleSource*> &xDipoles ) {
159
+					std::vector< std::shared_ptr<DipoleSource> > &xDipoles ) {
178 160
 
179 161
 		Real scale = (Real)(NumberOfTurns)*Current;
180 162
 
@@ -200,7 +182,7 @@ namespace Lemma {
200 182
 
201 183
 		///////////////////
202 184
 		// dipoles for this segment
203
-		std::vector<DipoleSource*>           xDipoles;
185
+		std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
204 186
 
205 187
 		// go towards p1
206 188
 		if ( ((c-p1).array().abs() > minDipoleMoment).any() ) {
@@ -317,33 +299,5 @@ namespace Lemma {
317 299
 		Dipoles.insert(Dipoles.end(), xDipoles.begin(), xDipoles.end());
318 300
 	}
319 301
 
320
-    #ifdef HAVE_YAMLCPP
321
-
322
-    //--------------------------------------------------------------------------------------
323
-    //       Class:  PolygonalWireAntenna
324
-    //      Method:  Serialize
325
-    //--------------------------------------------------------------------------------------
326
-    YAML::Node PolygonalWireAntenna::Serialize (  ) const {
327
-        YAML::Node node = WireAntenna::Serialize();
328
-        node.SetTag( this->Name );
329
-        node["minDipoleRatio"]  = minDipoleRatio;
330
-        node["maxDipoleMoment"] = maxDipoleMoment;
331
-        node["minDipoleMoment"] = minDipoleMoment;
332
-        return node;
333
-    }		// -----  end of method PolygonalWireAntenna::Serialize  -----
334
-
335
-
336
-    //--------------------------------------------------------------------------------------
337
-    //       Class:  WireAntenna
338
-    //      Method:  DeSerialize
339
-    //--------------------------------------------------------------------------------------
340
-    PolygonalWireAntenna* PolygonalWireAntenna::DeSerialize ( const YAML::Node& node ) {
341
-        PolygonalWireAntenna* Object = new PolygonalWireAntenna(node);
342
-        Object->AttachTo(Object);
343
-        DESERIALIZECHECK( node, Object )
344
-        return Object ;
345
-    }		// -----  end of method WireAntenna::DeSerialize  -----
346
-
347
-    #endif
348 302
 
349 303
 }

+ 1
- 1
vim/c.vim View File

@@ -17,7 +17,7 @@ syn keyword nspace Lemma YAML Eigen
17 17
 
18 18
 " Lemma types
19 19
 highlight leType ctermfg=Yellow guifg=Yellow
20
-syn keyword leType HankelTransform FHTAnderson801 KernelEM1D KernelEM1DSpec KernelEM1DBase KernelEM1DManager DipoleSource EarthModel LayeredEarth LayeredEarthEM TEMSurvey TEMSurveyLine TEMSurveyLineRecord TEMInductiveReceiver WireAntenna PolygonalWireAntenna TEMTransmitter TEMReceiver Instrument InstrumentTem LemmaObject FieldPoints DCIPElectrode TEMSurveyData TEMSurveyLineData TEMSurveyLineRecordData  ASCIIParser CubicSplineInterpolator RectilinearGrid GridReader RectilinearGridReader RectilinearGridVTKExporter Filter WindowFilter DEMParticle DEMGrain Data DataReader 
20
+syn keyword leType HankelTransform FHTAnderson801 FHTKey201 FHTKey101 FHTKey51 KernelEM1D KernelEM1DSpec KernelEM1DBase KernelEM1DManager DipoleSource EarthModel LayeredEarth LayeredEarthEM TEMSurvey TEMSurveyLine TEMSurveyLineRecord TEMInductiveReceiver WireAntenna PolygonalWireAntenna TEMTransmitter TEMReceiver Instrument InstrumentTem LemmaObject FieldPoints DCIPElectrode TEMSurveyData TEMSurveyLineData TEMSurveyLineRecordData  ASCIIParser CubicSplineInterpolator RectilinearGrid GridReader RectilinearGridReader RectilinearGridVTKExporter Filter WindowFilter DEMParticle DEMGrain Data DataReader 
21 21
 
22 22
 " Deprecated Lemma Types
23 23
 highlight dleType ctermfg=Blue guifg=Blue 

Loading…
Cancel
Save