Browse Source

Fix MSVC warnings regarding unsigned integer comparisons, and DipoleSource::Serialize infinite recursion.

add-code-of-conduct-1
Trevor Irons 6 years ago
parent
commit
a25a93d59c

+ 1
- 1
Modules/DCIP/CMakeLists.txt View File

38
 
38
 
39
 	# Install
39
 	# Install
40
 	install ( TARGETS dcip DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
40
 	install ( TARGETS dcip DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
41
-	install ( FILES include/EMSchur3D  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 
41
+	install ( FILES include/DCIP  DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma ) 
42
 	install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma  FILES_MATCHING PATTERN "*.h")
42
 	install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma  FILES_MATCHING PATTERN "*.h")
43
 
43
 
44
 	#install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")
44
 	#install ( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/  FILES_MATCHING PATTERN "FDEM1D")

+ 11
- 0
Modules/DCIP/include/DCIP View File

1
+#ifndef  DCIP_INC
2
+#define  DCIP_INC
3
+
4
+#include "DCSurvey.h"
5
+#include "DCIPElectrode.h"
6
+
7
+#endif   // ----- #ifndef DCIP_INC  -----
8
+
9
+/* vim: set tabstop=4 expandtab: */
10
+/* vim: set filetype=cpp: */
11
+

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

26
 target_link_libraries(  Hantenna  "lemmacore" "fdem1d")
26
 target_link_libraries(  Hantenna  "lemmacore" "fdem1d")
27
 set_property(TARGET Hantenna PROPERTY CXX_STANDARD 14)
27
 set_property(TARGET Hantenna PROPERTY CXX_STANDARD 14)
28
 
28
 
29
+add_executable( DipoleSource DipoleSource.cpp  )
30
+target_link_libraries(  DipoleSource  "lemmacore" "fdem1d")
31
+set_property(TARGET DipoleSource PROPERTY CXX_STANDARD 14)
32
+
29
 INSTALL_TARGETS( "/share/FDEM1D/"
33
 INSTALL_TARGETS( "/share/FDEM1D/"
30
 	LayeredEarthEM 
34
 	LayeredEarthEM 
31
 	FieldPoints
35
 	FieldPoints
33
 	EMDipEarth1D
37
 	EMDipEarth1D
34
     CircularLoop
38
     CircularLoop
35
 	Hantenna
39
 	Hantenna
40
+	DipoleSource
36
 )
41
 )
37
 
42
 
38
 install (DIRECTORY inp  DESTINATION "${CMAKE_INSTALL_PREFIX}/share/FDEM1D/" )
43
 install (DIRECTORY inp  DESTINATION "${CMAKE_INSTALL_PREFIX}/share/FDEM1D/" )

+ 39
- 0
Modules/FDEM1D/examples/DipoleSource.cpp 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/25/2018 12:41:37 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 "FDEM1D"
21
+
22
+using namespace Lemma;
23
+
24
+int main() {
25
+    auto dip = DipoleSource::NewSP();
26
+    dip->SetLocation( Vector3r(1.,2.,3.) );
27
+    std::cout << "Dipole 1: " << dip << "\n" << *dip << std::endl;
28
+
29
+    auto dip2 = dip->Clone(); // literal copy of pointer
30
+    dip2->SetLocation( Vector3r(1.,2.,3.) );
31
+    std::cout << "Dipole 2: " << dip2 << "\n" << *dip2 << std::endl;
32
+
33
+//    if (*dip == *dip2) {
34
+//        std::cout << "equal" << std::endl;
35
+//    } else {
36
+//        std::cout << "not equal" << std::endl;
37
+//    }
38
+}
39
+

+ 28
- 23
Modules/FDEM1D/include/DipoleSource.h View File

8
   @file
8
   @file
9
   @author   Trevor Irons
9
   @author   Trevor Irons
10
   @date     12/02/2009
10
   @date     12/02/2009
11
-  @version  $Id: dipolesource.h 203 2015-01-09 21:19:04Z tirons $
12
  **/
11
  **/
13
 
12
 
14
 #ifndef __DIPOLESOURCE_H
13
 #ifndef __DIPOLESOURCE_H
47
 
46
 
48
         friend std::ostream &operator<<(std::ostream &stream, const DipoleSource &ob);
47
         friend std::ostream &operator<<(std::ostream &stream, const DipoleSource &ob);
49
 
48
 
49
+        friend class EMEarth1D;
50
+
50
         public:
51
         public:
51
 
52
 
53
+            //bool operator==(DipoleSource& rhs)const;
54
+
52
             // ====================  LIFECYCLE     ======================
55
             // ====================  LIFECYCLE     ======================
53
 
56
 
54
             /** Default locked constructor. */
57
             /** Default locked constructor. */
86
 
89
 
87
             // ====================  OPERATORS     ======================
90
             // ====================  OPERATORS     ======================
88
 
91
 
89
-            // ====================  OPERATIONS    ======================
90
-
91
-            /** Determines if kernels have been loaded already, and if so if they can be reused
92
-             */
93
-            void SetKernels(const int& ifreq,  const FIELDCALCULATIONS&  Fields, std::shared_ptr<FieldPoints> Receivers, const int& irec,
94
-                    std::shared_ptr<LayeredEarthEM> Earth );
95
-
96
-            /** resets the kernels if they cannot be reused */
97
-            virtual void ReSetKernels(const int& ifreq,  const FIELDCALCULATIONS&  Fields, std::shared_ptr<FieldPoints> Receivers,
98
-                    const int& irec, std::shared_ptr<LayeredEarthEM> Earth );
99
-
100
-            /** Updates the receiver fields */
101
-            virtual void UpdateFields(const int& ifreq, HankelTransform* Hankel, const Real& wavef);
102
 
92
 
103
             // ====================  ACCESS        ======================
93
             // ====================  ACCESS        ======================
104
 
94
 
133
             /// Sets the dipole source type
123
             /// Sets the dipole source type
134
             /// @param[in] stype is one of the enerated values taking either
124
             /// @param[in] stype is one of the enerated values taking either
135
             /// ELECTRICDIPOLE or MAGNETICDIPOLE
125
             /// ELECTRICDIPOLE or MAGNETICDIPOLE
136
-            void SetType(const DipoleSourceType &stype);
126
+            void SetType(const DIPOLESOURCETYPE &stype);
137
 
127
 
138
             /// Sets the dipole moment
128
             /// Sets the dipole moment
139
             void SetMoment(const Real &moment);
129
             void SetMoment(const Real &moment);
157
             /// number of frequencies
147
             /// number of frequencies
158
             void SetFrequencies(const VectorXr& freqs);
148
             void SetFrequencies(const VectorXr& freqs);
159
 
149
 
160
-
161
             // ====================  INQUIRY       ======================
150
             // ====================  INQUIRY       ======================
162
 
151
 
163
             /**  Accessor to polarisation vector.
152
             /**  Accessor to polarisation vector.
172
             /// @param coordinate 0=x, 1=y, 2=z
161
             /// @param coordinate 0=x, 1=y, 2=z
173
             Real  GetLocation(const int &coordinate);
162
             Real  GetLocation(const int &coordinate);
174
 
163
 
175
-            /// Returns enumerated of DipoleSourceType
176
-            DipoleSourceType GetDipoleSourceType();
164
+            /// Returns enumerated of DIPOLESOURCETYPE
165
+            DIPOLESOURCETYPE GetDipoleSourceType();
177
 
166
 
178
             /// Returns the dipole type
167
             /// Returns the dipole type
179
-            DipoleSourceType GetType();
168
+            DIPOLESOURCETYPE GetType();
180
 
169
 
181
             /// Returns pointer to KernelEM1DManager
170
             /// Returns pointer to KernelEM1DManager
182
             std::shared_ptr<KernelEM1DManager>  GetKernelManager();
171
             std::shared_ptr<KernelEM1DManager>  GetKernelManager();
212
             /** Returns the name of the underlying class, similiar to Python's type */
201
             /** Returns the name of the underlying class, similiar to Python's type */
213
             virtual std::string GetName() const ;
202
             virtual std::string GetName() const ;
214
 
203
 
204
+        protected:
205
+
206
+            // ====================  OPERATIONS    ======================
207
+
208
+            /** Determines if kernels have been loaded already, and if so if they can be reused
209
+             */
210
+            void SetKernels(const int& ifreq,  const FIELDCALCULATIONS&  Fields, std::shared_ptr<FieldPoints> Receivers, const int& irec,
211
+                    std::shared_ptr<LayeredEarthEM> Earth );
212
+
213
+            /** resets the kernels if they cannot be reused */
214
+            virtual void ReSetKernels(const int& ifreq,  const FIELDCALCULATIONS&  Fields, std::shared_ptr<FieldPoints> Receivers,
215
+                    const int& irec, std::shared_ptr<LayeredEarthEM> Earth );
216
+
217
+            /** Updates the receiver fields */
218
+            virtual void UpdateFields(const int& ifreq, HankelTransform* Hankel, const Real& wavef);
219
+
215
         private:
220
         private:
216
 
221
 
217
             // ====================  DATA MEMBERS  ======================
222
             // ====================  DATA MEMBERS  ======================
218
 
223
 
219
             /// Defines the type of source (magnetic or electric)
224
             /// Defines the type of source (magnetic or electric)
220
-            DipoleSourceType             Type;
225
+            DIPOLESOURCETYPE             Type;
221
 
226
 
222
             // Polarization of the dipole, (x, y or z)
227
             // Polarization of the dipole, (x, y or z)
223
             //DipoleSourcePolarisation     Polarisation;
228
             //DipoleSourcePolarisation     Polarisation;
253
             VectorXi                     ik;
258
             VectorXi                     ik;
254
 
259
 
255
             /// Central location of the dipole
260
             /// Central location of the dipole
256
-            Vector3r                     Location;
261
+            Vector3r                                    Location;
257
 
262
 
258
             /// Unit vector defining directionality of the dipole
263
             /// Unit vector defining directionality of the dipole
259
-            Vector3r                     Phat;
264
+            Vector3r                                    Phat;
260
 
265
 
261
             /// Freqencies of the source, in Hz
266
             /// Freqencies of the source, in Hz
262
-            VectorXr                     Freqs;
267
+            VectorXr                                    Freqs;
263
 
268
 
264
             /// Storage of the EM1D kernels used by this dipole
269
             /// Storage of the EM1D kernels used by this dipole
265
             std::shared_ptr<KernelEM1DManager>          KernelManager;
270
             std::shared_ptr<KernelEM1DManager>          KernelManager;

+ 39
- 17
Modules/FDEM1D/src/DipoleSource.cpp View File

24
 
24
 
25
 
25
 
26
     // ====================    FRIENDS     ======================
26
     // ====================    FRIENDS     ======================
27
+
27
     std::ostream &operator<<(std::ostream &stream, const DipoleSource &ob) {
28
     std::ostream &operator<<(std::ostream &stream, const DipoleSource &ob) {
28
         stream << ob.Serialize()  << "\n";
29
         stream << ob.Serialize()  << "\n";
29
         return stream;
30
         return stream;
30
     }
31
     }
31
 
32
 
33
+/*
34
+    bool DipoleSource::operator == (DipoleSource& rhs) const {
35
+        if (Location != rhs.Location) return false;
36
+        return true;
37
+    }
38
+*/
32
 
39
 
33
     // ====================  LIFECYCLE     ======================
40
     // ====================  LIFECYCLE     ======================
34
 
41
 
45
         this->Phat.setZero();
52
         this->Phat.setZero();
46
     }
