Kaynağa Gözat

Updated for TEM1D, including skeleton testing framework.

add-code-of-conduct-1
Trevor Irons 6 yıl önce
ebeveyn
işleme
f1bfa16424

+ 2
- 2
Documentation/Doxyfile.in Dosyayı Görüntüle

@@ -858,7 +858,7 @@ EXCLUDE_SYMBOLS        =
858 858
 # that contain example code fragments that are included (see the \include
859 859
 # command).
860 860
 
861
-EXAMPLE_PATH           = ./unittest \
861
+EXAMPLE_PATH           = ./Modules/examples/ \
862 862
                          ./
863 863
 
864 864
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
@@ -2178,7 +2178,7 @@ DOT_NUM_THREADS        = 0
2178 2178
 # The default value is: Helvetica.
2179 2179
 # This tag requires that the tag HAVE_DOT is set to YES.
2180 2180
 
2181
-DOT_FONTNAME           = FreeSans
2181
+DOT_FONTNAME           = Helvetica 
2182 2182
 
2183 2183
 # The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
2184 2184
 # dot graphs.

+ 0
- 1
Modules/LemmaCore/testing/SerializeCheck.h Dosyayı Görüntüle

@@ -10,7 +10,6 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      06/16/2016 09:12:46 PM
13
- * @version   $Id$
14 13
  * @author    Trevor Irons (ti)
15 14
  * @email     tirons@egi.utah.edu
16 15
  * @copyright Copyright (c) 2016, University of Utah

+ 2
- 0
Modules/TEM1D/CMakeLists.txt Dosyayı Görüntüle

@@ -27,6 +27,8 @@ install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma
27 27
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")
28 28
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/FDEM1D  FILES_MATCHING PATTERN "*.h")
29 29
 
