本文整理汇总了C++中MultiLevelMesh::EraseCoarseLevels方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiLevelMesh::EraseCoarseLevels方法的具体用法?C++ MultiLevelMesh::EraseCoarseLevels怎么用?C++ MultiLevelMesh::EraseCoarseLevels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiLevelMesh
的用法示例。
在下文中一共展示了MultiLevelMesh::EraseCoarseLevels方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** args) {
// init Petsc-MPI communicator
FemusInit mpinit(argc, args, MPI_COMM_WORLD);
// define multilevel mesh
MultiLevelMesh mlMsh;
// read coarse level mesh and generate finers level meshes
double scalingFactor = 1.;
mlMsh.ReadCoarseMesh("./input/square_quad.neu", "seventh", scalingFactor);
/* "seventh" is the order of accuracy that is used in the gauss integration scheme
probably in the future it is not going to be an argument of this function */
unsigned maxNumberOfMeshes = 5;
vector < vector < double > > l2Norm;
l2Norm.resize(maxNumberOfMeshes);
vector < vector < double > > semiNorm;
semiNorm.resize(maxNumberOfMeshes);
for (unsigned i = 0; i < maxNumberOfMeshes; i++) { // loop on the mesh level
unsigned numberOfUniformLevels = i + 1;
unsigned numberOfSelectiveLevels = 0;
mlMsh.RefineMesh( numberOfUniformLevels + numberOfSelectiveLevels, numberOfUniformLevels , NULL);
// erase all the coarse mesh levels
mlMsh.EraseCoarseLevels(numberOfUniformLevels - 1);
// print mesh info
mlMsh.PrintInfo();
FEOrder feOrder[3] = {FIRST, SERENDIPITY, SECOND};
l2Norm[i].resize(3);
semiNorm[i].resize(3);
for (unsigned j = 0; j < 3; j++) { // loop on the FE Order
std::cout << "level = " << i << " FEM = " << j << std::endl;
// define the multilevel solution and attach the mlMsh object to it
MultiLevelSolution mlSol(&mlMsh);
// add variables to mlSol
mlSol.AddSolution("u", LAGRANGE, feOrder[j]);
mlSol.AddSolution("v", LAGRANGE, feOrder[j]);
mlSol.Initialize("All");
// attach the boundary condition function and generate boundary data
mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);
mlSol.GenerateBdc("u");
mlSol.GenerateBdc("v");
// define the multilevel problem attach the mlSol object to it
MultiLevelProblem mlProb(&mlSol);
// add system Poisson in mlProb as a Linear Implicit System
NonLinearImplicitSystem& system = mlProb.add_system < NonLinearImplicitSystem > ("Poisson");
// add solution "u" to system
system.AddSolutionToSystemPDE("u");
system.AddSolutionToSystemPDE("v");
// attach the assembling function to system
system.SetAssembleFunction(AssembleBilaplaceProblem_AD);
// initilaize and solve the system
system.init();
system.MGsolve();
std::pair< double , double > norm = GetErrorNorm(&mlSol);
l2Norm[i][j] = norm.first;
semiNorm[i][j] = norm.second;
// print solutions
std::vector < std::string > variablesToBePrinted;
variablesToBePrinted.push_back("All");
VTKWriter vtkIO(&mlSol);
vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted, i);
}
}
// print the seminorm of the error and the order of convergence between different levels
std::cout << std::endl;
std::cout << std::endl;
std::cout << "l2 ERROR and ORDER OF CONVERGENCE:\n\n";
std::cout << "LEVEL\tFIRST\t\t\tSERENDIPITY\t\tSECOND\n";
for (unsigned i = 0; i < maxNumberOfMeshes; i++) {
std::cout << i + 1 << "\t";
std::cout.precision(14);
for (unsigned j = 0; j < 3; j++) {
std::cout << l2Norm[i][j] << "\t";
}
std::cout << std::endl;
//.........这里部分代码省略.........
示例2: main
int main(int argc, char** args) {
// init Petsc-MPI communicator
FemusInit mpinit(argc, args, MPI_COMM_WORLD);
// define multilevel mesh
MultiLevelMesh mlMsh;
// read coarse level mesh and generate finers level meshes
double scalingFactor = 1.;
mlMsh.ReadCoarseMesh("./input/cube_hex.neu", "seventh", scalingFactor);
//mlMsh.ReadCoarseMesh ( "./input/square_quad.neu", "seventh", scalingFactor );
/* "seventh" is the order of accuracy that is used in the gauss integration scheme
probably in the furure it is not going to be an argument of this function */
unsigned dim = mlMsh.GetDimension();
unsigned numberOfUniformLevels = 3;
unsigned numberOfSelectiveLevels = 0;
mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL);
// erase all the coarse mesh levels
mlMsh.EraseCoarseLevels(numberOfUniformLevels - 1);
// print mesh info
mlMsh.PrintInfo();
MultiLevelSolution mlSol(&mlMsh);
// add variables to mlSol
mlSol.AddSolution("U", LAGRANGE, SECOND);
mlSol.AddSolution("V", LAGRANGE, SECOND);
if (dim == 3) mlSol.AddSolution("W", LAGRANGE, SECOND);
mlSol.AddSolution("P", LAGRANGE, FIRST);
mlSol.Initialize("All");
// attach the boundary condition function and generate boundary data
mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);
mlSol.GenerateBdc("All");
// define the multilevel problem attach the mlSol object to it
MultiLevelProblem mlProb(&mlSol);
// add system Poisson in mlProb as a Linear Implicit System
NonLinearImplicitSystem& system = mlProb.add_system < NonLinearImplicitSystem > ("NS");
// add solution "u" to system
system.AddSolutionToSystemPDE("U");
system.AddSolutionToSystemPDE("V");
if (dim == 3) system.AddSolutionToSystemPDE("W");
system.AddSolutionToSystemPDE("P");
// attach the assembling function to system
system.SetAssembleFunction(AssembleBoussinesqAppoximation_AD);
// initilaize and solve the system
system.init();
system.solve();
// print solutions
std::vector < std::string > variablesToBePrinted;
variablesToBePrinted.push_back("All");
VTKWriter vtkIO(&mlSol);
vtkIO.write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted);
return 0;
}
示例3: main
int main ( int argc, char** argv )
{
// init Petsc-MPI communicator
FemusInit mpinit ( argc, argv, MPI_COMM_WORLD );
MultiLevelMesh mlMsh;
double scalingFactor = 1.;
unsigned numberOfSelectiveLevels = 0;
// mlMsh.ReadCoarseMesh ( "../input/nonlocal_boundary_test.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/interface.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest1.neu", "eighth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest2.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest3.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest4.neu", "eighth", scalingFactor );
mlMsh.ReadCoarseMesh ( "../input/maxTest5.neu", "eighth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest6.neu", "eighth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest7.neu", "eighth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest8.neu", "eighth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest9.neu", "eighth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest10.neu", "eighth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/maxTest2Continuous.neu", "second", scalingFactor );
//mlMsh.ReadCoarseMesh ( "../input/martaTest0.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest1.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest2.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest3.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest4.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest5.neu", "fifth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest7.neu", "fifth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest8.neu", "fifth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest9.neu", "fifth", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/martaTest4Coarser.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/trial1.neu", "second", scalingFactor );
// mlMsh.ReadCoarseMesh ( "../input/trial2.neu", "second", scalingFactor );
mlMsh.RefineMesh ( numberOfUniformLevels + numberOfSelectiveLevels, numberOfUniformLevels , NULL );
mlMsh.EraseCoarseLevels ( numberOfUniformLevels - 1 );
// numberOfUniformLevels = 1;
unsigned dim = mlMsh.GetDimension();
MultiLevelSolution mlSol ( &mlMsh );
// add variables to mlSol
mlSol.AddSolution ( "u", LAGRANGE, FIRST, 2 );
mlSol.AddSolution ( "u_local", LAGRANGE, FIRST, 2 );
mlSol.AddSolution ( "u_exact", LAGRANGE, FIRST, 2 );
mlSol.Initialize ( "All" );
mlSol.Initialize ( "u_exact", InitalValueU );
mlSol.AttachSetBoundaryConditionFunction ( SetBoundaryCondition );
// ******* Set boundary conditions *******
mlSol.GenerateBdc ( "All" );
//BEGIN assemble and solve nonlocal problem
MultiLevelProblem ml_prob ( &mlSol );
// ******* Add FEM system to the MultiLevel problem *******
LinearImplicitSystem& system = ml_prob.add_system < LinearImplicitSystem > ( "NonLocal" );
system.AddSolutionToSystemPDE ( "u" );
// ******* System FEM Assembly *******
system.SetAssembleFunction ( AssembleNonLocalSys );
system.SetMaxNumberOfLinearIterations ( 1 );
// ******* set MG-Solver *******
system.SetMgType ( V_CYCLE );
system.SetAbsoluteLinearConvergenceTolerance ( 1.e-50 );
// system.SetNonLinearConvergenceTolerance(1.e-9);
// system.SetMaxNumberOfNonLinearIterations(20);
system.SetNumberPreSmoothingStep ( 1 );
system.SetNumberPostSmoothingStep ( 1 );
// ******* Set Preconditioner *******
system.SetLinearEquationSolverType ( FEMuS_DEFAULT );
system.SetSparsityPatternMinimumSize ( 500u ); //TODO tune
system.init();
// ******* Set Smoother *******
system.SetSolverFineGrids ( GMRES );
system.SetPreconditionerFineGrids ( ILU_PRECOND );
system.SetTolerances ( 1.e-20, 1.e-20, 1.e+50, 100 );
// ******* Solution *******
system.MGsolve();
//END assemble and solve nonlocal problem
//.........这里部分代码省略.........
示例4: main
int main(int argc, char** args) {
// init Petsc-MPI communicator
FemusInit mpinit(argc, args, MPI_COMM_WORLD);
// define multilevel mesh
unsigned maxNumberOfMeshes;
maxNumberOfMeshes = 1;
vector < vector < double > > l2Norm;
l2Norm.resize(maxNumberOfMeshes);
vector < vector < double > > semiNorm;
semiNorm.resize(maxNumberOfMeshes);
for (unsigned i = 0; i < maxNumberOfMeshes; i++) { // loop on the mesh level
std::ostringstream filename;
filename << "./input/sphere.neu";
MultiLevelMesh mlMsh;
// read coarse level mesh and generate finers level meshes
double scalingFactor = 2.;
//mlMsh.ReadCoarseMesh("./input/circle_quad.neu","seventh", scalingFactor);
mlMsh.ReadCoarseMesh(filename.str().c_str(), "seventh", scalingFactor);
/* "seventh" is the order of accuracy that is used in the gauss integration scheme
probably in the furure it is not going to be an argument of this function */
unsigned dim = mlMsh.GetDimension();
unsigned numberOfUniformLevels = 4;
unsigned numberOfSelectiveLevels = 0;
mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL);
// erase all the coarse mesh levels
mlMsh.EraseCoarseLevels(numberOfUniformLevels - 1);
// print mesh info
mlMsh.PrintInfo();
FEOrder feOrder = SECOND;
l2Norm[i].resize(1);
semiNorm[i].resize(1);
// define the multilevel solution and attach the mlMsh object to it
MultiLevelSolution mlSol(&mlMsh);
// add variables to mlSol
mlSol.AddSolution("X", LAGRANGE, feOrder, 2);
mlSol.AddSolution("Y", LAGRANGE, feOrder, 2);
mlSol.AddSolution("Z", LAGRANGE, feOrder, 2);
mlSol.AddSolution("H", LAGRANGE, feOrder, 2);
mlSol.Initialize("X", InitalValueXTorus);
mlSol.Initialize("Y", InitalValueYTorus);
mlSol.Initialize("Z", InitalValueZTorus);
mlSol.Initialize("H", InitalValueHTorus);
// attach the boundary condition function and generate boundary data
mlSol.AttachSetBoundaryConditionFunction(SetBoundaryConditionTorus);
// mlSol.Initialize("X", InitalValueXSphere);
// mlSol.Initialize("Y", InitalValueYSphere);
// mlSol.Initialize("Z", InitalValueZSphere);
// mlSol.Initialize("H", InitalValueHSphere);
// // attach the boundary condition function and generate boundary data
// mlSol.AttachSetBoundaryConditionFunction(SetBoundaryConditionSphere);
mlSol.GenerateBdc("X", "Steady");
mlSol.GenerateBdc("Y", "Steady");
mlSol.GenerateBdc("Z", "Steady");
mlSol.GenerateBdc("H", "Steady");
// define the multilevel problem attach the mlSol object to it
MultiLevelProblem mlProb(&mlSol);
// add system Wilmore in mlProb as a Linear Implicit System
TransientNonlinearImplicitSystem& system = mlProb.add_system < TransientNonlinearImplicitSystem > ("Willmore");
// add solution "X", "Y", "Z" and "H" to the system
system.AddSolutionToSystemPDE("X");
system.AddSolutionToSystemPDE("Y");
system.AddSolutionToSystemPDE("Z");
system.AddSolutionToSystemPDE("H");
system.SetMaxNumberOfNonLinearIterations(6);
// attach the assembling function to system
system.SetAssembleFunction(AssembleWillmoreFlow_AD);
// initilaize and solve the system
system.init();
std::vector < std::string > variablesToBePrinted;
variablesToBePrinted.push_back("All");
std::vector < std::string > surfaceVariables;
//.........这里部分代码省略.........
示例5: main
int main(int argc, char** args)
{
unsigned precType = 0;
if (argc >= 2) {
Miu = strtod(args[1], NULL);
std::cout << Miu << std::endl;
}
// init Petsc-MPI communicator
FemusInit mpinit(argc, args, MPI_COMM_WORLD);
// define multilevel mesh
MultiLevelMesh mlMsh;
// read coarse level mesh and generate finers level meshes
double scalingFactor = 1.;
//mlMsh.ReadCoarseMesh("./input/cube_hex.neu","seventh",scalingFactor);
mlMsh.ReadCoarseMesh("./input/quad_square.neu", "seventh", scalingFactor);
/* "seventh" is the order of accuracy that is used in the gauss integration scheme
probably in the furure it is not going to be an argument of this function */
unsigned dim = mlMsh.GetDimension();
unsigned numberOfUniformLevels = 8;
unsigned numberOfSelectiveLevels = 0;
mlMsh.RefineMesh(numberOfUniformLevels + numberOfSelectiveLevels, numberOfUniformLevels, SetRefinementFlag);
// mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL);
// erase all the coarse mesh levels
mlMsh.EraseCoarseLevels(3);
// print mesh info
mlMsh.PrintInfo();
MultiLevelSolution mlSol(&mlMsh);
// add variables to mlSol
mlSol.AddSolution("U", LAGRANGE, SECOND);
mlSol.AddSolution("V", LAGRANGE, SECOND);
if (dim == 3) mlSol.AddSolution("W", LAGRANGE, SECOND);
mlSol.AddSolution("P", DISCONTINUOUS_POLYNOMIAL, FIRST);
mlSol.AssociatePropertyToSolution("P", "Pressure");
mlSol.Initialize("All");
// mlSol.Initialize("U", InitalValueU);
// attach the boundary condition function and generate boundary data
mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);
mlSol.FixSolutionAtOnePoint("P");
mlSol.GenerateBdc("All");
// define the multilevel problem attach the mlSol object to it
MultiLevelProblem mlProb(&mlSol);
// add system Poisson in mlProb as a Linear Implicit System
NonLinearImplicitSystem& system = mlProb.add_system < NonLinearImplicitSystem > ("NS");
// add solution "u" to system
system.AddSolutionToSystemPDE("U");
system.AddSolutionToSystemPDE("V");
if (dim == 3) system.AddSolutionToSystemPDE("W");
system.AddSolutionToSystemPDE("P");
//system.SetLinearEquationSolverType(FEMuS_DEFAULT);
system.SetLinearEquationSolverType(FEMuS_ASM);
// attach the assembling function to system
system.SetAssembleFunction(AssembleBoussinesqAppoximation);
system.SetMaxNumberOfNonLinearIterations(20);
system.SetNonLinearConvergenceTolerance(1.e-8);
//system.SetMaxNumberOfResidualUpdatesForNonlinearIteration(10);
//system.SetResidualUpdateConvergenceTolerance(1.e-15);
system.SetMaxNumberOfLinearIterations(1);
system.SetAbsoluteLinearConvergenceTolerance(1.e-15);
system.SetMgType(V_CYCLE);
system.SetNumberPreSmoothingStep(1);
system.SetNumberPostSmoothingStep(1);
// initilaize and solve the system
system.init();
system.SetSolverFineGrids(RICHARDSON);
system.SetPreconditionerFineGrids(MLU_PRECOND);
system.SetTolerances(1.e-5, 1.e-8, 1.e+50, 30, 30); //GMRES tolerances
system.ClearVariablesToBeSolved();
system.AddVariableToBeSolved("All");
system.SetNumberOfSchurVariables(1);
system.SetElementBlockNumber("All");
system.MGsolve();
// print solutions
std::vector < std::string > variablesToBePrinted;
variablesToBePrinted.push_back("All");
VTKWriter vtkIO(&mlSol);
vtkIO.Write(DEFAULT_OUTPUTDIR, "biquadratic", variablesToBePrinted);
mlMsh.PrintInfo();
//.........这里部分代码省略.........
示例6: main
int main(int argc, char** args) {
unsigned precType = 0;
if(argc >= 2) {
if(!strcmp("FS_VT", args[1])) precType = FS_VTp;
else if(!strcmp("FS_TV", args[1])) precType = FS_TVp;
else if(!strcmp("ASM_VT", args[1])) precType = ASM_VTp;
else if(!strcmp("ASM_TV", args[1])) precType = ASM_TVp;
else if(!strcmp("ILU_VT", args[1])) precType = ILU_VTp;
if(!strcmp("ILU_TV", args[1])) precType = ILU_TVp;
if(precType == 0) {
std::cout << "wrong input arguments!" << std::endl;
abort();
}
}
else {
std::cout << "No input argument set default preconditioner = NS+T" << std::endl;
precType = FS_VTp;
}
if(argc >= 3) {
Prandtl = strtod(args[2], NULL);
std::cout << Prandtl << std::endl;
}
if(argc >= 4) {
Rayleigh = strtod(args[3], NULL);
std::cout << Rayleigh << std::endl;
}
// init Petsc-MPI communicator
FemusInit mpinit(argc, args, MPI_COMM_WORLD);
// define multilevel mesh
MultiLevelMesh mlMsh;
// read coarse level mesh and generate finers level meshes
double scalingFactor = 1.;
//mlMsh.ReadCoarseMesh("./input/cube_hex.neu","seventh",scalingFactor);
mlMsh.ReadCoarseMesh("./input/rectangle_w4_h1.neu", "seventh", scalingFactor);
/* "seventh" is the order of accuracy that is used in the gauss integration scheme
probably in the furure it is not going to be an argument of this function */
unsigned dim = mlMsh.GetDimension();
unsigned numberOfUniformLevels = 7;
unsigned numberOfSelectiveLevels = 0;
mlMsh.RefineMesh(numberOfUniformLevels , numberOfUniformLevels + numberOfSelectiveLevels, NULL);
// erase all the coarse mesh levels
//mlMsh.EraseCoarseLevels(numberOfUniformLevels - 3);
mlMsh.EraseCoarseLevels(3);
// print mesh info
mlMsh.PrintInfo();
MultiLevelSolution mlSol(&mlMsh);
// add variables to mlSol
mlSol.AddSolution("T", LAGRANGE, SERENDIPITY, 2);
mlSol.AddSolution("U", LAGRANGE, SECOND, 2);
mlSol.AddSolution("V", LAGRANGE, SECOND, 2);
if(dim == 3) mlSol.AddSolution("W", LAGRANGE, SECOND, 2);
//mlSol.AddSolution("P", LAGRANGE, FIRST);
mlSol.AddSolution("P", DISCONTINUOUS_POLYNOMIAL, FIRST, 2);
mlSol.AssociatePropertyToSolution("P", "Pressure");
mlSol.Initialize("All");
mlSol.Initialize("T", InitalValueT);
// attach the boundary condition function and generate boundary data
mlSol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);
mlSol.FixSolutionAtOnePoint("P");
mlSol.GenerateBdc("U");
mlSol.GenerateBdc("V");
mlSol.GenerateBdc("P");
mlSol.GenerateBdc("T", "Time_dependent");
// define the multilevel problem attach the mlSol object to it
MultiLevelProblem mlProb(&mlSol);
// add system Poisson in mlProb as a Linear Implicit System
TransientNonlinearImplicitSystem& system = mlProb.add_system < TransientNonlinearImplicitSystem > ("NS");
if(precType == FS_TVp || precType == ASM_TVp || precType == ILU_TVp) system.AddSolutionToSystemPDE("T");
// add solution "u" to system
system.AddSolutionToSystemPDE("U");
system.AddSolutionToSystemPDE("V");
if(precType == ASM_VTp) system.AddSolutionToSystemPDE("T");
if(dim == 3) system.AddSolutionToSystemPDE("W");
system.AddSolutionToSystemPDE("P");
//.........这里部分代码省略.........