53
     }
47
 
54
 
55
+    DipoleSource::DipoleSource( const YAML::Node& node, const ctor_key& key ) : LemmaObject( node, key ),
56
+                    Type(NOSOURCETYPE),
57
+                    irec(-1),
58
+                    Phase(0),
59
+                    Moment(1),
60
+                    KernelManager(nullptr),
61
+                    Receivers(nullptr),
62
+                    Earth(nullptr)
63
+    {
64
+        Type = string2Enum<DIPOLESOURCETYPE>(node["Type"].as<std::string>());
65
+        this->Location = node["Location"].as<Vector3r>();
66
+        this->Phat.setZero();
67
+    }
68
+
69
+
48
     DipoleSource::~DipoleSource() {
70
     DipoleSource::~DipoleSource() {
49
     }
71
     }
50
 
72
 
53
     }
75
     }
54
 
76
 
55
     YAML::Node DipoleSource::Serialize() const {
77
     YAML::Node DipoleSource::Serialize() const {
56
-        YAML::Node node = DipoleSource::Serialize();
78
+        YAML::Node node = LemmaObject::Serialize();
57
         node.SetTag( GetName() );
79
         node.SetTag( GetName() );
58
-        /*
59
-        node["LayerConductivity"] = LayerConductivity;
60
-        node["LayerSusceptibility"] = LayerSusceptibility;
61
-        node["LayerLowFreqSusceptibility"] = LayerLowFreqSusceptibility;
62
-        node["LayerHighFreqSusceptibility"] = LayerHighFreqSusceptibility;
63
-        node["LayerTauSusceptibility"] = LayerTauSusceptibility;
64
-        node["LayerBreathSusceptibility"] = LayerBreathSusceptibility;
65
-        node["LayerPermitivity"] = LayerPermitivity;
66
-        node["LayerLowFreqPermitivity"] = LayerLowFreqPermitivity;
67
-        node["LayerHighFreqPermitivity"] = LayerHighFreqPermitivity;
68
-        node["LayerTauPermitivity"] = LayerTauPermitivity;
69
-        node["LayerBreathPermitivity"] = LayerBreathPermitivity;
70
-        */
80
+        node["Type"] = enum2String(Type);
81
+        node["Location"] = Location;
82
+        node["Phat"] = Phat;
83
+        node["Freqs"] = Freqs;
84
+        node["Phase"] = Phase;
85
+        node["Moment"] = Moment;
71
         return node;
86
         return node;
72
     }
87
     }