30
+install ( FILES include/TEM1D  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 
31
+
30 32
 # Examples
31 33
 if (LEMMA_BUILD_EXAMPLES)
32 34
 	add_subdirectory(examples)

+ 7
- 0
Modules/TEM1D/include/TEM1D Dosyayı Görüntüle

@@ -0,0 +1,7 @@
1
+#pragma once
2
+
3
+#include "TEMTransmitter.h"
4
+#include "TEMReceiver.h"
5
+
6
+/* vim: set tabstop=4 expandtab: */
7
+/* vim: set filetype=cpp: */

+ 11
- 16
Modules/TEM1D/include/TEMReceiver.h Dosyayı Görüntüle

@@ -11,7 +11,7 @@
11 11
  * @file
12 12
  * @date      10/08/2014 02:36:47 PM
13 13
  * @author    Trevor Irons (ti)
14
- * @email     Trevor.Irons@Utah.edu
14
+ * @email     Trevor.Irons@lemmasoftware.org
15 15
  * @copyright Copyright (c) 2014, Trevor Irons
16 16
  */
17 17
 #pragma once
@@ -30,8 +30,8 @@
30 30
 namespace Lemma {
31 31
 
32 32
 /**
33
-  \brief
34
-  \details
33
+  \brief   Describes a TEM receiver
34
+  \details A general class for TEM receivers
35 35
  */
36 36
 class TEMReceiver : public FieldPoints {
37 37
 
@@ -122,19 +122,6 @@ class TEMReceiver : public FieldPoints {
122 122
 
123 123
     // ====================  INQUIRY       =======================
124 124
 
125
-     #ifdef HAVE_YAMLCPP
126
-	/**
127
-     *  Uses YAML to serialize this object.
128
-     *  @return a YAML::Node
129
-     */
130
-    YAML::Node Serialize() const;
131
-
132
-    /**
133
-     *   Constructs an object from a YAML::Node.
134
-     */
135
-    static TEMReceiver* DeSerialize(const YAML::Node& node);
136
-     #endif
137
-
138 125
     /**
139 126
      * @return centre point of gates in sec
140 127
      */
@@ -150,6 +137,11 @@ class TEMReceiver : public FieldPoints {
150 137
      */
151 138
     Real    GetReferenceTime();
152 139
 
140
+    /** Returns the name of the underlying class, similiar to Python's type */
141
+    virtual std::string GetName() const {
142
+        return this->CName;
143
+    }
144
+
153 145
     protected:
154 146
 
155 147
     // ====================  LIFECYCLE     =======================
@@ -162,6 +154,9 @@ class TEMReceiver : public FieldPoints {
162 154
 
163 155
     private:
164 156
 
157
+    /** ASCII string representation of the class name */
158
+    static constexpr auto CName = "TEMReceiver";
159
+
165 160
     // ====================  DATA MEMBERS  =========================
166 161
 
167 162
     Real            moment;

+ 26
- 41
Modules/TEM1D/include/TEMTransmitter.h Dosyayı Görüntüle

@@ -10,10 +10,8 @@
10 10
 /**
11 11
  * @file
12 12
  * @date      09/29/2014 11:43:17 AM
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
 
@@ -22,17 +20,12 @@
22 20
 
23 21
 #include "PolygonalWireAntenna.h"
24 22
 
25
-#ifdef HAVE_YAMLCPP
26
-#include "yaml-cpp/yaml.h"
27
-#endif
28
-
29 23
 namespace Lemma {
30 24
 
31 25
 /**
32
-  \brief   Describes a TEM pulse sequence
33
-  \details Flexible class desribing a pulse sequence used by
34
-           a TEM instruement. Can be used by Airborne or Ground
35
-           instruments.
26
+  \brief   Describes a TEM transmitter
27
+  \details Flexible class desribing a source used by TEM instrument.
28
+           Can be used by Airborne or Ground instruments.
36 29
  */
37 30
 class TEMTransmitter : public PolygonalWireAntenna {
38 31
 
@@ -42,22 +35,29 @@ class TEMTransmitter : public PolygonalWireAntenna {
42 35
 
43 36
     // ====================  LIFECYCLE     =======================
44 37
 
38
+    /** Default protected constructor, use New */
39
+    explicit TEMTransmitter (const ctor_key& );
40
+
41
+    /** Default protected constructor, use New */
42
+    TEMTransmitter (const YAML::Node& node, const ctor_key& );
43
+
44
+    /** Default protected destructor, use Delete */
45
+    ~TEMTransmitter ();
46
+
45 47
     /**
46 48
      * @copybrief LemmaObject::New()
47 49
      * @copydetails LemmaObject::New()
48 50
      */
49
-    static TEMTransmitter* New();
51
+    static std::shared_ptr<TEMTransmitter> NewSP();
50 52
 
51 53
     /**
52 54
      *  Performs a deep copy of this and returns pointer
53 55
      */
54
-    TEMTransmitter* Clone();
56
+    std::shared_ptr<TEMTransmitter> Clone();
55 57
 
56
-    /**
57
-     *  @copybrief   LemmaObject::Delete()
58
-     *  @copydetails LemmaObject::Delete()
59
-     */
60
-    void Delete();
58
+    YAML::Node Serialize() const;
59
+
60
+    static std::shared_ptr<TEMTransmitter> DeSerialize(const YAML::Node& node);
61 61
 
62 62
     // ====================  OPERATORS     =======================
63 63
 
@@ -71,6 +71,8 @@ class TEMTransmitter : public PolygonalWireAntenna {
71 71
 
72 72
     void SetWaveform( const VectorXr& times, const VectorXr& amps, const TIMEUNITS& units );
73 73
 
74
+    // ====================  INQUIRY       =======================
75
+
74 76
     /**
75 77
      *  @return the waveform times in seconds
76 78
      */
@@ -80,36 +82,19 @@ class TEMTransmitter : public PolygonalWireAntenna {
80 82
      */
81 83
     VectorXr GetWfmAmps();
82 84
 
83
-    // ====================  INQUIRY       =======================
84
-
85
-#ifdef HAVE_YAMLCPP
86
-    YAML::Node Serialize() const;
87
-    static TEMTransmitter* DeSerialize(const YAML::Node& node);
88
-#endif
85
+    /** Returns the name of the underlying class, similiar to Python's type */
86
+    virtual std::string GetName() const {
87
+        return this->CName;
88
+    }
89 89
 
90 90
     protected:
91 91
 
92 92
     // ====================  LIFECYCLE     =======================
93 93
 
94
-    /** Default protected constructor, use New */
95
-    TEMTransmitter (const std::string& name);
96
-
97
-#ifdef HAVE_YAMLCPP
98
-    /** Default protected constructor, use New */
99
-    TEMTransmitter (const YAML::Node& node);
100
-#endif
101
-
102
-    /** Default protected destructor, use Delete */
103
-    ~TEMTransmitter ();
104
-
105
-    /**
106
-     *  @copybrief   LemmaObject::Release()
107
-     *  @copydetails LemmaObject::Release()
108
-     */
109
-    void Release();
110
-
111 94
     private:
112 95
 
96
+    static constexpr auto CName = "TEMTransmitter";
97
+
113 98
     // ====================  DATA MEMBERS  =========================
114 99
 
115 100
     Real                    repFreq;

+ 17
- 54
Modules/TEM1D/src/TEMTransmitter.cpp Dosyayı Görüntüle

@@ -23,24 +23,10 @@ namespace Lemma {
23 23
 
24 24
 // ====================  FRIEND METHODS  =====================
25 25
 
26
-#ifdef HAVE_YAMLCPP
27 26
 std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
28
-    stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
27
+    stream << ob.Serialize()  << "\n";
29 28
     return stream;
30 29
 }
31
-// TODO CONSIDER INPUT OPERATOR TOO!
32
-//std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
33
-//    stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
34
-//    return stream;
35
-//}
36
-#else
37
-std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
38
-    stream << *(PolygonalWireAntenna*)(&ob);
39
-    stream << "YOU SHOULD COMPILE WITH YAML-CPP\n";
40
-    return stream;
41
-}
42
-#endif
43
-
44 30
 
45 31
 // ====================  LIFECYCLE     =======================
46 32
 
@@ -49,36 +35,34 @@ std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
49 35
 //      Method:  TEMTransmitter
50 36
 // Description:  constructor (protected)
51 37
 //--------------------------------------------------------------------------------------
52
-TEMTransmitter::TEMTransmitter (const std::string& name) : PolygonalWireAntenna(name),
53
-    repFreq(0), repFreqUnits(HZ) {
38
+TEMTransmitter::TEMTransmitter (const ctor_key& key) :
39
+    PolygonalWireAntenna(key), repFreq(0), repFreqUnits(HZ)
40
+{
54 41
 
55 42
 }  // -----  end of method TEMTransmitter::TEMTransmitter  (constructor)  -----
56 43
 
57
-#ifdef HAVE_YAMLCPP
58 44
 //--------------------------------------------------------------------------------------
59 45
 //       Class:  TEMTransmitter
60 46
 //      Method:  TEMTransmitter
61 47
 // Description:  Deserializing constructor (protected)
62 48
 //--------------------------------------------------------------------------------------
63
-TEMTransmitter::TEMTransmitter (const YAML::Node& node) : PolygonalWireAntenna(node) {
64
-
49
+TEMTransmitter::TEMTransmitter (const YAML::Node& node, const ctor_key& key) :
50
+        PolygonalWireAntenna(node, key)
51
+{
65 52
     repFreq =  node["repFreq"].as<Real>();
66 53
     repFreqUnits =  string2Enum<FREQUENCYUNITS>( node["repFreqUnits"].as<std::string>() );
67 54
     wfmTimes = node["wfmTimes"].as<VectorXr>();
68 55
     wfmTimes = node["wfmAmps"].as<VectorXr>();
69 56
 
70 57
 }  // -----  end of method TEMTransmitter::TEMTransmitter  (constructor)  -----
71
-#endif
72 58
 
73 59
 //--------------------------------------------------------------------------------------
74 60
 //       Class:  TEMTransmitter
75 61
 //      Method:  New()
76 62
 // Description:  public constructor
77 63
 //--------------------------------------------------------------------------------------
78
-TEMTransmitter* TEMTransmitter::New() {
79
-    TEMTransmitter*  Obj = new TEMTransmitter("TEMTransmitter");
80
-    Obj->AttachTo(Obj);
81
-    return Obj;
64
+std::shared_ptr<TEMTransmitter> TEMTransmitter::NewSP() {
65
+    return std::make_shared<TEMTransmitter>( ctor_key() );
82 66
 }
83 67
 
84 68
 
@@ -86,8 +70,8 @@ TEMTransmitter* TEMTransmitter::New() {
86 70
 //       Class:  TEMTransmitter
87 71
 //      Method:  Clone
88 72
 //--------------------------------------------------------------------------------------
89
-TEMTransmitter* TEMTransmitter::Clone (  ) {
90
-    TEMTransmitter* copy = TEMTransmitter::New();
73
+std::shared_ptr<TEMTransmitter> TEMTransmitter::Clone (  ) {
74
+    auto copy = TEMTransmitter::NewSP();
91 75
     //copy->AttachTo(copy); // NO! Attached above!
92 76
 	copy->NumberOfPoints = this->NumberOfPoints;
93 77
 	copy->Freqs = this->Freqs;
@@ -116,32 +100,12 @@ TEMTransmitter::~TEMTransmitter () {
116 100
 
117 101
 //--------------------------------------------------------------------------------------
118 102
 //       Class:  TEMTransmitter
119
-//      Method:  Delete
120
-// Description:  public destructor
121
-//--------------------------------------------------------------------------------------
122
-void TEMTransmitter::Delete() {
123
-    this->DetachFrom(this);
124
-}
125
-
126
-//--------------------------------------------------------------------------------------
127
-//       Class:  TEMTransmitter
128
-//      Method:  Release
129
-// Description:  destructor (protected)
130
-//--------------------------------------------------------------------------------------
131
-void TEMTransmitter::Release() {
132
-    delete this;
133
-}
134
-
135
-//--------------------------------------------------------------------------------------
136
-//       Class:  TEMTransmitter
137 103
 //      Method:  Serialize
138 104
 //--------------------------------------------------------------------------------------
139
-#ifdef HAVE_YAMLCPP
140 105
 YAML::Node TEMTransmitter::Serialize (  ) const {
141 106
 
142 107
     YAML::Node node = PolygonalWireAntenna::Serialize();
143
-        // or we could do just like below. Same basic uglyness
144
-        node.SetTag( this->Name) ; //((PolygonalWireAntenna*)(&ob))->GetName() );
108
+        node.SetTag( this->GetName() );
145 109
         //node["address"] =  ss.str();
146 110
 
147 111
         node["repFreq"]      = this->repFreq;
@@ -156,13 +120,12 @@ YAML::Node TEMTransmitter::Serialize (  ) const {
156 120
 //       Class:  TEMTransmitter
157 121
 //      Method:  DeSerialize
158 122
 //--------------------------------------------------------------------------------------
159
-TEMTransmitter* TEMTransmitter::DeSerialize ( const  YAML::Node& node  ) {
160
-    TEMTransmitter* Object = new TEMTransmitter(node);
161
-    Object->AttachTo(Object);
162
-    DESERIALIZECHECK( node, Object )
163
-    return  Object;
123
+std::shared_ptr<TEMTransmitter> TEMTransmitter::DeSerialize ( const  YAML::Node& node  ) {
124
+    if (node.Tag() != "TEMTransmitter") {
125
+        throw  DeSerializeTypeMismatch( "TEMTransmitter", node.Tag());
126
+    }
127
+    return std::make_shared<TEMTransmitter> ( node, ctor_key() );
164 128
 }		// -----  end of method TEMTransmitter::DeSerialize  -----
165
-#endif
166 129
 
167 130
     // ====================  INQUIRY       =======================
168 131
 

+ 8
- 0
Modules/TEM1D/testing/CMakeLists.txt Dosyayı Görüntüle

@@ -0,0 +1,8 @@
1
+
2
+include_directories( ${CXXTEST_INCLUDE_DIR} )
3
+
4
+CXXTEST_ADD_TEST(unittest_TEM1D_GetNameCheck GetNameCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/GetNameCheck.h)
5
+target_link_libraries(unittest_TEM1D_GetNameCheck "lemmacore" "fdem1d" "tem1d")
6
+
7
+CXXTEST_ADD_TEST(unittest_TEM1D_SerializeCheck SerializeCheck.cc ${CMAKE_CURRENT_SOURCE_DIR}/SerializeCheck.h)
8
+target_link_libraries(unittest_TEM1D_SerializeCheck "lemmacore" "fdem1d" "tem1d")

+ 42
- 0
Modules/TEM1D/testing/GetNameCheck.h Dosyayı Görüntüle

@@ -0,0 +1,42 @@
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      10/16/2018 12:46:43 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     Trevor.Irons@utah.edu
16
+ * @copyright Copyright (c) 2018, University of Utah
17
+ * @copyright Copyright (c) 2018, Lemma Software, LLC
18
+ */
19
+
20
+#include <cxxtest/TestSuite.h>
21
+#include <TEM1D>
22
+
23
+using namespace Lemma;
24
+
25
+class MyTestSuite : public CxxTest::TestSuite
26
+{
27
+    public:
28
+
29
+    void testTEMTransmitter( void )
30
+    {
31
+        auto Obj = TEMTransmitter::NewSP();
32
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("TEMTransmitter") );
33
+    }
34
+
35
+    void testTEMReceiver( void )
36
+    {
37
+        auto Obj = TEMReceiver::NewSP();
38
+        TS_ASSERT_EQUALS( Obj->GetName(), std::string("TEMReceiver") );
39
+    }
40
+
41
+};
42
+

+ 56
- 0
Modules/TEM1D/testing/SerializeCheck.h Dosyayı Görüntüle

@@ -0,0 +1,56 @@
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      10/16/2018 12:43:19 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     Trevor.Irons@utah.edu
16
+ * @copyright Copyright (c) 2018, University of Utah
17
+ * @copyright Copyright (c) 2018, Lemma Software, LLC
18
+ */
19
+
20
+#include <cxxtest/TestSuite.h>
21
+#include <TEM1D>
22
+
23
+using namespace Lemma;
24
+
25
+class MyTestSuite : public CxxTest::TestSuite
26
+{
27
+    public:
28
+
29
+//     void test_trace(void)
30
+//     {
31
+//         TS_TRACE("This is a test tracing message.");
32
+//     }
33
+//
34
+//     void test_warn(void)
35
+//     {
36
+//         TS_WARN("This is a test warning message.");
37
+//     }
38
+
39
+    void testTEMTransmitter( void )
40
+    {
41
+        auto Obj = TEMTransmitter::NewSP();
42
+        YAML::Node node = Obj->Serialize();
43
+        auto Obj2 = TEMTransmitter::DeSerialize(node);
44
+        TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
45
+    }
46
+
47
+    void testTEMReceiver( void )
48
+    {
49
+        auto Obj = TEMReceiver::NewSP();
50
+        YAML::Node node = Obj->Serialize();
51
+        auto Obj2 = TEMReceiver::DeSerialize(node);
52
+        TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
53
+    }
54
+
55
+
56
+};

Loading…
İptal
Kaydet