Pārlūkot izejas kodu

Work towards brining inline with Lemma 0.1.2

master
Trevor Irons 6 gadus atpakaļ
vecāks
revīzija
b236e28b6d
7 mainītis faili ar 306 papildinājumiem un 151 dzēšanām
  1. 6
    0
      CMakeLists.txt
  2. 25
    0
      config/EMSchur3DConfig.h.in
  3. 104
    0
      examples/EMSchur3D.cpp
  4. 115
    109
      include/EMSchur3D.h
  5. 19
    10
      include/EMSchur3DBase.h
  6. 7
    2
      include/bicgstab.h
  7. 30
    30
      src/EMSchur3DBase.cpp

+ 6
- 0
CMakeLists.txt Parādīt failu

@@ -5,6 +5,12 @@ set(EMSCHUR3D_VERSION_PATCH "1")
5 5
 set(EMSCHUR3D_VERSION "\"${EMSCHUR3D_VERSION_MAJOR}.${EMSCHUR3D_VERSION_MINOR}.${EMSCHUR3D_VERSION_PATCH}\"")
6 6
 set(EMSCHUR3D_VERSION_NOQUOTES "${EMSCHUR3D_VERSION_MAJOR}.${EMSCHUR3D_VERSION_MINOR}.${EMSCHUR3D_VERSION_PATCH}")
7 7
 
8
+configure_file (
9
+	"${CMAKE_CURRENT_SOURCE_DIR}/config/EMSchur3DConfig.h.in"
10
+	"${PROJECT_BINARY_DIR}/include/EMSchur3DConfig.h"
11
+)
12
+install ( FILES  ${PROJECT_BINARY_DIR}/include/EMSchur3DConfig.h   DESTINATION ${CMAKE_INSTALL_PREFIX}/include/Lemma/ )
13
+
8 14
 add_subdirectory("src")
9 15
 add_library( emschur3d ${EMSCHUR3DSOURCE} )  
