Quellcode durchsuchen

WOrk towards new C++-11

enhancement_3
T-bone vor 7 Jahren
Ursprung
Commit
12ede2fdea

+ 19
- 23
Modules/FDEM1D/include/LayeredEarthEM.h Datei anzeigen

@@ -25,19 +25,32 @@ namespace Lemma {
25 25
     /// \brief  1D layered earth. Attributes include all aspects of
26 26
     /// Cole-Cole model.
27 27
     /// \details   Primarily used for EM calculations.
28
+    /** @todo Layer 0 can be set right now, but all logic ignores and assumes
29
+              air layer. This is surprising to users and constitutes a bug.
30
+     */
28 31
     // =======================================================================
29 32
     class LayeredEarthEM : public LayeredEarth {
30 33
 
31
-        public:
34
+        // ====================    FRIENDS     ===========================
35
+        /** Recursively streams information about this class */
36
+        friend std::ostream &operator<<(std::ostream &stream, const LayeredEarthEM &ob);
37
+
32 38
 
33
-            // ====================    FRIENDS     ===========================
39
+        struct ctor_key {};
34 40
 
35
-            /** Recursively streams information about this class */
36
-            friend std::ostream &operator<<(std::ostream &stream,
37
-                        const LayeredEarthEM &ob);
41
+        public:
38 42
 
39 43
             // ====================  LIFECYCLE     ===========================
40 44
 
45
+            /** Default protected constructor. */
46
+            explicit LayeredEarthEM ( const ctor_key& );
47
+
48
+            /** Default protected constructor. */
49
+			LayeredEarthEM ( const YAML::Node& node, const ctor_key& );
50
+
51
+            /** Default protected constructor. */
52
+            virtual ~LayeredEarthEM ();
53
+
41 54
             /**
42 55
              *  Factory method for generating concrete class.
43 56
              *  @return a std::shared_ptr of type LayeredEarthEM
@@ -240,23 +253,8 @@ namespace Lemma {
240 253
 
241 254
         protected:
242 255
 
243
-            // ====================  LIFECYCLE     ===========================
244
-
245
-            /** Default protected constructor. */
246
-            LayeredEarthEM ( );
247
-
248
-            /** Default protected constructor. */
249
-			LayeredEarthEM (const YAML::Node& node);
250
-
251
-            /** Default protected constructor. */
252
-            ~LayeredEarthEM ();
253
-
254
-            /**
255
-             * @copybrief LemmaObject::Release()
256
-             * @copydetails LemmaObject::Release()
257
-             */
258
-            void Release();
259 256
 
257
+        private:
260 258
             // ====================  DATA MEMBERS  ===========================
261 259
 
262 260
             /** Vector of layer Conductivity */
@@ -304,8 +302,6 @@ namespace Lemma {
304 302
             /** Relaxation breath for each layer */
305 303
             VectorXr          LayerBreathPermitivity;
306 304
 
307
-            private:
308
-
309 305
             /** ASCII string representation of the class name */
310 306
             static constexpr auto CName = "LayeredEarthEM";
311 307
 

+ 31
- 5
Modules/FDEM1D/src/LayeredEarthEM.cpp Datei anzeigen

@@ -16,23 +16,49 @@
16 16
 namespace Lemma {
17 17
 
18 18
     std::ostream &operator << (std::ostream &stream, const LayeredEarthEM &ob) {
19
-        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
19
+        stream << ob.Serialize()  << "\n---\n"; // End of doc ---
20 20
         return stream;
21 21
     }
22 22
 
23 23
     // ====================  LIFECYCLE     ===================================
24 24
 
25
-    LayeredEarthEM::LayeredEarthEM( ) : LayeredEarth() {
25
+    LayeredEarthEM::LayeredEarthEM( const ctor_key& ) : LayeredEarth() {
26
+    }
27
+
28
+    LayeredEarthEM::LayeredEarthEM( const YAML::Node& node, const ctor_key& ) : LayeredEarth(node) {
29
+
30
+        LayerConductivity = node["LayerConductivity"].as<VectorXcr>();
31
+
32
+        LayerSusceptibility = node["LayerSusceptibility"].as<VectorXcr>();
33
+        LayerLowFreqSusceptibility = node["LayerLowFreqSusceptibility"].as<VectorXr>();
34
+        LayerHighFreqSusceptibility = node["LayerHighFreqSusceptibility"].as<VectorXr>();
35
+        LayerTauSusceptibility = node["LayerTauSusceptibility"].as<VectorXr>();
36
+        LayerBreathSusceptibility = node["LayerBreathSusceptibility"].as<VectorXr>();
37
+
38
+        LayerPermitivity = node["LayerPermitivity"].as<VectorXcr>();
39
+        LayerLowFreqPermitivity = node["LayerLowFreqPermitivity"].as<VectorXr>();
40
+        LayerHighFreqPermitivity = node["LayerHighFreqPermitivity"].as<VectorXr>();
41
+        LayerTauPermitivity = node["LayerTauPermitivity"].as<VectorXr>();
42
+        LayerBreathPermitivity = node["LayerBreathPermitivity"].as<VectorXr>();
43
+
26 44
     }
27 45
 
28 46
     LayeredEarthEM::~LayeredEarthEM() {
29 47
     }
30 48
 
31 49
     std::shared_ptr<LayeredEarthEM> LayeredEarthEM::NewSP() {
32
-        std::shared_ptr<LayeredEarthEM> sp(new  LayeredEarthEM( ), LemmaObjectDeleter() );
33
-        return sp;
50
+        return std::make_shared<LayeredEarthEM> ( ctor_key() );
34 51
     }
35 52
 
53
+    std::shared_ptr<LayeredEarthEM> LayeredEarthEM::DeSerialize( const YAML::Node& node ) {
54
+        if (node.Tag() != "LayeredEarthEM") {
55
+            throw  DeSerializeTypeMismatch( "LayeredEarthEM", node.Tag());
56
+        }
57
+        return std::make_shared<LayeredEarthEM> ( node, ctor_key() );
58
+    }
59
+
60
+
61
+
36 62
     YAML::Node LayeredEarthEM::Serialize() const {
37 63
         YAML::Node node = LayeredEarth::Serialize();
38 64
         node.SetTag( GetName() );
@@ -110,7 +136,7 @@ namespace Lemma {
110 136
         LayerConductivity[ilay] = sig;
111 137
     }
112 138
 
113
-/*
139
+/*  // TODO fix layer 0 problem, 1/0 --> infty, plus layer 0 is ignored anyway
114 140
     void LayeredEarthEM::SetLayerResistivity(const VectorXcr &rhos) {
115 141
         if (rhos.size() != this->NumberOfLayers )
116 142
             throw EarthModelParametersDoNotMatchNumberOfLayers( );

+ 1
- 1
Modules/LemmaCore/src/CubicSplineInterpolator.cpp Datei anzeigen

@@ -29,7 +29,7 @@ namespace Lemma {
29 29
     // ====================  FRIEND METHODS  =====================
30 30
 
31 31
     std::ostream &operator << (std::ostream &stream, const CubicSplineInterpolator &ob) {
32
-        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
32
+        stream << ob.Serialize()  << "\n---\n"; // End of doc ---
33 33
         return stream;
34 34
     }
35 35
 

Laden…
Abbrechen
Speichern