Explorar el Código

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

master
Trevor Irons hace 5 años
padre
commit
b473bf7daf

+ 2
- 9
Modules/FDEM1D/include/KernelEM1DReflBase.h Ver fichero

@@ -64,13 +64,6 @@ namespace Lemma {
64 64
                 Zyi = VectorXcr::Zero(nlay);
65 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 67
                 Earth = EarthIn;
75 68
 
76 69
                 LayerThickness.resize(nlay);
@@ -231,11 +224,11 @@ namespace Lemma {
231 224
 			VectorXr     LayerThickness;
232 225
 			VectorXr     LayerDepth;
233 226
 
234
-			/// Reflection/Transmission coeffients for upgoing waves in a
227
+			/// Reflection/Transmission coef. for upgoing waves in a
235 228
 			/// layered earth model
236 229
 			VectorXcr    rtu;
237 230
 
238
-			/// Reflection/Transmission coeffients for downgoing waves in
231
+			/// Reflection/Transmission coef. for downgoing waves in
239 232
 			/// a layered earth model
240 233
 			VectorXcr    rtd;
241 234
 

+ 2
- 10
Modules/FDEM1D/include/PolygonalWireAntenna.h Ver fichero

@@ -8,7 +8,6 @@
8 8
   @file
9 9
   @author   Trevor Irons
10 10
   @date     05/18/2010
11
-  @version  $Id: PolygonalWireAntenna.h 211 2015-02-27 05:43:26Z tirons $
12 11
  **/
13 12
 #ifndef  POLYGONALWIREANTENNA_INC
14 13
 #define  POLYGONALWIREANTENNA_INC
@@ -145,15 +144,8 @@ namespace Lemma {
145 144
                             const Vector3r &rp);
146 145
 
147 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 150
         private:
159 151
 

+ 13
- 9
Modules/FDEM1D/src/PolygonalWireAntenna.cpp Ver fichero

@@ -121,10 +121,15 @@ namespace Lemma {
121 121
         if ( (rRepeat-rp).norm() > 1e-16 ) {
122 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 128
 		    // loop over all segments
125 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 133
             rRepeat = rp;
129 134
 
130 135
         } else {
@@ -191,8 +196,8 @@ namespace Lemma {
191 196
 	}
192 197
 
193 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 202
 		Vector3r phat = (p1-p2).array() / (p1-p2).norm();
198 203
 		Vector3r c    = this->ClosestPointOnLine(p1, p2, tp);
@@ -203,10 +208,6 @@ namespace Lemma {
203 208
         // unit vector
204 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 211
 		// go towards p1
211 212
 		if ( ((c-p1).array().abs() > minDipoleMoment).any() ) {
212 213
 
@@ -319,8 +320,11 @@ namespace Lemma {
319 320
 			}
320 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…
Cancelar
Guardar