本文整理汇总了C++中BFPtr::graphNorm方法的典型用法代码示例。如果您正苦于以下问题:C++ BFPtr::graphNorm方法的具体用法?C++ BFPtr::graphNorm怎么用?C++ BFPtr::graphNorm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFPtr
的用法示例。
在下文中一共展示了BFPtr::graphNorm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
bf->addTerm( t2hat, v2);
bf->addTerm( -p, v1->dx() );
bf->addTerm( -p, v2->dy() );
// continuity equation
bf->addTerm( -u1, vc->dx() );
bf->addTerm( -u2, vc->dy() );
bf->addTerm( u1hat, vc->times_normal_x() );
bf->addTerm( u2hat, vc->times_normal_y() );
//////////////////// SPECIFY RHS ///////////////////////
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
// stress equation
rhs->addTerm( -sigma1_prev * tau1 );
rhs->addTerm( -sigma2_prev * tau2 );
rhs->addTerm( -u1_prev * tau1->div() );
rhs->addTerm( -u2_prev * tau2->div() );
// momentum equation
// rhs->addTerm( -beta*sigma1_prev * v1 );
// rhs->addTerm( -beta*sigma2_prev * v2 );
rhs->addTerm( -1./Re*sigma1_prev * v1->grad() );
rhs->addTerm( -1./Re*sigma2_prev * v2->grad() );
// continuity equation
rhs->addTerm( u1_prev * vc->dx() );
rhs->addTerm( u2_prev * vc->dy() );
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = Teuchos::rcp(new IP);
if (norm == 0)
{
ip = bf->graphNorm();
}
else if (norm == 1)
{
// ip = bf->l2Norm();
}
//////////////////// CREATE BCs ///////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
SpatialFilterPtr left = Teuchos::rcp( new ConstantXBoundary(-1) );
SpatialFilterPtr right = Teuchos::rcp( new ConstantXBoundary(3) );
SpatialFilterPtr top = Teuchos::rcp( new ConstantYBoundary(1) );
SpatialFilterPtr bottom = Teuchos::rcp( new ConstantYBoundary(-1) );
SpatialFilterPtr circle = Teuchos::rcp( new CircleBoundary(radius) );
FunctionPtr boundaryU1 = Teuchos::rcp( new BoundaryU1 );
bc->addDirichlet(u1hat, left, boundaryU1);
bc->addDirichlet(u2hat, left, zero);
bc->addDirichlet(u1hat, right, boundaryU1);
bc->addDirichlet(u2hat, right, zero);
bc->addDirichlet(u1hat, top, zero);
bc->addDirichlet(u2hat, top, zero);
bc->addDirichlet(u1hat, bottom, zero);
bc->addDirichlet(u2hat, bottom, zero);
bc->addDirichlet(u1hat, circle, zero);
bc->addDirichlet(u2hat, circle, zero);
// zero mean constraint on pressure
bc->addZeroMeanConstraint(p);
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, ip) );
if (enforceLocalConservation)
{
示例2: main
//.........这里部分代码省略.........
// robust test norm
FunctionPtr C_h = Teuchos::rcp( new EpsilonScaling(eps) );
FunctionPtr invH = Teuchos::rcp(new InvHScaling);
FunctionPtr invSqrtH = Teuchos::rcp(new InvSqrtHScaling);
FunctionPtr sqrtH = Teuchos::rcp(new SqrtHScaling);
FunctionPtr hSwitch = Teuchos::rcp(new HSwitch(ipSwitch,mesh));
ip->addTerm(hSwitch*sqrt(eps) * v->grad() );
ip->addTerm(hSwitch*beta * v->grad() );
ip->addTerm(hSwitch*tau->div() );
// graph norm
ip->addTerm( (one-hSwitch)*((1.0/eps) * tau + v->grad()));
ip->addTerm( (one-hSwitch)*(beta * v->grad() - tau->div()));
// regularizing terms
ip->addTerm(C_h/sqrt(eps) * tau );
ip->addTerm(invSqrtH*v);
*/
// robust test norm
IPPtr robIP = Teuchos::rcp(new IP);
FunctionPtr C_h = Teuchos::rcp( new EpsilonScaling(eps) );
FunctionPtr invH = Teuchos::rcp(new InvHScaling);
FunctionPtr invSqrtH = Teuchos::rcp(new InvSqrtHScaling);
FunctionPtr sqrtH = Teuchos::rcp(new SqrtHScaling);
FunctionPtr hSwitch = Teuchos::rcp(new HSwitch(ipSwitch,mesh));
robIP->addTerm(sqrt(eps) * v->grad() );
robIP->addTerm(beta * v->grad() );
robIP->addTerm(tau->div() );
// regularizing terms
robIP->addTerm(C_h/sqrt(eps) * tau );
robIP->addTerm(invSqrtH*v);
IPPtr graphIP = confusionBF->graphNorm();
graphIP->addTerm(invSqrtH*v);
// graphIP->addTerm(C_h/sqrt(eps) * tau );
IPPtr switchIP = Teuchos::rcp(new IPSwitcher(robIP,graphIP,ipSwitch)); // rob IP for h>ipSwitch mesh size, graph norm o/w
ip = switchIP;
LinearTermPtr vVecLT = Teuchos::rcp(new LinearTerm);
LinearTermPtr tauVecLT = Teuchos::rcp(new LinearTerm);
vVecLT->addTerm(sqrt(eps)*v->grad());
tauVecLT->addTerm(C_h/sqrt(eps)*tau);
LinearTermPtr restLT = Teuchos::rcp(new LinearTerm);
restLT->addTerm(alpha*v);
restLT->addTerm(invSqrtH*v);
restLT = restLT + beta * v->grad();
restLT = restLT + tau->div();
//////////////////// SPECIFY RHS ///////////////////////
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
FunctionPtr f = zero;
// f = one;
rhs->addTerm( f * v ); // obviously, with f = 0 adding this term is not necessary!
//////////////////// CREATE BCs ///////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
SpatialFilterPtr Inflow = Teuchos::rcp(new LeftInflow);
SpatialFilterPtr wallBoundary = Teuchos::rcp(new WallBoundary);//MeshUtilities::rampBoundary(rampHeight);
SpatialFilterPtr freeStream = Teuchos::rcp(new FreeStreamBoundary);
bc->addDirichlet(uhat, wallBoundary, one);
// bc->addDirichlet(uhat, wallBoundary, Teuchos::rcp(new WallSmoothBC(eps)));
示例3: 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
double epsilon = args.Input<double>("--epsilon", "diffusion parameter");
int numRefs = args.Input<int>("--numRefs", "number of refinement steps");
bool enforceLocalConservation = args.Input<bool>("--conserve", "enforce local conservation");
int norm = args.Input<int>("--norm", "0 = graph\n 1 = robust\n 2 = modified robust");
// Optional arguments (have defaults)
halfwidth = args.Input("--halfwidth", "half the width of the wedge", 0.5);
bool allQuads = args.Input("--allQuads", "use only quads in mesh", false);
bool zeroL2 = args.Input("--zeroL2", "take L2 term on v in robust norm to zero", enforceLocalConservation);
args.Process();
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactory varFactory;
VarPtr tau = varFactory.testVar("tau", HDIV);
VarPtr v = varFactory.testVar("v", HGRAD);
// define trial variables
VarPtr uhat = varFactory.traceVar("uhat");
VarPtr beta_n_u_minus_sigma_n = varFactory.fluxVar("fhat");
VarPtr u = varFactory.fieldVar("u");
VarPtr sigma = varFactory.fieldVar("sigma", VECTOR_L2);
vector<double> beta;
beta.push_back(1.0);
beta.push_back(0.0);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
// tau terms:
bf->addTerm(sigma / epsilon, tau);
bf->addTerm(u, tau->div());
bf->addTerm(-uhat, tau->dot_normal());
// v terms:
bf->addTerm( sigma, v->grad() );
bf->addTerm( beta * u, - v->grad() );
bf->addTerm( beta_n_u_minus_sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = Teuchos::rcp(new IP);
// Graph norm
if (norm == 0)
{
ip = bf->graphNorm();
FunctionPtr h2_scaling = Teuchos::rcp( new ZeroMeanScaling );
ip->addZeroMeanTerm( h2_scaling*v );
}
// Robust norm
else if (norm == 1)
{
// robust test norm
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(epsilon) );
FunctionPtr h2_scaling = Teuchos::rcp( new ZeroMeanScaling );
if (!zeroL2)
ip->addTerm( v );
ip->addTerm( sqrt(epsilon) * v->grad() );
// Weight these two terms for inflow
ip->addTerm( beta * v->grad() );
ip->addTerm( tau->div() );
ip->addTerm( ip_scaling/sqrt(epsilon) * tau );
if (zeroL2)
ip->addZeroMeanTerm( h2_scaling*v );
}
// Modified robust norm
else if (norm == 2)
{
// robust test norm
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(epsilon) );
FunctionPtr h2_scaling = Teuchos::rcp( new ZeroMeanScaling );
if (!zeroL2)
ip->addTerm( v );
ip->addTerm( sqrt(epsilon) * v->grad() );
ip->addTerm( tau->div() - beta*v->grad() );
ip->addTerm( ip_scaling/sqrt(epsilon) * tau );
if (zeroL2)
ip->addZeroMeanTerm( h2_scaling*v );
}
//////////////////// SPECIFY RHS ///////////////////////
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
FunctionPtr f = Teuchos::rcp( new ConstantScalarFunction(0.0) );
rhs->addTerm( f * v ); // obviously, with f = 0 adding this term is not necessary!
//////////////////// CREATE BCs ///////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
Teuchos::RCP<PenaltyConstraints> pc = Teuchos::rcp( new PenaltyConstraints );
FunctionPtr n = Teuchos::rcp( new UnitNormalFunction );
//.........这里部分代码省略.........
示例4: 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
double epsilon = args.Input<double>("--epsilon", "diffusion parameter");
int numRefs = args.Input<int>("--numRefs", "number of refinement steps");
bool enforceLocalConservation = args.Input<bool>("--conserve", "enforce local conservation");
int norm = args.Input<int>("--norm", "0 = graph\n 1 = robust\n 2 = modified robust");
// Optional arguments (have defaults)
bool zeroL2 = args.Input("--zeroL2", "take L2 term on v in robust norm to zero", false);
args.Process();
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
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 sigma = varFactory.fieldVar("sigma", VECTOR_L2);
vector<double> beta;
beta.push_back(1.0);
beta.push_back(0.0);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
// tau terms:
bf->addTerm(sigma / epsilon, tau);
bf->addTerm(u, tau->div());
bf->addTerm(-uhat, tau->dot_normal());
// v terms:
bf->addTerm( sigma, v->grad() );
bf->addTerm( beta * u, - v->grad() );
bf->addTerm( beta_n_u_minus_sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = Teuchos::rcp(new IP);
if (norm == 0)
{
ip = bf->graphNorm();
FunctionPtr h2_scaling = Teuchos::rcp( new ZeroMeanScaling );
ip->addZeroMeanTerm( h2_scaling*v );
}
// Robust norm
else if (norm == 1)
{
// robust test norm
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(epsilon) );
FunctionPtr h2_scaling = Teuchos::rcp( new ZeroMeanScaling );
if (!zeroL2)
ip->addTerm( v );
ip->addTerm( sqrt(epsilon) * v->grad() );
// Weight these two terms for inflow
ip->addTerm( beta * v->grad() );
ip->addTerm( tau->div() );
ip->addTerm( ip_scaling/sqrt(epsilon) * tau );
if (zeroL2)
ip->addZeroMeanTerm( h2_scaling*v );
}
// Modified robust norm
else if (norm == 2)
{
// robust test norm
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(epsilon) );
FunctionPtr h2_scaling = Teuchos::rcp( new ZeroMeanScaling );
// FunctionPtr ip_weight = Teuchos::rcp( new IPWeight() );
if (!zeroL2)
ip->addTerm( v );
ip->addTerm( sqrt(epsilon) * v->grad() );
ip->addTerm( beta * v->grad() );
ip->addTerm( tau->div() - beta*v->grad() );
ip->addTerm( ip_scaling/sqrt(epsilon) * tau );
if (zeroL2)
ip->addZeroMeanTerm( h2_scaling*v );
}
// // robust test norm
// IPPtr robIP = Teuchos::rcp(new IP);
// FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(epsilon) );
// if (!enforceLocalConservation)
// robIP->addTerm( ip_scaling * v );
// robIP->addTerm( sqrt(epsilon) * v->grad() );
// // Weight these two terms for inflow
// FunctionPtr ip_weight = Teuchos::rcp( new IPWeight() );
// robIP->addTerm( ip_weight * beta * v->grad() );
// robIP->addTerm( ip_weight * tau->div() );
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
origin[2] = t0;
Teuchos::RCP<Solver> solver = Teuchos::rcp( new KluSolver );
#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.
示例6: main
//.........这里部分代码省略.........
// vector< CellTopoPtrLegacy > cellTopos;
vector< CellTopoPtr> cellTopos;
cellTopos.push_back(quad_4);
cellTopos.push_back(tri_3);
MeshGeometryPtr meshGeometry = Teuchos::rcp( new MeshGeometry(vertices, elementVertices, cellTopos) );
MeshTopologyPtr meshTopology = Teuchos::rcp( new MeshTopology(meshGeometry) );
//////////////////// 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");
示例7: 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");
bool enforceLocalConservation = args.Input<bool>("--conserve", "enforce local conservation");
bool steady = args.Input<bool>("--steady", "run steady rather than transient");
// Optional arguments (have defaults)
double dt = args.Input("--dt", "time step", 0.25);
int numTimeSteps = args.Input("--nt", "number of time steps", 20);
halfWidth = args.Input("--halfWidth", "half width of inlet profile", 1.0);
args.Process();
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactory varFactory;
VarPtr v = varFactory.testVar("v", HGRAD);
// define trial variables
VarPtr beta_n_u_hat = varFactory.fluxVar("\\widehat{\\beta \\cdot n }");
VarPtr u = varFactory.fieldVar("u");
vector<double> beta;
beta.push_back(1.0);
beta.push_back(0.0);
//////////////////// BUILD MESH ///////////////////////
BFPtr 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 = 8, verticalCells = 8;
// create a pointer to a new mesh:
Teuchos::RCP<Mesh> mesh = Mesh::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);
SolutionPtr prevTimeFlow = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP) );
SolutionPtr flowResidual = Teuchos::rcp(new Solution(mesh, nullBC, nullRHS, nullIP) );
FunctionPtr u_prev_time = Teuchos::rcp( new PreviousSolutionFunction(prevTimeFlow, u) );
//////////////////// DEFINE BILINEAR FORM ///////////////////////
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
FunctionPtr invDt = Teuchos::rcp(new ScalarParamFunction(1.0/dt));
// v terms:
bf->addTerm( beta * u, - v->grad() );
bf->addTerm( beta_n_u_hat, v);
if (!steady)
{
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();
// ip->addTerm(v);
// ip->addTerm(beta*v->grad());
//////////////////// CREATE BCs ///////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
SpatialFilterPtr lBoundary = Teuchos::rcp( new LeftBoundary );
FunctionPtr u1 = Teuchos::rcp( new InletBC );
bc->addDirichlet(beta_n_u_hat, lBoundary, -u1);
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, ip) );
// ==================== Register Solutions ==========================
mesh->registerSolution(solution);
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
//////////////////// SPECIFY RHS ///////////////////////
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
// stress equation
rhs->addTerm( -u1_prev * tau1->div() );
rhs->addTerm( -u2_prev * tau2->div() );
// momentum equation
rhs->addTerm( 2.*u1_prev*u1_prev * v1->dx() );
rhs->addTerm( u2_prev*u1_prev * v1->dy() );
rhs->addTerm( u1_prev*u2_prev * v1->dy() );
rhs->addTerm( u2_prev*u1_prev * v2->dx() );
rhs->addTerm( u1_prev*u2_prev * v1->dy() );
rhs->addTerm( 2.*u2_prev*u2_prev * v2->dy() );
// rhs->addTerm( p_prev * v1->dx() );
// rhs->addTerm( p_prev * v2->dy() );
// rhs->addTerm( -sigma1_prev * v1->grad() );
// rhs->addTerm( -sigma2_prev * v2->grad() );
// rhs->addTerm( -sigma11_prev * v1->dx() );
// rhs->addTerm( -sigma12_prev * v1->dy() );
// rhs->addTerm( -sigma12_prev * v2->dx() );
// rhs->addTerm( -sigma22_prev * v2->dy() );
// continuity equation
rhs->addTerm( u1_prev * q->dx() );
rhs->addTerm( u2_prev * q->dy() );
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = Teuchos::rcp(new IP);
if (norm == 0)
{
ip = bf->graphNorm();
}
else if (norm == 1)
{
// ip = bf->l2Norm();
}
//////////////////// CREATE BCs ///////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
// Teuchos::RCP<PenaltyConstraints> pc = Teuchos::rcp( new PenaltyConstraints );
SpatialFilterPtr left = Teuchos::rcp( new ConstantXBoundary(-0.5) );
SpatialFilterPtr right = Teuchos::rcp( new ConstantXBoundary(1) );
SpatialFilterPtr top = Teuchos::rcp( new ConstantYBoundary(-0.5) );
SpatialFilterPtr bottom = Teuchos::rcp( new ConstantYBoundary(1.5) );
bc->addDirichlet(u1hat, left, u1Exact);
bc->addDirichlet(u2hat, left, u2Exact);
bc->addDirichlet(u1hat, right, u1Exact);
bc->addDirichlet(u2hat, right, u2Exact);
bc->addDirichlet(u1hat, top, u1Exact);
bc->addDirichlet(u2hat, top, u2Exact);
bc->addDirichlet(u1hat, bottom, u1Exact);
bc->addDirichlet(u2hat, bottom, u2Exact);
// zero mean constraint on pressure
bc->addZeroMeanConstraint(p);
// pc->addConstraint(u1hat*u2hat-t1hat == zero, top);
// pc->addConstraint(u2hat*u2hat-t2hat == zero, top);
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, ip) );
// solution->setFilter(pc);
// if (enforceLocalConservation) {
示例9: main
//.........这里部分代码省略.........
// exporter.exportFunction(vect, "vect2", 1, 10, cellIDToNum1DPts);
// exporter.exportFunction(fbdr, "boundary2", 0);
exporter.exportFunction(bdrfunctions, bdrfunctionNames, 1, 10);
}
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactory varFactory;
VarPtr tau = varFactory.testVar("tau", HDIV);
VarPtr v = varFactory.testVar("v", HGRAD);
// 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);
示例10: testPoisson
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;
}
示例11: main
//.........这里部分代码省略.........
int numCells1D = pow(2.0,minLogElements);
if (rank==0)
{
cout << "L^2 order: " << polyOrder << endl;
cout << "Re = " << Re << endl;
}
int kovasznayCubatureEnrichment = 20; // 20 is better than 10 for accurately measuring error on the coarser meshes.
vector< VGPNavierStokesProblem > problems;
do
{
VGPNavierStokesProblem problem = VGPNavierStokesProblem(Re,quadPointsKovasznay,
numCells1D,numCells1D,
H1Order, pToAdd,
u1_exact, u2_exact, p_exact, useCompliantNorm || useStokesCompliantNorm);
problem.backgroundFlow()->setCubatureEnrichmentDegree(kovasznayCubatureEnrichment);
problem.solutionIncrement()->setCubatureEnrichmentDegree(kovasznayCubatureEnrichment);
problem.backgroundFlow()->setZeroMeanConstraintRho(zmcRho);
problem.solutionIncrement()->setZeroMeanConstraintRho(zmcRho);
FunctionPtr dt_inv;
if (artificialTimeStepping)
{
// // LHS gets u_inc / dt:
BFPtr bf = problem.bf();
dt_inv = ParameterFunction::parameterFunction(1.0 / dt); //Teuchos::rcp( new ConstantScalarFunction(1.0 / dt, "\\frac{1}{dt}") );
bf->addTerm(-dt_inv * u1_vgp, v1_vgp);
bf->addTerm(-dt_inv * u2_vgp, v2_vgp);
problem.setIP( bf->graphNorm() ); // graph norm has changed...
}
else
{
dt_inv = Function::zero();
}
problems.push_back(problem);
if ( useCompliantNorm )
{
problem.setIP(problem.vgpNavierStokesFormulation()->scaleCompliantGraphNorm(dt_inv));
}
else if (useStokesCompliantNorm)
{
VGPStokesFormulation stokesForm(1.0); // pretend Re = 1 in the graph norm
problem.setIP(stokesForm.scaleCompliantGraphNorm());
}
else if (useStokesGraphNorm)
{
VGPStokesFormulation stokesForm(1.0); // pretend Re = 1 in the graph norm
problem.setIP(stokesForm.graphNorm());
}
else if (! useGraphNorm )
{
// then use the naive:
problem.setIP(problem.bf()->naiveNorm(spaceDim));
}
if (rank==0)
{
cout << numCells1D << " x " << numCells1D << ": " << problem.mesh()->numGlobalDofs() << " dofs " << endl;
}
numCells1D *= 2;
}
示例12: 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
double epsilon = args.Input<double>("--epsilon", "diffusion parameter");
int numRefs = args.Input<int>("--numRefs", "number of refinement steps");
bool enforceLocalConservation = args.Input<bool>("--conserve", "enforce local conservation");
bool graphNorm = args.Input<bool>("--graphNorm", "use the graph norm rather than robust test norm");
// Optional arguments (have defaults)
bool highLiftAirfoil = args.Input("--highLift", "use high lift airfoil rather than NACA0012", false);
args.Process();
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactory varFactory;
VarPtr tau = varFactory.testVar("tau", HDIV);
VarPtr v = varFactory.testVar("v", HGRAD);
// define trial variables
VarPtr uhat = varFactory.traceVar("uhat");
VarPtr beta_n_u_minus_sigma_n = varFactory.fluxVar("fhat");
VarPtr u = varFactory.fieldVar("u");
VarPtr sigma = varFactory.fieldVar("sigma", VECTOR_L2);
vector<double> beta;
beta.push_back(1.0);
beta.push_back(0.25);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
// tau terms:
bf->addTerm(sigma / epsilon, tau);
bf->addTerm(u, tau->div());
bf->addTerm(-uhat, tau->dot_normal());
// v terms:
bf->addTerm( sigma, v->grad() );
bf->addTerm( beta * u, - v->grad() );
bf->addTerm( beta_n_u_minus_sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = Teuchos::rcp(new IP);
if (graphNorm)
{
ip = bf->graphNorm();
}
else
{
// robust test norm
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(epsilon) );
if (!enforceLocalConservation)
ip->addTerm( ip_scaling * v );
ip->addTerm( sqrt(epsilon) * v->grad() );
// Weight these two terms for inflow
ip->addTerm( beta * v->grad() );
ip->addTerm( tau->div() );
ip->addTerm( ip_scaling/sqrt(epsilon) * tau );
if (enforceLocalConservation)
ip->addZeroMeanTerm( v );
}
//////////////////// SPECIFY RHS ///////////////////////
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
FunctionPtr f = Teuchos::rcp( new ConstantScalarFunction(0.0) );
rhs->addTerm( f * v ); // obviously, with f = 0 adding this term is not necessary!
//////////////////// CREATE BCs ///////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
Teuchos::RCP<PenaltyConstraints> pc = Teuchos::rcp( new PenaltyConstraints );
SpatialFilterPtr lBoundary = Teuchos::rcp( new LeftBoundary );
SpatialFilterPtr tBoundary = Teuchos::rcp( new TopBoundary );
SpatialFilterPtr bBoundary = Teuchos::rcp( new BottomBoundary );
SpatialFilterPtr rBoundary = Teuchos::rcp( new RightBoundary );
FunctionPtr n = Teuchos::rcp( new UnitNormalFunction );
SpatialFilterPtr airfoilInflowBoundary = Teuchos::rcp( new AirfoilInflowBoundary(beta) );
SpatialFilterPtr airfoilOutflowBoundary = Teuchos::rcp( new AirfoilOutflowBoundary(beta) );
FunctionPtr u0 = Teuchos::rcp( new ZeroBC );
FunctionPtr u1 = Teuchos::rcp( new OneBC );
bc->addDirichlet(beta_n_u_minus_sigma_n, lBoundary, u0);
bc->addDirichlet(beta_n_u_minus_sigma_n, bBoundary, u0);
// bc->addDirichlet(uhat, airfoilInflowBoundary, u1);
// bc->addDirichlet(uhat, tBoundary, u0);
bc->addDirichlet(beta_n_u_minus_sigma_n, airfoilInflowBoundary, beta*n*u1);
bc->addDirichlet(uhat, airfoilOutflowBoundary, u1);
// pc->addConstraint(beta*uhat->times_normal() - beta_n_u_minus_sigma_n == u0, rBoundary);
// pc->addConstraint(beta*uhat->times_normal() - beta_n_u_minus_sigma_n == u0, tBoundary);
//////////////////// BUILD MESH ///////////////////////
// define nodes for mesh
//.........这里部分代码省略.........
示例13: main
//.........这里部分代码省略.........
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);
soln0->setCubatureEnrichmentDegree(5);
FunctionPtr u_soln0 = Function::solution(u, soln0);
FunctionPtr qHat_soln0 = Function::solution(qHat, soln0);
RHSPtr rhs1 = RHS::rhs();
rhs1->addTerm(u_soln0 / dt * v);
rhs1->addTerm((1-theta) * u_soln0 * c * v->grad());
SolutionPtr soln1 = Solution::solution(mesh, bc, rhs1, ip);
soln1->setCubatureEnrichmentDegree(5);
FunctionPtr u_soln1 = Function::solution(u, soln1);
FunctionPtr qHat_soln1 = Function::solution(qHat, soln1);
RHSPtr rhs2 = RHS::rhs(); // after the first solve on soln0, we'll swap out initialRHS for rhs2
rhs2->addTerm(u_soln1 / dt * v);
rhs2->addTerm((1-theta) * u_soln1 * c * v->grad());
Teuchos::RCP<Solver> solver = Teuchos::rcp( new KluSolver );
#ifdef HAVE_AMESOS_MUMPS
if (useMumpsIfAvailable) solver = Teuchos::rcp( new MumpsSolver );
#endif
// double energyErrorSum = 0;
ostringstream filePrefix;
filePrefix << "convectingCone_k" << k << "_t";
int frameNumber = 0;
示例14: main
//.........这里部分代码省略.........
if (rank==0)
stokesBF->printTrialTestInteractions();
stokesBF->setUseExtendedPrecisionSolveForOptimalTestFunctions(useExtendedPrecisionForOptimalTestInversion);
mesh = MeshFactory::quadMesh(stokesBF, H1Order, pToAdd);
//////////////////// CREATE BCs ///////////////////////
BCPtr bc = BC::bc();
//////////////////// CREATE RHS ///////////////////////
RHSPtr rhs = RHS::rhs(); // zero for now...
IPPtr ip;
qoptIP = Teuchos::rcp(new IP());
if (useCompliantGraphNorm) {
qoptIP->addTerm( mu * v1->dx() + tau1->x() ); // sigma11
qoptIP->addTerm( mu * v1->dy() + tau1->y() ); // sigma12
qoptIP->addTerm( mu * v2->dx() + tau2->x() ); // sigma21
qoptIP->addTerm( mu * v2->dy() + tau2->y() ); // sigma22
qoptIP->addTerm( mu * v1->dx() + mu * v2->dy() ); // pressure
qoptIP->addTerm( h * tau1->div() - h * q->dx() ); // u1
qoptIP->addTerm( h * tau2->div() - h * q->dy()); // u2
qoptIP->addTerm( (mu / h) * v1 );
qoptIP->addTerm( (mu / h) * v2 );
qoptIP->addTerm( q );
qoptIP->addTerm( tau1 );
qoptIP->addTerm( tau2 );
} else { // standard graph norm, then
qoptIP = stokesBF->graphNorm();
}
ip = qoptIP;
if (rank==0)
ip->printInteractions();
// aim is just to answer one simple question:
// have I figured out a trial-space preimage for optimal test function (q=1, tau=0, v=0)?
SolutionPtr soln = Teuchos::rcp(new Solution(mesh));
FunctionPtr x = Function::xn();
FunctionPtr y = Function::yn();
// u1 = u1_hat = x / 2
FunctionPtr u1_exact = x / 2;
// u2 = u2_hat = y / 2
FunctionPtr u2_exact = y / 2;
// sigma = 0.5 * I
FunctionPtr sigma11_exact = Function::constant(0.5);
FunctionPtr sigma22_exact = Function::constant(0.5);
// tn_hat = 0.5 * n
FunctionPtr n = Function::normal();
FunctionPtr t1n_exact = n->x() / 2;
FunctionPtr t2n_exact = n->y() / 2;
map<int, FunctionPtr > exact_soln;
exact_soln[u1->ID()] = u1_exact;
示例15: 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
//////////////////// DECLARE VARIABLES ///////////////////////
// define test variables
VarFactory varFactory;
VarPtr tau = varFactory.testVar("tau", HDIV);
VarPtr v = varFactory.testVar("v", HGRAD);
// define trial variables
VarPtr uhat = varFactory.traceVar("uhat");
VarPtr sigma_n = varFactory.fluxVar("fhat");
VarPtr u = varFactory.fieldVar("u");
VarPtr sigma1 = varFactory.fieldVar("sigma1");
VarPtr sigma2 = varFactory.fieldVar("sigma2");
//////////////////// DEFINE BILINEAR FORM ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
// tau terms:
bf->addTerm(sigma1, tau->x());
bf->addTerm(sigma2, tau->y());
bf->addTerm(u, tau->div());
bf->addTerm(-uhat, tau->dot_normal());
// v terms:
bf->addTerm( sigma1, v->dx() );
bf->addTerm( sigma2, v->dy() );
bf->addTerm( -sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
IPPtr ip = bf->graphNorm();
//////////////////// SPECIFY RHS ///////////////////////
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
FunctionPtr f = Teuchos::rcp( new ConstantScalarFunction(1.0) );
rhs->addTerm( f * v );
//////////////////// CREATE BCs ///////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
Teuchos::RCP<PenaltyConstraints> pc = Teuchos::rcp( new PenaltyConstraints );
FunctionPtr n = Teuchos::rcp( new UnitNormalFunction );
FunctionPtr zero = Teuchos::rcp( new ConstantScalarFunction(0.0) );
FunctionPtr one = Teuchos::rcp( new ConstantScalarFunction(1.0) );
SpatialFilterPtr inflow = Teuchos::rcp( new Inflow );
bc->addDirichlet(uhat, inflow, zero);
SpatialFilterPtr leadingWedge = Teuchos::rcp( new LeadingWedge );
bc->addDirichlet(uhat, leadingWedge, zero);
SpatialFilterPtr trailingWedge = Teuchos::rcp( new TrailingWedge );
bc->addDirichlet(sigma_n, trailingWedge, zero);
// bc->addDirichlet(uhat, trailingWedge, zero);
SpatialFilterPtr top = Teuchos::rcp( new Top );
bc->addDirichlet(uhat, top, zero);
SpatialFilterPtr outflow = Teuchos::rcp( new Outflow );
bc->addDirichlet(uhat, outflow, zero);
//////////////////// BUILD MESH ///////////////////////
bool allQuads = true;
int H1Order = 3, pToAdd = 2;
// define nodes for mesh
vector< FieldContainer<double> > vertices;
FieldContainer<double> pt(2);
vector< vector<int> > elementIndices;
vector<int> q(4);
vector<int> t(3);
if (allQuads)
{
pt(0) = -halfwidth;
pt(1) = -1;
vertices.push_back(pt);
pt(0) = 0;
pt(1) = 0;
vertices.push_back(pt);
pt(0) = halfwidth;
pt(1) = -1;
vertices.push_back(pt);
pt(0) = halfwidth;
pt(1) = halfwidth;
vertices.push_back(pt);
pt(0) = 0;
pt(1) = halfwidth;
vertices.push_back(pt);
pt(0) = -halfwidth;
pt(1) = halfwidth;
vertices.push_back(pt);
q[0] = 0;
//.........这里部分代码省略.........