Browse Source

WOrk towards new C++-11

enhancement_3
T-bone 8 years ago
parent
commit
12ede2fdea

+ 19
- 23
Modules/FDEM1D/include/LayeredEarthEM.h View File

25
     /// \brief  1D layered earth. Attributes include all aspects of
25
     /// \brief  1D layered earth. Attributes include all aspects of
26
     /// Cole-Cole model.
26
     /// Cole-Cole model.
27
     /// \details   Primarily used for EM calculations.
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
     class LayeredEarthEM : public LayeredEarth {
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
             // ====================  LIFECYCLE     ===========================
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
              *  Factory method for generating concrete class.
55
              *  Factory method for generating concrete class.
43
              *  @return a std::shared_ptr of type LayeredEarthEM
56
              *  @return a std::shared_ptr of type LayeredEarthEM
240
 
253
 
241
         protected:
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
             // ====================  DATA MEMBERS  ===========================
258
             // ====================  DATA MEMBERS  ===========================
261
 
259
 
262
             /** Vector of layer Conductivity */
260
             /** Vector of layer Conductivity */
304
             /** Relaxation breath for each layer */
302
             /** Relaxation breath for each layer */
305
             VectorXr          LayerBreathPermitivity;
303
             VectorXr          LayerBreathPermitivity;
306
 
304
 
307
-            private:
308
-
309
             /** ASCII string representation of the class name */
305
             /** ASCII string representation of the class name */
310
             static constexpr auto CName = "LayeredEarthEM";
306
             static constexpr auto CName = "LayeredEarthEM";
311
 
307
 

+ 31
- 5
Modules/FDEM1D/src/LayeredEarthEM.cpp View File

16
 namespace Lemma {
16
 namespace Lemma {
17
 
17
 
18
     std::ostream &operator << (std::ostream &stream, const LayeredEarthEM &ob) {
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
         return stream;
20
         return stream;
21
     }
21
     }
22
 
22
 
23
     // ====================  LIFECYCLE     ===================================
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
     LayeredEarthEM::~LayeredEarthEM() {
46
     LayeredEarthEM::~LayeredEarthEM() {
29
     }
47
     }
30
 
48
 
31
     std::shared_ptr<LayeredEarthEM> LayeredEarthEM::NewSP() {
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
     YAML::Node LayeredEarthEM::Serialize() const {
62
     YAML::Node LayeredEarthEM::Serialize() const {
37
         YAML::Node node = LayeredEarth::Serialize();
63
         YAML::Node node = LayeredEarth::Serialize();
38
         node.SetTag( GetName() );
64
         node.SetTag( GetName() );
110
         LayerConductivity[ilay] = sig;
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
     void LayeredEarthEM::SetLayerResistivity(const VectorXcr &rhos) {
140
     void LayeredEarthEM::SetLayerResistivity(const VectorXcr &rhos) {
115
         if (rhos.size() != this->NumberOfLayers )
141
         if (rhos.size() != this->NumberOfLayers )
116
             throw EarthModelParametersDoNotMatchNumberOfLayers( );
142
             throw EarthModelParametersDoNotMatchNumberOfLayers( );

+ 1
- 1
Modules/LemmaCore/src/CubicSplineInterpolator.cpp View File

29
     // ====================  FRIEND METHODS  =====================
29
     // ====================  FRIEND METHODS  =====================
30
 
30
 
31
     std::ostream &operator << (std::ostream &stream, const CubicSplineInterpolator &ob) {
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
         return stream;
33
         return stream;
34
     }
34
     }
35
 
35
 

Loading…
Cancel
Save