73
 
88
 
89
+    std::shared_ptr< DipoleSource > DipoleSource::DeSerialize(const YAML::Node& node) {
90
+        if (node.Tag() != "DipoleSource") {
91
+            throw  DeSerializeTypeMismatch( "DipoleSource", node.Tag());
92
+        }
93
+        return std::make_shared<DipoleSource> ( node, ctor_key() );
94
+    }
95
+
74
     std::shared_ptr<DipoleSource> DipoleSource::Clone() {
96
     std::shared_ptr<DipoleSource> DipoleSource::Clone() {
75
 
97
 
76
         auto Obj = DipoleSource::NewSP();
98
         auto Obj = DipoleSource::NewSP();
152
 //         };
174
 //         };
153
     }
175
     }
154
 
176
 
155
-    void DipoleSource::SetType(const DipoleSourceType & stype) {
177
+    void DipoleSource::SetType(const DIPOLESOURCETYPE & stype) {
156
 
178
 
157
         switch (stype) {
179
         switch (stype) {
158
             case (GROUNDEDELECTRICDIPOLE):
180
             case (GROUNDEDELECTRICDIPOLE):
182
         return Phat;
204
         return Phat;
183
     }
205
     }
184
 
206
 
185
-    DipoleSourceType DipoleSource::GetType() {
207
+    DIPOLESOURCETYPE DipoleSource::GetType() {
186
         return Type;
208
         return Type;
187
     }
209
     }
188
 
210
 
1236
         }
1258
         }
