Browse Source

Updates for Lemma with shared_ptr, working again.

master
Trevor Irons 5 years ago
parent
commit
e8dbeb24d1

+ 11
- 3
CMakeLists.txt View File

1
-if (LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT)
1
+if (LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT)
2
 	include_directories(${CMAKE_INSTALL_PREFIX}/include)
2
 	include_directories(${CMAKE_INSTALL_PREFIX}/include)
3
 
3
 
4
 	include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" )
4
 	include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" )
5
 	add_subdirectory("src")
5
 	add_subdirectory("src")
6
-
6
+	
7
 	add_library( fem4ellipticpde ${FEMSOURCE} )  
7
 	add_library( fem4ellipticpde ${FEMSOURCE} )  
8
-	target_link_libraries(fem4ellipticpde "lemmacore")
9
 
8
 
9
+	set_target_properties(fem4ellipticpde PROPERTIES 
10
+		VERSION  "${LEMMA_VERSION_NOQUOTES}"
11
+		SOVERSION "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}"
12
+		PROJECT_LABEL "FDEM1D ${LABEL_SUFFIX}"
13
+    	CXX_STANDARD 14
14
+    	CXX_STANDARD_REQUIRED ON
15
+	)
16
+
17
+	target_link_libraries(fem4ellipticpde "lemmacore" "dcip")
10
 	install ( TARGETS fem4ellipticpde DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
18
 	install ( TARGETS fem4ellipticpde DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
11
 
19
 
12
 	if (LEMMA_BUILD_EXAMPLES)
20
 	if (LEMMA_BUILD_EXAMPLES)

+ 2
- 3
examples/FEM4EllipticPDE_bhmag.cpp View File

145
 
145
 
146
     ////////////////////////////////////////////
146
     ////////////////////////////////////////////
147
     // Solve
147
     // Solve
148
-    FEM4EllipticPDE *Solver = FEM4EllipticPDE::New();
148
+    auto Solver = FEM4EllipticPDE::NewSP();
149
         //Solver->SetGFunction(implG);
149
         //Solver->SetGFunction(implG);
150
         //Solver->SetGFunction(Magnet);
150
         //Solver->SetGFunction(Magnet);
151
         //Solver->SetSigmaFunction(implSigma);
151
         //Solver->SetSigmaFunction(implSigma);
156
         Solver->Solve(argv[3]);
156
         Solver->Solve(argv[3]);
157
 
157
 
158
     // Clean up
158
     // Clean up
159
-    Solver->Delete();
159
+    //Solver->Delete();
160
     GReader->Delete();
160
     GReader->Delete();
161
     //implG->Delete();
161
     //implG->Delete();
162
-
163
     exit(EXIT_SUCCESS);
162
     exit(EXIT_SUCCESS);
164
 }
163
 }
165
 
164
 

+ 2
- 3
examples/LinearMag/Sphere.cpp View File

17
  * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
17
  * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
18
  */
18
  */
19
 
19
 
20
-#include "Lemma"
20
+#include "LemmaCore"
21
 #include "LinearMag.h"
21
 #include "LinearMag.h"
22
 
22
 
23
 using namespace Lemma;
23
 using namespace Lemma;
42
         exit(EXIT_SUCCESS);
42
         exit(EXIT_SUCCESS);
43
     }
43
     }
44
 
44
 
45
-    LinearMag* Mag = LinearMag::New();
45
+    auto Mag = LinearMag::NewSP();
46
         Mag->SetInducingMagField( 55234., 0, 0, NANOTESLA );
46
         Mag->SetInducingMagField( 55234., 0, 0, NANOTESLA );
47
         Mag->SetVTUGridFile( argv[1] );
47
         Mag->SetVTUGridFile( argv[1] );
48
         Mag->CalculateRHS( "kappa" );
48
         Mag->CalculateRHS( "kappa" );
51
     // Print out YAML serialization of class
51
     // Print out YAML serialization of class
52
     std::cout << *Mag << std::endl;
52
     std::cout << *Mag << std::endl;
53
 
53
 
54
-    Mag->Delete();
55
     exit(EXIT_SUCCESS);
54
     exit(EXIT_SUCCESS);
56
 }
55
 }
57
 
56
 

+ 2
- 4
examples/ResampleWithDataset.cpp View File

30
 #include <cmath>
30
 #include <cmath>
