|
@@ -174,26 +174,32 @@ void LinearMag::ScaleB0 ( const MAGUNITS& U ) {
|
174
|
174
|
//--------------------------------------------------------------------------------------
|
175
|
175
|
void LinearMag::CalculateRHS ( const std::string& susName ) {
|
176
|
176
|
|
|
177
|
+ std::cout << "Calculating RHS...";
|
|
178
|
+ std::cout.flush();
|
|
179
|
+
|
177
|
180
|
if ( !vtkGrid->GetCellData()->GetScalars(susName.c_str()) ) {
|
178
|
181
|
std::string err("No cell data by name ");
|
179
|
182
|
err.append(susName);
|
180
|
183
|
throw std::runtime_error(err.c_str());
|
181
|
184
|
}
|
182
|
185
|
|
|
186
|
+ if (!vtkGrid->GetNumberOfPoints()) {
|
|
187
|
+ throw std::runtime_error("Number of points zero in input grid!");
|
|
188
|
+ }
|
|
189
|
+
|
183
|
190
|
vtkDoubleArray* G = vtkDoubleArray::New();
|
184
|
191
|
G->SetNumberOfComponents(1);
|
185
|
192
|
G->SetNumberOfTuples( vtkGrid->GetNumberOfPoints() );
|
186
|
193
|
G->SetName("G");
|
187
|
194
|
//g.resize(vtkGrid->GetNumberOfPoints());
|
188
|
195
|
VectorXr GG = VectorXr::Zero( vtkGrid->GetNumberOfPoints() );
|
189
|
|
-
|
|
196
|
+
|
190
|
197
|
// Iterate over all the points or all of the cells?
|
191
|
198
|
for (int ic=0; ic < vtkGrid->GetNumberOfCells(); ++ic) {
|
192
|
199
|
|
193
|
200
|
if ( vtkGrid->GetCell(ic)->GetNumberOfPoints() != 4 ) {
|
194
|
201
|
throw std::runtime_error("Non-tetrahedral mesh encountered!");
|
195
|
202
|
}
|
196
|
|
-
|
197
|
203
|
Real cellSus = vtkGrid->GetCellData()->GetScalars(susName.c_str())->GetTuple(ic)[0];
|
198
|
204
|
|
199
|
205
|
Eigen::Matrix<Real, 4, 4> C = Eigen::Matrix<Real, 4, 4>::Zero() ;
|
|
@@ -221,8 +227,6 @@ void LinearMag::CalculateRHS ( const std::string& susName ) {
|
221
|
227
|
*/
|
222
|
228
|
// Face 0, ID 0,1,2
|
223
|
229
|
Eigen::Matrix<Real, 3, 2> CC = Eigen::Matrix<Real, 3, 2>::Ones() ;
|
224
|
|
- {
|
225
|
|
-
|
226
|
230
|
CC.col(1) = C.row(0).tail<3>() - C.row(1).tail<3>();
|
227
|
231
|
CC.col(2) = C.row(0).tail<3>() - C.row(2).tail<3>();
|
228
|
232
|
Vector3r nhat = CC.col(1).cross(CC.col(2));
|
|
@@ -231,8 +235,7 @@ void LinearMag::CalculateRHS ( const std::string& susName ) {
|
231
|
235
|
GG(ID[0]) += flux;
|
232
|
236
|
GG(ID[1]) += flux;
|
233
|
237
|
GG(ID[2]) += flux;
|
234
|
|
- }
|
235
|
|
- // Face 1, ID 0,1,3
|
|
238
|
+ // Face 1, ID 0,1,3
|
236
|
239
|
{
|
237
|
240
|
CC.col(1) = C.row(0).tail<3>() - C.row(1).tail<3>();
|
238
|
241
|
CC.col(2) = C.row(0).tail<3>() - C.row(3).tail<3>();
|
|
@@ -243,7 +246,7 @@ void LinearMag::CalculateRHS ( const std::string& susName ) {
|
243
|
246
|
GG(ID[1]) += flux;
|
244
|
247
|
GG(ID[3]) += flux;
|
245
|
248
|
}
|
246
|
|
- // Face 1, ID 0,2,3
|
|
249
|
+ // Face 2, ID 0,2,3
|
247
|
250
|
{
|
248
|
251
|
CC.col(1) = C.row(0).tail<3>() - C.row(2).tail<3>();
|
249
|
252
|
CC.col(2) = C.row(0).tail<3>() - C.row(3).tail<3>();
|
|
@@ -254,7 +257,7 @@ void LinearMag::CalculateRHS ( const std::string& susName ) {
|
254
|
257
|
GG(ID[2]) += flux;
|
255
|
258
|
GG(ID[3]) += flux;
|
256
|
259
|
}
|
257
|
|
- // Face 1, ID 1,2,3
|
|
260
|
+ // Face 3, ID 1,2,3
|
258
|
261
|
{
|
259
|
262
|
CC.col(1) = C.row(1).tail<3>() - C.row(2).tail<3>();
|
260
|
263
|
CC.col(2) = C.row(1).tail<3>() - C.row(3).tail<3>();
|
|
@@ -273,6 +276,8 @@ void LinearMag::CalculateRHS ( const std::string& susName ) {
|
273
|
276
|
|
274
|
277
|
vtkGrid->GetPointData()->AddArray( G );
|
275
|
278
|
vtkGrid->GetPointData()->SetScalars( G );
|
|
279
|
+ std::cout << "finished" << std::endl;
|
|
280
|
+
|
276
|
281
|
return ;
|
277
|
282
|
} // ----- end of method LinearMag::CalculateRHS -----
|
278
|
283
|
|