1237
     }
1259
     }
1238
 
1260
 
1239
-    DipoleSourceType DipoleSource::GetDipoleSourceType() {
1261
+    DIPOLESOURCETYPE DipoleSource::GetDipoleSourceType() {
1240
         return this->Type;
1262
         return this->Type;
1241
     }
1263
     }
1242
 
1264
 

+ 6
- 6
Modules/FDEM1D/src/EMEarth1D.cpp View File

320
                     for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
320
                     for (int irec=0; irec<Receivers->GetNumberOfPoints(); ++irec) {
321
                         if (!Receivers->GetMask(irec)) {
321
                         if (!Receivers->GetMask(irec)) {
322
                             AntCopy->ApproximateWithElectricDipoles(Receivers->GetLocation(irec));
322
                             AntCopy->ApproximateWithElectricDipoles(Receivers->GetLocation(irec));
323
-                            for (int idip=0; idip<AntCopy->GetNumberOfDipoles(); ++idip) {
323
+                            for (unsigned int idip=0; idip<AntCopy->GetNumberOfDipoles(); ++idip) {
324
                                 auto tDipole = AntCopy->GetDipoleSource(idip);
324
                                 auto tDipole = AntCopy->GetDipoleSource(idip);
325
                                 //#ifdef LEMMAUSEOMP
325
                                 //#ifdef LEMMAUSEOMP
326
                                 //#pragma omp for schedule(static, 1)
326
                                 //#pragma omp for schedule(static, 1)
381
                             #pragma omp for schedule(static, 1)
381
                             #pragma omp for schedule(static, 1)
382
                             #endif
382
                             #endif
383
                             for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies(); ++ifreq) {
383
                             for (int ifreq=0; ifreq<Antenna->GetNumberOfFrequencies(); ++ifreq) {
384
-                                for (int idip=0; idip<Antenna->GetNumberOfDipoles(); ++idip) {
384
+                                for (unsigned int idip=0; idip<Antenna->GetNumberOfDipoles(); ++idip) {
385
                                     auto tDipole = Antenna->GetDipoleSource(idip);
385
                                     auto tDipole = Antenna->GetDipoleSource(idip);
386
                                     // Propogation constant in free space
386
                                     // Propogation constant in free space
387
                                     Real wavef   = tDipole->GetAngularFrequency(ifreq) *
387
                                     Real wavef   = tDipole->GetAngularFrequency(ifreq) *
445
                                 #ifdef LEMMAUSEOMP
445
                                 #ifdef LEMMAUSEOMP
446
                                 #pragma omp for schedule(static, 1)
446
                                 #pragma omp for schedule(static, 1)
447
                                 #endif
447
                                 #endif
448
-                                for (int idip=0; idip<Antenna->GetNumberOfDipoles(); ++idip) {
448
+                                for (unsigned int idip=0; idip<Antenna->GetNumberOfDipoles(); ++idip) {
449
                                     //#pragma omp critical
449
                                     //#pragma omp critical
450
                                     //{
450
                                     //{
451
                                     //cout << "idip=" << idip << "\tthread num=" << omp_get_thread_num() << '\n';
451
                                     //cout << "idip=" << idip << "\tthread num=" << omp_get_thread_num() << '\n';
473
             // TODO, getting wrong answer, curiously worKernel->GetKs() with MakeCalc, maybe
473
             // TODO, getting wrong answer, curiously worKernel->GetKs() with MakeCalc, maybe
474
             // a threading issue, use SolveSingleTxRxPair maype instead of call
474
             // a threading issue, use SolveSingleTxRxPair maype instead of call
475
             // to MakeCalc3? !!!
475
             // to MakeCalc3? !!!
476
-            for (int idip=0; idip<Antenna->GetNumberOfDipoles(); ++idip) {
476
+            for (unsigned int idip=0; idip<Antenna->GetNumberOfDipoles(); ++idip) {
477
                 this->Dipole = Antenna->GetDipoleSource(idip);
477
                 this->Dipole = Antenna->GetDipoleSource(idip);
478
                 MakeCalc3();
478
                 MakeCalc3();
479
                 //++disp;
479
                 //++disp;
782
         // Determine the min and max arguments
782
         // Determine the min and max arguments
783
         Real rhomin = 1e9;
783
         Real rhomin = 1e9;
784
         Real rhomax = 1e-9;
784
         Real rhomax = 1e-9;
785
-        for (int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
785
+        for (unsigned int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
786
             auto tDipole = antenna->GetDipoleSource(idip);
786
             auto tDipole = antenna->GetDipoleSource(idip);
787
             Real rho = (Receivers->GetLocation(irec).head<2>() - tDipole->GetLocation().head<2>()).norm();
787
             Real rho = (Receivers->GetLocation(irec).head<2>() - tDipole->GetLocation().head<2>()).norm();
788
             rhomin = std::min(rhomin, rho);
788
             rhomin = std::min(rhomin, rho);
804
         Hankel->ComputeLaggedRelated( 1.0*rhomax, nlag, tDipole->GetKernelManager() );
804
         Hankel->ComputeLaggedRelated( 1.0*rhomax, nlag, tDipole->GetKernelManager() );
805
 
805
 
806
         // Sort the dipoles by rho
806
         // Sort the dipoles by rho
807
-        for (int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
807
+        for (unsigned int idip=0; idip<antenna->GetNumberOfDipoles(); ++idip) {
808
             auto tDipole = antenna->GetDipoleSource(idip);
808
             auto tDipole = antenna->GetDipoleSource(idip);
809
             tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
809
             tDipole->SetKernels(ifreq, FieldsToCalculate, Receivers, irec, Earth);
810
             // Pass Hankel2 a message here so it knows which one to return in Zgauss!
810
             // Pass Hankel2 a message here so it knows which one to return in Zgauss!

+ 10
- 0
Modules/FDEM1D/testing/SerializeCheck.h View File

100
             TS_ASSERT_EQUALS( Obj->GetLocationZ(ip), Obj->GetLocation(ip)(2) );
100
             TS_ASSERT_EQUALS( Obj->GetLocationZ(ip), Obj->GetLocation(ip)(2) );
101
         }
101
         }
102
     }
102
     }
103
+
104
+    void testDipoleSource(void)
105
+    {
106
+        auto Obj = DipoleSource::NewSP();
107
+        YAML::Node node = Obj->Serialize();
108
+        auto Obj2 = DipoleSource::DeSerialize(node);
109
+        TS_ASSERT_EQUALS( Obj->GetName(), Obj2->GetName() );
110
+    }
111
+
112
+
103
 };
113
 };
104
 
114
 

+ 3
- 1
Modules/LemmaCore/include/helper.h View File

64
     std::string enum2String(const FIELDCALCULATIONS& Htype);
64
     std::string enum2String(const FIELDCALCULATIONS& Htype);
65
     /// convert enums to string saves repeated code useful for YAML serializing
65
     /// convert enums to string saves repeated code useful for YAML serializing
66
     std::string enum2String(const WINDOWTYPE& Wtype);
66
     std::string enum2String(const WINDOWTYPE& Wtype);
67
+    /// convert enums to string saves repeated code useful for YAML serializing
68
+    std::string enum2String(const DIPOLESOURCETYPE& Wtype);
67
 
69
 
68
     // other way around is a template, where template argument lets us know
70
     // other way around is a template, where template argument lets us know
69
     // which specialisation to use.
71
     // which specialisation to use.
120
 } // end namespace Lemma
122
 } // end namespace Lemma
121
 
123
 
122
 ///////////////////////////////////////////////////////
124
 ///////////////////////////////////////////////////////
123
-// YAML Serializing helper functions. Can we move this into helper.h
125
+// YAML Serializing helper functions.
124
 namespace YAML {
126
 namespace YAML {
125
 
127
 
126
 template<>
128
 template<>

+ 5
- 4
Modules/LemmaCore/include/lemma.h View File

214
         typedef Eigen::Matrix<Real, 3, 1> Vector3r;
214
         typedef Eigen::Matrix<Real, 3, 1> Vector3r;
215
 
215
 
216
         typedef Eigen::Matrix<Real, Eigen::Dynamic, 1>::Index Index;
216
         typedef Eigen::Matrix<Real, Eigen::Dynamic, 1>::Index Index;
217
-        
218
-	/// A 3 X Dynamic Component Eigen matrix of Reals
217
+
218
+	    /// A 3 X Dynamic Component Eigen matrix of Reals
219
         typedef Eigen::Matrix<Real, 3, Eigen::Dynamic> Vector3Xr;
219
         typedef Eigen::Matrix<Real, 3, Eigen::Dynamic> Vector3Xr;
220
 
220
 
221
         /// Variable length Eigen vector of Reals
221
         /// Variable length Eigen vector of Reals
299
 
299
 
300
         /** Enum is OK because these are the only physically possible sources.
300
         /** Enum is OK because these are the only physically possible sources.
301
          @param NOSOURCETYPE is default.
301
          @param NOSOURCETYPE is default.
302
-         @param ELECTRICDIPOLE is an electric dipole
302
+         @param GROUNDEDELECTRICDIPOLE is an grounded electric dipole
303
+         @param UNGROUNDEDELECTRICDIPOLE is an ungrounded electric dipole
303
          @param MAGNETICDIPOLE is a magnetic dipole
304
          @param MAGNETICDIPOLE is a magnetic dipole
304
         */
305
         */
305
-        enum DipoleSourceType {NOSOURCETYPE, GROUNDEDELECTRICDIPOLE, UNGROUNDEDELECTRICDIPOLE, MAGNETICDIPOLE};
306
+        enum DIPOLESOURCETYPE {NOSOURCETYPE, GROUNDEDELECTRICDIPOLE, UNGROUNDEDELECTRICDIPOLE, MAGNETICDIPOLE};
306
 
307
 
307
         /// Only three polarizations are supported. They may be summed to
308
         /// Only three polarizations are supported. They may be summed to
308
         /// approximate others
309
         /// approximate others

+ 26
- 0
Modules/LemmaCore/src/helper.cpp View File

177
     }
177
     }
178
 }
178
 }
179
 
179
 
180
+std::string enum2String( const DIPOLESOURCETYPE& Type ) {
181
+    switch (Type) {
182
+        case NOSOURCETYPE:
183
+            return std::string("NOSOURCETYPE");
184
+        case GROUNDEDELECTRICDIPOLE:
185
+            return std::string("GROUNDEDELECTRICDIPOLE");
186
+        case UNGROUNDEDELECTRICDIPOLE:
187
+            return std::string("UNGROUNDEDELECTRICDIPOLE");
188
+        case MAGNETICDIPOLE:
189
+            return std::string("MAGNETICDIPOLE");
190
+        default:
191
+            throw( std::runtime_error( "In enum2String DIPOLESOURCETYPE, type not identified" ) );
192
+    }
193
+}
194
+
180
 template<>
195
 template<>
181
 FREQUENCYUNITS string2Enum<FREQUENCYUNITS>( const std::string& str ) {
196
 FREQUENCYUNITS string2Enum<FREQUENCYUNITS>( const std::string& str ) {
182
     if       (str ==  "HZ") return   HZ;
197
     if       (str ==  "HZ") return   HZ;
238
     }
253
     }
239
 }
254
 }
240
 
255
 
256
+template<>
257
+DIPOLESOURCETYPE string2Enum<DIPOLESOURCETYPE>( const std::string& str ) {
258
+    if      (str == "NOSOURCETYPE")              return NOSOURCETYPE;
259
+    if      (str == "GROUNDEDELECTRICDIPOLE")    return GROUNDEDELECTRICDIPOLE;
260
+    if      (str == "UNGROUNDEDELECTRICDIPOLE")  return UNGROUNDEDELECTRICDIPOLE;
261
+    if      (str == "MAGNETICDIPOLE")            return MAGNETICDIPOLE;
262
+    else {
263
+        throw std::runtime_error("string not recognized as DipoleSource");
264
+    }
265
+}
266
+
241
 }		// -----  end of Lemma  name  -----
267
 }		// -----  end of Lemma  name  -----
242
 
268
 

+ 3
- 3
vim/c.vim View File

1
 "highlight cComment ctermfg=Green guifg=Green
1
 "highlight cComment ctermfg=Green guifg=Green
2
 highlight cType ctermfg=Green guifg=Green
2
 highlight cType ctermfg=Green guifg=Green
3
-syn keyword cType Real Complex VectorXr VectorXcr Vector3r Vector3Xr VectorXi Vector3cr Vector3Xcr MatrixXr MatrixXi MatrixXcr shared_ptr make_shared
3
+syn keyword cType string Real Complex VectorXr VectorXcr Vector3r Vector3Xr VectorXi Vector3cr Vector3Xcr MatrixXr MatrixXi MatrixXcr shared_ptr make_shared
4
 
4
 
5
 highlight constType ctermfg=Red guifg=Red
5
 highlight constType ctermfg=Red guifg=Red
6
 syn keyword constType  PI EPSILON0 MU0 QPI  
6
 syn keyword constType  PI EPSILON0 MU0 QPI  
7
 
7
 
8
 highlight eType ctermfg=Magenta guifg=Magenta
8
 highlight eType ctermfg=Magenta guifg=Magenta
9
-syn keyword eType  MAGUNITS  TEMPUNITS  TIMEUNITS FREQUENCYUNITS FEMCOILORIENTATION ORIENTATION FIELDTYPE FIELDCOMPONENT SPATIALCOORDINANT HANKELTRANSFORMTYPE FIELDCALCULATIONS WINDOWTYPE 
9
+syn keyword eType  MAGUNITS  TEMPUNITS  TIMEUNITS FREQUENCYUNITS FEMCOILORIENTATION ORIENTATION FIELDTYPE FIELDCOMPONENT SPATIALCOORDINANT HANKELTRANSFORMTYPE FIELDCALCULATIONS WINDOWTYPE DIPOLESOURCETYPE 
10
 
10
 
11
 highlight eeType ctermfg=Cyan guifg=Cyan
11
 highlight eeType ctermfg=Cyan guifg=Cyan
12
-syn keyword eeType  TESLA NANOTESLA GAUSS CELCIUS KELVIN SEC MILLISEC MICROSEC NANOSEC PICOSEC HZ KHZ MHZ GHZ COAXIAL COPLANAR HFIELDREAL HFIELDIMAG EFIELDREAL EFIELDIMAG XCOMPONENT YCOMPONENT ZCOMPONENT XCOORD YCOORD ZCOORD X Y Z NX  NY  NZ ANDERSON801 CHAVE FHTKEY201 FHTKEY101 FHTKEY51 FHTKONG241 FHTKONG121 FHTKONG61 QWEKEY E H BOTH HAMMING HANNING RECTANGULAR
12
+syn keyword eeType  TESLA NANOTESLA GAUSS CELCIUS KELVIN SEC MILLISEC MICROSEC NANOSEC PICOSEC HZ KHZ MHZ GHZ COAXIAL COPLANAR HFIELDREAL HFIELDIMAG EFIELDREAL EFIELDIMAG XCOMPONENT YCOMPONENT ZCOMPONENT XCOORD YCOORD ZCOORD X Y Z NX  NY  NZ ANDERSON801 CHAVE FHTKEY201 FHTKEY101 FHTKEY51 FHTKONG241 FHTKONG121 FHTKONG61 QWEKEY E H BOTH HAMMING HANNING RECTANGULAR NOSOURCETYPE GROUNDEDELECTRICDIPOLE UNGROUNDEDELECTRICDIPOLE MAGNETICDIPOLE
13
 
13
 
14
 " Namespaces
14
 " Namespaces
15
 highlight nspace ctermfg=Red guifg=Red
15
 highlight nspace ctermfg=Red guifg=Red

Loading…
Cancel
Save