31
 #include <Eigen/Core>
31
 #include <Eigen/Core>
32
 
32
 
33
-
34
 int main(int argc, char**argv) {
33
 int main(int argc, char**argv) {
35
 
34
 
36
-
37
     std::cout << "Mesh boundary assigment routine\n";
35
     std::cout << "Mesh boundary assigment routine\n";
38
     if (argc<4) {
36
     if (argc<4) {
39
         std::cout << "usage:\n" << "./ResampleWithDataset  inMesh.vtu  boundaries.stl  outG.vtu" << std::endl;
37
         std::cout << "usage:\n" << "./ResampleWithDataset  inMesh.vtu  boundaries.stl  outG.vtu" << std::endl;
83
 
81
 
84
     //std::cout << *Resample << std::endl;.
82
     //std::cout << *Resample << std::endl;.
85
 
83
 
86
-   std::cout << "Resampled grid, ncells=" << Resample->GetOutput()->GetNumberOfCells()  
87
-             << " npoints=" << Resample->GetOutput()->GetNumberOfPoints() << std::endl; 
84
+   std::cout << "Resampled grid, ncells=" << Resample->GetOutput()->GetNumberOfCells()
85
+             << " npoints=" << Resample->GetOutput()->GetNumberOfPoints() << std::endl;
88
 
86
 
89
     vtkXMLUnstructuredGridWriter* Writer = vtkXMLUnstructuredGridWriter::New();
87
     vtkXMLUnstructuredGridWriter* Writer = vtkXMLUnstructuredGridWriter::New();
90
         Writer->SetInputData( Resample->GetOutput() );
88
         Writer->SetInputData( Resample->GetOutput() );

+ 3
- 6
examples/VTKDC.cpp View File

79
     std::ifstream ifstr(argv[2]);
79
     std::ifstream ifstr(argv[2]);
80
     //std::vector<YAML::Node> nodes = YAML::LoadAll(ifstr);
80
     //std::vector<YAML::Node> nodes = YAML::LoadAll(ifstr);
81
     YAML::Node nodes = YAML::Load(ifstr);
81
     YAML::Node nodes = YAML::Load(ifstr);
82
-    DCSurvey* Survey = DCSurvey::DeSerialize(nodes);
82
+    auto Survey = DCSurvey::DeSerialize(nodes);
83
     //std::cout << *Survey << std::endl;
83
     //std::cout << *Survey << std::endl;
84
 
84
 
85
 
85
 
86
     ////////////////////////////////////////////
86
     ////////////////////////////////////////////
87
     // Solve
87
     // Solve
88
-    FEM4EllipticPDE *Solver = FEM4EllipticPDE::New();
88
+    auto Solver = FEM4EllipticPDE::NewSP();
89
         //Solver->SetGFunction(implG);
89
         //Solver->SetGFunction(implG);
90
         //Solver->SetGFunction(Magnet);
90
         //Solver->SetGFunction(Magnet);
91
         //Solver->SetSigmaFunction(implSigma);
91
         //Solver->SetSigmaFunction(implSigma);
92
         //Solver->SetBoundaryStep(.05);
92
         //Solver->SetBoundaryStep(.05);
93
 
93
 
94
         Solver->SetGrid(uGrid);
94
         Solver->SetGrid(uGrid);
95
-        Solver->SetupDC(Survey, 0);
95
+        Solver->SetupDC( Survey.get(), 0 );
96
         Solver->Solve( argv[3] );
96
         Solver->Solve( argv[3] );
97
         //Solver->SetGrid(rGrid);
97
         //Solver->SetGrid(rGrid);
98
         //Solver->Solve(argv[3]);
98
         //Solver->Solve(argv[3]);
99
 
99
 
100
-    Survey->Delete();
101
-    Solver->Delete();
102
-
103
     exit(EXIT_SUCCESS);
100
     exit(EXIT_SUCCESS);
104
 }
101
 }

+ 17
- 24
include/FEM4EllipticPDE.h View File

88
             /** Returns a pointer to a new object of type FEM4EllipticPDE.
88
             /** Returns a pointer to a new object of type FEM4EllipticPDE.
89
              * It allocates all necessary memory.
89
              * It allocates all necessary memory.
90
              */
90
              */
91
-            static FEM4EllipticPDE* New();
91
+            static std::shared_ptr<FEM4EllipticPDE> NewSP();
92
 
92
 
93
-            /** Deletes this object. Delete also disconnects any
94
-             * attachments to this object.
93
+            /**
94
+             * Default locked constructor.
95
              */
95
              */
96
-            void Delete();
96
+            explicit FEM4EllipticPDE (const ctor_key& key);
97
+
98
+            /** Protected DeDerializing constructor, use factory DeSerialize  method*/
99
+            FEM4EllipticPDE (const YAML::Node& node, const ctor_key& key);
97
 
100
 
101
+            /** Default protected constructor. */
102
+            ~FEM4EllipticPDE ();
98
 
103
 
99
-            #ifdef HAVE_YAMLCPP
100
             /**
104
             /**
101
              *  Uses YAML to serialize this object.
105
              *  Uses YAML to serialize this object.
102
              *  @return a YAML::Node
106
              *  @return a YAML::Node
106
             /**
110
             /**
107
              *   Constructs an object from a YAML::Node.
111
              *   Constructs an object from a YAML::Node.
108
              */
112
              */
109
-            static FEM4EllipticPDE* DeSerialize(const YAML::Node& node);
110
-            #endif
113
+            static std::shared_ptr<FEM4EllipticPDE> DeSerialize(const YAML::Node& node);
111
 
114
 
112
             // ====================  OPERATORS     =======================
115
             // ====================  OPERATORS     =======================
113
 
116
 
170
 
173
 
171
             // ====================  INQUIRY       =======================
174
             // ====================  INQUIRY       =======================
172
 
175
 
176
+            /** Returns the name of the underlying class, similiar to Python's type */
177
+            virtual std::string GetName() const {
178
+                return this->CName;
179
+            }
180
+
173
         protected:
181
         protected:
174
 
182
 
175
             // ====================  LIFECYCLE     =======================
183
             // ====================  LIFECYCLE     =======================
176
 
184
 
177
-            /// Default protected constructor.
178
-            FEM4EllipticPDE (const std::string& cname);
179
-
180
-            #ifdef HAVE_YAMLCPP
181
-            /** Protected DeDerializing constructor, use factory DeSerialize  method*/
182
-            FEM4EllipticPDE (const YAML::Node& node);
183
-            #endif
184
-
185
-            /** Default protected constructor. */
186
-            ~FEM4EllipticPDE ();
187
-
188
-            /**
189
-             * @copybrief LemmaObject::Release()
190
-             * @copydetails LemmaObject::Release()
191
-             */
192
-            void Release();
193
-
194
             // ====================  OPERATIONS    =======================
185
             // ====================  OPERATIONS    =======================
195
 
186
 
196
             /** Used internally to construct stiffness matrix, A
187
             /** Used internally to construct stiffness matrix, A
316
 
307
 
317
         private:
308
         private:
318
 
309
 
310
+            static constexpr auto CName = "FEM4EllipticPDE";
311
+
319
     }; // -----  end of class  FEM4EllipticPDE  -----
312
     }; // -----  end of class  FEM4EllipticPDE  -----
320
 
313
 
321
     /*! @} */
314
     /*! @} */

+ 18
- 31
include/LinearMag.h View File

41
      */
41
      */
42
     class LinearMag : public FEM4EllipticPDE {
42
     class LinearMag : public FEM4EllipticPDE {
43
 
43
 
44
-        friend std::ostream &operator<<(std::ostream &stream,
45
-                const LinearMag &ob);
44
+        friend std::ostream &operator << (std::ostream &stream, const LinearMag &ob);
46
 
45
 
47
         public:
46
         public:
48
 
47
 
49
         // ====================  LIFECYCLE     =======================
48
         // ====================  LIFECYCLE     =======================
50
 
49
 
51
         /**
50
         /**
52
-         * @copybrief LemmaObject::New()
53
-         * @copydetails LemmaObject::New()
51
+         * @copybrief LemmaObject::NewSP()
52
+         * @copydetails LemmaObject::NewSP()
54
          */
53
          */
55
-        static LinearMag* New();
54
+        static std::shared_ptr<LinearMag> NewSP();
56
 
55
 
57
-        /**
58
-         *  @copybrief   LemmaObject::Delete()
59
-         *  @copydetails LemmaObject::Delete()
60
-         */
61
-        void Delete();
56
+        /** Default protected constructor, use New */
57
+        LinearMag (const ctor_key& key);
58
+
59
+        /** Protected DeDerializing constructor, use factory DeSerialize  method*/
60
+        LinearMag (const YAML::Node& node, const ctor_key& key);
61
+
62
+        /** Default protected destructor, use Delete */
63
+        ~LinearMag ();
62
 
64
 
63
-#ifdef HAVE_YAMLCPP
64
         /**
65
         /**
65
          *  Uses YAML to serialize this object.
66
          *  Uses YAML to serialize this object.
66
          *  @return a YAML::Node
67
          *  @return a YAML::Node
70
         /**
71
         /**
71
          *   Constructs an object from a YAML::Node.
72
          *   Constructs an object from a YAML::Node.
72
          */
73
          */
73
-        static LinearMag* DeSerialize(const YAML::Node& node);
74
-#endif
74
+        static std::shared_ptr<LinearMag> DeSerialize(const YAML::Node& node);
75
 
75
 
76
         // ====================  OPERATORS     =======================
76
         // ====================  OPERATORS     =======================
77
 
77
 
103
 
103
 
104
         // ====================  INQUIRY       =======================
104
         // ====================  INQUIRY       =======================
105
 
105
 
106
+        /** Returns the name of the underlying class, similiar to Python's type */
107
+        virtual std::string GetName() const { return this->CName; }
108
+
106
         protected:
109
         protected:
107
 
110
 
108
         // ====================  LIFECYCLE     =======================
111
         // ====================  LIFECYCLE     =======================
109
 
112
 
110
-        /** Default protected constructor, use New */
111
-        LinearMag (const std::string& name);
112
-
113
-#ifdef HAVE_YAMLCPP
114
-        /** Protected DeDerializing constructor, use factory DeSerialize  method*/
115
-        LinearMag (const YAML::Node& node);
116
-#endif
117
-
118
-        /** Default protected destructor, use Delete */
119
-        ~LinearMag ();
120
-
121
-        /**
122
-         *  @copybrief   LemmaObject::Release()
123
-         *  @copydetails LemmaObject::Release()
124
-         */
125
-        void Release();
126
-
127
         private:
113
         private:
128
 
114
 
129
         // ====================  DATA MEMBERS  =========================
115
         // ====================  DATA MEMBERS  =========================
130
 
116
 
131
         Vector3r    B0;
117
         Vector3r    B0;
132
 
118
 
133
-
134
         /**
119
         /**
135
          *   Used internally to scale mag units into Tesla
120
          *   Used internally to scale mag units into Tesla
136
          */
121
          */
137
         void ScaleB0 ( const MAGUNITS& U);
122
         void ScaleB0 ( const MAGUNITS& U);
138
 
123
 
124
+        static constexpr auto CName = "LinearMag";
125
+
139
     }; // -----  end of class  LinearMag  -----
126
     }; // -----  end of class  LinearMag  -----
140
 
127
 
141
     /*! @} */ // End of group
128
     /*! @} */ // End of group

+ 14
- 39
src/FEM4EllipticPDE.cpp View File

19
   @file
19
   @file
20
   @author   Trevor Irons
20
   @author   Trevor Irons
21
   @date     08/16/12
21
   @date     08/16/12
22
-  @version   0.0
23
  **/
22
  **/
24
 
23
 
25
 #include "FEM4EllipticPDE.h"
24
 #include "FEM4EllipticPDE.h"
26
 
25
 
27
 namespace Lemma {
26
 namespace Lemma {
28
 
27
 
29
-#ifdef HAVE_YAMLCPP
30
     std::ostream &operator << (std::ostream &stream, const FEM4EllipticPDE &ob) {
28
     std::ostream &operator << (std::ostream &stream, const FEM4EllipticPDE &ob) {
31
-        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
29
+        stream << ob.Serialize()  << "\n";
32
         return stream;
30
         return stream;
33
     }
31
     }
34
-#else
35
-	std::ostream &operator<<(std::ostream &stream,
36
-				const FEM4EllipticPDE &ob) {
37
-		stream << *(LemmaObject*)(&ob);
38
-		return stream;
39
-	}
40
-#endif
41
-
42
 
32
 
43
 	// ====================  LIFECYCLE     =======================
33
 	// ====================  LIFECYCLE     =======================
44
 
34
 
45
-	FEM4EllipticPDE::FEM4EllipticPDE(const std::string&name) :
46
-			LemmaObject(name), BndryH(10), BndrySigma(10),
35
+	FEM4EllipticPDE::FEM4EllipticPDE( const ctor_key& key ) :
36
+			LemmaObject(key), BndryH(10), BndrySigma(10),
47
             vtkSigma(nullptr), vtkG(nullptr), vtkGrid(nullptr), gFcn3(nullptr) {
37
             vtkSigma(nullptr), vtkG(nullptr), vtkGrid(nullptr), gFcn3(nullptr) {
48
 	}
38
 	}
49
 
39
 
50
-    #ifdef HAVE_YAMLCPP
51
     //--------------------------------------------------------------------------------------
40
     //--------------------------------------------------------------------------------------
52
     //       Class:  FEM4EllipticPDE
41
     //       Class:  FEM4EllipticPDE
53
     //      Method:  FEM4EllipticPDE
42
     //      Method:  FEM4EllipticPDE
54
     // Description:  DeSerializing constructor (protected)
43
     // Description:  DeSerializing constructor (protected)
55
     //--------------------------------------------------------------------------------------
44
     //--------------------------------------------------------------------------------------
56
-    FEM4EllipticPDE::FEM4EllipticPDE (const YAML::Node& node) : LemmaObject(node) {
45
+    FEM4EllipticPDE::FEM4EllipticPDE (const YAML::Node& node, const ctor_key& key) : LemmaObject(node, key) {
57
         // TODO impliment
46
         // TODO impliment
58
         throw std::runtime_error("FEM4ELLIPTICPDE YAML CONSTRUCTOR NOT IMPLIMENTED!");
47
         throw std::runtime_error("FEM4ELLIPTICPDE YAML CONSTRUCTOR NOT IMPLIMENTED!");
59
     }  // -----  end of method FEM4EllipticPDE::FEM4EllipticPDE  (constructor)  -----
48
     }  // -----  end of method FEM4EllipticPDE::FEM4EllipticPDE  (constructor)  -----
60
-    #endif
61
 
49
 
62
 	FEM4EllipticPDE::~FEM4EllipticPDE() {
50
 	FEM4EllipticPDE::~FEM4EllipticPDE() {
63
 	}
51
 	}
64
 
52
 
65
-    void FEM4EllipticPDE::Release() {
66
-        delete this;
67
-    }
68
-
69
-    FEM4EllipticPDE* FEM4EllipticPDE::New( ) {
70
-        FEM4EllipticPDE* Obj = new FEM4EllipticPDE("FEM4EllipticPDE");
71
-        Obj->AttachTo(Obj);
72
-        return Obj;
53
+    std::shared_ptr<FEM4EllipticPDE> FEM4EllipticPDE::NewSP( ) {
54
+        return std::make_shared<FEM4EllipticPDE>( ctor_key() );
73
     }
55
     }
74
 
56
 
75
-    void FEM4EllipticPDE::Delete() {
76
-        this->DetachFrom(this);
77
-    }
78
-
79
-#ifdef HAVE_YAMLCPP
80
     //--------------------------------------------------------------------------------------
57
     //--------------------------------------------------------------------------------------
81
     //       Class:  FEM4EllipticPDE
58
     //       Class:  FEM4EllipticPDE
82
     //      Method:  Serialize
59
     //      Method:  Serialize
83
     //--------------------------------------------------------------------------------------
60
     //--------------------------------------------------------------------------------------
84
     YAML::Node  FEM4EllipticPDE::Serialize (  ) const {
61
     YAML::Node  FEM4EllipticPDE::Serialize (  ) const {
85
-        YAML::Node node = LemmaObject::Serialize();;
86
-        node.SetTag( this->Name );
87
-        // FILL IN CLASS SPECIFICS HERE
62
+        YAML::Node node = LemmaObject::Serialize();
63
+        node.SetTag( this->GetName() );
64
+        // node["thing"] = value;
88
         return node;
65
         return node;
89
     }		// -----  end of method FEM4EllipticPDE::Serialize  -----
66
     }		// -----  end of method FEM4EllipticPDE::Serialize  -----
90
 
67
 
91
-
92
     //--------------------------------------------------------------------------------------
68
     //--------------------------------------------------------------------------------------
93
     //       Class:  FEM4EllipticPDE
69
     //       Class:  FEM4EllipticPDE
94
     //      Method:  DeSerialize
70
     //      Method:  DeSerialize
95
     //--------------------------------------------------------------------------------------
71
     //--------------------------------------------------------------------------------------
96
-    FEM4EllipticPDE* FEM4EllipticPDE::DeSerialize ( const YAML::Node& node  ) {
97
-        FEM4EllipticPDE* Object = new FEM4EllipticPDE(node);
98
-        Object->AttachTo(Object);
99
-        DESERIALIZECHECK( node, Object )
100
-            return Object ;
72
+    std::shared_ptr<FEM4EllipticPDE> FEM4EllipticPDE::DeSerialize ( const YAML::Node& node  ) {
73
+        if (node.Tag() != "FEM4EllipticPDE") {
74
+            throw DeSerializeTypeMismatch( "FEM4EllipticPDE", node.Tag() );
75
+        }
76
+        return std::make_shared<FEM4EllipticPDE> (node, ctor_key());
101
     }		// -----  end of method FEM4EllipticPDE::DeSerialize  -----
77
     }		// -----  end of method FEM4EllipticPDE::DeSerialize  -----
102
-#endif
103
 
78
 
104
     // ====================  OPERATIONS    =======================
79
     // ====================  OPERATIONS    =======================
105
 
80
 

+ 12
- 47
src/LinearMag.cpp View File

10
 /**
10
 /**
11
  * @file
11
  * @file
12
  * @date      03/21/2016 02:10:08 PM
12
  * @date      03/21/2016 02:10:08 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
22
 namespace Lemma {
21
 namespace Lemma {
23
 
22
 
24
 // ====================  FRIEND METHODS  =====================
23
 // ====================  FRIEND METHODS  =====================
25
-#ifdef HAVE_YAMLCPP
26
 std::ostream &operator << (std::ostream &stream, const LinearMag &ob) {
24
 std::ostream &operator << (std::ostream &stream, const LinearMag &ob) {
27
-    stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapsulate thingy
25
+    stream << ob.Serialize()  << "\n";
28
     return stream;
26
     return stream;
29
 }
27
 }
30
-#else
31
-std::ostream &operator<<(std::ostream &stream, const LinearMag& ob) {
32
-    stream << *(FEM4EllipticPDE*)(&ob);
33
-    return stream;
34
-}
35
-#endif
36
 
28
 
37
 // ====================  LIFECYCLE     =======================
29
 // ====================  LIFECYCLE     =======================
38
 
30
 
41
 //      Method:  LinearMag
33
 //      Method:  LinearMag
42
 // Description:  constructor (protected)
34
 // Description:  constructor (protected)
43
 //--------------------------------------------------------------------------------------
35
 //--------------------------------------------------------------------------------------
44
-LinearMag::LinearMag (const std::string& name) : FEM4EllipticPDE(name) {
36
+LinearMag::LinearMag (const ctor_key& key) : FEM4EllipticPDE(key) {
45
 
37
 
46
 }  // -----  end of method LinearMag::LinearMag  (constructor)  -----
38
 }  // -----  end of method LinearMag::LinearMag  (constructor)  -----
47
 
39
 
48
-#ifdef HAVE_YAMLCPP
49
 //--------------------------------------------------------------------------------------
40
 //--------------------------------------------------------------------------------------
50
 //       Class:  LinearMag
41
 //       Class:  LinearMag
51
 //      Method:  LinearMag
42
 //      Method:  LinearMag
52
 // Description:  DeSerializing constructor (protected)
43
 // Description:  DeSerializing constructor (protected)
53
 //--------------------------------------------------------------------------------------
44
 //--------------------------------------------------------------------------------------
54
-LinearMag::LinearMag (const YAML::Node& node) : FEM4EllipticPDE(node) {
45
+LinearMag::LinearMag (const YAML::Node& node, const ctor_key& key) : FEM4EllipticPDE(node, key) {
55
 
46
 
56
 }  // -----  end of method LinearMag::LinearMag  (constructor)  -----
47
 }  // -----  end of method LinearMag::LinearMag  (constructor)  -----
57
-#endif
58
 
48
 
59
 //--------------------------------------------------------------------------------------
49
 //--------------------------------------------------------------------------------------
60
 //       Class:  LinearMag
50
 //       Class:  LinearMag
61
 //      Method:  New()
51
 //      Method:  New()
62
 // Description:  public constructor
52
 // Description:  public constructor
63
 //--------------------------------------------------------------------------------------
53
 //--------------------------------------------------------------------------------------
64
-LinearMag* LinearMag::New() {
65
-    LinearMag*  Obj = new LinearMag("LinearMag");
66
-    Obj->AttachTo(Obj);
67
-    return Obj;
54
+std::shared_ptr<LinearMag> LinearMag::NewSP() {
55
+    return std::make_shared<LinearMag>( ctor_key() );
68
 }
56
 }
69
 
57
 
70
 //--------------------------------------------------------------------------------------
58
 //--------------------------------------------------------------------------------------
78
 
66
 
79
 //--------------------------------------------------------------------------------------
67
 //--------------------------------------------------------------------------------------
80
 //       Class:  LinearMag
68
 //       Class:  LinearMag
81
-//      Method:  Delete
82
-// Description:  public destructor
83
-//--------------------------------------------------------------------------------------
84
-void LinearMag::Delete() {
85
-    this->DetachFrom(this);
86
-}
87
-
88
-//--------------------------------------------------------------------------------------
89
-//       Class:  LinearMag
90
-//      Method:  Release
91
-// Description:  destructor (protected)
92
-//--------------------------------------------------------------------------------------
93
-void LinearMag::Release() {
94
-    delete this;
95
-}
96
-
97
-
98
-#ifdef HAVE_YAMLCPP
99
-//--------------------------------------------------------------------------------------
100
-//       Class:  LinearMag
101
 //      Method:  Serialize
69
 //      Method:  Serialize
102
 //--------------------------------------------------------------------------------------
70
 //--------------------------------------------------------------------------------------
103
 YAML::Node  LinearMag::Serialize (  ) const {
71
 YAML::Node  LinearMag::Serialize (  ) const {
104
     YAML::Node node = FEM4EllipticPDE::Serialize();;
72
     YAML::Node node = FEM4EllipticPDE::Serialize();;
105
-    node.SetTag( this->Name );
73
+    node.SetTag( this->GetName() );
106
     // FILL IN CLASS SPECIFICS HERE
74
     // FILL IN CLASS SPECIFICS HERE
107
     node["B0"] = B0;
75
     node["B0"] = B0;
108
     return node;
76
     return node;
113
 //       Class:  LinearMag
81
 //       Class:  LinearMag
114
 //      Method:  DeSerialize
82
 //      Method:  DeSerialize
115
 //--------------------------------------------------------------------------------------
83
 //--------------------------------------------------------------------------------------
116
-LinearMag* LinearMag::DeSerialize ( const YAML::Node& node  ) {
117
-    LinearMag* Object = new LinearMag(node);
118
-    Object->AttachTo(Object);
119
-    DESERIALIZECHECK( node, Object )
120
-        return Object ;
84
+std::shared_ptr<LinearMag> LinearMag::DeSerialize ( const YAML::Node& node ) {
85
+    if ( node.Tag() != "LinearMag") {
86
+        throw DeSerializeTypeMismatch( "LinearMag", node.Tag() );
87
+    }
88
+    return std::make_shared<LinearMag>( node, ctor_key() );
121
 }		// -----  end of method LinearMag::DeSerialize  -----
89
 }		// -----  end of method LinearMag::DeSerialize  -----
122
-#endif
123
-
124
-
125
 
90
 
126
 //--------------------------------------------------------------------------------------
91
 //--------------------------------------------------------------------------------------
127
 //       Class:  LinearMag
92
 //       Class:  LinearMag
193
     G->SetName("G");
158
     G->SetName("G");
194
     //g.resize(vtkGrid->GetNumberOfPoints());
159
     //g.resize(vtkGrid->GetNumberOfPoints());
195
     VectorXr GG = VectorXr::Zero( vtkGrid->GetNumberOfPoints() );
160
     VectorXr GG = VectorXr::Zero( vtkGrid->GetNumberOfPoints() );
196
-    
161
+
197
     // Iterate over all the points or all of the cells?
162
     // Iterate over all the points or all of the cells?
198
     for (int ic=0; ic < vtkGrid->GetNumberOfCells(); ++ic) {
163
     for (int ic=0; ic < vtkGrid->GetNumberOfCells(); ++ic) {
199
 
164
 

Loading…
Cancel
Save