37 #pragma GCC diagnostic ignored "-Wunused-variable" 38 #pragma GCC diagnostic ignored "-Wunused-parameter" 40 #include <Epetra_ConfigDefs.h> 43 #include <Epetra_MpiComm.h> 45 #include <Epetra_SerialComm.h> 49 #pragma GCC diagnostic warning "-Wunused-variable" 50 #pragma GCC diagnostic warning "-Wunused-parameter" 52 #include <lifev/core/LifeV.hpp> 55 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 56 #include <lifev/core/algorithm/PreconditionerML.hpp> 57 #include <lifev/core/algorithm/SolverAztecOO.hpp> 59 #include <lifev/core/array/MatrixEpetraStructured.hpp> 60 #include <lifev/core/array/VectorBlockMonolithicEpetra.hpp> 62 #include <lifev/core/util/LifeChrono.hpp> 64 #include <lifev/eta/expression/Integrate.hpp> 66 #include <lifev/core/fem/BCHandler.hpp> 67 #include <lifev/core/fem/BCManage.hpp> 68 #include <lifev/core/fem/FESpace.hpp> 69 #include <lifev/eta/fem/ETFESpace.hpp> 71 #include <lifev/core/fem/GradientRecovery.hpp> 73 #include <lifev/core/filter/ExporterEnsight.hpp> 74 #include <lifev/core/filter/ExporterHDF5.hpp> 76 #include <lifev/core/mesh/MeshPartitioner.hpp> 77 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 79 #include <lifev/core/mesh/RegionMesh.hpp> 80 #include <lifev/core/mesh/MeshUtility.hpp> 81 #include <lifev/core/mesh/MeshData.hpp> 83 #include <lifev/level_set/fem/LevelSetQRAdapter.hpp> 90 #define NORMAL_CORRECTION 1
92 using namespace LifeV;
148 return distToSurface;
230 std::cout <<
" ### Motion ### " << std::endl;
231 std::cout <<
" theta : " << theta <<
" (rad) " << std::endl;
232 std::cout <<
" omega : " << 60.0 * omega / (2.0 *
M_PI) <<
" (rpm) " << std::endl;
233 std::cout <<
" alpha : " << alpha <<
" (rad/s2) " << std::endl;
251 Real nnorm (x * x + y * y);
300 Real r (std::sqrt (x * x + y * y) );
355 #define VISCOSITY eval(viscosity, value(ETlsFESpace,LSSolutionOld)) 377 #define DENSITY eval(density, value(ETlsFESpace,LSSolutionOld)) 387 Real norm (sqrt ( value[0]*value[0] + value[1]*value[1] + value[2]*value[2]) );
391 return value
* (1.0 / norm);
410 Real norm (sqrt ( value[0]*value[0] + value[1]*value[1] + value[2]*value[2]) );
493 #define BOTTOM_LINE 1
499 int main (
int argc,
char** argv )
504 MPI_Init (&argc, &argv);
505 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
507 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
511 bool verbose = (Comm->MyPID() == 0);
514 GetPot command_line (argc, argv);
515 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
517 GetPot dataFile (
"data" );
521 viscosityPlus = dataFile (
"physics/viscosityPlus", 1e-3);
522 viscosityMinus = dataFile (
"physics/viscosityMinus", 2e-5);
523 densityPlus = dataFile (
"physics/densityPlus", 1000.0);
524 densityMinus = dataFile (
"physics/densityMinus", 1.0);
526 NSSupg = dataFile (
"oseen/stab/supg", 1e-3);
527 NSPspg = dataFile (
"oseen/stab/pspg", 1e-3);
528 NSdivdiv = dataFile (
"oseen/stab/divdiv", 5e2);
530 NormalizeCorrection = dataFile (
"oseen/pressure/normalize_correction",
true);
532 LSSupg = dataFile (
"level_set/advection/supg", 5e-2);
534 HJdt = dataFile (
"level_set/hj/dt", 2e-2);
535 HJfinalTime = dataFile (
"level_set/hj/final", HJdt);
536 HJsupg = dataFile (
"level_set/hj/supg", 5e-1);
537 HJeach = dataFile (
"level_set/hj/each", 1);
538 HJpenal = dataFile (
"level_set/hj/penalisation", 1e5);
540 liquidHeight = dataFile (
"physics/liquid_height", 0.1);
541 cylinderRadius = dataFile (
"physics/cylinder_radius", 0.144);
542 cylinderHeight = dataFile (
"physics/cylinder_height", 0.4);
544 thetaInit = dataFile (
"physics/theta_init", 0.0);
545 omegaInit = 2 *
M_PI * dataFile (
"physics/omega_init", 0.0) / 60.0;
546 tRise = dataFile (
"physics/time_rise", 6.0);
547 omegaMax = 2 *
M_PI * dataFile (
"physics/omega_final", 60.0) / 60.0;
549 shakeRadius = dataFile (
"physics/shake_radius", 0.1);
551 slipLength = dataFile (
"oseen/bc/slip_length", 0.05);
552 noSlipCoef = dataFile (
"oseen/bc/no_slip_coef", 1e6);
553 viscosityRatio = dataFile (
"oseen/bc/ratio", 50.0);
554 slipFriction = dataFile (
"oseen/bc/slip_friction", 0.0);
556 exportEach = dataFile (
"exporter/each", 1);
558 alphaBL = dataFile (
"mesh/alphaBL", 0.0);
562 std::cout <<
"alpha : " << alphaBL << std::endl;
566 Real exactVolume (
M_PI * cylinderRadius * cylinderRadius * liquidHeight);
569 std::cout <<
"Exact : " << exactVolume << std::endl;
574 std::cout <<
" Reading and partitioning the mesh " << std::endl;
580 dataMesh.setup (dataFile,
"mesh");
582 std::shared_ptr < mesh_Type > fullMeshPtr (
new mesh_Type);
583 std::shared_ptr < mesh_Type > localMeshPtr (
new mesh_Type);
587 std::cout <<
"Hello " << exactVolume << std::endl;
589 readMesh (*fullMeshPtr, dataMesh);
599 std::cout <<
" BL factor : " << alphaBL << std::endl;
603 fullMeshPtr->meshTransformer().transformMesh (meshMap);
606 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
607 localMeshPtr = meshPart.meshPartition();
615 std::cout <<
" Building FESpaces " << std::endl;
620 std::string uOrder (
"P1");
621 std::string pOrder (
"P1");
622 std::string lsOrder (
"P1");
624 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uFESpace (
new FESpace< mesh_Type, MapEpetra > (localMeshPtr, uOrder, 3, Comm) );
625 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > pFESpace (
new FESpace< mesh_Type, MapEpetra > (localMeshPtr, pOrder, 1, Comm) );
626 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > lsFESpace (
new FESpace< mesh_Type, MapEpetra > (localMeshPtr, lsOrder, 1, Comm) );
630 std::cout << std::endl <<
" ### Dof Summary ###: " << std::endl;
634 std::cout <<
" Velocity : " << uFESpace->map().map (Unique)->NumGlobalElements() << std::endl;
638 std::cout <<
" Pressure : " << pFESpace->map().map (Unique)->NumGlobalElements() << std::endl;
642 std::cout <<
" Level set : " << lsFESpace->map().map (Unique)->NumGlobalElements() << std::endl << std::endl;
648 std::cout <<
" Building EA FESpaces " << std::endl;
652 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 3 > > ETuFESpace (
new ETFESpace< mesh_Type, MapEpetra, 3, 3 > (meshPart, & (uFESpace->refFE() ), Comm) );
653 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETpFESpace (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPart, & (pFESpace->refFE() ), Comm) );
654 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETlsFESpace (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPart, & (lsFESpace->refFE() ), Comm) );
659 std::cout <<
" Initial conditions " << std::endl;
662 vector_type LSSolution (ETlsFESpace->map(), Unique);
664 lsFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (initLSFct), LSSolution, 0.0);
666 vector_type LSSolutionOld (LSSolution, Repeated);
667 vector_type HJSolutionOld (LSSolution, Repeated);
668 vector_type HJProjSolution (LSSolution, Repeated);
670 vector_type velocitySolution (ETuFESpace->map(), Unique);
672 uFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (initVelocity), velocitySolution, 0.0);
674 vector_type velocitySolutionOld (velocitySolution, Repeated);
676 vector_type velocitySolutionOldOld (velocitySolution, Repeated);
679 vector_block_type NSSolution (ETuFESpace->map() | ETpFESpace->map(), Unique);
683 vector_block_type NSSolutionOld (NSSolution , Repeated);
684 NSSolutionOld *= 0.0;
689 std::cout <<
" Building the solvers " << std::endl;
693 SolverAztecOO LSAdvectionSolver;
694 LSAdvectionSolver.setCommunicator (Comm);
695 LSAdvectionSolver.setDataFromGetPot (dataFile,
"solver");
696 LSAdvectionSolver.setupPreconditioner (dataFile,
"prec");
698 SolverAztecOO NSSolver;
699 NSSolver.setCommunicator (Comm);
700 NSSolver.setDataFromGetPot (dataFile,
"solver");
701 NSSolver.setupPreconditioner (dataFile,
"prec");
703 SolverAztecOO HJSolver;
704 HJSolver.setCommunicator (Comm);
705 HJSolver.setDataFromGetPot (dataFile,
"solver");
706 HJSolver.setupPreconditioner (dataFile,
"prec");
710 std::cout <<
" Building the exporter " << std::endl;
714 ExporterHDF5<mesh_Type> exporter ( dataFile, meshPart.meshPartition(),
"solution", Comm->MyPID() );
715 exporter.setMultimesh (
false);
717 std::shared_ptr<vector_type> LSExported (
new vector_type (LSSolutionOld, Repeated) );
718 std::shared_ptr<vector_type> NSExported (
new vector_type (NSSolutionOld, Repeated) );
720 const UInt PressureOffset ( 3 * uFESpace->dof().numTotalDof() );
722 exporter.addVariable ( ExporterData<mesh_Type>::ScalarField,
"level-set", lsFESpace, LSExported, UInt (0) );
723 exporter.addVariable ( ExporterData<mesh_Type>::VectorField,
"velocity", uFESpace, NSExported, UInt (0) );
724 exporter.addVariable ( ExporterData<mesh_Type>::ScalarField,
"pressure", pFESpace, NSExported, PressureOffset);
728 std::cout <<
" Loading time stuff " << std::endl;
732 Real currentTime ( dataFile (
"time/initial", 0.0) );
733 Real finalTime ( dataFile (
"time/final", 1.0) );
734 Real dt ( dataFile (
"time/dt", 0.1) );
740 std::cout <<
" Exporting the initial condition " << std::endl;
744 exporter.postProcess (currentTime);
749 std::cout << std::endl;
753 std::cout <<
" ### Simulation times ### " << std::endl;
757 std::cout <<
" From " << currentTime <<
" to " << finalTime << std::endl;
761 std::cout <<
" Time step: " << dt << std::endl;
765 std::cout << std::endl;
771 while (currentTime < finalTime)
773 LifeChrono ChronoIteration;
774 ChronoIteration.start();
781 std::cout << std::endl;
785 std::cout <<
"----------------------------" << std::endl;
789 std::cout <<
" Time : " << currentTime << std::endl;
793 std::cout <<
" Iter : " << niter << std::endl;
797 std::cout <<
"----------------------------" << std::endl;
801 std::cout << std::endl;
806 std::cout <<
"[Navier-Stokes] Assembling the matrix ... " << std::flush;
809 LifeChrono ChronoItem;
812 #define SUPG_TEST value(NSSupg)*h_K * (grad(phi_i)*eval(normalize,value(ETuFESpace,velocitySolutionOld))) 814 #define PSPG_TEST value(NSPspg)*h_K * grad(phi_i) 816 #define DIVDIV_TEST value(NSdivdiv)*h_K*div(phi_i) 819 vector_type velocityExtrapolated (velocitySolutionOld * 2 - velocitySolutionOldOld, Repeated);
821 vector_type velocityBdfRHS (velocitySolutionOld * 2 - velocitySolutionOldOld * 0.5, Repeated);
823 vector_type velocityExtrapolated (velocitySolutionOld, Repeated);
825 vector_type velocityBdfRHS (velocitySolutionOld, Repeated);
829 std::shared_ptr<matrix_block_type> NSMatrix (
new matrix_block_type ( ETuFESpace->map() | ETpFESpace->map() ) );
833 std::shared_ptr<DensityFct> density (
new DensityFct);
834 std::shared_ptr<ViscosityFct> viscosity (
new ViscosityFct);
835 std::shared_ptr<NormalizeFct> normalize (
new NormalizeFct);
837 using namespace ExpressionAssembly;
840 elements (ETuFESpace->mesh() ),
842 adapt (ETlsFESpace, LSSolutionOld, uFESpace->qr() ),
849 * ( value (alpha / dt) * dot (phi_i, phi_j)
850 + dot (grad (phi_j) *value (ETuFESpace, velocityExtrapolated), phi_i)
853 +
VISCOSITY * dot (grad (phi_i), grad (phi_j) )
861 grad (phi_j) *value (ETuFESpace, velocityExtrapolated) *
DENSITY 862 + value (1.0 / dt) *
DENSITY * phi_j
866 >> NSMatrix->block (0, 0);
870 elements (ETuFESpace->mesh() ),
873 adapt (ETlsFESpace, LSSolutionOld, uFESpace->qr() ),
878 value (-1.0) *phi_j * div (phi_i)
885 >> NSMatrix->block (0, 1);
889 elements (ETuFESpace->mesh() ),
892 adapt (ETlsFESpace, LSSolutionOld, uFESpace->qr() ),
901 grad (phi_j) *value (ETuFESpace, velocityExtrapolated) *
DENSITY 902 + value (1.0 / dt) *
DENSITY * phi_j
907 >> NSMatrix->block (1, 0);
911 elements (ETuFESpace->mesh() ),
914 adapt (ETlsFESpace, LSSolutionOld, uFESpace->qr() ),
925 >> NSMatrix->block (1, 1);
933 std::cout << ChronoItem.diff() <<
" s" << std::endl;
938 std::cout <<
"[Navier-Stokes] Boundary integral ... " << std::flush;
944 QuadratureBoundary myBDQR (buildTetraBDQR (quadRuleTria4pt) );
947 using namespace ::LifeV::ExpressionAssembly;
949 std::shared_ptr<DensityFct> density (
new DensityFct);
950 std::shared_ptr<ViscosityFct> viscosity (
new ViscosityFct);
951 std::shared_ptr<HeavisideFct> heaviside (
new HeavisideFct);
952 std::shared_ptr<NormalizeFct> normalize (
new NormalizeFct);
955 integrate ( boundary (ETuFESpace->mesh(),
WALL),
956 adapt (ETlsFESpace, LSSolutionOld, myBDQR),
962 value (-1.0) *
VISCOSITY * dot ( (grad (phi_j) *Nface), Nface)
963 * dot ( phi_i, Nface )
964 ) >> NSMatrix->block (0, 0);
966 integrate ( boundary (ETuFESpace->mesh(),
WALL),
972 value (1.0) *phi_j * dot ( phi_i, Nface )
973 ) >> NSMatrix->block (0, 1);
976 #ifdef FULL_CORRECTION 977 integrate ( boundary (ETuFESpace->mesh(), WALL),
978 adapt (ETlsFESpace, LSSolutionOld, myBDQR),
984 value (-1.0) *VISCOSITY * dot ( (grad (phi_j) *Nface), phi_i)
986 ) >> NSMatrix->block (0, 0);
988 integrate ( boundary (ETuFESpace->mesh(), WALL),
994 value (1.0) *phi_j * dot ( phi_i, Nface )
995 ) >> NSMatrix->block (0, 1);
1004 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1010 std::cout <<
"[Navier-Stokes] Closing the matrix ... " << std::flush;
1015 NSMatrix->globalAssemble();
1020 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1026 std::cout <<
"[Navier-Stokes] Lifting the pressure ... " << std::flush;
1031 vector_type PressurePlus (ETpFESpace->map(), Repeated);
1032 vector_type PressureMinus (ETpFESpace->map(), Repeated);
1035 vector_type N0 (GradientRecovery::ZZGradient (ETlsFESpace, LSSolutionOld, 0), Repeated);
1036 vector_type N1 (GradientRecovery::ZZGradient (ETlsFESpace, LSSolutionOld, 1), Repeated);
1037 vector_type N2 (GradientRecovery::ZZGradient (ETlsFESpace, LSSolutionOld, 2), Repeated);
1039 vector_type f0 (ETlsFESpace->map(), Unique);
1041 lsFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (volumeForce0), f0, currentTime);
1042 vector_type f1 (ETlsFESpace->map(), Unique);
1043 lsFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (volumeForce1), f1, currentTime);
1044 vector_type f2 (ETlsFESpace->map(), Unique);
1045 lsFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (volumeForce2), f2, currentTime);
1047 vector_type gn ( (densityPlus - densityMinus) * ( N0 * f0 + N1 * f1 + N2 * f2 ), Repeated);
1048 vector_type nNorm ( ( N0 * N0 + N1 * N1 + N2 * N2 ), Repeated);
1050 PressurePlus *= 0.0;
1051 PressureMinus *= 0.0;
1053 const UInt nbElements (ETpFESpace->mesh()->numElements() );
1054 const UInt nbLocalPDof (ETpFESpace->refFE().nbDof() );
1057 for (UInt iElement (0); iElement < nbElements; ++iElement)
1059 for (UInt iDof (0); iDof < nbLocalPDof; ++iDof)
1061 UInt globalID ( ETlsFESpace->dof().localToGlobalMap (iElement, iDof) );
1063 Real lsValue ( LSSolutionOld[globalID] );
1067 if (NormalizeCorrection)
1069 PressureMinus[globalID] = -lsValue * gn[globalID] / sqrt (nNorm[globalID]) ;
1073 PressureMinus[globalID] = -lsValue * gn[globalID];
1078 if (NormalizeCorrection)
1080 PressurePlus[globalID] = lsValue * gn[globalID] / sqrt (nNorm[globalID]) ;
1084 PressurePlus[globalID] = lsValue * gn[globalID];
1095 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1100 std::cout <<
"[Navier-Stokes] Assembling the rhs ... " << std::flush;
1105 vector_type forceRhs (ETuFESpace->map(), Unique);
1107 uFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (volumeForce), forceRhs, currentTime);
1109 vector_block_type NSRhs ( ETuFESpace->map() | ETpFESpace->map() , Repeated );
1113 using namespace ExpressionAssembly;
1115 std::shared_ptr<DensityFct> density (
new DensityFct);
1116 std::shared_ptr<ViscosityFct> viscosity (
new ViscosityFct);
1117 std::shared_ptr<HeavisideFct> heaviside (
new HeavisideFct);
1118 std::shared_ptr<NormalizeFct> normalize (
new NormalizeFct);
1121 elements (ETuFESpace->mesh() ),
1123 adapt (ETlsFESpace, LSSolutionOld, uFESpace->qr() ),
1128 * dot ( value (1 / dt) *value (ETuFESpace, velocityBdfRHS) + value (ETuFESpace, forceRhs)
1133 * ( eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) *value (ETpFESpace, PressurePlus)
1134 + (value (1.0) - eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) ) *value (ETpFESpace, PressureMinus) )
1139 DENSITY * value (1 / dt) *value (ETuFESpace, velocityBdfRHS)
1140 +
DENSITY * value (ETuFESpace, forceRhs)
1141 - ( eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) *grad (ETpFESpace, PressurePlus)
1142 + (value (1.0) - eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) ) *grad (ETpFESpace, PressureMinus) )
1150 elements (ETuFESpace->mesh() ),
1152 adapt (ETlsFESpace, LSSolutionOld, pFESpace->qr() ),
1159 DENSITY * value (1 / dt) *value (ETuFESpace, velocityBdfRHS)
1160 +
DENSITY * value (ETuFESpace, forceRhs)
1161 - ( eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) *grad (ETpFESpace, PressurePlus)
1162 + (value (1.0) - eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) ) *grad (ETpFESpace, PressureMinus) )
1172 integrate ( boundary (ETuFESpace->mesh(),
WALL),
1174 adapt (ETlsFESpace, LSSolutionOld, myBDQR),
1177 value (-1.0) * ( eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) *value (ETpFESpace, PressurePlus)
1178 + (value (1.0) - eval (heaviside, value (ETlsFESpace, LSSolutionOld) ) ) *value (ETpFESpace, PressureMinus) )
1179 * dot (phi_i, Nface)
1190 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1196 std::cout <<
"[Navier-Stokes] Closing the rhs ... " << std::flush;
1201 vector_block_type NSRhsUnique ( NSRhs, Unique );
1206 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1212 std::cout <<
"[Navier-Stokes] Applying boundary conditions ... " << std::flush;
1217 BCHandler NSBCHandler;
1218 BCFunctionBase ZeroBCFct (zeroFct);
1219 BCFunctionBase OneBCFct (oneFct);
1221 std::vector<UInt> compXY (2);
1226 vector_type LSReplicated (ETlsFESpace->map() + ETlsFESpace->map() + ETlsFESpace->map() );
1227 LSReplicated *= 0.0;
1228 LSReplicated.add (LSSolution, 0);
1229 LSReplicated.add (LSSolution, ETlsFESpace->dof().numTotalDof() );
1230 LSReplicated.add (LSSolution, 2 * ETlsFESpace->dof().numTotalDof() );
1233 LSReplicated.apply (slipFct);
1235 vector_type RobinVec (0.0 * velocitySolution, Repeated);
1236 vector_type RobinCoeff (LSReplicated, Repeated);
1238 BCVector uRobin (RobinVec, ETuFESpace->dof().numTotalDof(), 0);
1239 uRobin.setRobinCoeffVector (RobinCoeff);
1240 uRobin.setBetaCoeff (0.0);
1242 BCFunctionDirectional directionFct (zeroFct, normalDirection);
1244 NSBCHandler.addBC (
"BottomL",
BOTTOM_LINE, Essential, Full, ZeroBCFct , 3);
1245 NSBCHandler.addBC (
"TopL",
TOP_LINE, Essential, Full, ZeroBCFct , 3);
1246 NSBCHandler.addBC (
"Bottom",
BOTTOM, Essential, Full, ZeroBCFct , 3);
1248 NSBCHandler.addBC (
"Wall",
WALL, Essential, Normal, ZeroBCFct);
1252 NSBCHandler.addBC (
"Wall",
WALL, Robin, Full, uRobin , 3);
1255 NSBCHandler.addBC (
"Top",
TOP, Essential, Full, ZeroBCFct , 3);
1257 NSBCHandler.bcUpdate ( *meshPart.meshPartition(), uFESpace->feBd(), uFESpace->dof() );
1259 bcManage (*NSMatrix, NSRhsUnique,
1260 *uFESpace->mesh(), uFESpace->dof(),
1261 NSBCHandler, uFESpace->feBd(), 1.0, currentTime);
1268 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1273 std::cout <<
"[Navier-Stokes] Solving the system " << std::endl;
1277 NSSolver.setMatrix (*NSMatrix);
1280 std::shared_ptr<matrix_type> NSMatrixNoBlock (
new matrix_type ( NSMatrix->map() ) );
1281 *NSMatrixNoBlock += *NSMatrix;
1283 NSSolver.solveSystem (NSRhsUnique, NSSolution, NSMatrixNoBlock);
1288 std::cout <<
"[Navier-Stokes] Time advancing ... " << std::flush;
1293 NSSolutionOld = NSSolution;
1295 velocitySolutionOldOld = velocitySolutionOld;
1297 velocitySolutionOld.subset (NSSolutionOld);
1302 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1308 std::cout << std::endl;
1314 std::cout <<
"[LS advection] Assembling the matrix ... " << std::flush;
1319 std::shared_ptr<matrix_type> LSAdvectionMatrix (
new matrix_type ( ETlsFESpace->map() ) );
1320 *LSAdvectionMatrix *= 0.0;
1323 using namespace ExpressionAssembly;
1325 std::shared_ptr<SignFct> sign (
new SignFct);
1326 std::shared_ptr<NormalizeFct> normalize (
new NormalizeFct);
1329 elements (ETlsFESpace->mesh() ),
1338 value (1 / dt) *phi_i * phi_j
1341 + dot ( value (ETuFESpace, velocitySolutionOld) , grad (phi_j) ) *phi_i
1344 + ( value (LSSupg) *h_K )
1345 * ( value (1 / dt) *phi_j + dot ( value (ETuFESpace, velocitySolutionOld) , grad (phi_j) ) )
1347 * dot ( eval (normalize, value (ETuFESpace, velocitySolutionOld) ) , grad (phi_i) )
1350 >> LSAdvectionMatrix;
1357 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1363 std::cout <<
"[LS advection] Closing the matrix ... " << std::flush;
1368 LSAdvectionMatrix->globalAssemble();
1373 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1379 std::cout <<
"[LS advection] Assembling the rhs ... " << std::flush;
1384 vector_type LSAdvectionRhs ( ETlsFESpace->map(), Repeated );
1385 LSAdvectionRhs *= 0.0;
1388 using namespace ExpressionAssembly;
1390 std::shared_ptr<SignFct> sign (
new SignFct);
1391 std::shared_ptr<NormalizeFct> normalize (
new NormalizeFct);
1394 elements (ETlsFESpace->mesh() ),
1402 value (1 / dt) *value (ETlsFESpace, LSSolutionOld) *phi_i
1405 + ( value (LSSupg) *h_K )
1406 * (value (1 / dt) *value (ETlsFESpace, LSSolutionOld) )
1408 * dot ( eval (normalize, value (ETuFESpace, velocitySolutionOld) ) , grad (phi_i) )
1416 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1422 std::cout <<
"[LS advection] Closing the rhs ... " << std::flush;
1427 vector_type LSAdvectionRhsUnique ( LSAdvectionRhs, Unique );
1432 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1438 std::cout <<
"[LS advection] Solving the system " << std::endl;
1442 LSAdvectionSolver.setMatrix (*LSAdvectionMatrix);
1443 LSAdvectionSolver.solveSystem (LSAdvectionRhsUnique, LSSolution, LSAdvectionMatrix);
1448 std::cout <<
"[Hamilton-J.] Initializing ... " << std::flush;
1454 LSSolutionOld = LSSolution;
1455 HJSolutionOld = LSSolution;
1457 HJSolver.resetPreconditioner();
1462 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1467 if (niter % HJeach == 0)
1470 while ( HJtime < HJfinalTime)
1476 std::cout << std::endl;
1480 std::cout <<
"[Hamilton-J.] Time : " << HJtime << std::endl;
1484 std::cout <<
"[Hamilton-J.] Building the matrix ... " << std::flush;
1490 std::shared_ptr<matrix_type> HJMatrix (
new matrix_type ( ETlsFESpace->map() ) );
1493 #define BETA ( eval(sign, value(ETlsFESpace,LSSolutionOld) ) * eval(normalization, grad(ETlsFESpace,HJSolutionOld) ) ) 1496 using namespace ExpressionAssembly;
1498 std::shared_ptr<SignFct> sign (
new SignFct);
1499 std::shared_ptr<NormalizeFct> normalization (
new NormalizeFct);
1502 elements (ETlsFESpace->mesh() ),
1504 adapt (ETlsFESpace, LSSolutionOld, lsFESpace->qr() ),
1511 value (1 / HJdt) *phi_i * phi_j
1512 + dot (
BETA , grad (phi_j) ) *phi_i
1515 + ( value (HJsupg) *h_K )
1516 * ( value (1 / HJdt) *phi_j + dot (
BETA , grad (phi_j) ) )
1517 * dot (
BETA , grad (phi_i) )
1519 * (value (1.0) - ifCrossed (ETlsFESpace, LSSolutionOld) )
1522 value (HJpenal) * ( phi_i * phi_j )
1523 *ifCrossed (ETlsFESpace, LSSolutionOld)
1533 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1539 std::cout <<
"[Hamilton-J.] Closing the matrix ... " << std::flush;
1544 HJMatrix->globalAssemble();
1549 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1555 std::cout <<
"[Hamilton-J.] Assembling the rhs " << std::flush;
1560 vector_type HJRhs ( ETlsFESpace->map(), Repeated );
1564 using namespace ExpressionAssembly;
1566 std::shared_ptr<SignFct> sign (
new SignFct);
1567 std::shared_ptr<NormalizeFct> normalization (
new NormalizeFct);
1568 std::shared_ptr<NormFct> norm (
new NormFct);
1571 elements (ETlsFESpace->mesh() ),
1573 adapt (ETlsFESpace, LSSolutionOld, lsFESpace->qr() ),
1578 value (1 / HJdt) *value (ETlsFESpace, HJSolutionOld) *phi_i
1579 + eval (sign, value (ETlsFESpace, LSSolutionOld) ) *phi_i
1581 + ( value (HJsupg) *h_K )
1582 * ( value (1 / HJdt) *value (ETlsFESpace, HJSolutionOld) + eval (sign, value (ETlsFESpace, LSSolutionOld) ) )
1583 * dot (
BETA, grad (phi_i) )
1584 ) * (value (1.0) - ifCrossed (ETlsFESpace, LSSolutionOld) )
1586 + value (HJpenal) * ( phi_i * value (ETlsFESpace, LSSolutionOld) / eval (norm, grad (ETlsFESpace, LSSolutionOld) ) ) * ifCrossed (ETlsFESpace, LSSolutionOld)
1595 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1601 std::cout <<
"[Hamilton-J.] Closing the rhs ... " << std::flush;
1606 vector_type HJRhsUnique ( HJRhs, Unique );
1611 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1617 std::cout <<
"[Hamilton-J.] Solving the system ... " << std::flush;
1622 HJSolver.setMatrix (*HJMatrix);
1623 HJSolver.solveSystem (HJRhsUnique, LSSolution, HJMatrix);
1628 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1634 std::cout <<
"[Hamilton-J.] Update the solution ... " << std::flush;
1639 HJSolutionOld = LSSolution;
1644 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1649 std::cout << std::endl;
1656 std::cout <<
"[LS correction] Correction of the volume ... " << std::flush;
1661 Real localVolume = 0.0;
1662 Real globalVolume = 0.0;
1664 Real localArea = 0.0;
1665 Real globalArea = 0.0;
1668 using namespace ExpressionAssembly;
1670 std::shared_ptr<HeavisideFct> heaviside (
new HeavisideFct);
1671 std::shared_ptr<SmoothDeltaFct> delta (
new SmoothDeltaFct);
1674 elements (ETlsFESpace->mesh() ),
1675 adapt (ETlsFESpace, LSSolution, lsFESpace->qr() ),
1676 eval (heaviside, value (ETlsFESpace, LSSolution) )
1681 elements (ETlsFESpace->mesh() ),
1682 adapt (ETlsFESpace, LSSolution, lsFESpace->qr() ),
1683 eval (delta, value (ETlsFESpace, LSSolution) )
1690 Comm->SumAll (&localVolume, &globalVolume, 1);
1693 Comm->SumAll (&localArea, &globalArea, 1);
1696 LSSolution += volumeRelaxation * (exactVolume - globalVolume) / globalArea;
1702 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1706 std::cout <<
"[LS correction] Rel. vol. diff: " << (exactVolume - globalVolume) / exactVolume << std::endl;
1710 std::cout <<
"[LS correction] Approx. area: " << globalArea << std::endl;
1716 std::cout <<
"[LS advection] Time advancing ... " << std::flush;
1721 LSSolutionOld = LSSolution;
1726 std::cout << ChronoItem.diff() <<
" s" << std::endl;
1732 std::cout <<
" Exporting " << std::endl;
1736 *LSExported = LSSolutionOld;
1737 *NSExported = NSSolutionOld;
1739 if (niter % exportEach == 0)
1741 exporter.postProcess (currentTime);
1744 ChronoIteration.stop();
1747 std::cout << std::endl <<
" Total iteration time : " << ChronoIteration.diff() <<
" s" << std::endl;
1752 displayMotionParameters (currentTime);
1758 exporter.closeFile();
1765 return ( EXIT_SUCCESS );
void meshMap(Real &x, Real &y, Real &z)
VectorEpetra - The Epetra Vector format Wrapper.
VectorBlockMonolithicEpetra - class of block vector.
Real initLSFct(const Real &, const Real &, const Real &, const Real &z, const ID &)
bool NormalizeCorrection(true)
HeavisideFct(const HeavisideFct &)
return_Type operator()(const Real &value)
Real volumeForce(const Real &t, const Real &, const Real &, const Real &, const ID &i)
VectorSmall< 3 > return_Type
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
Real normalDirection(const Real &, const Real &x, const Real &y, const Real &, const ID &i)
ViscosityFct(const ViscosityFct &)
Real volumeRelaxation(0.5)
return_Type operator()(const VectorSmall< 3 > &value)
Real cylinderRadius(0.144)
Real volumeForce0(const Real &t, const Real &x, const Real &y, const Real &z, const ID &)
static const LifeV::UInt elm_nodes_num[]
Real zeroFct(const Real &, const Real &, const Real &, const Real &, const ID &)
VectorSmall< 3 > operator*(Real const &factor) const
Operator * (multiplication by scalar on the right)
MatrixEpetra< Real > matrix_type
Real viscosityMinus(2e-5)
RegionMesh< LinearTetra > mesh_Type
Real volumeForce1(const Real &t, const Real &x, const Real &y, const Real &z, const ID &)
Real oneFct(const Real &, const Real &, const Real &, const Real &, const ID &)
NormalizeFct(const NormalizeFct &)
double Real
Generic real data.
return_Type operator()(const Real &value)
Real viscosityRatio(50.0)
#define NORMAL_CORRECTION
return_Type operator()(const Real &value)
int main(int argc, char **argv)
return_Type operator()(const Real &value)
MatrixEpetraStructured - class of block matrix.
void displayMotionParameters(const Real &t)
return_Type operator()(const VectorSmall< 3 > value)
Real initVelocity(const Real &, const Real &, const Real &, const Real &, const ID &i)
VectorBlockMonolithicEpetra vector_block_type
DensityFct(const DensityFct &)
return_Type operator()(const Real &value)
SmoothDeltaFct(const SmoothDeltaFct &)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
MatrixEpetraStructured< Real > matrix_block_type
Real volumeForce2(const Real &t, const Real &x, const Real &y, const Real &z, const ID &)