|
@@ -11,77 +11,80 @@
|
11
|
11
|
@version $Id: receiverpoints.cpp 203 2015-01-09 21:19:04Z tirons $
|
12
|
12
|
**/
|
13
|
13
|
|
14
|
|
-#include "receiverpoints.h"
|
|
14
|
+#include "FieldPoints.h"
|
15
|
15
|
|
16
|
16
|
namespace Lemma {
|
17
|
17
|
|
18
|
18
|
// ==================== FRIENDS ======================
|
19
|
19
|
|
20
|
|
-#ifdef HAVE_YAMLCPP
|
21
|
|
- std::ostream &operator << (std::ostream &stream, const ReceiverPoints &ob) {
|
22
|
|
- stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
|
|
20
|
+ std::ostream &operator << (std::ostream &stream, const FieldPoints &ob) {
|
|
21
|
+ stream << ob.Serialize() << "\n---\n"; // End of doc ---
|
23
|
22
|
return stream;
|
24
|
23
|
}
|
25
|
|
-#else
|
26
|
|
- std::ostream &operator<<(std::ostream &stream,
|
27
|
|
- const ReceiverPoints &ob) {
|
28
|
|
-
|
29
|
|
- stream << *(LemmaObject*)(&ob);
|
30
|
|
- stream << "Number of Receivers "<< ob.NumberOfReceivers << "\n";
|
31
|
|
- return stream;
|
32
|
|
- }
|
33
|
|
-#endif
|
34
|
24
|
|
35
|
25
|
// ==================== LIFECYCLE ===================================
|
36
|
26
|
|
37
|
|
- ReceiverPoints::ReceiverPoints(const std::string& name) :
|
38
|
|
- LemmaObject(name),
|
39
|
|
- NumberOfReceivers(0), NumberOfBinsE(0), NumberOfBinsH(0) {
|
|
27
|
+ FieldPoints::FieldPoints( const ctor_key& ) : LemmaObject( ),
|
|
28
|
+ NumberOfPoints(0), NumberOfBinsE(0), NumberOfBinsH(0) {
|
40
|
29
|
}
|
41
|
30
|
|
42
|
|
-#ifdef HAVE_YAMLCPP
|
43
|
31
|
//--------------------------------------------------------------------------------------
|
44
|
|
- // Class: ReceiverPoints
|
45
|
|
- // Method: ReceiverPoints
|
|
32
|
+ // Class: FieldPoints
|
|
33
|
+ // Method: FieldPoints
|
46
|
34
|
// Description: constructor (protected)
|
47
|
35
|
//--------------------------------------------------------------------------------------
|
48
|
|
- ReceiverPoints::ReceiverPoints (const YAML::Node& node) : LemmaObject(node) {
|
49
|
|
-
|
|
36
|
+ FieldPoints::FieldPoints (const YAML::Node& node, const ctor_key&) : LemmaObject(node) {
|
50
|
37
|
//DeSerialize
|
51
|
|
- NumberOfReceivers = node["NumberOfReceivers"].as<int>();
|
|
38
|
+ NumberOfPoints = node["NumberOfPoints"].as<int>();
|
52
|
39
|
NumberOfBinsE = node["NumberOfBinsE"].as<int>();
|
53
|
40
|
NumberOfBinsH = node["NumberOfBinsH"].as<int>();
|
54
|
41
|
Mask = node["Mask"].as<VectorXi>();
|
55
|
42
|
Locations = node["Locations"].as<Vector3Xr>();
|
|
43
|
+ } // ----- end of method FieldPoints::FieldPoints (constructor) -----
|
56
|
44
|
|
57
|
|
- } // ----- end of method ReceiverPoints::ReceiverPoints (constructor) -----
|
58
|
|
-#endif
|
59
|
|
-
|
60
|
|
- ReceiverPoints::~ReceiverPoints() {
|
61
|
|
- if (this->NumberOfReferences != 0)
|
62
|
|
- throw DeleteObjectWithReferences( this );
|
|
45
|
+ FieldPoints::~FieldPoints() {
|
63
|
46
|
}
|
64
|
47
|
|
65
|
|
- ReceiverPoints* ReceiverPoints::New() {
|
66
|
|
- ReceiverPoints* Obj = new ReceiverPoints("ReceiverPoints");
|
67
|
|
- Obj->AttachTo(Obj);
|
68
|
|
- return Obj;
|
|
48
|
+ std::shared_ptr<FieldPoints> FieldPoints::NewSP() {
|
|
49
|
+ return std::make_shared<FieldPoints> ( ctor_key() );
|
69
|
50
|
}
|
70
|
51
|
|
71
|
|
- void ReceiverPoints::Delete() {
|
72
|
|
- this->DetachFrom(this);
|
73
|
|
- }
|
|
52
|
+ //--------------------------------------------------------------------------------------
|
|
53
|
+ // Class: FieldPoints
|
|
54
|
+ // Method: Serialize
|
|
55
|
+ //--------------------------------------------------------------------------------------
|
|
56
|
+ YAML::Node FieldPoints::Serialize ( ) const {
|
|
57
|
+ YAML::Node node = LemmaObject::Serialize();
|
|
58
|
+ node.SetTag( GetName() );
|
74
|
59
|
|
75
|
|
- void ReceiverPoints::Release() {
|
76
|
|
- delete this;
|
77
|
|
- }
|
|
60
|
+ // update here
|
|
61
|
+ node["NumberOfPoints"] = NumberOfPoints;
|
|
62
|
+ node["NumberOfBinsE"] = NumberOfBinsE;
|
|
63
|
+ node["NumberOfBinsH"] = NumberOfBinsH;
|
|
64
|
+ node["Mask"] = Mask;
|
|
65
|
+ node["Locations"] = Locations;// Can be huge
|
|
66
|
+ //std::cout << "Locations.data" << Locations.data()[0] << std::endl;
|
|
67
|
+ return node;
|
|
68
|
+ } // ----- end of method FieldPoints::Serialize -----
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+ //--------------------------------------------------------------------------------------
|
|
72
|
+ // Class: FieldPoints
|
|
73
|
+ // Method: DeSerialize
|
|
74
|
+ //--------------------------------------------------------------------------------------
|
|
75
|
+ std::shared_ptr<FieldPoints> FieldPoints::DeSerialize ( const YAML::Node& node ) {
|
|
76
|
+ if (node.Tag() != "FieldPoints") {
|
|
77
|
+ throw DeSerializeTypeMismatch( "FieldPoints", node.Tag());
|
|
78
|
+ }
|
|
79
|
+ return std::make_shared<FieldPoints> ( node, ctor_key() );
|
|
80
|
+ } // ----- end of method FieldPoints::DeSerialize -----
|
78
|
81
|
|
79
|
82
|
// ==================== ACCESS ===================================
|
80
|
83
|
|
81
|
|
- void ReceiverPoints::SetNumberOfReceivers(const int &nrec) {
|
|
84
|
+ void FieldPoints::SetNumberOfPoints(const int &nrec) {
|
82
|
85
|
|
83
|
86
|
if (nrec > 0)
|
84
|
|
- this->NumberOfReceivers = nrec;
|
|
87
|
+ this->NumberOfPoints = nrec;
|
85
|
88
|
else
|
86
|
89
|
throw std::runtime_error("NUMBER RECEIVERS LESS THAN 1");
|
87
|
90
|
|
|
@@ -95,52 +98,52 @@ namespace Lemma {
|
95
|
98
|
ResizeHField();
|
96
|
99
|
}
|
97
|
100
|
|
98
|
|
- void ReceiverPoints::ResizeEField() {
|
|
101
|
+ void FieldPoints::ResizeEField() {
|
99
|
102
|
Efield.clear();
|
100
|
103
|
for (int i=0; i<NumberOfBinsE; ++i) {
|
101
|
104
|
Eigen::Matrix<Complex, 3, Eigen::Dynamic> tempe;
|
102
|
105
|
this->Efield.push_back(tempe);
|
103
|
|
- this->Efield[i].resize(Eigen::NoChange, NumberOfReceivers);
|
|
106
|
+ this->Efield[i].resize(Eigen::NoChange, NumberOfPoints);
|
104
|
107
|
this->Efield[i].setZero();
|
105
|
108
|
}
|
106
|
109
|
}
|
107
|
110
|
|
108
|
|
- void ReceiverPoints::ResizeHField() {
|
|
111
|
+ void FieldPoints::ResizeHField() {
|
109
|
112
|
Hfield.clear();
|
110
|
113
|
for (int i=0; i<NumberOfBinsH; ++i) {
|
111
|
114
|
Eigen::Matrix<Complex, 3, Eigen::Dynamic> temph;
|
112
|
115
|
this->Hfield.push_back(temph);
|
113
|
|
- this->Hfield[i].resize(Eigen::NoChange, NumberOfReceivers);
|
|
116
|
+ this->Hfield[i].resize(Eigen::NoChange, NumberOfPoints);
|
114
|
117
|
this->Hfield[i].setZero();
|
115
|
118
|
}
|
116
|
119
|
}
|
117
|
120
|
|
118
|
|
- void ReceiverPoints::SetNumberOfBinsE(const int& nbins) {
|
|
121
|
+ void FieldPoints::SetNumberOfBinsE(const int& nbins) {
|
119
|
122
|
NumberOfBinsE = nbins;
|
120
|
123
|
ResizeEField();
|
121
|
124
|
}
|
122
|
125
|
|
123
|
|
- void ReceiverPoints::SetNumberOfBinsH(const int& nbins) {
|
|
126
|
+ void FieldPoints::SetNumberOfBinsH(const int& nbins) {
|
124
|
127
|
NumberOfBinsH = nbins;
|
125
|
128
|
ResizeHField();
|
126
|
129
|
}
|
127
|
130
|
|
128
|
|
- void ReceiverPoints::SetLocation(const int&nrec,const Vector3r& loc) {
|
|
131
|
+ void FieldPoints::SetLocation(const int&nrec,const Vector3r& loc) {
|
129
|
132
|
this->Locations.col(nrec) = loc;
|
130
|
133
|
}
|
131
|
134
|
|
132
|
|
- void ReceiverPoints::SetLocation(const int&nrec,const Real& xp,
|
|
135
|
+ void FieldPoints::SetLocation(const int&nrec,const Real& xp,
|
133
|
136
|
const Real& yp, const Real& zp) {
|
134
|
137
|
this->Locations.col(nrec) << xp, yp, zp;
|
135
|
138
|
}
|
136
|
139
|
|
137
|
|
- void ReceiverPoints::SetEfield(const int& nbin,
|
|
140
|
+ void FieldPoints::SetEfield(const int& nbin,
|
138
|
141
|
const int& loc, const Complex &ex,
|
139
|
142
|
const Complex &ey, const Complex &ez) {
|
140
|
143
|
this->Efield[nbin].col(loc) << ex, ey, ez;
|
141
|
144
|
}
|
142
|
145
|
|
143
|
|
- void ReceiverPoints::AppendEfield(const int&nbin, const int& loc,
|
|
146
|
+ void FieldPoints::AppendEfield(const int&nbin, const int& loc,
|
144
|
147
|
const Complex &ex,
|
145
|
148
|
const Complex &ey, const Complex &ez) {
|
146
|
149
|
#ifdef LEMMAUSEOMP
|
|
@@ -149,13 +152,13 @@ namespace Lemma {
|
149
|
152
|
this->Efield[nbin].col(loc) += Vector3cr(ex, ey, ez); //temp;
|
150
|
153
|
}
|
151
|
154
|
|
152
|
|
- void ReceiverPoints::SetHfield(const int &nbin, const int& loc,
|
|
155
|
+ void FieldPoints::SetHfield(const int &nbin, const int& loc,
|
153
|
156
|
const Complex &hx, const Complex &hy,
|
154
|
157
|
const Complex &hz) {
|
155
|
158
|
this->Hfield[nbin].col(loc) << hx, hy, hz;
|
156
|
159
|
}
|
157
|
160
|
|
158
|
|
- void ReceiverPoints::AppendHfield(const int &nbin, const int& loc,
|
|
161
|
+ void FieldPoints::AppendHfield(const int &nbin, const int& loc,
|
159
|
162
|
const Complex &hx, const Complex &hy,
|
160
|
163
|
const Complex &hz) {
|
161
|
164
|
// #ifdef LEMMAUSEOMP
|
|
@@ -182,83 +185,83 @@ namespace Lemma {
|
182
|
185
|
|
183
|
186
|
|
184
|
187
|
// ==================== INQUIRY ===================================
|
185
|
|
- Vector3Xr ReceiverPoints::GetLocations() {
|
|
188
|
+ Vector3Xr FieldPoints::GetLocations() {
|
186
|
189
|
return this->Locations;
|
187
|
190
|
}
|
188
|
191
|
|
189
|
|
- MatrixXr ReceiverPoints::GetLocationsMat() {
|
|
192
|
+ MatrixXr FieldPoints::GetLocationsMat() {
|
190
|
193
|
return MatrixXr(this->Locations);
|
191
|
194
|
}
|
192
|
195
|
|
193
|
|
- Vector3r ReceiverPoints::GetLocation(const int &nrec) {
|
|
196
|
+ Vector3r FieldPoints::GetLocation(const int &nrec) {
|
194
|
197
|
return this->Locations.col(nrec);
|
195
|
198
|
}
|
196
|
199
|
|
197
|
|
- Real ReceiverPoints::GetLocationX(const int &nrec) {
|
|
200
|
+ Real FieldPoints::GetLocationX(const int &nrec) {
|
198
|
201
|
return this->Locations.col(nrec)[0];
|
199
|
202
|
}
|
200
|
203
|
|
201
|
|
- Real ReceiverPoints::GetLocationY(const int &nrec) {
|
|
204
|
+ Real FieldPoints::GetLocationY(const int &nrec) {
|
202
|
205
|
return this->Locations.col(nrec)[1];
|
203
|
206
|
}
|
204
|
207
|
|
205
|
|
- Real ReceiverPoints::GetLocationZ(const int &nrec) {
|
|
208
|
+ Real FieldPoints::GetLocationZ(const int &nrec) {
|
206
|
209
|
return this->Locations.col(nrec)[2];
|
207
|
210
|
}
|
208
|
211
|
|
209
|
|
- Vector3cr ReceiverPoints::GetEfield(const int &nfreq, const int&nrec) {
|
|
212
|
+ Vector3cr FieldPoints::GetEfield(const int &nfreq, const int&nrec) {
|
210
|
213
|
return this->Efield[nfreq].col(nrec);
|
211
|
214
|
}
|
212
|
215
|
|
213
|
|
- Vector3cr ReceiverPoints::GetHfield(const int &nfreq, const int&nrec) {
|
|
216
|
+ Vector3cr FieldPoints::GetHfield(const int &nfreq, const int&nrec) {
|
214
|
217
|
return this->Hfield[nfreq].col(nrec);
|
215
|
218
|
}
|
216
|
219
|
|
217
|
|
- std::vector<Vector3Xcr> ReceiverPoints::GetHfield( ) {
|
|
220
|
+ std::vector<Vector3Xcr> FieldPoints::GetHfield( ) {
|
218
|
221
|
return this->Hfield;
|
219
|
222
|
}
|
220
|
223
|
|
221
|
|
- std::vector<Vector3Xcr> ReceiverPoints::GetEfield( ) {
|
|
224
|
+ std::vector<Vector3Xcr> FieldPoints::GetEfield( ) {
|
222
|
225
|
return this->Efield;
|
223
|
226
|
}
|
224
|
227
|
|
225
|
|
- Vector3Xcr ReceiverPoints::GetEfield (const int &nfreq) {
|
|
228
|
+ Vector3Xcr FieldPoints::GetEfield (const int &nfreq) {
|
226
|
229
|
return this->Efield[nfreq];
|
227
|
230
|
}
|
228
|
231
|
|
229
|
|
- MatrixXcr ReceiverPoints::GetEfieldMat (const int &nfreq) {
|
|
232
|
+ MatrixXcr FieldPoints::GetEfieldMat (const int &nfreq) {
|
230
|
233
|
return MatrixXcr(this->Efield[nfreq]);
|
231
|
234
|
}
|
232
|
235
|
|
233
|
|
- MatrixXcr ReceiverPoints::GetHfieldMat (const int &nfreq) {
|
|
236
|
+ MatrixXcr FieldPoints::GetHfieldMat (const int &nfreq) {
|
234
|
237
|
return MatrixXcr(this->Hfield[nfreq]);
|
235
|
238
|
}
|
236
|
239
|
|
237
|
|
- Vector3Xcr ReceiverPoints::GetHfield (const int &nfreq) {
|
|
240
|
+ Vector3Xcr FieldPoints::GetHfield (const int &nfreq) {
|
238
|
241
|
return this->Hfield[nfreq];
|
239
|
242
|
}
|
240
|
243
|
|
241
|
|
- void ReceiverPoints::MaskPoint(const int& imask) {
|
|
244
|
+ void FieldPoints::MaskPoint(const int& imask) {
|
242
|
245
|
Mask(imask) = true;
|
243
|
246
|
}
|
244
|
247
|
|
245
|
|
- void ReceiverPoints::UnMaskPoint(const int& imask) {
|
|
248
|
+ void FieldPoints::UnMaskPoint(const int& imask) {
|
246
|
249
|
Mask(imask) = false;
|
247
|
250
|
}
|
248
|
251
|
|
249
|
|
- void ReceiverPoints::UnMaskAllPoints() {
|
|
252
|
+ void FieldPoints::UnMaskAllPoints() {
|
250
|
253
|
Mask.setZero();
|
251
|
254
|
}
|
252
|
255
|
|
253
|
|
- int ReceiverPoints::GetMask(const int& i) {
|
|
256
|
+ int FieldPoints::GetMask(const int& i) {
|
254
|
257
|
return Mask(i);
|
255
|
258
|
}
|
256
|
259
|
|
257
|
|
- int ReceiverPoints::GetNumberOfReceivers() {
|
258
|
|
- return this->NumberOfReceivers;
|
|
260
|
+ int FieldPoints::GetNumberOfPoints() {
|
|
261
|
+ return this->NumberOfPoints;
|
259
|
262
|
}
|
260
|
263
|
|
261
|
|
- void ReceiverPoints::ClearFields() {
|
|
264
|
+ void FieldPoints::ClearFields() {
|
262
|
265
|
for (int i=0; i<NumberOfBinsE; ++i) {
|
263
|
266
|
this->Efield[i].setZero();
|
264
|
267
|
}
|
|
@@ -267,42 +270,8 @@ namespace Lemma {
|
267
|
270
|
}
|
268
|
271
|
}
|
269
|
272
|
|
270
|
|
-
|
271
|
|
-#ifdef HAVE_YAMLCPP
|
272
|
|
- //--------------------------------------------------------------------------------------
|
273
|
|
- // Class: ReceiverPoints
|
274
|
|
- // Method: Serialize
|
275
|
|
- //--------------------------------------------------------------------------------------
|
276
|
|
- YAML::Node ReceiverPoints::Serialize ( ) const {
|
277
|
|
- YAML::Node node = LemmaObject::Serialize(); //static_cast<const LemmaObject*>(this)->Serialize();
|
278
|
|
- node.SetTag( this->Name ); // Set Tag after doing parents
|
279
|
|
-
|
280
|
|
- // update here
|
281
|
|
- node["NumberOfReceivers"] = NumberOfReceivers;
|
282
|
|
- node["NumberOfBinsE"] = NumberOfBinsE;
|
283
|
|
- node["NumberOfBinsH"] = NumberOfBinsH;
|
284
|
|
- //node["Mask"] = Mask;
|
285
|
|
- //std::cout << "Locations.data" << Locations.data()[0] << std::endl;
|
286
|
|
- // node["Locations"] = Locations.data(); // HUGE
|
287
|
|
- return node;
|
288
|
|
- } // ----- end of method ReceiverPoints::Serialize -----
|
289
|
|
-
|
290
|
|
-
|
291
|
|
- //--------------------------------------------------------------------------------------
|
292
|
|
- // Class: ReceiverPoints
|
293
|
|
- // Method: DeSerialize
|
294
|
|
- //--------------------------------------------------------------------------------------
|
295
|
|
- ReceiverPoints* ReceiverPoints::DeSerialize ( const YAML::Node& node ) {
|
296
|
|
- ReceiverPoints* Object = new ReceiverPoints(node);
|
297
|
|
- Object->AttachTo(Object);
|
298
|
|
- DESERIALIZECHECK( node, Object )
|
299
|
|
- return Object ;
|
300
|
|
- } // ----- end of method ReceiverPoints::DeSerialize -----
|
301
|
|
-#endif
|
302
|
|
-
|
303
|
|
-
|
304
|
273
|
#ifdef LEMMAUSEVTK
|
305
|
|
- vtkActor* ReceiverPoints::GetVtkGlyphActor(const FIELDTYPE &ftype,
|
|
274
|
+ vtkActor* FieldPoints::GetVtkGlyphActor(const FIELDTYPE &ftype,
|
306
|
275
|
const Real &clip, const Real &scale,
|
307
|
276
|
const int &nfreq) {
|
308
|
277
|
|
|
@@ -325,7 +294,7 @@ namespace Lemma {
|
325
|
294
|
vVects->SetNumberOfComponents(3);
|
326
|
295
|
|
327
|
296
|
// Make PointData
|
328
|
|
- for (int ic=0; ic<NumberOfReceivers; ++ic) {
|
|
297
|
+ for (int ic=0; ic<NumberOfPoints; ++ic) {
|
329
|
298
|
|
330
|
299
|
Vector3r loc = this->GetLocation(ic);
|
331
|
300
|
|
|
@@ -401,14 +370,14 @@ namespace Lemma {
|
401
|
370
|
return vActor;
|
402
|
371
|
}
|
403
|
372
|
|
404
|
|
- vtkDataObject* ReceiverPoints::GetVtkDataObject(const FIELDTYPE &ftype,
|
|
373
|
+ vtkDataObject* FieldPoints::GetVtkDataObject(const FIELDTYPE &ftype,
|
405
|
374
|
const int& nbin,
|
406
|
375
|
const int& start, const int& end,
|
407
|
376
|
const FIELDCOMPONENT& fcomp,
|
408
|
377
|
const SPATIALCOORDINANT &scord) {
|
409
|
378
|
|
410
|
379
|
if (start < 0) throw 77;
|
411
|
|
- if (end > NumberOfReceivers) throw 78;
|
|
380
|
+ if (end > NumberOfPoints) throw 78;
|
412
|
381
|
if (start > end) throw 79;
|
413
|
382
|
|
414
|
383
|
int ifc(-1);
|
|
@@ -487,7 +456,7 @@ namespace Lemma {
|
487
|
456
|
return _dataObject;
|
488
|
457
|
}
|
489
|
458
|
|
490
|
|
- vtkDataObject* ReceiverPoints::GetVtkDataObjectFreq(const FIELDTYPE &ftype,
|
|
459
|
+ vtkDataObject* FieldPoints::GetVtkDataObjectFreq(const FIELDTYPE &ftype,
|
491
|
460
|
const int& nrec,
|
492
|
461
|
const int& fstart, const int& fend,
|
493
|
462
|
const FIELDCOMPONENT& fcomp,
|