Browse Source

Updated for TEM1D, including skeleton testing framework.

add-code-of-conduct-1
Trevor Irons 5 years ago
parent
commit
f1bfa16424

+ 2
- 2
Documentation/Doxyfile.in View File

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

+ 0
- 1
Modules/LemmaCore/testing/SerializeCheck.h View File

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

+ 2
- 0
Modules/TEM1D/CMakeLists.txt View File

27
 #install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")
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")
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
 # Examples
32
 # Examples
31
 if (LEMMA_BUILD_EXAMPLES)
33
 if (LEMMA_BUILD_EXAMPLES)
32
 	add_subdirectory(examples)
34
 	add_subdirectory(examples)

+ 7
- 0
Modules/TEM1D/include/TEM1D View File

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 View File

11
  * @file
11
  * @file
12
  * @date      10/08/2014 02:36:47 PM
12
  * @date      10/08/2014 02:36:47 PM
13
  * @author    Trevor Irons (ti)
13
  * @author    Trevor Irons (ti)
14
- * @email     Trevor.Irons@Utah.edu
14
+ * @email     Trevor.Irons@lemmasoftware.org
15
  * @copyright Copyright (c) 2014, Trevor Irons
15
  * @copyright Copyright (c) 2014, Trevor Irons
16
  */
16
  */
17
 #pragma once
17
 #pragma once
