|
@@ -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() {
|