Trevor Irons 8年前
コミット
c6c0a773b3
5個のファイルの変更304行の追加2行の削除
  1. 19
    0
      include/FEM4EllipticPDE.h
  2. 115
    0
      include/LinearMag.h
  3. 1
    0
      src/CMakeLists.txt
  4. 46
    2
      src/FEM4EllipticPDE.cpp
  5. 123
    0
      src/LinearMag.cpp

+ 19
- 0
include/FEM4EllipticPDE.h ファイルの表示

@@ -93,6 +93,20 @@ namespace Lemma {
93 93
              */
94 94
             void Delete();
95 95
 
96
+
97
+            #ifdef HAVE_YAMLCPP
98
+            /**
99
+             *  Uses YAML to serialize this object.
100
+             *  @return a YAML::Node
101
+             */
102
+            YAML::Node Serialize() const;
103
+
104
+            /**
105
+             *   Constructs an object from a YAML::Node.
106
+             */
107
+            static FEM4EllipticPDE* DeSerialize(const YAML::Node& node);
108
+            #endif
109
+
96 110
             // ====================  OPERATORS     =======================
97 111
 
98 112
             // ====================  OPERATIONS    =======================
@@ -147,6 +161,11 @@ namespace Lemma {
147 161
             /// Default protected constructor.
148 162
             FEM4EllipticPDE (const std::string& cname);
149 163
 
164
+            #ifdef HAVE_YAMLCPP
165
+            /** Protected DeDerializing constructor, use factory DeSerialize  method*/
166
+            FEM4EllipticPDE (const YAML::Node& node);
167
+            #endif
168
+
150 169
             /** Default protected constructor. */
151 170
             ~FEM4EllipticPDE ();
152 171
 

+ 115
- 0
include/LinearMag.h ファイルの表示

@@ -0,0 +1,115 @@
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      03/21/2016 01:39:32 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Lemma Software, LLC
18
+ */
19
+
20
+#ifndef  LINEARMAG_INC
21
+#define  LINEARMAG_INC
22
+
23
+#include	"FEM4EllipticPDE.h"
24
+
25
+namespace Lemma {
26
+
27
+    /** \addtogroup FEM4EllipticPDE
28
+     @{
29
+     */
30
+
31
+    /**
32
+      \brief   Provides modelling of linear magnetic media
33
+      \details This class solves the problem
34
+        \f{equation}{
35
+            \nabla^2 u(\mathbf{r}) = \nabla \cdot \kappa(\mathbf{r}) \mathbf{H}_0,
36
+        \f}
37
+        where \f$ \mathbf{H}_0\f$ is the static <B>homogeneous</B> inducing field, \f$ \kappa \f$
38
+        is the <B>isotropic</B> magnetic suceptibility. The secondary field can be calculated
39
+        \f$ \mathbf{H} = -\nabla \cdot u \f$
40
+     */
41
+    class LinearMag : public FEM4EllipticPDE {
42
+
43
+        friend std::ostream &operator<<(std::ostream &stream,
44
+                const LinearMag &ob);
45
+
46
+        public:
47
+
48
+        // ====================  LIFECYCLE     =======================
49
+
50
+        /**
51
+         * @copybrief LemmaObject::New()
52
+         * @copydetails LemmaObject::New()
53
+         */
54
+        static LinearMag* New();
55
+
56
+        /**
57
+         *  @copybrief   LemmaObject::Delete()
58
+         *  @copydetails LemmaObject::Delete()
59
+         */
60
+        void Delete();
61
+
62
+#ifdef HAVE_YAMLCPP
63
+        /**
64
+         *  Uses YAML to serialize this object.
65
+         *  @return a YAML::Node
66
+         */
67
+        YAML::Node Serialize() const;
68
+
69
+        /**
70
+         *   Constructs an object from a YAML::Node.
71
+         */
72
+        static LinearMag* DeSerialize(const YAML::Node& node);
73
+#endif
74
+
75
+        // ====================  OPERATORS     =======================
76
+
77
+        // ====================  OPERATIONS    =======================
78
+
79
+        // ====================  ACCESS        =======================
80
+
81
+        // ====================  INQUIRY       =======================
82
+
83
+        protected:
84
+
85
+        // ====================  LIFECYCLE     =======================
86
+
87
+        /** Default protected constructor, use New */
88
+        LinearMag (const std::string& name);
89
+
90
+#ifdef HAVE_YAMLCPP
91
+        /** Protected DeDerializing constructor, use factory DeSerialize  method*/
92
+        LinearMag (const YAML::Node& node);
93
+#endif
94
+
95
+        /** Default protected destructor, use Delete */
96
+        ~LinearMag ();
97
+
98
+        /**
99
+         *  @copybrief   LemmaObject::Release()
100
+         *  @copydetails LemmaObject::Release()
101
+         */
102
+        void Release();
103
+
104
+        private:
105
+
106
+        // ====================  DATA MEMBERS  =========================
107
+
108
+    }; // -----  end of class  LinearMag  -----
109
+
110
+    /*! @} */ // End of group
111
+
112
+}		// -----  end of Lemma  name  -----
113
+
114
+#endif   // ----- #ifndef LINEARMAG_INC  -----
115
+

+ 1
- 0
src/CMakeLists.txt ファイルの表示

@@ -1,5 +1,6 @@
1 1
 set (FEMSOURCE
2 2
 	${FEMSOURCE}
3 3
 	${CMAKE_CURRENT_SOURCE_DIR}/FEM4EllipticPDE.cpp
4
+	${CMAKE_CURRENT_SOURCE_DIR}/LinearMag.cpp
4 5
 	PARENT_SCOPE
5 6
 )

+ 46
- 2
src/FEM4EllipticPDE.cpp ファイルの表示

@@ -38,20 +38,39 @@
38 38
 
39 39
 namespace Lemma {
40 40
 
41
+#ifdef HAVE_YAMLCPP
42
+    std::ostream &operator << (std::ostream &stream, const FEM4EllipticPDE &ob) {
43
+        stream << ob.Serialize()  << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
44
+        return stream;
45
+    }
46
+#else
41 47
 	std::ostream &operator<<(std::ostream &stream,
42 48
 				const FEM4EllipticPDE &ob) {
43
-
44 49
 		stream << *(LemmaObject*)(&ob);
45 50
 		return stream;
46 51
 	}
52
+#endif
53
+
47 54
 
48 55
 	// ====================  LIFECYCLE     =======================
49 56
 
50 57
 	FEM4EllipticPDE::FEM4EllipticPDE(const std::string&name) :
51 58
 			LemmaObject(name), BndryH(10), BndrySigma(10),
52
-            vtkSigma(NULL), vtkG(NULL), vtkGrid(NULL), gFcn3(NULL) {
59
+            vtkSigma(nullptr), vtkG(nullptr), vtkGrid(nullptr), gFcn3(nullptr) {
53 60
 	}
54 61
 
62
+    #ifdef HAVE_YAMLCPP
63
+    //--------------------------------------------------------------------------------------
64
+    //       Class:  FEM4EllipticPDE
65
+    //      Method:  FEM4EllipticPDE
66
+    // Description:  DeSerializing constructor (protected)
67
+    //--------------------------------------------------------------------------------------
68
+    FEM4EllipticPDE::FEM4EllipticPDE (const YAML::Node& node) : LemmaObject(node) {
69
+        // TODO impliment
70
+        throw std::runtime_error("FEM4ELLIPTICPDE YAML CONSTRUCTOR NOT IMPLIMENTED!");
71
+    }  // -----  end of method FEM4EllipticPDE::FEM4EllipticPDE  (constructor)  -----
72
+    #endif
73
+
55 74
 	FEM4EllipticPDE::~FEM4EllipticPDE() {
56 75
 	}
57 76
 
@@ -69,6 +88,31 @@ namespace Lemma {
69 88
         this->DetachFrom(this);
70 89
     }
71 90
 
91
+#ifdef HAVE_YAMLCPP
92
+    //--------------------------------------------------------------------------------------
93
+    //       Class:  FEM4EllipticPDE
94
+    //      Method:  Serialize
95
+    //--------------------------------------------------------------------------------------
96
+    YAML::Node  FEM4EllipticPDE::Serialize (  ) const {
97
+        YAML::Node node = LemmaObject::Serialize();;
98
+        node.SetTag( this->Name );
99
+        // FILL IN CLASS SPECIFICS HERE
100
+        return node;
101
+    }		// -----  end of method FEM4EllipticPDE::Serialize  -----
102
+
103
+
104
+    //--------------------------------------------------------------------------------------
105
+    //       Class:  FEM4EllipticPDE
106
+    //      Method:  DeSerialize
107
+    //--------------------------------------------------------------------------------------
108
+    FEM4EllipticPDE* FEM4EllipticPDE::DeSerialize ( const YAML::Node& node  ) {
109
+        FEM4EllipticPDE* Object = new FEM4EllipticPDE(node);
110
+        Object->AttachTo(Object);
111
+        DESERIALIZECHECK( node, Object )
112
+            return Object ;
113
+    }		// -----  end of method FEM4EllipticPDE::DeSerialize  -----
114
+#endif
115
+
72 116
     // ====================  OPERATIONS    =======================
73 117
 
74 118
     void FEM4EllipticPDE::SetSigmaFunction(vtkImplicitFunction* sigma) {

+ 123
- 0
src/LinearMag.cpp ファイルの表示

@@ -0,0 +1,123 @@
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      03/21/2016 02:10:08 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2016, University of Utah
17
+ * @copyright Copyright (c) 2016, Lemma Software, LLC
18
+ */
19
+
20
+#include "LinearMag.h"
21
+
22
+namespace Lemma {
23
+
24
+// ====================  FRIEND METHODS  =====================
25
+#ifdef HAVE_YAMLCPP
26
+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
28
+    return stream;
29
+}
30
+#else
31
+std::ostream &operator<<(std::ostream &stream, const LinearMag& ob) {
32
+    stream << *(FEM4EllipticPDE*)(&ob);
33
+    return stream;
34
+}
35
+#endif
36
+
37
+// ====================  LIFECYCLE     =======================
38
+
39
+//--------------------------------------------------------------------------------------
40
+//       Class:  LinearMag
41
+//      Method:  LinearMag
42
+// Description:  constructor (protected)
43
+//--------------------------------------------------------------------------------------
44
+LinearMag::LinearMag (const std::string& name) : FEM4EllipticPDE(name) {
45
+
46
+}  // -----  end of method LinearMag::LinearMag  (constructor)  -----
47
+
48
+#ifdef HAVE_YAMLCPP
49
+//--------------------------------------------------------------------------------------
50
+//       Class:  LinearMag
51
+//      Method:  LinearMag
52
+// Description:  DeSerializing constructor (protected)
53
+//--------------------------------------------------------------------------------------
54
+LinearMag::LinearMag (const YAML::Node& node) : FEM4EllipticPDE(node) {
55
+
56
+}  // -----  end of method LinearMag::LinearMag  (constructor)  -----
57
+#endif
58
+
59
+//--------------------------------------------------------------------------------------
60
+//       Class:  LinearMag
61
+//      Method:  New()
62
+// Description:  public constructor
63
+//--------------------------------------------------------------------------------------
64
+LinearMag* LinearMag::New() {
65
+    LinearMag*  Obj = new LinearMag("LinearMag");
66
+    Obj->AttachTo(Obj);
67
+    return Obj;
68
+}
69
+
70
+//--------------------------------------------------------------------------------------
71
+//       Class:  LinearMag
72
+//      Method:  ~LinearMag
73
+// Description:  destructor (protected)
74
+//--------------------------------------------------------------------------------------
75
+LinearMag::~LinearMag () {
76
+
77
+}  // -----  end of method LinearMag::~LinearMag  (destructor)  -----
78
+
79
+//--------------------------------------------------------------------------------------
80
+//       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
102
+//--------------------------------------------------------------------------------------
103
+YAML::Node  LinearMag::Serialize (  ) const {
104
+    YAML::Node node = FEM4EllipticPDE::Serialize();;
105
+    node.SetTag( this->Name );
106
+    // FILL IN CLASS SPECIFICS HERE
107
+    return node;
108
+}		// -----  end of method LinearMag::Serialize  -----
109
+
110
+
111
+//--------------------------------------------------------------------------------------
112
+//       Class:  LinearMag
113
+//      Method:  DeSerialize
114
+//--------------------------------------------------------------------------------------
115
+LinearMag* LinearMag::DeSerialize ( const YAML::Node& node  ) {
116
+    LinearMag* Object = new LinearMag(node);
117
+    Object->AttachTo(Object);
118
+    DESERIALIZECHECK( node, Object )
119
+        return Object ;
120
+}		// -----  end of method LinearMag::DeSerialize  -----
121
+#endif
122
+
123
+}		// -----  end of Lemma  name  -----

読み込み中…
キャンセル
保存