30
 namespace Lemma {
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
 class TEMReceiver : public FieldPoints {
36
 class TEMReceiver : public FieldPoints {
37
 
37
 
122
 
122
 
123
     // ====================  INQUIRY       =======================
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
      * @return centre point of gates in sec
126
      * @return centre point of gates in sec
140
      */
127
      */
150
      */
137
      */
151
     Real    GetReferenceTime();
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
     protected:
145
     protected:
154
 
146
 
155
     // ====================  LIFECYCLE     =======================
147
     // ====================  LIFECYCLE     =======================
162
 
154
 
163
     private:
155
     private:
164
 
156
 
157
+    /** ASCII string representation of the class name */
158
+    static constexpr auto CName = "TEMReceiver";
159
+
165
     // ====================  DATA MEMBERS  =========================
160
     // ====================  DATA MEMBERS  =========================
166
 
161
 
167
     Real            moment;
162
     Real            moment;

+ 26
- 41
Modules/TEM1D/include/TEMTransmitter.h View File

10
 /**
10
 /**
11
  * @file
11
  * @file
12
  * @date      09/29/2014 11:43:17 AM
12
  * @date      09/29/2014 11:43:17 AM
13
- * @version   $Id$
14
  * @author    Trevor Irons (ti)
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
  * @copyright Copyright (c) 2014, Trevor Irons
15
  * @copyright Copyright (c) 2014, Trevor Irons
18
  */
16
  */
19
 
17
 
22
 
20
 
23
 #include "PolygonalWireAntenna.h"
21
 #include "PolygonalWireAntenna.h"
24
 
22
 
25
-#ifdef HAVE_YAMLCPP
26
-#include "yaml-cpp/yaml.h"
27
-#endif
28
-
29
 namespace Lemma {
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
 class TEMTransmitter : public PolygonalWireAntenna {
30
 class TEMTransmitter : public PolygonalWireAntenna {
38
 
31
 
42
 
35
 
43
     // ====================  LIFECYCLE     =======================
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
      * @copybrief LemmaObject::New()
48
      * @copybrief LemmaObject::New()
47
      * @copydetails LemmaObject::New()
49
      * @copydetails LemmaObject::New()
48
      */
50
      */
49
-    static TEMTransmitter* New();
51
+    static std::shared_ptr<TEMTransmitter> NewSP();
50
 
52
 
51
     /**
53
     /**
52
      *  Performs a deep copy of this and returns pointer
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
     // ====================  OPERATORS     =======================
62
     // ====================  OPERATORS     =======================
63
 
63
 
71
 
71
 
72
     void SetWaveform( const VectorXr& times, const VectorXr& amps, const TIMEUNITS& units );
72
     void SetWaveform( const VectorXr& times, const VectorXr& amps, const TIMEUNITS& units );
73
 
73
 
74
+    // ====================  INQUIRY       =======================
75
+
74
     /**
76
     /**
75
      *  @return the waveform times in seconds
77
      *  @return the waveform times in seconds
76
      */
78
      */
80
      */
82
      */
81
     VectorXr GetWfmAmps();
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
     protected:
90
     protected:
91
 
91
 
92
     // ====================  LIFECYCLE     =======================
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
     private:
94
     private:
112
 
95
 
96
+    static constexpr auto CName = "TEMTransmitter";
97
+
113
     // ====================  DATA MEMBERS  =========================
98
     // ====================  DATA MEMBERS  =========================
114
 
99
 
115
     Real                    repFreq;
100
     Real                    repFreq;

+ 17
- 54
Modules/TEM1D/src/TEMTransmitter.cpp View File

23
 
23
 
24
 // ====================  FRIEND METHODS  =====================
24
 // ====================  FRIEND METHODS  =====================
25
 
25
 
26
-#ifdef HAVE_YAMLCPP
27
 std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
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
     return stream;
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
 // ====================  LIFECYCLE     =======================
31
 // ====================  LIFECYCLE     =======================
46
 
32
 
49
 //      Method:  TEMTransmitter
35
 //      Method:  TEMTransmitter
50
 // Description:  constructor (protected)
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
 }  // -----  end of method TEMTransmitter::TEMTransmitter  (constructor)  -----
42
 }  // -----  end of method TEMTransmitter::TEMTransmitter  (constructor)  -----
56
 
43
 
57
-#ifdef HAVE_YAMLCPP
58
 //--------------------------------------------------------------------------------------
44
 //--------------------------------------------------------------------------------------
59
 //       Class:  TEMTransmitter
45
 //       Class:  TEMTransmitter
60
 //      Method:  TEMTransmitter
46
 //      Method:  TEMTransmitter
61
 // Description:  Deserializing constructor (protected)
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
     repFreq =  node["repFreq"].as<Real>();
52
     repFreq =  node["repFreq"].as<Real>();
66
     repFreqUnits =  string2Enum<FREQUENCYUNITS>( node["repFreqUnits"].as<std::string>() );
53
     repFreqUnits =  string2Enum<FREQUENCYUNITS>( node["repFreqUnits"].as<std::string>() );
67
     wfmTimes = node["wfmTimes"].as<VectorXr>();
54
     wfmTimes = node["wfmTimes"].as<VectorXr>();
68
     wfmTimes = node["wfmAmps"].as<VectorXr>();
55
     wfmTimes = node["wfmAmps"].as<VectorXr>();
69
 
56
 
70
 }  // -----  end of method TEMTransmitter::TEMTransmitter  (constructor)  -----
57
 }  // -----  end of method TEMTransmitter::TEMTransmitter  (constructor)  -----
71
-#endif
72
 
58
 
73
 //--------------------------------------------------------------------------------------
59
 //--------------------------------------------------------------------------------------
74
 //       Class:  TEMTransmitter
60
 //       Class:  TEMTransmitter
75
 //      Method:  New()
61
 //      Method:  New()
76
 // Description:  public constructor
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
 //       Class:  TEMTransmitter
70
 //       Class:  TEMTransmitter
87
 //      Method:  Clone
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
     //copy->AttachTo(copy); // NO! Attached above!
75
     //copy->AttachTo(copy); // NO! Attached above!
92
 	copy->NumberOfPoints = this->NumberOfPoints;
76
 	copy->NumberOfPoints = this->NumberOfPoints;
93
 	copy->Freqs = this->Freqs;
77
 	copy->Freqs = this->Freqs;
116
 
100
 
117
 //--------------------------------------------------------------------------------------
101
 //--------------------------------------------------------------------------------------
118
 //       Class:  TEMTransmitter
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
 //      Method:  Serialize
103
 //      Method:  Serialize
138
 //--------------------------------------------------------------------------------------
104
 //--------------------------------------------------------------------------------------
139
-#ifdef HAVE_YAMLCPP
140
 YAML::Node TEMTransmitter::Serialize (  ) const {
105
 YAML::Node TEMTransmitter::Serialize (  ) const {
141
 
106
 
142
     YAML::Node node = PolygonalWireAntenna::Serialize();
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
         //node["address"] =  ss.str();
109
         //node["address"] =  ss.str();
146
 
110
 
147
         node["repFreq"]      = this->repFreq;
111
         node["repFreq"]      = this->repFreq;
156
 //       Class:  TEMTransmitter
120
 //       Class:  TEMTransmitter
157
 //      Method:  DeSerialize
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
 }		// -----  end of method TEMTransmitter::DeSerialize  -----
128
 }		// -----  end of method TEMTransmitter::DeSerialize  -----
165
-#endif
166
 
129
 
167
     // ====================  INQUIRY       =======================
130
     // ====================  INQUIRY       =======================
168
 
131
 

+ 8
- 0
Modules/TEM1D/testing/CMakeLists.txt View File

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 View File

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 View File

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…
Cancel
Save