Browse Source

Polygonal wire antenna now uses std::move realizing some perf. benefits.

master
Trevor Irons 4 years ago
parent
commit
b473bf7daf

+ 2
- 9
Modules/FDEM1D/include/KernelEM1DReflBase.h View File

64
                 Zyi = VectorXcr::Zero(nlay);
64
                 Zyi = VectorXcr::Zero(nlay);
65
                 th = VectorXcr::Zero(nlay);
65
                 th = VectorXcr::Zero(nlay);
66
 
66
 
67
-                // Don't attach Earth, because this is performance critical.
68
-                // Everying is internal, it's OK relax Frankie
69
-                //if (Earth != NULL) {
70
-                //    Earth->DetachFrom(this);
71
-                //    Earth = NULL;
72
-                //}
73
-                //EarthIn->AttachTo(this);
74
                 Earth = EarthIn;
67
                 Earth = EarthIn;
75
 
68
 
76
                 LayerThickness.resize(nlay);
69
                 LayerThickness.resize(nlay);
231
 			VectorXr     LayerThickness;
224
 			VectorXr     LayerThickness;
232
 			VectorXr     LayerDepth;
225
 			VectorXr     LayerDepth;
233
 
226
 
234
-			/// Reflection/Transmission coeffients for upgoing waves in a
227
+			/// Reflection/Transmission coef. for upgoing waves in a
235
 			/// layered earth model
228
 			/// layered earth model
236
 			VectorXcr    rtu;
229
 			VectorXcr    rtu;
237
 
230
 
238
-			/// Reflection/Transmission coeffients for downgoing waves in
231
+			/// Reflection/Transmission coef. for downgoing waves in
239
 			/// a layered earth model
232
 			/// a layered earth model
240
 			VectorXcr    rtd;
233
 			VectorXcr    rtd;
241
 
234
 

+ 2
- 10
Modules/FDEM1D/include/PolygonalWireAntenna.h View File

8
   @file
8
   @file
9
   @author   Trevor Irons
9
   @author   Trevor Irons
10
   @date     05/18/2010
10
   @date     05/18/2010
11
-  @version  $Id: PolygonalWireAntenna.h 211 2015-02-27 05:43:26Z tirons $
12
  **/
11
  **/
13
 #ifndef  POLYGONALWIREANTENNA_INC
12
 #ifndef  POLYGONALWIREANTENNA_INC
14
 #define  POLYGONALWIREANTENNA_INC
13
 #define  POLYGONALWIREANTENNA_INC
145
                             const Vector3r &rp);
144
                             const Vector3r &rp);
146
 
145
 
147
             /// Interpolates dipoles along line segment defined by p0 and p1.
146
             /// Interpolates dipoles along line segment defined by p0 and p1.
148
-            void InterpolateLineSegment(const Vector3r &p0, const Vector3r &p1,
149
-                            const Vector3r &rp);
150
-
151
-
152
-            /// List of the dipoles
153
-            //std::vector<DipoleSource*>           Dipoles;
154
-
155
-            /// Points that define this loop
156
-            //Vector3Xr                            Points;
147
+            void InterpolateLineSegment(const Vector3r &p0, const Vector3r &p1, const Vector3r &rp,
148
+                            std::vector< std::shared_ptr<DipoleSource> > &Dipoles );
157
 
149
 
158
         private:
150
         private:
159
 
151
 

+ 13
- 9
Modules/FDEM1D/src/PolygonalWireAntenna.cpp View File

121
         if ( (rRepeat-rp).norm() > 1e-16 ) {
121
         if ( (rRepeat-rp).norm() > 1e-16 ) {
122
 		    Dipoles.clear();
122
 		    Dipoles.clear();
123
 
123
 
124
+            ///////////////////
125
+		    // dipole array, this has impoved performance over directly pushing
126
+		    std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
127
+
124
 		    // loop over all segments
128
 		    // loop over all segments
125
 		    for (int iseg=0; iseg<NumberOfPoints-1; ++iseg) {
129
 		    for (int iseg=0; iseg<NumberOfPoints-1; ++iseg) {
126
-			    InterpolateLineSegment(Points.col(iseg), Points.col(iseg+1), rp);
130
+			    InterpolateLineSegment(Points.col(iseg), Points.col(iseg+1), rp, xDipoles);
127
 		    }
131
 		    }
132
+            Dipoles = std::move(xDipoles);
128
             rRepeat = rp;
133
             rRepeat = rp;
129
 
134
 
130
         } else {
135
         } else {
191
 	}
196
 	}
192
 
197
 
193
 	void PolygonalWireAntenna::InterpolateLineSegment(const Vector3r &p1,
198
 	void PolygonalWireAntenna::InterpolateLineSegment(const Vector3r &p1,
194
-					const Vector3r &p2, const Vector3r & tp) {
195
-
199
+					const Vector3r &p2, const Vector3r & tp,
200
+					std::vector< std::shared_ptr<DipoleSource> > &xDipoles ) {
196
 
201
 
197
 		Vector3r phat = (p1-p2).array() / (p1-p2).norm();
202
 		Vector3r phat = (p1-p2).array() / (p1-p2).norm();
198
 		Vector3r c    = this->ClosestPointOnLine(p1, p2, tp);
203
 		Vector3r c    = this->ClosestPointOnLine(p1, p2, tp);
203
         // unit vector
208
         // unit vector
204
 		Vector3r cdir = (p2-p1).array() / (p2-p1).norm();
209
 		Vector3r cdir = (p2-p1).array() / (p2-p1).norm();
205
 
210
 
206
-		///////////////////
207
-		// dipoles for this segment
208
-		std::vector< std::shared_ptr<DipoleSource> >       xDipoles;
209
-
210
 		// go towards p1
211
 		// go towards p1
211
 		if ( ((c-p1).array().abs() > minDipoleMoment).any() ) {
212
 		if ( ((c-p1).array().abs() > minDipoleMoment).any() ) {
212
 
213
 
319
 			}
320
 			}
320
 			// else case 0: nearly 'perfect' fit do nothing
321
 			// else case 0: nearly 'perfect' fit do nothing
321
 		}
322
 		}
322
-		Dipoles.insert(Dipoles.end(), xDipoles.begin(), xDipoles.end());
323
-	}
324
 
323
 
324
+        //Dipoles.insert(Dipoles.end(), xDipoles.begin(), xDipoles.end());
325
+        //Dipoles = xDipoles;
326
+        //xDipoles.clear();
327
+
328
+	}
325
 
329
 
326
 }
330
 }

Loading…
Cancel
Save