本文整理汇总了C++中teuchos::RCP::L2NormOfError方法的典型用法代码示例。如果您正苦于以下问题:C++ RCP::L2NormOfError方法的具体用法?C++ RCP::L2NormOfError怎么用?C++ RCP::L2NormOfError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::RCP
的用法示例。
在下文中一共展示了RCP::L2NormOfError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
#ifdef HAVE_MPI
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
int rank=mpiSession.getRank();
int numProcs=mpiSession.getNProc();
#else
int rank = 0;
int numProcs = 1;
#endif
int polyOrder = 3;
int pToAdd = 4; // for tests
// define our manufactured solution or problem bilinear form:
double epsilon = 1e-5;
bool useTriangles = false;
Teuchos::RCP<ConfusionBilinearForm> bf = Teuchos::rcp(new ConfusionBilinearForm(epsilon));
Teuchos::RCP<VortexManufacturedSolution> exactSolution = Teuchos::rcp(new VortexManufacturedSolution(epsilon));
bool useExactSolution =true;
FieldContainer<double> quadPoints(4,2);
quadPoints(0,0) = 0.0; // x1
quadPoints(0,1) = 0.0; // y1
quadPoints(1,0) = 1.0;
quadPoints(1,1) = 0.0;
quadPoints(2,0) = 1.0;
quadPoints(2,1) = 1.0;
quadPoints(3,0) = 0.0;
quadPoints(3,1) = 1.0;
int H1Order = polyOrder + 1;
int horizontalCells = 4, verticalCells = 4;
////////////////////////////////////////////////////////////////////
// SET UP PROBLEM
////////////////////////////////////////////////////////////////////
// create a pointer to a new mesh:
Teuchos::RCP<Mesh> mesh = Mesh::buildQuadMesh(quadPoints, horizontalCells, verticalCells, bf, H1Order, H1Order+pToAdd, useTriangles);
mesh->setPartitionPolicy(Teuchos::rcp(new ZoltanMeshPartitionPolicy("HSFC")));
// define our inner product:
// Teuchos::RCP<ConfusionInnerProduct> ip = Teuchos::rcp( new ConfusionInnerProduct( bf, mesh ) );
Teuchos::RCP<MathInnerProduct> ip = Teuchos::rcp( new MathInnerProduct( bf ) );
// create a solution object
Teuchos::RCP<Solution> solution;
Teuchos::RCP<LocalStiffnessMatrixFilter> penaltyBC;
if (useExactSolution){
solution = Teuchos::rcp(new Solution(mesh, exactSolution->bc(), exactSolution->ExactSolution::rhs(), ip));
penaltyBC= Teuchos::rcp(new PenaltyMethodFilter(exactSolution));
} else {
Teuchos::RCP<VortexProblem> problem = Teuchos::rcp( new VortexProblem(bf) );
solution = Teuchos::rcp(new Solution(mesh, problem, problem, ip));
penaltyBC = Teuchos::rcp(new PenaltyMethodFilter(problem));
}
solution->setFilter(penaltyBC);
////////////////////////////////////////////////////////////////////
// define refinement strategy:
double energyThreshold = .2;
Teuchos::RCP<RefinementStrategy> refinementStrategy = Teuchos::rcp(new RefinementStrategy(solution,energyThreshold));
solution->solve(false);
cout << "Processor " << rank << " returned from solve()." << endl;
if (rank==0){
solution->writeFieldsToFile(ConfusionBilinearForm::U, "u.m");
solution->writeFluxesToFile(ConfusionBilinearForm::U_HAT, "u_hat.dat");
solution->writeFluxesToFile(ConfusionBilinearForm::BETA_N_U_MINUS_SIGMA_HAT, "sigma_hat.dat");
}
double l2error = exactSolution->L2NormOfError(*solution, ConfusionBilinearForm::U,15);
cout << " L2 error: " << l2error << endl;
bool limitIrregularity = true;
int numRefinements = 6;
double thresholdFactor = 0.2;
int refIterCount = 0;
vector<double> errorVector;
vector<double> L2errorVector;
vector<int> dofVector;
for (int i=0; i<numRefinements; i++) {
double totalEnergyError = solution->energyErrorTotal();
if (useExactSolution){
// print out the L2 error of the solution:
int cubDegree = 20;
l2error = exactSolution->L2NormOfError(*solution, ConfusionBilinearForm::U,cubDegree);
L2errorVector.push_back(l2error);
}
if (rank==0){
if (useExactSolution) {
cout << "L2 error: " << l2error << endl;
}
}
errorVector.push_back(totalEnergyError);
dofVector.push_back(mesh->numGlobalDofs());
//.........这里部分代码省略.........