本文整理汇总了C++中BCPtr类的典型用法代码示例。如果您正苦于以下问题:C++ BCPtr类的具体用法?C++ BCPtr怎么用?C++ BCPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BCPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
Teuchos::GlobalMPISession mpiSession(&argc, &argv, NULL); // initialize MPI
Teuchos::CommandLineProcessor cmdp(false,true); // false: don't throw exceptions; true: do return errors for unrecognized options
int numElements = 3;
double xLeft = 0.0, xRight = 1.0;
int polyOrder = 1, delta_k = 1;
cmdp.setOption("numElements", &numElements );
cmdp.setOption("polyOrder", &polyOrder );
cmdp.setOption("delta_k", &delta_k );
cmdp.setOption("xLeft", &xLeft );
cmdp.setOption("xRight", &xRight );
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL)
{
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return -1;
}
int spaceDim = 1;
bool conformingTraces = true; // conformingTraces argument has no effect in 1D
PoissonFormulation poissonForm(spaceDim, conformingTraces);
MeshPtr mesh = MeshFactory::intervalMesh(poissonForm.bf(), xLeft, xRight, numElements, polyOrder + 1, delta_k); // 1D equispaced
RHSPtr rhs = RHS::rhs(); // zero RHS
IPPtr ip = poissonForm.bf()->graphNorm();
BCPtr bc = BC::bc();
bc->addDirichlet(poissonForm.phi_hat(), SpatialFilter::allSpace(), Function::zero());
SolutionPtr solution = Solution::solution(poissonForm.bf(), mesh, bc, rhs, ip);
solution->solve();
GDAMinimumRule* minRule = dynamic_cast<GDAMinimumRule*>(mesh->globalDofAssignment().get());
// minRule->printGlobalDofInfo();
Teuchos::RCP<Epetra_CrsMatrix> A = solution->getStiffnessMatrix();
EpetraExt::RowMatrixToMatrixMarketFile("A.dat",*A, NULL, NULL, false);
HDF5Exporter exporter(mesh);
return 0;
}
示例2: main
//.........这里部分代码省略.........
// mathematician's norm
IPPtr mathIP = Teuchos::rcp(new IP());
mathIP->addTerm(tau);
mathIP->addTerm(tau->div());
mathIP->addTerm(v);
mathIP->addTerm(v->grad());
// quasi-optimal norm
IPPtr qoptIP = Teuchos::rcp(new IP);
if (!useCompliantGraphNorm) {
qoptIP->addTerm( tau / eps + v->grad() );
qoptIP->addTerm( beta_const * v->grad() - tau->div() );
qoptIP->addTerm( v );
} else {
FunctionPtr h = Teuchos::rcp( new hFunction );
// here, we're aiming at optimality in 1/h^2 |u|^2 + 1/eps^2 |sigma|^2
qoptIP->addTerm( tau + eps * v->grad() );
qoptIP->addTerm( h * beta_const * v->grad() - tau->div() );
qoptIP->addTerm(v);
qoptIP->addTerm(tau);
}
//////////////////// SPECIFY RHS ///////////////////////
RHSPtr rhs = RHS::rhs();
FunctionPtr f = Teuchos::rcp( new ConstantScalarFunction(0.0) );
rhs->addTerm( f * v ); // obviously, with f = 0 adding this term is not necessary!
//////////////////// CREATE BCs ///////////////////////
BCPtr bc = BC::bc();
SpatialFilterPtr inflowBoundary = Teuchos::rcp( new InflowSquareBoundary );
SpatialFilterPtr outflowBoundary = Teuchos::rcp( new OutflowSquareBoundary );
FunctionPtr u0 = Teuchos::rcp( new U0 );
bc->addDirichlet(uhat, outflowBoundary, u0);
bc->addDirichlet(uhat, inflowBoundary, u0);
// Teuchos::RCP<PenaltyConstraints> pc = Teuchos::rcp(new PenaltyConstraints);
// pc->addConstraint(uhat==u0,inflowBoundary);
//////////////////// BUILD MESH ///////////////////////
// create a new mesh on a single-cell, unit square domain
Teuchos::RCP<Mesh> mesh = MeshFactory::quadMeshMinRule(confusionBF, H1Order, delta_k);
//////////////////// SOLVE & REFINE ///////////////////////
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, qoptIP) );
// solution->setFilter(pc);
double energyThreshold = 0.2; // for mesh refinements
bool useRieszRepBasedRefStrategy = true;
if (rank==0) {
if (useRieszRepBasedRefStrategy) {
cout << "using RieszRep-based refinement strategy.\n";
} else {
cout << "using solution-based refinement strategy.\n";
}
}
Teuchos::RCP<RefinementStrategy> refinementStrategy;
if (!useRieszRepBasedRefStrategy) {
refinementStrategy = Teuchos::rcp( new RefinementStrategy( solution, energyThreshold ) );
示例3: BF
bool VectorizedBasisTestSuite::testPoisson()
{
bool success = true;
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactoryPtr varFactory = VarFactory::varFactory();
VarPtr tau = varFactory->testVar("\\tau", HDIV);
VarPtr v = varFactory->testVar("v", HGRAD);
// define trial variables
VarPtr uhat = varFactory->traceVar("\\widehat{u}");
VarPtr sigma_n = varFactory->fluxVar("\\widehat{\\sigma_{n}}");
VarPtr u = varFactory->fieldVar("u");
VarPtr sigma = varFactory->fieldVar("\\sigma", VECTOR_L2);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
// tau terms:
bf->addTerm(sigma, tau);
bf->addTerm(u, tau->div());
bf->addTerm(-uhat, tau->dot_normal());
// v terms:
bf->addTerm( sigma, v->grad() );
bf->addTerm( -sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = bf->graphNorm();
//////////////////// SPECIFY RHS ///////////////////////
RHSPtr rhs = RHS::rhs();
FunctionPtr f = Function::constant(1.0);
rhs->addTerm( f * v );
//////////////////// CREATE BCs ///////////////////////
BCPtr bc = BC::bc();
SpatialFilterPtr boundary = SpatialFilter::allSpace();
FunctionPtr zero = Function::zero();
bc->addDirichlet(uhat, boundary, zero);
//////////////////// BUILD MESH ///////////////////////
int H1Order = 3, pToAdd = 2;
// define nodes for mesh
FieldContainer<double> meshBoundary(4,2);
meshBoundary(0,0) = 0.0; // x1
meshBoundary(0,1) = 0.0; // y1
meshBoundary(1,0) = 1.0;
meshBoundary(1,1) = 0.0;
meshBoundary(2,0) = 1.0;
meshBoundary(2,1) = 1.0;
meshBoundary(3,0) = 0.0;
meshBoundary(3,1) = 1.0;
int horizontalCells = 1, verticalCells = 1;
// create a pointer to a new mesh:
Teuchos::RCP<Mesh> mesh = MeshFactory::buildQuadMesh(meshBoundary, horizontalCells, verticalCells,
bf, H1Order, H1Order+pToAdd, false);
//////////////////// SOLVE & REFINE ///////////////////////
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, ip) );
double energyThreshold = 0.2; // for mesh refinements
RefinementStrategy refinementStrategy( solution, energyThreshold );
#ifdef USE_VTK
VTKExporter exporter(solution, mesh, varFactory);
#endif
for (int refIndex=0; refIndex<=4; refIndex++)
{
solution->solve(false);
#ifdef USE_VTK
// output commented out because it's not properly part of the test.
// stringstream outfile;
// outfile << "test_" << refIndex;
// exporter.exportSolution(outfile.str());
#endif
if (refIndex < 4)
refinementStrategy.refine(false); // don't print to console
}
return success;
}
示例4: 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 = 2;
// define our manufactured solution or problem bilinear form:
double epsilon = 1e-3;
bool useTriangles = false;
int pToAdd = 2;
int nCells = 2;
if ( argc > 1)
{
nCells = atoi(argv[1]);
if (rank==0)
{
cout << "numCells = " << nCells << endl;
}
}
int numSteps = 20;
if ( argc > 2)
{
numSteps = atoi(argv[2]);
if (rank==0)
{
cout << "num NR steps = " << numSteps << endl;
}
}
int useHessian = 0; // defaults to "not use"
if ( argc > 3)
{
useHessian = atoi(argv[3]);
if (rank==0)
{
cout << "useHessian = " << useHessian << endl;
}
}
int thresh = numSteps; // threshhold for when to apply linesearch/hessian
if ( argc > 4)
{
thresh = atoi(argv[4]);
if (rank==0)
{
cout << "thresh = " << thresh << endl;
}
}
int H1Order = polyOrder + 1;
double energyThreshold = 0.2; // for mesh refinements
double nonlinearStepSize = 0.5;
double nonlinearRelativeEnergyTolerance = 1e-8; // used to determine convergence of the nonlinear solution
////////////////////////////////////////////////////////////////////
// DEFINE VARIABLES
////////////////////////////////////////////////////////////////////
// new-style bilinear form definition
VarFactory varFactory;
VarPtr uhat = varFactory.traceVar("\\widehat{u}");
VarPtr beta_n_u_minus_sigma_hat = varFactory.fluxVar("\\widehat{\\beta_n u - \\sigma_n}");
VarPtr u = varFactory.fieldVar("u");
VarPtr sigma1 = varFactory.fieldVar("\\sigma_1");
VarPtr sigma2 = varFactory.fieldVar("\\sigma_2");
VarPtr tau = varFactory.testVar("\\tau",HDIV);
VarPtr v = varFactory.testVar("v",HGRAD);
BFPtr bf = Teuchos::rcp( new BF(varFactory) ); // initialize bilinear form
////////////////////////////////////////////////////////////////////
// CREATE MESH
////////////////////////////////////////////////////////////////////
// create a pointer to a new mesh:
Teuchos::RCP<Mesh> mesh = MeshUtilities::buildUnitQuadMesh(nCells, bf, H1Order, H1Order+pToAdd);
mesh->setPartitionPolicy(Teuchos::rcp(new ZoltanMeshPartitionPolicy("HSFC")));
////////////////////////////////////////////////////////////////////
// INITIALIZE BACKGROUND FLOW FUNCTIONS
////////////////////////////////////////////////////////////////////
BCPtr nullBC = Teuchos::rcp((BC*)NULL);
RHSPtr nullRHS = Teuchos::rcp((RHS*)NULL);
IPPtr nullIP = Teuchos::rcp((IP*)NULL);
SolutionPtr backgroundFlow = Teuchos::rcp(new Solution(mesh, nullBC,
nullRHS, nullIP) );
vector<double> e1(2); // (1,0)
e1[0] = 1;
vector<double> e2(2); // (0,1)
e2[1] = 1;
FunctionPtr u_prev = Teuchos::rcp( new PreviousSolutionFunction(backgroundFlow, u) );
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
// define trial variables
VarPtr uhat = varFactory.traceVar("uhat");
VarPtr fhat = varFactory.fluxVar("fhat");
VarPtr u = varFactory.fieldVar("u");
VarPtr sigma = varFactory.fieldVar("sigma", VECTOR_L2);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
// tau terms:
bf->addTerm(sigma, tau);
bf->addTerm(u, tau->div());
bf->addTerm(-uhat, tau->dot_normal());
// v terms:
bf->addTerm( sigma, v->grad() );
bf->addTerm( fhat, v);
//////////////////// BUILD MESH ///////////////////////
int H1Order = 4, pToAdd = 2;
Teuchos::RCP<Mesh> mesh = Teuchos::rcp( new Mesh (meshTopology, bf, H1Order, pToAdd) );
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = bf->graphNorm();
//////////////////// SPECIFY RHS ///////////////////////
RHSPtr rhs = RHS::rhs();
// Teuchos::RCP<RHS> rhs = Teuchos::rcp( new RHS );
FunctionPtr one = Function::constant(1.0);
rhs->addTerm( one * v );
//////////////////// CREATE BCs ///////////////////////
// Teuchos::RCP<BC> bc = Teuchos::rcp( new BCEasy );
BCPtr bc = BC::bc();
FunctionPtr zero = Function::zero();
SpatialFilterPtr entireBoundary = Teuchos::rcp( new EntireBoundary );
bc->addDirichlet(uhat, entireBoundary, zero);
//////////////////// SOLVE & REFINE ///////////////////////
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, ip) );
solution->solve(false);
RefinementStrategy refinementStrategy( solution, 0.2);
// Output solution
FunctionPtr uSoln = Function::solution(u, solution);
FunctionPtr sigmaSoln = Function::solution(sigma, solution);
FunctionPtr uhatSoln = Function::solution(uhat, solution);
FunctionPtr fhatSoln = Function::solution(fhat, solution);
{
XDMFExporter exporter(meshTopology, "Poisson", false);
exporter.exportFunction(uSoln, "u", 0, 4);
exporter.exportFunction(uSoln, "u", 1, 5);
exporter.exportFunction(uhatSoln, "uhat", 0, 4);
exporter.exportFunction(uhatSoln, "uhat", 1, 5);
// exporter.exportFunction(fhatSoln, "fhat", 0, 4);
// exporter.exportFunction(fhatSoln, "fhat", 1, 5);
}
{
XDMFExporter exporter(meshTopology, "PoissonSolution", false);
exporter.exportSolution(solution, mesh, varFactory, 0, 2, cellIDToSubdivision(mesh, 10));
refinementStrategy.refine(true);
solution->solve(false);
exporter.exportSolution(solution, mesh, varFactory, 1, 2, cellIDToSubdivision(mesh, 10));
}
// exporter.exportFunction(sigmaSoln, "Poisson-s", "sigma", 0, 5);
// exporter.exportFunction(uhatSoln, "Poisson-uhat", "uhat", 1, 6);
示例6: main
//.........这里部分代码省略.........
#ifdef HAVE_AMESOS_MUMPS
if (useMumpsIfAvailable) solver = Teuchos::rcp( new MumpsSolver );
#endif
// double errorPercentage = 0.5; // for mesh refinements: ask to refine elements that account for 80% of the error in each step
// Teuchos::RCP<RefinementStrategy> refinementStrategy;
// refinementStrategy = Teuchos::rcp( new ErrorPercentageRefinementStrategy( soln, errorPercentage ));
if (maxRefinements != 0)
{
cout << "Warning: maxRefinements is not 0, but the slice exporter implicitly assumes there won't be any refinements.\n";
}
MeshPtr mesh;
MeshPtr prevMesh;
SolutionPtr prevSoln;
mesh = MeshFactory::rectilinearMesh(bf, dimensions, elementCounts, H1Order, delta_k, origin);
if (rank==0) cout << "Initial mesh has " << mesh->getTopology()->activeCellCount() << " active (leaf) cells " << "and " << mesh->globalDofCount() << " degrees of freedom.\n";
FunctionPtr sideParity = Function::sideParity();
int lastFrameOutputted = -1;
SolutionPtr soln;
IPPtr ip;
ip = bf->graphNorm();
FunctionPtr u0 = Teuchos::rcp( new Cone_U0(0.0, 0.25, 0.1, 1.0, false) );
BCPtr bc = BC::bc();
bc->addDirichlet(qHat, inflowFilter, Function::zero()); // zero BCs enforced at the inflow boundary.
bc->addDirichlet(qHat, SpatialFilter::matchingZ(t0), u0);
MeshPtr initialMesh = mesh;
int startingSlabNumber;
if (previousSolutionTimeSlabNumber != -1)
{
startingSlabNumber = previousSolutionTimeSlabNumber + 1;
if (rank==0) cout << "Loading mesh from " << previousMeshFile << endl;
prevMesh = MeshFactory::loadFromHDF5(bf, previousMeshFile);
prevSoln = Solution::solution(mesh, bc, RHS::rhs(), ip); // include BC and IP objects for sake of condensed dof interpreter setup...
prevSoln->setUseCondensedSolve(useCondensedSolve);
if (rank==0) cout << "Loading solution from " << previousSolutionFile << endl;
prevSoln->loadFromHDF5(previousSolutionFile);
double tn = (previousSolutionTimeSlabNumber+1) * timeLengthPerSlab;
origin[2] = tn;
mesh = MeshFactory::rectilinearMesh(bf, dimensions, elementCounts, H1Order, delta_k, origin);
FunctionPtr q_prev = Function::solution(qHat, prevSoln);
FunctionPtr q_transfer = Teuchos::rcp( new MeshTransferFunction(-q_prev, prevMesh, mesh, tn) ); // negate because the normals go in opposite directions
bc = BC::bc();
bc->addDirichlet(qHat, inflowFilter, Function::zero()); // zero BCs enforced at the inflow boundary.
bc->addDirichlet(qHat, SpatialFilter::matchingZ(tn), q_transfer);
double t_slab_final = (previousSolutionTimeSlabNumber+1) * timeLengthPerSlab;
int frameOrdinal = 0;
示例7: BF
void TransientTests::SetUp()
{
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarPtr v = varFactory.testVar("v", HGRAD);
// define trial variables
beta_n_u_hat = varFactory.fluxVar("\\widehat{\\beta \\cdot n }");
u = varFactory.fieldVar("u");
vector<double> beta;
beta.push_back(1.0);
beta.push_back(0.0);
//////////////////// BUILD MESH ///////////////////////
bf = Teuchos::rcp( new BF(varFactory) );
// define nodes for mesh
FieldContainer<double> meshBoundary(4,2);
meshBoundary(0,0) = 0.0; // x1
meshBoundary(0,1) = -2.0; // y1
meshBoundary(1,0) = 4.0;
meshBoundary(1,1) = -2.0;
meshBoundary(2,0) = 4.0;
meshBoundary(2,1) = 2.0;
meshBoundary(3,0) = 0.0;
meshBoundary(3,1) = 2.0;
int horizontalCells = 4, verticalCells = 4;
// create a pointer to a new mesh:
mesh = MeshFactory::buildQuadMesh(meshBoundary, horizontalCells, verticalCells,
bf, H1Order, H1Order+pToAdd);
////////////////////////////////////////////////////////////////////
// INITIALIZE FLOW FUNCTIONS
////////////////////////////////////////////////////////////////////
BCPtr nullBC = Teuchos::rcp((BC*)NULL);
RHSPtr nullRHS = Teuchos::rcp((RHS*)NULL);
IPPtr nullIP = Teuchos::rcp((IP*)NULL);
prevTimeFlow = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP) );
flowResidual = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP) );
FunctionPtr u_prev_time = Teuchos::rcp( new PreviousSolutionFunction(prevTimeFlow, u) );
//////////////////// DEFINE BILINEAR FORM ///////////////////////
RHSPtr rhs = RHS::rhs();
FunctionPtr invDt = Teuchos::rcp(new ScalarParamFunction(1.0/dt));
// v terms:
bf->addTerm( beta * u, - v->grad() );
bf->addTerm( beta_n_u_hat, v);
// transient terms
bf->addTerm( u, invDt*v );
rhs->addTerm( u_prev_time * invDt * v );
//////////////////// SPECIFY RHS ///////////////////////
FunctionPtr f = Teuchos::rcp( new ConstantScalarFunction(0.0) );
rhs->addTerm( f * v ); // obviously, with f = 0 adding this term is not necessary!
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = bf->graphNorm();
//////////////////// CREATE BCs ///////////////////////
BCPtr bc = BC::bc();
SpatialFilterPtr lBoundary = Teuchos::rcp( new LeftBoundary );
FunctionPtr u1 = Teuchos::rcp( new InletBC );
bc->addDirichlet(beta_n_u_hat, lBoundary, -u1);
solution = Teuchos::rcp( new Solution(mesh, bc, rhs, ip) );
// ==================== Register Solutions ==========================
mesh->registerSolution(solution);
mesh->registerSolution(prevTimeFlow);
mesh->registerSolution(flowResidual);
// ==================== SET INITIAL GUESS ==========================
double u_free = 0.0;
map<int, Teuchos::RCP<Function> > functionMap;
functionMap[u->ID()] = Teuchos::rcp( new ConstantScalarFunction(u_free) );
// prevTimeFlow->projectOntoMesh(functionMap);
}
示例8: main
int main(int argc, char *argv[])
{
Teuchos::GlobalMPISession mpiSession(&argc, &argv, 0);
int spaceDim = 2;
int meshWidth = 2;
bool conformingTraces = true;
int H1Order = 2, delta_k = 3;
double domainWidth = 1.0e-3;
bool diagScaling = false;
double h = domainWidth / meshWidth;
double weight = h / 4.0; // ratio of area of square with sidelength h to its perimeter
double sigma_weight = 1.0; // h / 4.0; // sigma = sigma_weight * u->grad()
Space uHatSpace = conformingTraces ? HGRAD : L2;
VarFactoryPtr vf = VarFactory::varFactory();
// fields
VarPtr u = vf->fieldVar("u");
VarPtr sigma = vf->fieldVar("sigma", VECTOR_L2);
// traces
VarPtr u_hat = vf->traceVar("u_hat", uHatSpace);
VarPtr sigma_n = vf->fluxVar("sigma_n");
// tests
VarPtr v = vf->testVar("v", HGRAD);
VarPtr tau = vf->testVar("tau", HDIV);
BFPtr bf = BF::bf(vf);
// standard BF:
// bf->addTerm(sigma, v->grad());
// bf->addTerm(sigma_n, v);
//
// bf->addTerm(sigma, tau);
// bf->addTerm(u, tau->div());
// bf->addTerm(-u_hat, tau->dot_normal());
// weighted BF:
bf->addTerm(sigma, v->grad());
bf->addTerm(weight * sigma_n, v);
bf->addTerm(sigma, tau);
bf->addTerm(sigma_weight * u, tau->div());
bf->addTerm(- sigma_weight * weight * u_hat, tau->dot_normal());
IPPtr ip = IP::ip();
// standard IP:
ip->addTerm(tau + v->grad());
ip->addTerm(tau->div());
ip->addTerm(v);
ip->addTerm(tau);
// weighted IP:
// ip->addTerm(tau + v->grad());
// ip->addTerm(sigma_weight * tau->div());
// ip->addTerm(max(sigma_weight,1e-3) * v);
// ip->addTerm(sigma_weight * weight * tau);
BCPtr bc = BC::bc();
bc->addDirichlet(u_hat, SpatialFilter::allSpace(), Function::zero());
RHSPtr rhs = RHS::rhs();
rhs->addTerm(1.0 * sigma_weight * v);
vector<double> dimensions(spaceDim,domainWidth);
vector<int> elementCounts(spaceDim,meshWidth);
MeshPtr mesh = MeshFactory::rectilinearMesh(bf, dimensions, elementCounts, H1Order, delta_k);
SolutionPtr soln = Solution::solution(mesh, bc, rhs, ip);
soln->setUseCondensedSolve(true);
soln->initializeLHSVector();
soln->initializeStiffnessAndLoad();
soln->populateStiffnessAndLoad();
Teuchos::RCP<Epetra_RowMatrix> stiffness = soln->getStiffnessMatrix();
double condNumber = conditionNumberLAPACK(*stiffness, diagScaling);
cout << "condest (1-norm): " << condNumber << endl;
return 0;
}
示例9: BF
bool ScratchPadTests::testResidualMemoryError()
{
int rank = Teuchos::GlobalMPISession::getRank();
double tol = 1e-11;
bool success = true;
int nCells = 2;
double eps = 1e-2;
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactoryPtr varFactory = VarFactory::varFactory();
VarPtr tau = varFactory->testVar("\\tau", HDIV);
VarPtr v = varFactory->testVar("v", HGRAD);
// define trial variables
VarPtr uhat = varFactory->traceVar("\\widehat{u}");
VarPtr beta_n_u_minus_sigma_n = varFactory->fluxVar("\\widehat{\\beta \\cdot n u - \\sigma_{n}}");
VarPtr u = varFactory->fieldVar("u");
VarPtr sigma1 = varFactory->fieldVar("\\sigma_1");
VarPtr sigma2 = varFactory->fieldVar("\\sigma_2");
vector<double> beta;
beta.push_back(1.0);
beta.push_back(0.0);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr confusionBF = Teuchos::rcp( new BF(varFactory) );
// tau terms:
confusionBF->addTerm(sigma1 / eps, tau->x());
confusionBF->addTerm(sigma2 / eps, tau->y());
confusionBF->addTerm(u, tau->div());
confusionBF->addTerm(uhat, -tau->dot_normal());
// v terms:
confusionBF->addTerm( sigma1, v->dx() );
confusionBF->addTerm( sigma2, v->dy() );
confusionBF->addTerm( -u, beta * v->grad() );
confusionBF->addTerm( beta_n_u_minus_sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
// robust test norm
IPPtr robIP = Teuchos::rcp(new IP);
robIP->addTerm(tau);
robIP->addTerm(tau->div());
robIP->addTerm(v->grad());
robIP->addTerm(v);
//////////////////// SPECIFY RHS ///////////////////////
FunctionPtr zero = Function::constant(0.0);
FunctionPtr one = Function::constant(1.0);
RHSPtr rhs = RHS::rhs();
FunctionPtr f = zero;
// FunctionPtr f = one;
rhs->addTerm( f * v ); // obviously, with f = 0 adding this term is not necessary!
//////////////////// CREATE BCs ///////////////////////
BCPtr bc = BC::bc();
SpatialFilterPtr inflowBoundary = Teuchos::rcp( new LRInflowSquareBoundary );
SpatialFilterPtr outflowBoundary = Teuchos::rcp( new LROutflowSquareBoundary);
FunctionPtr n = Function::normal();
vector<double> e1,e2;
e1.push_back(1.0);
e1.push_back(0.0);
e2.push_back(0.0);
e2.push_back(1.0);
bc->addDirichlet(beta_n_u_minus_sigma_n, inflowBoundary, beta*n*one);
bc->addDirichlet(uhat, outflowBoundary, zero);
//////////////////// BUILD MESH ///////////////////////
// define nodes for mesh
int order = 2;
int H1Order = order+1;
int pToAdd = 2;
// create a pointer to a new mesh:
Teuchos::RCP<Mesh> mesh = MeshUtilities::buildUnitQuadMesh(nCells,confusionBF, H1Order, H1Order+pToAdd);
// mesh->setPartitionPolicy(Teuchos::rcp(new ZoltanMeshPartitionPolicy("HSFC")));
//////////////////// SOLVE & REFINE ///////////////////////
Teuchos::RCP<Solution> solution;
solution = Teuchos::rcp( new Solution(mesh, bc, rhs, robIP) );
solution->solve(false);
mesh->registerSolution(solution);
double energyErr1 = solution->energyErrorTotal();
LinearTermPtr residual = rhs->linearTermCopy();
residual->addTerm(-confusionBF->testFunctional(solution));
RieszRepPtr rieszResidual = Teuchos::rcp(new RieszRep(mesh, robIP, residual));
rieszResidual->computeRieszRep();
FunctionPtr e_v = RieszRep::repFunction(v,rieszResidual);
//.........这里部分代码省略.........
示例10: main
int main(int argc, char *argv[])
{
Teuchos::GlobalMPISession mpiSession(&argc, &argv, NULL); // initialize MPI
Teuchos::CommandLineProcessor cmdp(false,true); // false: don't throw exceptions; true: do return errors for unrecognized options
int numElements = 3;
vector<vector<double>> domainDim(3,vector<double>{0.0,1.0}); // first index: spaceDim; second: 0/1 for x0, x1, etc.
int polyOrder = 2, delta_k = 1;
int spaceDim = 2;
cmdp.setOption("numElements", &numElements );
cmdp.setOption("polyOrder", &polyOrder );
cmdp.setOption("delta_k", &delta_k );
cmdp.setOption("x0", &domainDim[0][0] );
cmdp.setOption("x1", &domainDim[0][1] );
cmdp.setOption("y0", &domainDim[1][0] );
cmdp.setOption("y1", &domainDim[1][1] );
cmdp.setOption("z0", &domainDim[2][0] );
cmdp.setOption("z1", &domainDim[2][1] );
cmdp.setOption("spaceDim", &spaceDim);
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL)
{
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return -1;
}
vector<double> x0(spaceDim);
vector<double> domainSize(spaceDim);
vector<int> elementCounts(spaceDim);
for (int d=0; d<spaceDim; d++)
{
x0[d] = domainDim[d][0];
domainSize[d] = domainDim[d][1] - x0[d];
elementCounts[d] = numElements;
}
bool conformingTraces = true; // no difference for primal/continuous formulations
PoissonFormulation formCG(spaceDim, conformingTraces, PoissonFormulation::CONTINUOUS_GALERKIN);
VarPtr q = formCG.q();
VarPtr phi = formCG.phi();
BFPtr bf = formCG.bf();
MeshPtr bubnovMesh = MeshFactory::rectilinearMesh(bf, domainSize, elementCounts, polyOrder, 0, x0);
// Right now, hanging nodes don't work with continuous field variables
// there is a GDAMinimumRule test demonstrating the failure, SolvePoisson2DContinuousGalerkinHangingNode.
// make a mesh with hanging nodes (when spaceDim > 1)
// {
// set<GlobalIndexType> cellsToRefine = {0};
// bubnovMesh->hRefine(cellsToRefine);
// }
RHSPtr rhs = RHS::rhs();
rhs->addTerm(1.0 * q); // unit forcing
IPPtr ip = Teuchos::null; // will give Bubnov-Galerkin
BCPtr bc = BC::bc();
bc->addDirichlet(phi, SpatialFilter::allSpace(), Function::zero());
SolutionPtr solution = Solution::solution(bf, bubnovMesh, bc, rhs, ip);
solution->solve();
HDF5Exporter exporter(bubnovMesh, "PoissonContinuousGalerkin");
exporter.exportSolution(solution);
/**** Sort-of-primal experiment ****/
// an experiment: try doing "primal" DPG with IBP to the boundary
// ip = IP::ip();
// ip->addTerm(q->grad());
// ip->addTerm(q);
//
// solution = Solution::solution(bf, bubnovMesh, bc, rhs, ip);
// solution->solve();
//
// HDF5Exporter primalNoFluxExporter(bubnovMesh, "PoissonPrimalNoFlux");
// primalNoFluxExporter.exportSolution(solution);
//*** Primal Formulation ***//
PoissonFormulation form(spaceDim, conformingTraces, PoissonFormulation::PRIMAL);
q = form.q();
phi = form.phi();
bf = form.bf();
bc = BC::bc();
bc->addDirichlet(phi, SpatialFilter::allSpace(), Function::zero());
rhs = RHS::rhs();
rhs->addTerm(1.0 * q); // unit forcing
MeshPtr primalMesh = MeshFactory::rectilinearMesh(bf, domainSize, elementCounts, polyOrder, delta_k, x0);
ip = IP::ip();
ip->addTerm(q->grad());
ip->addTerm(q);
// Right now, hanging nodes don't work with continuous field variables
//.........这里部分代码省略.........
示例11: main
int main(int argc, char *argv[]) {
#ifdef HAVE_MPI
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
choice::MpiArgs args( argc, argv );
#else
choice::Args args( argc, argv );
#endif
int commRank = Teuchos::GlobalMPISession::getRank();
int numProcs = Teuchos::GlobalMPISession::getNProc();
// Required arguments
int numRefs = args.Input<int>("--numRefs", "number of refinement steps");
int norm = args.Input<int>("--norm", "0 = graph\n 1 = robust\n 2 = coupled robust");
// Optional arguments (have defaults)
bool enforceLocalConservation = args.Input<bool>("--conserve", "enforce local conservation", false);
double Re = args.Input("--Re", "Reynolds number", 40);
double nu = 1./Re;
double lambda = Re/2.-sqrt(Re*Re/4+4*pi*pi);
int maxNewtonIterations = args.Input("--maxIterations", "maximum number of Newton iterations", 20);
int polyOrder = args.Input("--polyOrder", "polynomial order for field variables", 2);
int deltaP = args.Input("--deltaP", "how much to enrich test space", 2);
// string saveFile = args.Input<string>("--meshSaveFile", "file to which to save refinement history", "");
// string replayFile = args.Input<string>("--meshLoadFile", "file with refinement history to replay", "");
args.Process();
// if (commRank==0)
// {
// cout << "saveFile is " << saveFile << endl;
// cout << "loadFile is " << replayFile << endl;
// }
//////////////////// PROBLEM DEFINITIONS ///////////////////////
int H1Order = polyOrder+1;
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactory varFactory;
VarPtr tau11 = varFactory.testVar("tau11", HGRAD);
VarPtr tau12 = varFactory.testVar("tau12", HGRAD);
VarPtr tau22 = varFactory.testVar("tau22", HGRAD);
VarPtr v1 = varFactory.testVar("v1", HGRAD);
VarPtr v2 = varFactory.testVar("v2", HGRAD);
// define trial variables
VarPtr u1 = varFactory.fieldVar("u1");
VarPtr u2 = varFactory.fieldVar("u2");
VarPtr sigma11 = varFactory.fieldVar("sigma11");
VarPtr sigma12 = varFactory.fieldVar("sigma12");
VarPtr sigma22 = varFactory.fieldVar("sigma22");
VarPtr u1hat = varFactory.traceVar("u1hat");
VarPtr u2hat = varFactory.traceVar("u2hat");
VarPtr t1hat = varFactory.fluxVar("t1hat");
VarPtr t2hat = varFactory.fluxVar("t2hat");
//////////////////// BUILD MESH ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
// define nodes for mesh
FieldContainer<double> meshBoundary(4,2);
double xmin = -0.5;
double xmax = 1.0;
double ymin = -0.5;
double ymax = 1.5;
meshBoundary(0,0) = xmin; // x1
meshBoundary(0,1) = ymin; // y1
meshBoundary(1,0) = xmax;
meshBoundary(1,1) = ymin;
meshBoundary(2,0) = xmax;
meshBoundary(2,1) = ymax;
meshBoundary(3,0) = xmin;
meshBoundary(3,1) = ymax;
int horizontalCells = 6, verticalCells = 8;
// create a pointer to a new mesh:
Teuchos::RCP<Mesh> mesh = MeshFactory::buildQuadMesh(meshBoundary, horizontalCells, verticalCells,
bf, H1Order, H1Order+deltaP);
////////////////////////////////////////////////////////////////////
// INITIALIZE BACKGROUND FLOW FUNCTIONS
////////////////////////////////////////////////////////////////////
BCPtr nullBC = Teuchos::rcp((BC*)NULL);
RHSPtr nullRHS = Teuchos::rcp((RHS*)NULL);
IPPtr nullIP = Teuchos::rcp((IP*)NULL);
SolutionPtr backgroundFlow = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP) );
vector<double> e1(2); // (1,0)
e1[0] = 1;
vector<double> e2(2); // (0,1)
e2[1] = 1;
FunctionPtr u1_prev = Function::solution(u1, backgroundFlow);
FunctionPtr u2_prev = Function::solution(u2, backgroundFlow);
// FunctionPtr sigma11_prev = Function::solution(sigma11, backgroundFlow);
// FunctionPtr sigma12_prev = Function::solution(sigma12, backgroundFlow);
// FunctionPtr sigma22_prev = Function::solution(sigma22, backgroundFlow);
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
FunctionPtr c;
if (useConstantConvection)
{
c = Function::vectorize(Function::constant(0.5), Function::constant(0.5));
}
else
{
c = Function::vectorize(y-0.5, 0.5-x);
}
// FunctionPtr c = Function::vectorize(y, x);
FunctionPtr n = Function::normal();
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
bf->addTerm(u / dt, v);
bf->addTerm(- theta * u, c * v->grad());
// bf->addTerm(theta * u_hat, (c * n) * v);
bf->addTerm(qHat, v);
double width = 2.0, height = 2.0;
int horizontalCells = numCells, verticalCells = numCells;
double x0 = -0.5;
double y0 = -0.5;
if (usePeriodicBCs)
{
x0 = 0.0;
y0 = 0.0;
width = 1.0;
height = 1.0;
}
BCPtr bc = BC::bc();
SpatialFilterPtr inflowFilter = Teuchos::rcp( new InflowFilterForClockwisePlanarRotation (x0,x0+width,y0,y0+height,0.5,0.5));
vector< PeriodicBCPtr > periodicBCs;
if (! usePeriodicBCs)
{
// bc->addDirichlet(u_hat, SpatialFilter::allSpace(), Function::zero());
bc->addDirichlet(qHat, inflowFilter, Function::zero()); // zero BCs enforced at the inflow boundary.
}
else
{
periodicBCs.push_back(PeriodicBC::xIdentification(x0, x0+width));
periodicBCs.push_back(PeriodicBC::yIdentification(y0, y0+height));
}
MeshPtr mesh = MeshFactory::quadMeshMinRule(bf, H1Order, delta_k, width, height,
horizontalCells, verticalCells, false, x0, y0, periodicBCs);
FunctionPtr u0 = Teuchos::rcp( new Cone_U0(0.0, 0.25, 0.1, 1.0, usePeriodicBCs) );
RHSPtr initialRHS = RHS::rhs();
initialRHS->addTerm(u0 / dt * v);
initialRHS->addTerm((1-theta) * u0 * c * v->grad());
IPPtr ip;
// ip = Teuchos::rcp( new IP );
// ip->addTerm(v);
// ip->addTerm(c * v->grad());
ip = bf->graphNorm();
// create two Solution objects; we'll switch between these for time steps
SolutionPtr soln0 = Solution::solution(mesh, bc, initialRHS, ip);
示例13: main
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
int commRank = Teuchos::GlobalMPISession::getRank();
Comm.Barrier(); // set breakpoint here to allow debugger attachment to other MPI processes than the one you automatically attached to.
Teuchos::CommandLineProcessor cmdp(false,true); // false: don't throw exceptions; true: do return errors for unrecognized options
// problem parameters:
double mu = 0.1;
double permCoef = 1e4;
int numRefs = 0;
int k = 2, delta_k = 2;
string norm = "Graph";
cmdp.setOption("polyOrder",&k,"polynomial order for field variable u");
cmdp.setOption("delta_k", &delta_k, "test space polynomial order enrichment");
cmdp.setOption("numRefs",&numRefs,"number of refinements");
cmdp.setOption("norm", &norm, "norm");
cmdp.setOption("mu", &mu, "mu");
cmdp.setOption("permCoef", &permCoef, "Permeability coefficient");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL)
{
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return -1;
}
FunctionPtr zero = TFunction<double>::zero();
FunctionPtr one = TFunction<double>::constant(1);
FunctionPtr sin2pix = Teuchos::rcp( new Sin_ax(2*pi) );
FunctionPtr cos2pix = Teuchos::rcp( new Cos_ax(2*pi) );
FunctionPtr sin2piy = Teuchos::rcp( new Sin_ay(2*pi) );
FunctionPtr cos2piy = Teuchos::rcp( new Cos_ay(2*pi) );
FunctionPtr u1_exact = sin2pix*cos2piy;
FunctionPtr u2_exact = -cos2pix*sin2piy;
FunctionPtr x2 = TFunction<double>::xn(2);
FunctionPtr y2 = TFunction<double>::yn(2);
FunctionPtr p_exact = x2*y2 - 1./9;
FunctionPtr permInv = permCoef*(sin2pix + 1.1);
VarFactoryPtr vf = VarFactory::varFactory();
//fields:
VarPtr sigma1 = vf->fieldVar("sigma1", VECTOR_L2);
VarPtr sigma2 = vf->fieldVar("sigma2", VECTOR_L2);
VarPtr u1 = vf->fieldVar("u1", L2);
VarPtr u2 = vf->fieldVar("u2", L2);
VarPtr p = vf->fieldVar("p", L2);
// traces:
VarPtr u1hat = vf->traceVar("u1hat");
VarPtr u2hat = vf->traceVar("u2hat");
VarPtr t1c = vf->fluxVar("t1c");
VarPtr t2c = vf->fluxVar("t2c");
// test:
VarPtr v1 = vf->testVar("v1", HGRAD);
VarPtr v2 = vf->testVar("v2", HGRAD);
VarPtr tau1 = vf->testVar("tau1", HDIV);
VarPtr tau2 = vf->testVar("tau2", HDIV);
VarPtr q = vf->testVar("q", HGRAD);
BFPtr bf = Teuchos::rcp( new BF(vf) );
bf->addTerm(1./mu*sigma1, tau1);
bf->addTerm(1./mu*sigma2, tau2);
bf->addTerm(u1, tau1->div());
bf->addTerm(u2, tau2->div());
bf->addTerm(-u1hat, tau1->dot_normal());
bf->addTerm(-u2hat, tau2->dot_normal());
bf->addTerm(sigma1, v1->grad());
bf->addTerm(sigma2, v2->grad());
bf->addTerm(-p, v1->dx());
bf->addTerm(-p, v2->dy());
bf->addTerm(t1c, v1);
bf->addTerm(t2c, v2);
bf->addTerm(mu*permInv*u1, v1);
bf->addTerm(mu*permInv*u2, v2);
bf->addTerm(-u1, q->dx());
bf->addTerm(-u2, q->dy());
bf->addTerm(u1hat, q->times_normal_x());
bf->addTerm(u2hat, q->times_normal_y());
RHSPtr rhs = RHS::rhs();
BCPtr bc = BC::bc();
SpatialFilterPtr y_equals_one = SpatialFilter::matchingY(1.0);
//.........这里部分代码省略.........
示例14: main
//.........这里部分代码省略.........
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactoryPtr vf = VarFactory::varFactory();
VarPtr tau = vf->testVar("tau", HDIV);
VarPtr v = vf->testVar("v", HGRAD);
// define trial variables
VarPtr uhat = vf->traceVar("uhat");
VarPtr fhat = vf->fluxVar("fhat");
VarPtr u = vf->fieldVar("u");
VarPtr sigma = vf->fieldVar("sigma", VECTOR_L2);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(vf) );
// tau terms:
bf->addTerm(sigma, tau);
bf->addTerm(u, tau->div());
bf->addTerm(-uhat, tau->dot_normal());
// v terms:
bf->addTerm( sigma, v->grad() );
bf->addTerm( fhat, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = bf->graphNorm();
//////////////////// SPECIFY RHS ///////////////////////
RHSPtr rhs = RHS::rhs();
FunctionPtr one = Function::constant(1.0);
rhs->addTerm( one * v );
//////////////////// CREATE BCs ///////////////////////
BCPtr bc = BC::bc();
FunctionPtr zero = Function::zero();
SpatialFilterPtr entireBoundary = SpatialFilter::allSpace();
bc->addDirichlet(uhat, entireBoundary, zero);
//////////////////// SOLVE & REFINE ///////////////////////
// Output solution
Intrepid::FieldContainer<GlobalIndexType> savedCellPartition;
Teuchos::RCP<Epetra_FEVector> savedLHSVector;
{
//////////////////// BUILD MESH ///////////////////////
int H1Order = 4, pToAdd = 2;
Teuchos::RCP<Mesh> mesh = Teuchos::rcp( new Mesh (meshTopology, bf, H1Order, pToAdd) );
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, ip) );
solution->solve(false);
RefinementStrategy refinementStrategy( solution, 0.2);
HDF5Exporter exporter(mesh, "Poisson");
// exporter.exportSolution(solution, vf, 0, 2, cellIDToSubdivision(mesh, 4));
exporter.exportSolution(solution, 0, 2);
mesh->saveToHDF5("MeshSave.h5");
solution->saveToHDF5("SolnSave.h5");
solution->save("PoissonProblem");
// int numRefs = 1;
// for (int ref = 1; ref <= numRefs; ref++)
// {
// refinementStrategy.refine(commRank==0);
// solution->solve(false);
// mesh->saveToHDF5("MeshSave.h5");
// solution->saveToHDF5("SolnSave.h5");
// exporter.exportSolution(solution, vf, ref, 2, cellIDToSubdivision(mesh, 4));
示例15: main
//.........这里部分代码省略.........
{
cout << "NOT enforcing local conservation.\n";
}
if (enforceOneIrregularity)
{
cout << "Enforcing 1-irregularity.\n";
}
else
{
cout << "NOT enforcing 1-irregularity.\n";
}
}
//////////////////// CREATE BCs ///////////////////////
SpatialFilterPtr entireBoundary = Teuchos::rcp( new SpatialFilterUnfiltered );
FunctionPtr u1_prev = Function::solution(u1,solution);
FunctionPtr u2_prev = Function::solution(u2,solution);
FunctionPtr u1hat_prev = Function::solution(u1hat,solution);
FunctionPtr u2hat_prev = Function::solution(u2hat,solution);
//////////////////// SOLVE & REFINE ///////////////////////
FunctionPtr vorticity = Teuchos::rcp( new PreviousSolutionFunction(solution, - u1->dy() + u2->dx() ) );
// FunctionPtr vorticity = Teuchos::rcp( new PreviousSolutionFunction(solution,sigma12 - sigma21) );
RHSPtr streamRHS = RHS::rhs();
streamRHS->addTerm(vorticity * q_s);
((PreviousSolutionFunction*) vorticity.get())->setOverrideMeshCheck(true);
((PreviousSolutionFunction*) u1_prev.get())->setOverrideMeshCheck(true);
((PreviousSolutionFunction*) u2_prev.get())->setOverrideMeshCheck(true);
BCPtr streamBC = BC::bc();
// streamBC->addDirichlet(psin_hat, entireBoundary, u0_cross_n);
streamBC->addDirichlet(phi_hat, entireBoundary, zero);
// streamBC->addZeroMeanConstraint(phi);
IPPtr streamIP = Teuchos::rcp( new IP );
streamIP->addTerm(q_s);
streamIP->addTerm(q_s->grad());
streamIP->addTerm(v_s);
streamIP->addTerm(v_s->div());
SolutionPtr streamSolution = Teuchos::rcp( new Solution( streamMesh, streamBC, streamRHS, streamIP ) );
if (enforceLocalConservation)
{
FunctionPtr zero = Function::zero();
solution->lagrangeConstraints()->addConstraint(u1hat->times_normal_x() + u2hat->times_normal_y()==zero);
solnIncrement->lagrangeConstraints()->addConstraint(u1hat->times_normal_x() + u2hat->times_normal_y()==zero);
}
if (true)
{
FunctionPtr u1_incr = Function::solution(u1, solnIncrement);
FunctionPtr u2_incr = Function::solution(u2, solnIncrement);
FunctionPtr sigma11_incr = Function::solution(sigma11, solnIncrement);
FunctionPtr sigma12_incr = Function::solution(sigma12, solnIncrement);
FunctionPtr sigma21_incr = Function::solution(sigma21, solnIncrement);
FunctionPtr sigma22_incr = Function::solution(sigma22, solnIncrement);
FunctionPtr p_incr = Function::solution(p, solnIncrement);
FunctionPtr l2_incr = u1_incr * u1_incr + u2_incr * u2_incr + p_incr * p_incr
+ sigma11_incr * sigma11_incr + sigma12_incr * sigma12_incr
+ sigma21_incr * sigma21_incr + sigma22_incr * sigma22_incr;