|
@@ -221,8 +221,8 @@ namespace Lemma {
|
221
|
221
|
|
222
|
222
|
//#ifdef CGSOLVE
|
223
|
223
|
//Eigen::ConjugateGradient<Eigen::SparseMatrix<Real, Eigen::Lower > Eigen::DiagonalPreconditioner > cg;
|
224
|
|
- Eigen::ConjugateGradient< Eigen::SparseMatrix<Real> > cg(A);
|
225
|
|
- //Eigen::BiCGSTAB<Eigen::SparseMatrix<Real> > cg(A);
|
|
224
|
+ //Eigen::ConjugateGradient< Eigen::SparseMatrix<Real> > cg(A);
|
|
225
|
+ Eigen::BiCGSTAB<Eigen::SparseMatrix<Real> > cg(A);
|
226
|
226
|
//cg.setMaxIterations(3000);
|
227
|
227
|
//cg.setTolerance(1e-28);
|
228
|
228
|
VectorXr u = cg.solve(g);
|
|
@@ -340,21 +340,24 @@ namespace Lemma {
|
340
|
340
|
|
341
|
341
|
|
342
|
342
|
for (int ii=0; ii<4; ++ii) {
|
343
|
|
- for (int jj=0; jj<4; ++jj) {
|
344
|
|
- /* homogeneous Dirichlet boundary */
|
345
|
|
- if (jj==ii && C(ii,3)==13.5) {
|
346
|
|
- //Real bb = vtkGrid->GetPointData()->GetScalars("HomogeneousDirichlet")->GetTuple(ID[ii])[0];
|
347
|
|
- //if (jj==ii && ((bb-1.)<1e-8) ) {
|
348
|
|
- // Apply Homogeneous Dirichlet Boundary conditions
|
349
|
|
- Real bb = vtkGrid->GetPointData()->GetScalars("HomogeneousDirichlet")->GetTuple(ID[ii])[0];
|
350
|
|
- Real bdry = (1./(BndryH*BndryH))*BndrySigma*bb; // + sum;
|
351
|
|
- //Real bdry = GradPhi.col(ii).tail<3>().dot(GradPhi.col(ii).tail<3>())*BndrySigma*bb; // + sum;
|
352
|
|
- coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[jj], bdry + GradPhi.col(ii).tail<3>().dot(GradPhi.col(jj).tail<3>() ) * V * sigma_bar ) );
|
353
|
|
- //coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[jj], 1));
|
354
|
|
- //break;
|
355
|
|
- } else {
|
|
343
|
+ int bbi = vtkGrid->GetPointData()->GetScalars("HomogeneousDirichlet")->GetTuple(ID[ii])[0];
|
|
344
|
+ if (bbi) {
|
|
345
|
+ coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[ii], 1));
|
|
346
|
+ } else {
|
|
347
|
+ for (int jj=0; jj<4; ++jj) {
|
|
348
|
+ /* homogeneous Dirichlet boundary */
|
|
349
|
+ //if (jj==ii && C(ii,3)==13.5) {
|
|
350
|
+ //if (jj==ii && ((bb-1.)<1e-8) ) {
|
|
351
|
+ // Apply Homogeneous Dirichlet Boundary conditions
|
|
352
|
+ // Real bb = vtkGrid->GetPointData()->GetScalars("HomogeneousDirichlet")->GetTuple(ID[ii])[0];
|
|
353
|
+ // Real bdry = (1./(BndryH*BndryH))*BndrySigma*bb; // + sum;
|
|
354
|
+ //Real bdry = GradPhi.col(ii).tail<3>().dot(GradPhi.col(ii).tail<3>())*BndrySigma*bb; // + sum;
|
|
355
|
+ // coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[jj], bdry + GradPhi.col(ii).tail<3>().dot(GradPhi.col(jj).tail<3>() ) * V * sigma_bar ) );
|
|
356
|
+ //coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[jj], 1));
|
|
357
|
+ //break;
|
|
358
|
+ //} else {
|
356
|
359
|
coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[jj], GradPhi.col(ii).tail<3>().dot(GradPhi.col(jj).tail<3>() ) * V * sigma_bar ) );
|
357
|
|
- }
|
|
360
|
+ //}
|
358
|
361
|
/* */
|
359
|
362
|
/* Inhomogeneous Dirichlet */
|
360
|
363
|
//coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[jj], GradPhi.col(ii).tail<3>().dot(GradPhi.col(jj).tail<3>())*V*sigma_bar ));
|
|
@@ -362,6 +365,7 @@ namespace Lemma {
|
362
|
365
|
//coeffs.push_back( Eigen::Triplet<Real> ( ID[ii], ID[jj], GradPhi.col(ii).tail<3>().dot(GradPhi.col(jj).tail<3>() ) * V * sigma_bar ) );
|
363
|
366
|
}
|
364
|
367
|
}
|
|
368
|
+ }
|
365
|
369
|
//std::cout << "\r" << (int)(1e2*((float)(ic) / (float)(vtkGrid->GetNumberOfCells()))) << std::flush ;
|
366
|
370
|
}
|
367
|
371
|
A.setFromTriplets(coeffs.begin(), coeffs.end());
|
|
@@ -409,6 +413,7 @@ namespace Lemma {
|
409
|
413
|
}
|
410
|
414
|
*/
|
411
|
415
|
|
|
416
|
+ /*
|
412
|
417
|
VectorXr W = VectorXr::Zero(4);
|
413
|
418
|
for (int ii=0; ii<4; ++ii) {
|
414
|
419
|
W[ii] = vtkGrid->GetPointData()->GetScalars("HomogeneousDirichlet")->GetTuple(ID[ii])[0] *
|
|
@@ -419,6 +424,7 @@ namespace Lemma {
|
419
|
424
|
//auto G = GradPhi.block<3,4>(1,0).transpose()*GradPhi.block<3,4>(1,0)*W;
|
420
|
425
|
VectorXr G = GradPhi.block<3,4>(1,0).transpose()*GradPhi.block<3,4>(1,0)*W;
|
421
|
426
|
Real sigma_bar(1.);
|
|
427
|
+ */
|
422
|
428
|
|
423
|
429
|
for (int ii=0; ii<4; ++ii) {
|
424
|
430
|
// avg += vtkGrid->GetPointData()->GetScalars()->GetTuple(ID[ii])[0];
|
|
@@ -427,10 +433,14 @@ namespace Lemma {
|
427
|
433
|
//TODO this seems wrong!
|
428
|
434
|
//avg /= 4.;
|
429
|
435
|
// TODO test code remove
|
430
|
|
- g(ID[ii]) += V/4*(vtkGrid->GetPointData()->GetScalars("G")->GetTuple(ID[ii])[0]) ;
|
431
|
|
- if (std::abs(C(ii,3)-13.5) > 1e-5) {
|
432
|
|
- g(ID[ii]) -= G[ii]*(V/3.)*sigma_bar;
|
|
436
|
+ if (vtkGrid->GetPointData()->GetScalars("HomogeneousDirichlet")->GetTuple(ID[ii])[0]) {
|
|
437
|
+ g(ID[ii]) += vtkGrid->GetPointData()->GetScalars("analytic_phi")->GetTuple(ID[ii])[0];
|
|
438
|
+ } else {
|
|
439
|
+ g(ID[ii]) += (3.0*V)*(vtkGrid->GetPointData()->GetScalars("G")->GetTuple(ID[ii])[0]); // Why 3.0??
|
433
|
440
|
}
|
|
441
|
+ //if (std::abs(C(ii,3)-13.5) > 1e-5) {
|
|
442
|
+ // g(ID[ii]) -= G[ii]*(V)*sigma_bar;
|
|
443
|
+ //}
|
434
|
444
|
//g(ID[ii]) += V/4*avg;
|
435
|
445
|
//g(ID[ii]) += 6.67 *(V/4.) * avg;
|
436
|
446
|
}
|