Browse Source

Work towards new Merlin

master
T-bone 7 years ago
parent
commit
d92d993d72
3 changed files with 117 additions and 11 deletions
  1. 14
    8
      include/KernelV0.h
  2. BIN
      src/.KernelV0.cpp.swp
  3. 103
    3
      src/KernelV0.cpp

+ 14
- 8
include/KernelV0.h View File

@@ -121,12 +121,12 @@ namespace Lemma {
121 121
         }
122 122
 
123 123
         /**
124
-         *
124
+         *   Calculates a single imaging kernel, however, phased arrays are supported
125
+         *   so that more than one transmitter and/or receiver can be specified.
126
+         *   @param[in]
125 127
          */
126 128
         void CalculateK0 (const std::vector< std::string >& tx, const std::vector< std::string >& rx );
127 129
 
128
-        void CalculateK0 (const char* tx, const char* rx );
129
-
130 130
         // ====================  INQUIRY       =======================
131 131
         /**
132 132
          *  Returns the name of the underlying class, similiar to Python's type
@@ -143,11 +143,17 @@ namespace Lemma {
143 143
         /** Copy is disabled */
144 144
         KernelV0( const KernelV0& ) = delete;
145 145
 
146
-        // ====================  DATA MEMBERS  =========================
147
-
148 146
         private:
149 147
 
150
-        std::shared_ptr< LayeredEarthEM >        SigmaModel;
148
+        void IntegrateOnOctreeGrid( const Real& tolerance );
149
+
150
+        void EvaluateKids();
151
+
152
+        void EvaluateKids( const Complex& parentVal );
153
+
154
+        // ====================  DATA MEMBERS  =========================
155
+
156
+        std::shared_ptr< LayeredEarthEM >        SigmaModel = nullptr;
151 157
 
152 158
         std::map< std::string , std::shared_ptr< PolygonalWireAntenna > >  TxRx;
153 159
 
@@ -157,7 +163,7 @@ namespace Lemma {
157 163
     }; // -----  end of class  KernelV0  -----
158 164
 }  // -----  end of namespace Lemma ----
159 165
 
160
-/* vim: set tabstop=4 expandtab: */
161
-/* vim: set filetype=cpp: */
166
+/* vim: set tabstop=4 expandtab */
167
+/* vim: set filetype=cpp */
162 168
 
163 169
 #endif   // ----- #ifndef KERNELV0_INC  -----

BIN
src/.KernelV0.cpp.swp View File


+ 103
- 3
src/KernelV0.cpp View File

@@ -128,12 +128,112 @@ namespace Lemma {
128 128
 
129 129
     }
130 130
 