10 16
 target_include_directories( emschur3d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

+ 25
- 0
config/EMSchur3DConfig.h.in Parādīt failu

@@ -0,0 +1,25 @@
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      01/08/2018 04:01:30 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2018, University of Utah
17
+ * @copyright Copyright (c) 2018, Lemma Software, LLC
18
+ */
19
+
20
+#define EMSCHUR3D_VERSION_MAJOR @EMSCHUR3D_VERSION_MAJOR@
21
+#define EMSCHUR3D_VERSION_MINOR @EMSCHUR3D_VERSION_MINOR@
22
+#define EMSCHUR3D_VERSION_PATCH @EMSCHUR3D_VERSION_PATCH@
23
+#define EMSCHUR3D_VERSION @EMSCHUR3D_VERSION@
24
+
25
+

+ 104
- 0
examples/EMSchur3D.cpp Parādīt failu

@@ -0,0 +1,104 @@
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      01/04/2018 04:34:54 PM
13
+ * @version   $Id$
14
+ * @author    Trevor Irons (ti)
15
+ * @email     tirons@egi.utah.edu
16
+ * @copyright Copyright (c) 2018, University of Utah
17
+ * @copyright Copyright (c) 2018, Lemma Software, LLC
18
+ */
19
+
20
+#include <LemmaCore>
21
+#include "RectilinearGridReader.h"
22
+//#include "AEMSurveyReader.h"
23
+#include "EMSchur3D.h"
24
+//#include "LayeredEarthEMReader.h"
25
+//#include "CSymSimplicialCholesky.h"
26
+
27
+using namespace Lemma;
28
+
29
+int main( int argc, char** argv ) {
30
+
31
+    // BiCGSTAB Diagonal preconditioner
32
+    auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
33
+
34
+    if (argc < 3) {
35
+        std::cout << "EMSchur3D  <rgrid>  <1dmod>  <aemsurvey> " << std::endl;
36
+        exit( EXIT_SUCCESS );
37
+    }
38
+
39
+    ///////////////////////////////////////////////////
40
+    // Read in Grid
41
+    auto GridRead = RectilinearGridReader::NewSP();
42
+        try {
43
+            GridRead->ReadASCIIGridFile( argv[1] );
44
+        } catch (std::exception& e) {
45
+		    std::cout << "Caught an error opening ASCII Grid file: ";
46
+            std::cout << e.what() << std::endl;
47
+		    std::cout << "enter filename or 0 to exit programme\n";
48
+		    std::string inp;
49
+		    std::cin >> inp;
50
+		    if (inp != "0")
51
+                GridRead->ReadASCIIGridFile( inp.c_str() );
52
+            else exit(EXIT_FAILURE);
53
+	    }
54
+
55
+    //////////////////////////////////////////////////
56
+    // Read in Layered earth, for backgound model
57
+    auto LayEarthRead = LayeredEarthEMReader::NewSP();
58
+        try {
59
+            LayEarthRead->ReadASCIIInputFile( argv[2] );
60
+        } catch (std::exception& e) {
61
+		    std::cout << "Caught an error opening ASCII Layered Earth file: ";
62
+            std::cout << e.what() << std::endl;
63
+		    std::cout << "enter filename or 0 to exit programme\n";
64
+		    std::string inp;
65
+		    std::cin >> inp;
66
+		    if (inp != "0")
67
+                GridRead->ReadASCIIGridFile( inp.c_str() );
68
+            else exit(EXIT_FAILURE);
69
+	    }
70
+
71
+    /*
72
+    //////////////////////////////////////////////////
73
+    // Read in source specification
74
+    auto AEMRead = AEMSurveyReader::NewSP();
75
+        try{
76
+            AEMRead->ReadASCIIAEMFile(argv[4]);
77
+        } catch (std::exception& e) {
78
+		    std::cout << "Caught an error opening ASCII AEM file: ";
79
+            std::cout << e.what() << std::endl;
80
+		    std::cout << "enter filename or 0 to exit programme\n";
81
+		    std::string inp;
82
+		    std::cin >> inp;
83
+		    if (inp != "0")
84
+                AEMRead->ReadASCIIAEMFile( inp.c_str() );
85
+            else exit(EXIT_FAILURE);
86
+	    }
87
+    */
88
+
89
+    /*
90
+    //////////////////////////////////////////////////
91
+    // And solve
92
+    EM3D->SetRectilinearGrid(GridRead->GetGrid());
93
+    EM3D->SetLayeredEarthEM( LayEarthRead->GetLayeredEarth() );
94
+    EM3D->SetAEMSurvey( AEMRead->GetSurvey() );
95
+    EM3D->LoadMeshToolsConductivityModel( argv[3] );
96
+    EM3D->SetResFileName(argv[5]);
97
+    //EM3D->SetCSolver( Lemma::SPARSELU ); // Lemma::BiCGSTAB );
98
+    EM3D->Solve();
99
+    */
100
+    std::cout << *EM3D;
101
+
102
+    exit(EXIT_SUCCESS);
103
+}
104
+

+ 115
- 109
include/EMSchur3D.h Parādīt failu

@@ -23,6 +23,7 @@
23 23
 #define  EMSCHUR3D_INC
24 24
 
25 25
 #include "EMSchur3DBase.h"
26
+#include "bicgstab.h"
26 27
 //#include "CSymSimplicialCholesky.h"
27 28
 
28 29
 namespace Lemma {
@@ -35,6 +36,13 @@ namespace Lemma {
35 36
     template < class Solver >
36 37
     class EMSchur3D : public EMSchur3DBase {
37 38
 
39
+        friend std::ostream &operator << (std::ostream &stream, const EMSchur3D &ob) {
40
+            stream << ob.Serialize()  << "\n---\n"; // End of doc
41
+            return stream;
42
+        }
43
+
44
+        struct ctor_key {};
45
+
38 46
         //friend std::ostream &operator<<(std::ostream &stream,
39 47
         //        const EMSchur3D &ob);
40 48
 
@@ -46,20 +54,42 @@ namespace Lemma {
46 54
          * @copybrief LemmaObject::New()
47 55
          * @copydetails LemmaObject::New()
48 56
          */
49
-        static EMSchur3D* New() {
50
-            EMSchur3D<Solver>*  Obj = new EMSchur3D<Solver>("EMSchur3D");
51
-            Obj->AttachTo(Obj);
52
-            return Obj;
57
+        static std::shared_ptr< EMSchur3D > NewSP() {
58
+            return std::make_shared< EMSchur3D<Solver> >( ctor_key() );
59
+            //return std::make_shared< EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > > >( ctor_key() ) ;
60
+        }
61
+
62
+        /** Default protected constructor, use New */
63
+        explicit EMSchur3D ( const ctor_key& key ) : EMSchur3DBase( ), CSolver( nullptr ) {
64
+
65
+        }
66
+
67
+        /** Locked DeDerializing constructor, use factory DeSerialize  method*/
68
+        EMSchur3D (const YAML::Node& node): EMSchur3DBase(node), CSolver( nullptr ) {
69
+        }
70
+
71
+        /** Default protected destructor, use Delete */
72
+        virtual ~EMSchur3D () {
73
+            // TODO delete arrays
53 74
         }
54 75
 
55 76
         /**
56
-         *  @copybrief   LemmaObject::Delete()
57
-         *  @copydetails LemmaObject::Delete()
77
+         *  Uses YAML to serialize this object.
78
+         *  @return a YAML::Node
58 79
          */
59
-        void Delete() {
60
-            this->DetachFrom(this);
80
+        YAML::Node Serialize() const {
81
+            YAML::Node node = EMSchur3DBase::Serialize();
82
+            //node["NumberOfLayers"] = NumberOfLayers;
83
+            node.SetTag( this->GetName() );
84
+            return node;
61 85
         }
62 86
 
87
+        /**
88
+         *   Constructs an object from a YAML::Node.
89
+         */
90
+        static EMSchur3D* DeSerialize(const YAML::Node& node);
91
+
92
+
63 93
         // ====================  OPERATORS     =======================
64 94
 
65 95
         // ====================  OPERATIONS    =======================
@@ -68,57 +98,28 @@ namespace Lemma {
68 98
          *  @param[in] Source is the source term for generating primary fields
69 99
          *  @param[in] isource is the source index
70 100
          */
71
-        void SolveSource( DipoleSource* Source , const int& isource);
101
+        void SolveSource( std::shared_ptr<DipoleSource> Source , const int& isource);
72 102
 
73 103
         /** Builds the solver for the C matrix */
74 104
         void BuildCDirectSolver(  );
75 105
 
76 106
         // ====================  ACCESS        =======================
77 107
 
78
-        // ====================  INQUIRY       =======================
108
+        virtual std::string GetName() const {
109
+            return this->CName;
110
+        }
79 111
 
80
-#ifdef HAVE_YAMLCPP
81
-//         /**
82
-//          *  Uses YAML to serialize this object.
83
-//          *  @return a YAML::Node
84
-//          */
85
-//         YAML::Node Serialize() const;
86
-//
87
-//         /**
88
-//          *   Constructs an object from a YAML::Node.
89
-//          */
90
-//         static EMSchur3D* DeSerialize(const YAML::Node& node);
91
-#endif
112
+        // ====================  INQUIRY       =======================
92 113
 
93 114
         protected:
94 115
 
95 116
         // ====================  LIFECYCLE     =======================
96 117
 
97
-        /** Default protected constructor, use New */
98
-        EMSchur3D (const std::string& name) : EMSchur3DBase(name), CSolver(NULL) {
99
-        }
100
-
101
-// #ifdef HAVE_YAMLCPP
102
-//         /** Protected DeDerializing constructor, use factory DeSerialize  method*/
103
-//         EMSchur3D (const YAML::Node& node): EMSchur3DBase(node), CSolver(NULL) {
104
-//         }
105
-// #endif
106
-
107
-        /** Default protected destructor, use Delete */
108
-        ~EMSchur3D () {
109
-            // TODO delete arrays
110
-        }
111
-
112
-        /**
113
-         *  @copybrief   LemmaObject::Release()
114
-         *  @copydetails LemmaObject::Release()
115
-         */
116
-        void Release() {
117
-            delete this;
118
-        }
119
-
120 118
         private:
121 119
 
120
+        /** Copy constructor */
121
+        EMSchur3D( const EMSchur3D& ) = delete;
122
+
122 123
         // ====================  DATA MEMBERS  =========================
123 124
 
124 125
         /** The templated solver for C */
@@ -126,6 +127,9 @@ namespace Lemma {
126 127
 
127 128
         Eigen::SparseMatrix<Complex>  Csym;
128 129
 
130
+        static constexpr auto CName = "EMSchur3D";
131
+
132
+
129 133
     }; // -----  end of class  EMSchur3D  -----
130 134
 
131 135
 
@@ -138,7 +142,7 @@ namespace Lemma {
138 142
     //      Method:  SolveSource
139 143
     //--------------------------------------------------------------------------------------
140 144
     template < class Solver >
141
-    void EMSchur3D<Solver>::SolveSource ( DipoleSource* Source, const int& isource ) {
145
+    void EMSchur3D<Solver>::SolveSource ( std::shared_ptr<DipoleSource> Source, const int& isource ) {
142 146
 
143 147
         //  figure out which omega we are working with
144 148
         int iw = -1;
@@ -160,7 +164,8 @@ namespace Lemma {
160 164
         //       Alternatively, the bins function of ReceiverPoints could be extended quite easily.
161 165
         //       This may be the way to do this.
162 166
 
163
-        Lemma::ReceiverPoints* dpoint = Lemma::ReceiverPoints::New();
167
+        //Lemma::ReceiverPoints* dpoint = Lemma::ReceiverPoints::New();
168
+        std::shared_ptr< FieldPoints > dpoint = FieldPoints::NewSP();
164 169
 
165 170
         FillPoints(dpoint);
166 171
         PrimaryField(Source, dpoint);
@@ -288,7 +293,7 @@ namespace Lemma {
288 293
 
289 294
         WriteVTKResults( ResFile+ to_string(isource), A, Se, E0, E , Phi, ADiv, ADiv2, B);
290 295
 
291
-        dpoint->Delete();
296
+        //dpoint->Delete();
292 297
         return ;
293 298
 
294 299
     }		// -----  end of method EMSchur3D::SolveSource  -----
@@ -416,68 +421,69 @@ namespace Lemma {
416 421
 //         }
417 422
 //     }
418 423
 
419
-    template<>
420
-    void EMSchur3D< Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::NaturalOrdering<int> > > ::BuildCDirectSolver() {
421
-        CSolver = new Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::NaturalOrdering<int> > [Omegas.size()];
422
-        for (int iw=0; iw<Omegas.size(); ++iw) {
423
-            Csym = Cvec[iw].selfadjointView<Eigen::Lower>();
424
-            jsw_timer timer;
425
-            timer.begin();
426
-            /*  Complex system */
427
-            std::cout << "CSymSimplicialLLT<NaturalOrdering> pattern analyzing C_" << iw << ",";
428
-            std::cout.flush();
429
-            CSolver[iw].analyzePattern( Csym );
430
-            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
431
-            /* factorize */
432
-            timer.begin();
433
-            std::cout << "CSymSimplicialLLT<NaturalOrdering> factorising C_" << iw << ", ";
434
-            std::cout.flush();
435
-            CSolver[iw].factorize( Csym );
436
-            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
437
-        }
438
-    }
439
-
440
-    template<>
441
-    void EMSchur3D< Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > > ::BuildCDirectSolver() {
442
-        CSolver = new Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > [Omegas.size()];
443
-        for (int iw=0; iw<Omegas.size(); ++iw) {
444
-            //Csym = Cvec[iw].selfadjointView<Eigen::Lower>();
445
-            jsw_timer timer;
446
-            timer.begin();
447
-            /*  Complex system */
448
-            std::cout << "CSymSimplicialLLT<AMDOrdering> pattern analyzing C_" << iw << ",";
449
-            std::cout.flush();
450
-            CSolver[iw].analyzePattern( Cvec[iw] );
451
-            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
452
-            /* factorize */
453
-            timer.begin();
454
-            std::cout << "CSymSimplicialLLT<AMDOrdering> factorising C_" << iw << ", ";
455
-            std::cout.flush();
456
-            CSolver[iw].factorize( Cvec[iw] );
457
-            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
458
-        }
459
-    }
424
+//     template<>
425
+//     void EMSchur3D< Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::NaturalOrdering<int> > > ::BuildCDirectSolver() {
426
+//         CSolver = new Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::NaturalOrdering<int> > [Omegas.size()];
427
+//         for (int iw=0; iw<Omegas.size(); ++iw) {
428
+//             Csym = Cvec[iw].selfadjointView<Eigen::Lower>();
429
+//             jsw_timer timer;
430
+//             timer.begin();
431
+//             /*  Complex system */
432
+//             std::cout << "CSymSimplicialLLT<NaturalOrdering> pattern analyzing C_" << iw << ",";
433
+//             std::cout.flush();
434
+//             CSolver[iw].analyzePattern( Csym );
435
+//             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
436
+//             /* factorize */
437
+//             timer.begin();
438
+//             std::cout << "CSymSimplicialLLT<NaturalOrdering> factorising C_" << iw << ", ";
439
+//             std::cout.flush();
440
+//             CSolver[iw].factorize( Csym );
441
+//             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
442
+//         }
443
+//     }
444
+//
445
+//     template<>
446
+//     void EMSchur3D< Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > > ::BuildCDirectSolver() {
447
+//         CSolver = new Eigen::CSymSimplicialLLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > [Omegas.size()];
448
+//         for (int iw=0; iw<Omegas.size(); ++iw) {
449
+//             //Csym = Cvec[iw].selfadjointView<Eigen::Lower>();
450
+//             jsw_timer timer;
451
+//             timer.begin();
452
+//             /*  Complex system */
453
+//             std::cout << "CSymSimplicialLLT<AMDOrdering> pattern analyzing C_" << iw << ",";
454
+//             std::cout.flush();
455
+//             CSolver[iw].analyzePattern( Cvec[iw] );
456
+//             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
457
+//             /* factorize */
458
+//             timer.begin();
459
+//             std::cout << "CSymSimplicialLLT<AMDOrdering> factorising C_" << iw << ", ";
460
+//             std::cout.flush();
461
+//             CSolver[iw].factorize( Cvec[iw] );
462
+//             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
463
+//         }
464
+//     }
465
+//
466
+//     template<>
467
+//     void EMSchur3D< Eigen::CSymSimplicialLDLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > > ::BuildCDirectSolver() {
468
+//         CSolver = new Eigen::CSymSimplicialLDLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > [Omegas.size()];
469
+//         for (int iw=0; iw<Omegas.size(); ++iw) {
470
+//             Csym = Cvec[iw].selfadjointView<Eigen::Lower>();
471
+//             jsw_timer timer;
472
+//             timer.begin();
473
+//             /*  Complex system */
474
+//             std::cout << "CSymSimplicialLDLT<AMDOrdering> pattern analyzing C_" << iw << ",";
475
+//             std::cout.flush();
476
+//             CSolver[iw].analyzePattern( Csym );
477
+//             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
478
+//             /* factorize */
479
+//             timer.begin();
480
+//             std::cout << "CSymSimplicialLDLT<AMDOrdering> factorising C_" << iw << ", ";
481
+//             std::cout.flush();
482
+//             CSolver[iw].factorize( Csym );
483
+//             std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
484
+//         }
485
+//     }
460 486
 
461
-    template<>
462
-    void EMSchur3D< Eigen::CSymSimplicialLDLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > > ::BuildCDirectSolver() {
463
-        CSolver = new Eigen::CSymSimplicialLDLT< Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> > [Omegas.size()];
464
-        for (int iw=0; iw<Omegas.size(); ++iw) {
465
-            Csym = Cvec[iw].selfadjointView<Eigen::Lower>();
466
-            jsw_timer timer;
467
-            timer.begin();
468
-            /*  Complex system */
469
-            std::cout << "CSymSimplicialLDLT<AMDOrdering> pattern analyzing C_" << iw << ",";
470
-            std::cout.flush();
471
-            CSolver[iw].analyzePattern( Csym );
472
-            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
473
-            /* factorize */
474
-            timer.begin();
475
-            std::cout << "CSymSimplicialLDLT<AMDOrdering> factorising C_" << iw << ", ";
476
-            std::cout.flush();
477
-            CSolver[iw].factorize( Csym );
478
-            std::cout << " done in " << timer.end() / 60. << " [m]" << std::endl;
479
-        }
480
-    }
481 487
 
482 488
     template<>
483 489
     void EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::IncompleteLUT<Complex> > > ::BuildCDirectSolver() {

+ 19
- 10
include/EMSchur3DBase.h Parādīt failu

@@ -21,14 +21,16 @@
21 21
   @date     09/20/2013
22 22
   @version  $Id$
23 23
  **/
24
-
24
+#pragma once
25 25
 
26 26
 #ifndef  EMSCHUR3DBASE_INC
27 27
 #define  EMSCHUR3DBASE_INC
28 28
 
29 29
 #include <LemmaCore>
30
+#include "EMSchur3DConfig.h"
30 31
 #include <FDEM1D>
31 32
 
33
+
32 34
 //#include "LemmaObject.h"
33 35
 //#include "rectilineargrid.h"
34 36
 //#include "RectilinearGridVTKExporter.h"
@@ -40,7 +42,7 @@
40 42
 
41 43
 #include "timer.h"
42 44
 #include <Eigen/Sparse>
43
-#include "bicgstab.h"
45
+//#include "bicgstab.h"
44 46
 
45 47
 // Solvers
46 48
 #ifdef HAVE_PASTIX
@@ -140,20 +142,25 @@ class EMSchur3DBase : public LemmaObject {
140 142
             const EMSchur3DBase &ob);
141 143
 
142 144
     protected:
143
-    struct ctor_key {};
145
+
146
+    // since this is a ABC, key is not necessary...still would be nice to find a
147
+    // mechanism for specifying where keys may be passed down from...
148
+    //struct ctor_key {};
149
+    //template<typename U>
150
+    //friend class EMSchur3D;
144 151
 
145 152
     public:
146 153
 
147 154
     // ====================  LIFECYCLE     =======================
148 155
 
149 156
     /** Default protected constructor, use New */
150
-    explicit EMSchur3DBase ( const ctor_key& );
157
+    explicit EMSchur3DBase (  );
151 158
 
152 159
     /** Default protected constructor, use New */
153
-    explicit EMSchur3DBase ( const YAML::Node& node, const ctor_key& );
160
+    explicit EMSchur3DBase ( const YAML::Node& node );
154 161
 
155 162
     /** Default protected destructor, use Delete */
156
-    virtual ~EMSchur3DBase ();
163
+    virtual ~EMSchur3DBase ( );
157 164
 
158 165
     /**
159 166
      * Initialises antenna to contain no points, with no current
@@ -161,10 +168,10 @@ class EMSchur3DBase : public LemmaObject {
161 168
      */
162 169
     static std::shared_ptr<EMSchur3DBase> NewSP();
163 170
 
164
-    /**
171
+    /*
165 172
      * Provides deep copy
166 173
      */
167
-    virtual std::shared_ptr<EMSchur3DBase> Clone() const ;
174
+    //virtual std::shared_ptr<EMSchur3DBase> Clone() const ;
168 175
 
169 176
     /**
170 177
      *  Uses YAML to serialize this object.
@@ -240,7 +247,9 @@ class EMSchur3DBase : public LemmaObject {
240 247
     // ====================  INQUIRY       =======================
241 248
 
242 249
     /** Returns the name of the underlying class, similiar to Python's type */
243
-    virtual std::string GetName() const;
250
+    virtual std::string GetName() const {
251
+        return this->CName;
252
+    }
244 253
 
245 254
     protected:
246 255
 
@@ -319,7 +328,7 @@ class EMSchur3DBase : public LemmaObject {
319 328
      *  @param[in] Source is the source term for generating primary fields
320 329
      *  @param[in] isource is the source index
321 330
      */
322
-    virtual void SolveSource( DipoleSource* Source , const int& isource)=0;
331
+    virtual void SolveSource( std::shared_ptr< DipoleSource > Source , const int& isource)=0;
323 332
 
324 333
     /** Computes the primary field
325 334
      */

+ 7
- 2
include/bicgstab.h Parādīt failu

@@ -30,6 +30,10 @@
30 30
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
31 31
 //
32 32
 // ===========================================================================
33
+#pragma once
34
+
35
+#ifndef  BICGSTAB_INC
36
+#define  BICGSTAB_INC
33 37
 
34 38
 #include <Eigen/Core>
35 39
 #include <Eigen/Sparse>
@@ -45,7 +49,7 @@
45 49
 #include <string>
46 50
 #include <complex>
47 51
 #include <fstream>
48
-#include "lemma.h"
52
+#include <LemmaCore>
49 53
 #include "timer.h"
50 54
 
51 55
 using namespace Eigen;
@@ -795,7 +799,7 @@ int implicitbicgstab_ei(const SparseMat&  D,
795 799
 // On Output
796 800
 // X real solution vector
797 801
 // errorn = Real error norm
798
-int implicitbicgstab(const SparseMat& D,
802
+int implicitbicgstabnt(const SparseMat& D,
799 803
                      const SparseMat& C,
800 804
                      const VectorXcr& ioms,
801 805
                      const SparseMat& MC,
@@ -930,6 +934,7 @@ int implicitbicgstab(const SparseMat& D,
930 934
     return (0);
931 935
 }
932 936
 
937
+#endif   // ----- #ifndef BICGSTAB_INC  -----
933 938
 
934 939
 //int bicgstab(const SparseMat &A, Eigen::SparseLU< Eigen::SparseMatrix<Complex, RowMajor> ,
935 940
 

+ 30
- 30
src/EMSchur3DBase.cpp Parādīt failu

@@ -23,8 +23,8 @@
23 23
 
24 24
 #include "EMSchur3DBase.h"
25 25
 
26
-typedef Eigen::Triplet<Complex> Tc;
27
-typedef Eigen::Triplet<Real> Tr;
26
+typedef Eigen::Triplet<Lemma::Complex> Tc;
27
+typedef Eigen::Triplet<Lemma::Real> Tr;
28 28
 
29 29
 #define UPPER 0
30 30
 #define LOWER 1 // 1=true, 0=false
@@ -56,7 +56,7 @@ namespace Lemma {
56 56
     //      Method:  EMSchur3DBase
57 57
     // Description:  constructor (protected)
58 58
     //--------------------------------------------------------------------------------------
59
-    EMSchur3DBase::EMSchur3DBase ( const ctor_key& key ) : LemmaObject( ),
59
+    EMSchur3DBase::EMSchur3DBase ( ) : LemmaObject( ),
60 60
         Grid(nullptr),
61 61
         //Survey(nullptr),
62 62
         LayModel(nullptr), Cvec(nullptr),
@@ -69,7 +69,7 @@ namespace Lemma {
69 69
     //      Method:  EMSchur3DBase
70 70
     // Description:  constructor (protected)
71 71
     //--------------------------------------------------------------------------------------
72
-    EMSchur3DBase::EMSchur3DBase ( const YAML::Node& node, const ctor_key& key ) : LemmaObject(),
72
+    EMSchur3DBase::EMSchur3DBase ( const YAML::Node& node ) : LemmaObject(),
73 73
         Grid(nullptr),
74 74
         //Survey(nullptr),
75 75
         LayModel(nullptr), Cvec(nullptr),
@@ -96,6 +96,7 @@ namespace Lemma {
96 96
     YAML::Node EMSchur3DBase::Serialize (  ) const {
97 97
         YAML::Node node = LemmaObject::Serialize();
98 98
         node.SetTag( this->GetName() );
99
+        node["EMSchur3D_VERSION"] = EMSCHUR3D_VERSION;
99 100
         return node;
100 101
     }		// -----  end of method EMSchur3D::Serialize  -----
101 102
 
@@ -1203,22 +1204,21 @@ namespace Lemma {
1203 1204
         EImag->SetNumberOfComponents(3);
1204 1205
 
1205 1206
         // Interpolate
1206
-        VectorXcd  Ax(nx*ny*nz);       // A
1207
-        VectorXcd  Ay(nx*ny*nz);
1208
-        VectorXcd  Az(nx*ny*nz);
1209
-        VectorXcd  Bx(nx*ny*nz);       // B
1210
-        VectorXcd  By(nx*ny*nz);
1211
-        VectorXcd  Bz(nx*ny*nz);
1212
-        VectorXcd  Sex(nx*ny*nz);      // Se
1213
-        VectorXcd  Sey(nx*ny*nz);
1214
-        VectorXcd  Sez(nx*ny*nz);
1215
-        VectorXcd  E0x(nx*ny*nz);      // E0
1216
-        VectorXcd  E0y(nx*ny*nz);
1217
-        VectorXcd  E0z(nx*ny*nz);
1218
-        VectorXcd  Ex(nx*ny*nz);       // E
1219
-        VectorXcd  Ey(nx*ny*nz);
1220
-        VectorXcd  Ez(nx*ny*nz);
1221
-
1207
+        Eigen::VectorXcd  Ax(nx*ny*nz);       // A
1208
+        Eigen::VectorXcd  Ay(nx*ny*nz);
1209
+        Eigen::VectorXcd  Az(nx*ny*nz);
1210
+        Eigen::VectorXcd  Bx(nx*ny*nz);       // B
1211
+        Eigen::VectorXcd  By(nx*ny*nz);
1212
+        Eigen::VectorXcd  Bz(nx*ny*nz);
1213
+        Eigen::VectorXcd  Sex(nx*ny*nz);      // Se
1214
+        Eigen::VectorXcd  Sey(nx*ny*nz);
1215
+        Eigen::VectorXcd  Sez(nx*ny*nz);
1216
+        Eigen::VectorXcd  E0x(nx*ny*nz);      // E0
1217
+        Eigen::VectorXcd  E0y(nx*ny*nz);
1218
+        Eigen::VectorXcd  E0z(nx*ny*nz);
1219
+        Eigen::VectorXcd  Ex(nx*ny*nz);       // E
1220
+        Eigen::VectorXcd  Ey(nx*ny*nz);
1221
+        Eigen::VectorXcd  Ez(nx*ny*nz);
1222 1222
 
1223 1223
         ////////////////////////////////
1224 1224
         // X component
@@ -1301,16 +1301,16 @@ namespace Lemma {
1301 1301
             ADiv2ImagArray->InsertTuple1(i, std::imag(ADiv2(i)));
1302 1302
 
1303 1303
             // vectors
1304
-            AReal->InsertTuple3(i, real(Ax(i)), real(Ay(i)), real(Az(i)));
1305
-            AImag->InsertTuple3(i, imag(Ax(i)), imag(Ay(i)), imag(Az(i)));
1306
-            BReal->InsertTuple3(i, real(Bx(i)), real(By(i)), real(Bz(i)));
1307
-            BImag->InsertTuple3(i, imag(Bx(i)), imag(By(i)), imag(Bz(i)));
1308
-            SeReal->InsertTuple3(i, real(Sex(i)), real(Sey(i)), real(Sez(i)));
1309
-            SeImag->InsertTuple3(i, imag(Sex(i)), imag(Sey(i)), imag(Sez(i)));
1310
-            E0Real->InsertTuple3(i, real(E0x(i)), real(E0y(i)), real(E0z(i)));
1311
-            E0Imag->InsertTuple3(i, imag(E0x(i)), imag(E0y(i)), imag(E0z(i)));
1312
-            EReal-> InsertTuple3(i, real(Ex(i)), real(Ey(i)), real(Ez(i)));
1313
-            EImag-> InsertTuple3(i, imag(Ex(i)), imag(Ey(i)), imag(Ez(i)));
1304
+            AReal->InsertTuple3(i, std::real(Ax(i)), std::real(Ay(i)), std::real(Az(i)));
1305
+            AImag->InsertTuple3(i, std::imag(Ax(i)), std::imag(Ay(i)), std::imag(Az(i)));
1306
+            BReal->InsertTuple3(i, std::real(Bx(i)), std::real(By(i)), std::real(Bz(i)));
1307
+            BImag->InsertTuple3(i, std::imag(Bx(i)), std::imag(By(i)), std::imag(Bz(i)));
1308
+            SeReal->InsertTuple3(i, std::real(Sex(i)), std::real(Sey(i)), std::real(Sez(i)));
1309
+            SeImag->InsertTuple3(i, std::imag(Sex(i)), std::imag(Sey(i)), std::imag(Sez(i)));
1310
+            E0Real->InsertTuple3(i, std::real(E0x(i)), std::real(E0y(i)), std::real(E0z(i)));
1311
+            E0Imag->InsertTuple3(i, std::imag(E0x(i)), std::imag(E0y(i)), std::imag(E0z(i)));
1312
+            EReal-> InsertTuple3(i, std::real(Ex(i)), std::real(Ey(i)), std::real(Ez(i)));
1313
+            EImag-> InsertTuple3(i, std::imag(Ex(i)), std::imag(Ey(i)), std::imag(Ez(i)));
1314 1314
 
1315 1315
             ++i;
1316 1316
         }

Notiek ielāde…
Atcelt
Saglabāt