Bladeren bron

AEM survey added back

submodule
T-bone 6 jaren geleden
bovenliggende
commit
a8644b85af

+ 5
- 2
CMakeLists.txt Bestand weergeven

@@ -79,6 +79,7 @@ find_package(CxxTest)
79 79
 if (CXXTEST_FOUND)
80 80
 	# Do nothing
81 81
 else()
82
+	message( STATUS "CxxTest will be built and installed along with Lemma, override if desired in GUI."  )
82 83
 	ExternalProject_Add(CxxTest
83 84
 		GIT_REPOSITORY "https://github.com/CxxTest/cxxtest.git"
84 85
 		GIT_TAG "master"
@@ -91,8 +92,10 @@ else()
91 92
     	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
92 93
 			-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
93 94
 	)
94
-	set (CXXTEST_INCLUDE_DIR  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/")
95
-	set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" )
95
+	# The values "CACHE PATH "" FORCE" makes the GUI show the values of the local CxxTest, but this can cause issues 
96
+	# with users wanting to specify their own path, its not recommended  
97
+	set (CXXTEST_INCLUDE_DIR  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/") # CACHE  PATH "" FORCE )
98
+	set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen") # CACHE PATH "" FORCE )
96 99
 	find_package(CxxTest REQUIRED)
97 100
 endif()
98 101
 

+ 16
- 22
Modules/FDEM1D/include/AEMSurvey.h Bestand weergeven

@@ -12,9 +12,9 @@
12 12
  * @date      09/24/2013 04:06:42 PM
13 13
  * @version   $Id$
14 14
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
15
+ * @email     Trevor.Irons@lemmasoftware.org
16 16
  * @copyright Copyright (c) 2013, XRI Geophysics, LLC
17
- * @copyright Copyright (c) 2013, Trevor Irons
17
+ * @copyright Copyright (c) 2013,2018 Trevor Irons
18 18
  */
19 19
 
20 20
 #ifndef  AEMSURVEY_INC
@@ -48,13 +48,13 @@ class AEMSurvey : public LemmaObject {
48 48
      * @copybrief LemmaObject::New()
49 49
      * @copydetails LemmaObject::New()
50 50
      */
51
-    static AEMSurvey* New();
51
+    static std::shared_ptr<AEMSurvey> NewSP();
52 52
 
53
-    /**
54
-     *  @copybrief   LemmaObject::Delete()
55
-     *  @copydetails LemmaObject::Delete()
56
-     */
57
-    void Delete();
53
+    /** Default protected constructor, use New */
54
+    AEMSurvey (const ctor_key&);
55
+
56
+    /** Default protected destructor, use Delete */
57
+    ~AEMSurvey ();
58 58
 
59 59
     // ====================  OPERATORS     =======================
60 60
 
@@ -66,7 +66,7 @@ class AEMSurvey : public LemmaObject {
66 66
      *  general loops int the new future.
67 67
      *  @param[in] isource is the source fiducial to return
68 68
      */
69
-    DipoleSource* GetSource(const int& isource);
69
+    std::shared_ptr<DipoleSource> GetSource(const int& isource);
70 70
 
71 71
     /** @return the total number of sources
72 72
      */
@@ -79,30 +79,24 @@ class AEMSurvey : public LemmaObject {
79 79
 
80 80
     // ====================  INQUIRY       =======================
81 81
 
82
+    /** Returns the name of the underlying class, similiar to Python's type */
83
+    virtual std::string GetName() const {
84
+        return this->CName;
85
+    }
86
+
82 87
     protected:
83 88
 
84 89
     // ====================  LIFECYCLE     =======================
85 90
 
86
-    /** Default protected constructor, use New */
87
-    AEMSurvey (const std::string& name);
88
-
89
-    /** Default protected destructor, use Delete */
90
-    ~AEMSurvey ();
91
-
92
-    /**
93
-     *  @copybrief   LemmaObject::Release()
94
-     *  @copydetails LemmaObject::Release()
95
-     */
96
-    void Release();
97
-
98 91
     private:
99 92
 
100 93
     // ====================  DATA MEMBERS  =========================
101 94
 
102
-    std::vector<DipoleSource*>  Sources;
95
+    std::vector< std::shared_ptr<DipoleSource> >  Sources;
103 96
 
104 97
     VectorXr Freqs;
105 98
 
99
+    static constexpr auto CName = "AEMSurvey";
106 100
 
107 101
 }; // -----  end of class  AEMSurvey  -----
108 102
 

+ 18
- 24
Modules/FDEM1D/include/AEMSurveyReader.h Bestand weergeven

@@ -12,7 +12,7 @@
12 12
  * @date      09/24/2013 04:29:27 PM
13 13
  * @version   $Id$
14 14
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
15
+ * @email     Trevor.Irons@lemmasoftware.org
16 16
  * @copyright Copyright (c) 2013, XRI Geophysics, LLC
17 17
  * @copyright Copyright (c) 2013, Trevor Irons
18 18
  */
@@ -39,17 +39,17 @@ namespace Lemma {
39 39
 
40 40
         // ====================  LIFECYCLE     =======================
41 41
 
42
-        /*c
43
-         * @copybrief LemmaObject::New()
44
-         * @copydetails LemmaObject::New()
45
-         */
46
-        static AEMSurveyReader* New();
47
-
48 42
         /**
49
-         *  @copybrief   LemmaObject::Delete()
50
-         *  @copydetails LemmaObject::Delete()
43
+         * @copybrief LemmaObject::NewSP()
44
+         * @copydetails LemmaObject::NewSP()
51 45
          */
52
-        void Delete();
46
+        static std::shared_ptr<AEMSurveyReader> NewSP();
47
+
48
+        /** Default protected constructor, use New */
49
+        AEMSurveyReader (const ctor_key&);
50
+
51
+        /** Default protected destructor, use Delete */
52
+        ~AEMSurveyReader ();
53 53
 
54 54
         // ====================  OPERATORS     =======================
55 55
 
@@ -103,31 +103,25 @@ MD        // Source 5 type
103 103
         /**
104 104
          * @return the AEMSurvey based on the file read
105 105
          */
106
-        AEMSurvey* GetSurvey();
106
+        std::shared_ptr<AEMSurvey> GetSurvey();
107 107
 
108 108
         // ====================  INQUIRY       =======================
109
+        /** Returns the name of the underlying class, similiar to Python's type */
110
+        virtual std::string GetName() const {
111
+            return this->CName;
112
+        }
109 113
 
110 114
         protected:
111 115
 
112 116
         // ====================  LIFECYCLE     =======================
113 117
 
114
-        /** Default protected constructor, use New */
115
-        AEMSurveyReader (const std::string& name);
116
-
117
-        /** Default protected destructor, use Delete */
118
-        ~AEMSurveyReader ();
119
-
120
-        /**
121
-         *  @copybrief   LemmaObject::Release()
122
-         *  @copydetails LemmaObject::Release()
123
-         */
124
-        void Release();
125
-
126 118
         private:
127 119
 
128 120
         // ====================  DATA MEMBERS  =========================
129 121
 
130
-        AEMSurvey*  Survey;
122
+        std::shared_ptr<AEMSurvey>  Survey;
123
+
124
+        static constexpr auto CName = "AEMSurveyReader";
131 125
 
132 126
     }; // -----  end of class  AEMSurveyReader  -----
133 127
 

+ 2
- 1
Modules/FDEM1D/include/FDEM1D Bestand weergeven

@@ -10,7 +10,8 @@
10 10
 
11 11
 #include "EMEarth1D.h"
12 12
 
13
-//#include "AEMSurvey.h"
13
+#include "AEMSurvey.h"
14
+#include "AEMSurveyReader.h"
14 15
 
15 16
 // internal
16 17
 //#include "KernelEM1DManager.h"

+ 8
- 31
Modules/FDEM1D/src/AEMSurvey.cpp Bestand weergeven

@@ -12,9 +12,10 @@
12 12
  * @date      09/24/2013 04:09:04 PM
13 13
  * @version   $Id$
14 14
  * @author    Trevor Irons (ti)
15
- * @email     Trevor.Irons@xri-geo.com
15
+ * @email     Trevor.Irons@lemmasoftware.org
16 16
  * @copyright Copyright (c) 2013, XRI Geophysics, LLC
17 17
  * @copyright Copyright (c) 2013, Trevor Irons
18
+ * @copyright Copyright (c) 2018, Trevor Irons
18 19
  */
19 20
 
20 21
 #include "AEMSurvey.h"
@@ -24,9 +25,7 @@ namespace Lemma {
24 25
 // ====================  FRIEND METHODS  =====================
25 26
 
26 27
 std::ostream &operator<<(std::ostream &stream, const AEMSurvey &ob) {
27
-
28
-    stream << *(LemmaObject*)(&ob);
29
-
28
+    stream << ob.Serialize() << "\n";
30 29
     return stream;
31 30
 }
32 31
 
@@ -37,20 +36,18 @@ std::ostream &operator<<(std::ostream &stream, const AEMSurvey &ob) {
37 36
 //      Method:  AEMSurvey
38 37
 // Description:  constructor (protected)
39 38
 //--------------------------------------------------------------------------------------
40
-AEMSurvey::AEMSurvey (const std::string& name) : LemmaObject(name) {
39
+AEMSurvey::AEMSurvey (const ctor_key& key) : LemmaObject(key) {
41 40
 
42 41
 }  // -----  end of method AEMSurvey::AEMSurvey  (constructor)  -----
43 42
 
44 43
 
45 44
 //--------------------------------------------------------------------------------------
46 45
 //       Class:  AEMSurvey
47
-//      Method:  New()
46
+//      Method:  NewSP()
48 47
 // Description:  public constructor
49 48
 //--------------------------------------------------------------------------------------
50
-AEMSurvey* AEMSurvey::New() {
51
-    AEMSurvey*  Obj = new AEMSurvey("AEMSurvey");
52
-    Obj->AttachTo(Obj);
53
-    return Obj;
49
+std::shared_ptr<AEMSurvey> AEMSurvey::NewSP() {
50
+    return std::make_shared<AEMSurvey>(ctor_key());
54 51
 }
55 52
 
56 53
 //--------------------------------------------------------------------------------------
@@ -60,33 +57,13 @@ AEMSurvey* AEMSurvey::New() {
60 57
 //--------------------------------------------------------------------------------------
61 58
 AEMSurvey::~AEMSurvey () {
62 59
 
63
-    for (unsigned int isc=0; isc<Sources.size(); ++isc) Sources[isc]->Delete();
64
-
65 60
 }  // -----  end of method AEMSurvey::~AEMSurvey  (destructor)  -----
66 61
 
67 62
 //--------------------------------------------------------------------------------------
68 63
 //       Class:  AEMSurvey
69
-//      Method:  Delete
70
-// Description:  public destructor
71
-//--------------------------------------------------------------------------------------
72
-void AEMSurvey::Delete() {
73
-    this->DetachFrom(this);
74
-}
75
-
76
-//--------------------------------------------------------------------------------------
77
-//       Class:  AEMSurvey
78
-//      Method:  Release
79
-// Description:  destructor (protected)
80
-//--------------------------------------------------------------------------------------
81
-void AEMSurvey::Release() {
82
-    delete this;
83
-}
84
-
85
-//--------------------------------------------------------------------------------------
86
-//       Class:  AEMSurvey
87 64
 //      Method:  GetSource
88 65
 //--------------------------------------------------------------------------------------
89
-DipoleSource* AEMSurvey::GetSource ( const int& isource ) {
66
+std::shared_ptr<DipoleSource> AEMSurvey::GetSource ( const int& isource ) {
90 67
     return Sources[isource] ;
91 68
 }		// -----  end of method AEMSurvey::GetSource  -----
92 69
 

+ 8
- 37
Modules/FDEM1D/src/AEMSurveyReader.cpp Bestand weergeven

@@ -24,9 +24,7 @@ namespace Lemma {
24 24
     // ====================  FRIEND METHODS  =====================
25 25
 
26 26
     std::ostream &operator<<(std::ostream &stream, const AEMSurveyReader &ob) {
27
-
28
-        stream << *(LemmaObject*)(&ob);
29
-
27
+        stream << ob.Serialize() << "\n";
30 28
         return stream;
31 29
     }
32 30
 
@@ -37,8 +35,7 @@ namespace Lemma {
37 35
     //      Method:  AEMSurveyReader
38 36
     // Description:  constructor (protected)
39 37
     //--------------------------------------------------------------------------------------
40
-    AEMSurveyReader::AEMSurveyReader (const std::string& name) :
41
-        LemmaObject(name), Survey(NULL) {
38
+    AEMSurveyReader::AEMSurveyReader (const ctor_key& key) : LemmaObject(key), Survey(nullptr) {
42 39
 
43 40
     }  // -----  end of method AEMSurveyReader::AEMSurveyReader  (constructor)  -----
44 41
 
@@ -48,10 +45,8 @@ namespace Lemma {
48 45
     //      Method:  New()
49 46
     // Description:  public constructor
50 47
     //--------------------------------------------------------------------------------------
51
-    AEMSurveyReader* AEMSurveyReader::New() {
52
-        AEMSurveyReader*  Obj = new AEMSurveyReader("AEMSurveyReader");
53
-        Obj->AttachTo(Obj);
54
-        return Obj;
48
+    std::shared_ptr<AEMSurveyReader> AEMSurveyReader::NewSP() {
49
+        return std::make_shared<AEMSurveyReader>(ctor_key());
55 50
     }
56 51
 
57 52
     //--------------------------------------------------------------------------------------
@@ -60,33 +55,13 @@ namespace Lemma {
60 55
     // Description:  destructor (protected)
61 56
     //--------------------------------------------------------------------------------------
62 57
     AEMSurveyReader::~AEMSurveyReader () {
63
-        if (Survey) Survey->Delete();
64 58
     }  // -----  end of method AEMSurveyReader::~AEMSurveyReader  (destructor)  -----
65 59
 
66 60
     //--------------------------------------------------------------------------------------
67 61
     //       Class:  AEMSurveyReader
68
-    //      Method:  Delete
69
-    // Description:  public destructor
70
-    //--------------------------------------------------------------------------------------
71
-    void AEMSurveyReader::Delete() {
72
-        this->DetachFrom(this);
73
-    }
74
-
75
-    //--------------------------------------------------------------------------------------
76
-    //       Class:  AEMSurveyReader
77
-    //      Method:  Release
78
-    // Description:  destructor (protected)
79
-    //--------------------------------------------------------------------------------------
80
-    void AEMSurveyReader::Release() {
81
-        delete this;
82
-    }
83
-
84
-
85
-    //--------------------------------------------------------------------------------------
86
-    //       Class:  AEMSurveyReader
87 62
     //      Method:  GetSurvey
88 63
     //--------------------------------------------------------------------------------------
89
-    AEMSurvey* AEMSurveyReader::GetSurvey (  ) {
64
+    std::shared_ptr<AEMSurvey> AEMSurveyReader::GetSurvey (  ) {
90 65
         return Survey;
91 66
     }		// -----  end of method AEMSurveyReader::GetSurvey  -----
92 67
 
@@ -97,9 +72,8 @@ namespace Lemma {
97 72
     //--------------------------------------------------------------------------------------
98 73
     void AEMSurveyReader::ReadASCIIAEMFile (  const std::string& fname ) {
99 74
 
100
-        if (Survey) Survey->Delete();
101
-        Survey = AEMSurvey::New();
102
-        ASCIIParser* Parser = ASCIIParser::New();
75
+        Survey = AEMSurvey::NewSP();
76
+        auto Parser = ASCIIParser::NewSP();
103 77
         Parser->SetCommentString("//");
104 78
         Parser->Open(fname);
105 79
 
@@ -136,7 +110,7 @@ namespace Lemma {
136 110
             //std::vector<int> ivals = Parser->ReadInts(1);   // number of frequencies
137 111
             int nf = Parser->ReadInts(1)[0];   // number of frequencies
138 112
             for (int isc=0; isc<nf; ++isc) {
139
-                Survey->Sources.push_back(DipoleSource::New());
113
+                Survey->Sources.push_back(DipoleSource::NewSP());
140 114
                 int cnt = Survey->Sources.size() - 1; //
141 115
                 // and now set it
142 116
                 Survey->Sources[cnt]->SetNumberOfFrequencies(1);
@@ -159,9 +133,6 @@ namespace Lemma {
159 133
             }
160 134
             Parser->JumpToLocation(bp);
161 135
         }
162
-
163
-        Parser->Delete();
164
-
165 136
         return ;
166 137
     }		// -----  end of method AEMSurveyReader::ReadASCIIAEMFile  -----
167 138
 

+ 4
- 4
Modules/FDEM1D/testing/CMakeLists.txt Bestand weergeven

@@ -1,7 +1,7 @@
1 1
 include_directories(${CXXTEST_INCLUDE_DIR})
2 2
 
3
-CXXTEST_ADD_TEST(unittestFEM1D_GetNameCheck GetNameCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/GetNameCheck.h)
4
-target_link_libraries(unittestFEM1D_GetNameCheck "lemmacore" "fdem1d" "yaml-cpp")
3
+CXXTEST_ADD_TEST(unittest_FEM1D_GetNameCheck GetNameCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/GetNameCheck.h)
4
+target_link_libraries(unittest_FEM1D_GetNameCheck "lemmacore" "fdem1d" "yaml-cpp")
5 5
 
6
-CXXTEST_ADD_TEST(unittestFEM1D_SerializeCheck SerializeCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/SerializeCheck.h)
7
-target_link_libraries(unittestFEM1D_SerializeCheck "lemmacore" "fdem1d" "yaml-cpp")
6
+CXXTEST_ADD_TEST(unittest_FEM1D_SerializeCheck SerializeCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/SerializeCheck.h)
7
+target_link_libraries(unittest_FEM1D_SerializeCheck "lemmacore" "fdem1d" "yaml-cpp")

+ 33
- 3
Modules/FDEM1D/testing/GetNameCheck.h Bestand weergeven

@@ -33,22 +33,52 @@ class MyTestSuite : public CxxTest::TestSuite
33 33
         TS_ASSERT_EQUALS( Obj->GetName(), std::string("LayeredEarthEM") );
34 34
     }
35 35
 
36
+    void testLayeredEarthEMReader( void )
37
+    {
38
+        auto Obj = LayeredEarthEMReader::NewSP();
39
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("LayeredEarthEMReader") );
40
+    }
41
+
36 42
     void testFieldPoints( void )
37 43
     {
38 44
         auto Obj = FieldPoints::NewSP();
39 45
         TS_ASSERT_EQUALS( Obj->GetName(), std::string("FieldPoints") );
40 46
     }
41 47
 
48
+    void testWireAntenna( void )
49
+    {
50
+        auto Obj = WireAntenna::NewSP();
51
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("WireAntenna") );
52
+    }
53
+
54
+    void testPolygonalWireAntenna( void )
55
+    {
56
+        auto Obj = PolygonalWireAntenna::NewSP();
57
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("PolygonalWireAntenna") );
58
+    }
59
+
42 60
     void testDipoleSource( void )
43 61
     {
44 62
         auto Obj = DipoleSource::NewSP();
45 63
         TS_ASSERT_EQUALS( Obj->GetName(), std::string("DipoleSource") );
46 64
     }
47 65
 
48
-    void testWireAntenna( void )
66
+    void testEMEarth1D( void )
49 67
     {
50
-        auto Obj = WireAntenna::NewSP();
51
-        TS_ASSERT_EQUALS( Obj->GetName(), std::string("WireAntenna") );
68
+        auto Obj = EMEarth1D::NewSP();
69
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("EMEarth1D") );
70
+    }
71
+
72
+    void testAEMSurvey( void )
73
+    {
74
+        auto Obj = AEMSurvey::NewSP();
75
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("AEMSurvey") );
76
+    }
77
+
78
+    void testAEMSurveyReader( void )
79
+    {
80
+        auto Obj = AEMSurveyReader::NewSP();
81
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("AEMSurveyReader") );
52 82
     }
53 83
 
54 84
 //     void testKernelEM1DManager( void )

+ 6
- 6
Modules/LemmaCore/testing/CMakeLists.txt Bestand weergeven

@@ -4,12 +4,12 @@
4 4
 #add_test( testLemmaCoreTwo testTwo )
5 5
     	
6 6
 include_directories(${CXXTEST_INCLUDE_DIR})
7
-CXXTEST_ADD_TEST(unittest_GetNameCheck GetNameCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/GetNameCheck.h)
8
-target_link_libraries(unittest_GetNameCheck "lemmacore")
7
+CXXTEST_ADD_TEST(unittest_LemmaCore_GetNameCheck GetNameCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/GetNameCheck.h)
8
+target_link_libraries(unittest_LemmaCore_GetNameCheck "lemmacore")
9 9
 
10
-CXXTEST_ADD_TEST(unittest_SerializeCheck SerializeCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/SerializeCheck.h)
11
-target_link_libraries(unittest_SerializeCheck "lemmacore")
10
+CXXTEST_ADD_TEST(unittest_LemmaCore_SerializeCheck SerializeCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/SerializeCheck.h)
11
+target_link_libraries(unittest_LemmaCore_SerializeCheck "lemmacore")
12 12
 
13
-CXXTEST_ADD_TEST(unittest_CopyDisableCheck CopyDisableCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/CopyDisableCheck.h)
14
-target_link_libraries(unittest_CopyDisableCheck "lemmacore")
13
+CXXTEST_ADD_TEST(unittest_LemmaCore_CopyDisableCheck CopyDisableCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/CopyDisableCheck.h)
14
+target_link_libraries(unittest_LemmaCore_CopyDisableCheck "lemmacore")
15 15
  

Laden…
Annuleren
Opslaan