131
-    void KernelV0::CalculateK0 ( const char* tx, const char* rx ) {
131
+    //--------------------------------------------------------------------------------------
132
+    //       Class:  KernelV0
133
+    //      Method:  IntegrateOnOctreeGrid
134
+    //--------------------------------------------------------------------------------------
135
+    void KernelV0::IntegrateOnOctreeGrid( const Real& tolerance) {
136
+
137
+        Vector3r                Size;
138
+        Vector3r                Origin;
139
+        Vector3r                step;
140
+        Vector3r                cpos;
141
+
142
+        int                     level;
143
+        int                     maxlevel;
144
+        int                     index;
145
+        int                     counter;
146
+
147
+        Real                    cvol;
148
+        Real                    tvol;
149
+        Real                    tol;
150
+        Complex                 KernelSum;
151
+
152
+        //this->tol = tolerance;
153
+        Real KernelSum = 0.;
154
+        //Cursor->ToRoot();
155
+        //Cubes->SetNumberOfReceivers(8);
156
+        EvaluateKids( 1e9 ); // Large initial number don't waste time actually computing
157
+        //EvaluateKids();
158
+        //std::cout << "Kernel Sum from Generate Mesh "
159
+        //    << std::real(KernelSum) << "\t" << std::imag(KernelSum) << std::endl;
160
+
161
+        // old VTK thingy
162
+        //SetLeafDataFromGridCreation();
163
+    }
164
+
165
+    //--------------------------------------------------------------------------------------
166
+    //       Class:  KernelV0
167
+    //      Method:  EvaluateKids
168
+    //--------------------------------------------------------------------------------------
169
+    void KernelV0::EvaluateKids(const Complex& kval) {
170
+
171
+        assert("Evaluate Kids pre" && Cursor->CurrentIsLeaf());
172
+        vtkHyperOctreeCursor *tcurse = Cursor->Clone();
173
+        Real p[3];
174
+        Octree->SubdivideLeaf(Cursor);
175
+        tcurse->ToSameNode(Cursor);
176
+        std::cout << "\rPredivide Leaf count: " << Octree->GetNumberOfLeaves();
177
+
178
+        //std::cout.flush();
179
+        for (int child=0; child<8; ++child) {
180
+            Cursor->ToChild(child);
181
+            assert(Cursor->CurrentIsLeaf());
182
+            // Build cube
183
+            GetPosition(p);
184
+            cpos <<  p[0], p[1], p[2];
185
+            step  = ((Size).array() / std::pow(2.,Cursor->GetCurrentLevel()));
186
+            Cubes->SetLocation(child, cpos);
187
+            Cubes->SetLength(child, step);
188
+            //std::cout << "child " << child << " cpos\t" << cpos.transpose() << std::endl;
189
+            //std::cout << "child " << child << " step\t" << step.transpose() << std::endl;
190
+            Cursor->ToSameNode(tcurse);
191
+        }
132 192
 
193
+        // make calculation
194
+        Cubes->ClearFields();
195
+        VectorXcr f = SenseKernel->ComputeSensitivity();
196
+        if ( std::abs(std::abs(kval) - std::abs(f.array().abs().sum())) <= tol ||
197
+            Cursor->GetCurrentLevel() >= maxlevel ) {
198
+    	    // stop subdividing, save result
199
+    	    for (int child=0; child < 8; ++ child) {
200
+    	        Cursor->ToChild(child);
201
+    	        leafdata.push_back( std::abs(f(child)) / Cubes->GetVolume(child) );
202
+    	        // TODO fval is just a test
203
+    	        //leafdata.push_back( fval );
204
+    	        leafids.push_back(Cursor->GetLeafId());
205
+    	        KernelSum += f(child);
206
+    	        Cursor->ToParent();
207
+            }
208
+    	    return;
209
+        }
210
+
211
+        //std::cout << std::abs(kval) << "\t" <<
212
+        //         std::abs(f.array().abs().sum()) << "\t" << tol << std::endl;
213
+        for (int child=0; child < 8; ++ child) {
214
+            //std::cout << "Down the rabit hole " <<std::endl;
215
+            Cursor->ToChild(child);
216
+            EvaluateKids( f(child) );
217
+            //Cursor->ToParent();
218
+            Cursor->ToSameNode(tcurse);
219
+        }
220
+        tcurse->Delete();
221
+    }
222
+
223
+    //--------------------------------------------------------------------------------------
224
+    //       Class:  KernelV0
225
+    //      Method:  EvaluateKids
226
+    //--------------------------------------------------------------------------------------
227
+    void OctreeGrid::GetPosition( Real* p ) {
228
+        Real ratio=1.0/(1<<(Cursor->GetCurrentLevel()));
229
+        //step  = ((Size).array() / std::pow(2.,Cursor->GetCurrentLevel()));
230
+        p[0]=(Cursor->GetIndex(0)+.5)*ratio*Size[0]+Origin[0] ;//+ .5*step[0];
231
+        p[1]=(Cursor->GetIndex(1)+.5)*ratio*Size[1]+Origin[1] ;//+ .5*step[1];
232
+        p[2]=(Cursor->GetIndex(2)+.5)*ratio*Size[2]+Origin[2] ;//+ .5*step[2];
133 233
     }
134 234
 
135 235
 } // ----  end of namespace Lemma  ----
136 236
 
137
-/* vim: set tabstop=4 expandtab: */
138
-/* vim: set filetype=cpp: */
237
+/* vim: set tabstop=4 expandtab */
238
+/* vim: set filetype=cpp */
139 239
 

Loading…
Cancel
Save