소스 검색

Few changes to coupling code

master
Trevor Irons 8 년 전
부모
커밋
774a56095b
3개의 변경된 파일14개의 추가작업 그리고 18개의 파일을 삭제
  1. 3
    3
      examples/Coupling.cpp
  2. 2
    2
      include/Coupling.h
  3. 9
    13
      src/Coupling.cpp

+ 3
- 3
examples/Coupling.cpp 파일 보기

@@ -44,13 +44,13 @@ int main(int argc, char** argv) {
44 44
         Kern->PushCoil( "Coil 2", Tx2 );
45 45
         Kern->SetLayeredEarthEM( earth );
46 46
 
47
-        Kern->SetIntegrationSize( (Vector3r() << 200,200,200).finished() );
48
-        Kern->SetIntegrationOrigin( (Vector3r() << 0,0,2).finished() );
47
+        Kern->SetIntegrationSize( (Vector3r() << 200,200,50).finished() );
48
+        Kern->SetIntegrationOrigin( (Vector3r() << 0,0,5).finished() );
49 49
         Kern->SetTolerance( 1e-7 ); // 1e-12
50 50
 
51 51
     std::vector<std::string> tx = {std::string("Coil 1")};
52 52
     std::vector<std::string> rx = {std::string("Coil 2")};
53
-    VectorXr Offsets = VectorXr::LinSpaced(60,0.25,60); // nbins, low, high
53
+    VectorXr Offsets = VectorXr::LinSpaced(60, 5.25, 60); // nbins, low, high
54 54
 
55 55
     auto outfile = std::ofstream("coupling.dat");
56 56
     for (int ii=0; ii< Offsets.size(); ++ii) {

+ 2
- 2
include/Coupling.h 파일 보기

@@ -213,7 +213,7 @@ namespace Lemma {
213 213
          *  HyperOctree, which is useful for visualization.
214 214
          */
215 215
         void EvaluateKids2(  const Vector3r& size, const int& level, const Vector3r& cpos,
216
-                            const VectorXcr& parentVal, vtkHyperOctree* octree, vtkHyperOctreeCursor* curse );
216
+                            const Complex& parentVal, vtkHyperOctree* octree, vtkHyperOctreeCursor* curse );
217 217
 
218 218
         void GetPosition( vtkHyperOctreeCursor* Cursor, Real* p );
219 219
         #endif
@@ -241,7 +241,7 @@ namespace Lemma {
241 241
         std::map< std::string , std::shared_ptr< EMEarth1D > >             EMEarths;
242 242
 
243 243
         #ifdef LEMMAUSEVTK
244
-        std::map< int, VectorXcr  >               LeafDict;
244
+        std::map< int, Complex  >                 LeafDict;
245 245
         std::map< int, int     >                  LeafDictIdx;
246 246
         std::map< int, Real     >                 LeafDictErr;
247 247
         #endif

+ 9
- 13
src/Coupling.cpp 파일 보기

@@ -163,9 +163,7 @@ namespace Lemma {
163 163
                 oct->SetSize( Size(0), Size(1), Size(2) );
164 164
             vtkHyperOctreeCursor* curse = oct->NewCellCursor();
165 165
                 curse->ToRoot();
166
-            EvaluateKids2( Size, 0, cpos, VectorXcr::Ones(PulseI.size()), oct, curse );
167
-
168
-            for (int iq=0; iq<PulseI.size(); ++iq) {
166
+            EvaluateKids2( Size, 0, cpos, Complex(100.0), oct, curse );
169 167
 
170 168
             // Fill in leaf data
171 169
             vtkDoubleArray* kr = vtkDoubleArray::New();
@@ -190,9 +188,9 @@ namespace Lemma {
190 188
 
191 189
             //Real LeafVol(0);
192 190
             for (auto leaf : LeafDict) {
193
-                kr->InsertTuple1( leaf.first, std::real(leaf.second(iq)) );
194
-                ki->InsertTuple1( leaf.first, std::imag(leaf.second(iq)) );
195
-                km->InsertTuple1( leaf.first, std::abs(leaf.second(iq)) );
191
+                kr->InsertTuple1( leaf.first, std::real(leaf.second) );
192
+                ki->InsertTuple1( leaf.first, std::imag(leaf.second) );
193
+                km->InsertTuple1( leaf.first, std::abs(leaf.second) );
196 194
                 kid->InsertTuple1( leaf.first, leaf.first );
197 195
                 //LeafVol += std::real(leaf.second);
198 196
             }
@@ -211,8 +209,7 @@ namespace Lemma {
211 209
             auto write = vtkXMLHyperOctreeWriter::New();
212 210
                 //write.SetDataModeToAscii()
213 211
                 write->SetInputData(oct);
214
-                std::string fname = std::string("octree-") + to_string(ilay)
215
-                                  + std::string("-") + to_string(iq) + std::string(".vto");
212
+                std::string fname = std::string("octree-couple") + std::string(".vto");
216 213
                 write->SetFileName(fname.c_str());
217 214
                 write->Write();
218 215
                 write->Delete();
@@ -229,8 +226,6 @@ namespace Lemma {
229 226
             ki->Delete();
230 227
             km->Delete();
231 228
 
232
-            }
233
-
234 229
             curse->Delete();
235 230
             oct->Delete();
236 231
         #else
@@ -248,6 +243,7 @@ namespace Lemma {
248 243
     //--------------------------------------------------------------------------------------
249 244
     Complex Coupling::f( const Vector3r& r, const Real& volume, const Vector3cr& Ht, const Vector3cr& Hr ) {
250 245
         return volume*Ht.dot(Hr);
246
+        //return Ht.dot(Hr);
251 247
     }
252 248
 
253 249
     //--------------------------------------------------------------------------------------
@@ -258,7 +254,7 @@ namespace Lemma {
258 254
         const Complex& parentVal ) {
259 255
 
260 256
         std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
261
-        //std::cout.flush();
257
+        std::cout.flush();
262 258
 
263 259
         // Next level step, interested in one level below
264 260
         // bitshift requires one extra, faster than, and equivalent to std::pow(2, level+1)
@@ -410,14 +406,14 @@ namespace Lemma {
410 406
                 }
411 407
                 */
412 408
                 /* End of position test */
413
-                EvaluateKids2( size, level+1, cp, kvals.row(ichild), oct, curse );
409
+                EvaluateKids2( size, level+1, cp, kvals(ichild), oct, curse );
414 410
                 curse->ToParent();
415 411
             }
416 412
             return;  // not a leaf
417 413
         }
418 414
         LeafDict[curse->GetLeafId()] = ksum/(8.*vol);
419 415
         LeafDictIdx[curse->GetLeafId()] = nleaves;
420
-        Kern.row(ilay) += ksum;
416
+        SUM += ksum;
421 417
         VOLSUM += 8*vol;
422 418
         nleaves += 1;
423 419
         return;     // is a leaf

Loading…
취소
저장