Просмотр исходного кода

Few changes to coupling code

master
Trevor Irons 7 лет назад
Родитель
Сommit
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
         Kern->PushCoil( "Coil 2", Tx2 );
44
         Kern->PushCoil( "Coil 2", Tx2 );
45
         Kern->SetLayeredEarthEM( earth );
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
         Kern->SetTolerance( 1e-7 ); // 1e-12
49
         Kern->SetTolerance( 1e-7 ); // 1e-12
50
 
50
 
51
     std::vector<std::string> tx = {std::string("Coil 1")};
51
     std::vector<std::string> tx = {std::string("Coil 1")};
52
     std::vector<std::string> rx = {std::string("Coil 2")};
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
     auto outfile = std::ofstream("coupling.dat");
55
     auto outfile = std::ofstream("coupling.dat");
56
     for (int ii=0; ii< Offsets.size(); ++ii) {
56
     for (int ii=0; ii< Offsets.size(); ++ii) {

+ 2
- 2
include/Coupling.h Просмотреть файл

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

+ 9
- 13
src/Coupling.cpp Просмотреть файл

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

Загрузка…
Отмена
Сохранить