本文整理汇总了C++中IPPtr::addZeroMeanTerm方法的典型用法代码示例。如果您正苦于以下问题:C++ IPPtr::addZeroMeanTerm方法的具体用法?C++ IPPtr::addZeroMeanTerm怎么用?C++ IPPtr::addZeroMeanTerm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPPtr
的用法示例。
在下文中一共展示了IPPtr::addZeroMeanTerm方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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() );
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
// DEFINE INNER PRODUCT
////////////////////////////////////////////////////////////////////
// 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);
qoptIP->addTerm( v );
qoptIP->addTerm( tau / epsilon + v->grad() );
qoptIP->addTerm( beta * v->grad() - tau->div() );
// robust test norm
IPPtr robIP = Teuchos::rcp(new IP);
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(epsilon) );
if (!enforceLocalConservation)
{
robIP->addTerm( ip_scaling * v );
if (transient)
robIP->addTerm( invDt * 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() );
robIP->addTerm( ip_scaling/sqrt(epsilon) * tau );
if (enforceLocalConservation)
robIP->addZeroMeanTerm( v );
////////////////////////////////////////////////////////////////////
// DEFINE RHS
////////////////////////////////////////////////////////////////////
FunctionPtr f = Teuchos::rcp( new ConstantScalarFunction(0.0) );
rhs->addTerm( f * v ); // obviously, with f = 0 adding this term is not necessary!
////////////////////////////////////////////////////////////////////
// DEFINE BC
////////////////////////////////////////////////////////////////////
Teuchos::RCP<BCEasy> bc = Teuchos::rcp( new BCEasy );
// Teuchos::RCP<PenaltyConstraints> pc = Teuchos::rcp( new PenaltyConstraints );
SpatialFilterPtr lBoundary = Teuchos::rcp( new LeftBoundary );
SpatialFilterPtr tbBoundary = Teuchos::rcp( new TopBottomBoundary );
SpatialFilterPtr rBoundary = Teuchos::rcp( new RightBoundary );
FunctionPtr u0 = Teuchos::rcp( new ZeroBC );
FunctionPtr u_inlet = Teuchos::rcp( new InletBC );
// FunctionPtr n = Teuchos::rcp( new UnitNormalFunction );
bc->addDirichlet(beta_n_u_minus_sigma_n, lBoundary, u_inlet);
bc->addDirichlet(beta_n_u_minus_sigma_n, tbBoundary, u0);
bc->addDirichlet(uhat, rBoundary, u0);
// pc->addConstraint(beta_n_u_minus_sigma_n - uhat == u0, rBoundary);
////////////////////////////////////////////////////////////////////
// CREATE SOLUTION OBJECT
////////////////////////////////////////////////////////////////////
Teuchos::RCP<Solution> solution = Teuchos::rcp( new Solution(mesh, bc, rhs, robIP) );
// solution->setFilter(pc);
// ==================== Enforce Local Conservation ==================
示例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);
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("\\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_const;
beta_const.push_back(1.0);
beta_const.push_back(0.0);
// FunctionPtr beta = Teuchos::rcp(new Beta());
double eps = 1e-2;
//////////////////// 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( beta_const * u, - v->grad() );
confusionBF->addTerm( beta_n_u_minus_sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
// 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);
qoptIP->addTerm( v );
qoptIP->addTerm( tau / eps + v->grad() );
qoptIP->addTerm( beta_const * v->grad() - tau->div() );
// robust test norm
IPPtr robIP = Teuchos::rcp(new IP);
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(eps) );
if (enforceLocalConservation)
{
robIP->addZeroMeanTerm( v );
}
else
{
robIP->addTerm( ip_scaling * v );
}
robIP->addTerm( sqrt(eps) * v->grad() );
robIP->addTerm( beta_const * v->grad() );
robIP->addTerm( tau->div() );
robIP->addTerm( ip_scaling/sqrt(eps) * tau );
//////////////////// SPECIFY RHS ///////////////////////
FunctionPtr zero = Teuchos::rcp( new ConstantScalarFunction(0.0) );
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
FunctionPtr f = zero;
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 inflowBoundary = Teuchos::rcp( new InflowSquareBoundary );
// SpatialFilterPtr outflowBoundary = Teuchos::rcp( new OutflowSquareBoundary );
SpatialFilterPtr inflowTop = Teuchos::rcp(new InflowLshapeTop);
SpatialFilterPtr inflowBot = Teuchos::rcp(new InflowLshapeBottom);
SpatialFilterPtr LshapeBot1 = Teuchos::rcp(new LshapeBottom1);
SpatialFilterPtr LshapeBot2 = Teuchos::rcp(new LshapeBottom2);
SpatialFilterPtr Top = Teuchos::rcp(new LshapeTop);
SpatialFilterPtr Out = Teuchos::rcp(new LshapeOutflow);
FunctionPtr u0 = Teuchos::rcp( new U0 );
bc->addDirichlet(uhat, LshapeBot1, u0);
bc->addDirichlet(uhat, LshapeBot2, u0);
bc->addDirichlet(uhat, Top, u0);
bc->addDirichlet(uhat, Out, u0);
//.........这里部分代码省略.........
示例5: 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("\\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_const;
double c = sqrt(1.25);
beta_const.push_back(1.0/c);
beta_const.push_back(.5/c);
// FunctionPtr beta = Teuchos::rcp(new Beta());
double eps = 1e-3;
//////////////////// 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( beta_const * u, - v->grad() );
confusionBF->addTerm( beta_n_u_minus_sigma_n, v);
//////////////////// DEFINE INNER PRODUCT(S) ///////////////////////
// quasi-optimal norm
IPPtr qoptIP = Teuchos::rcp(new IP);
qoptIP->addTerm( v );
qoptIP->addTerm( tau / eps + v->grad() );
qoptIP->addTerm( beta_const * v->grad() - tau->div() );
// robust test norm
IPPtr robIP = Teuchos::rcp(new IP);
FunctionPtr ip_scaling = Teuchos::rcp( new EpsilonScaling(eps) );
if (enforceLocalConservation)
{
robIP->addZeroMeanTerm( v );
}
else
{
robIP->addTerm( ip_scaling * v );
}
robIP->addTerm( sqrt(eps) * v->grad() );
bool useNewBC = false;
FunctionPtr weight = Teuchos::rcp( new SqrtWeight(eps) );
if (useNewBC)
{
robIP->addTerm( beta_const * v->grad() );
robIP->addTerm( tau->div() );
robIP->addTerm( ip_scaling/sqrt(eps) * tau );
}
else
{
robIP->addTerm( weight * beta_const * v->grad() );
robIP->addTerm( weight * tau->div() );
robIP->addTerm( weight * ip_scaling/sqrt(eps) * tau );
}
//////////////////// SPECIFY RHS ///////////////////////
FunctionPtr zero = Teuchos::rcp( new ConstantScalarFunction(0.0) );
Teuchos::RCP<RHSEasy> rhs = Teuchos::rcp( new RHSEasy );
FunctionPtr f = zero;
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 inflowBoundary = Teuchos::rcp( new InflowSquareBoundary );
SpatialFilterPtr outflowBoundary = Teuchos::rcp( new OutflowSquareBoundary );
FunctionPtr u0 = Teuchos::rcp( new U0 );
FunctionPtr n = Teuchos::rcp( new UnitNormalFunction );
bc->addDirichlet(uhat, outflowBoundary, zero);
if (useNewBC)
{
bc->addDirichlet(beta_n_u_minus_sigma_n, inflowBoundary, beta_const*n*u0);
//.........这里部分代码省略.........
示例6: 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
//.........这里部分代码省略.........
示例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
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", true);
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 fhat = varFactory.fluxVar("fhat");
VarPtr u = varFactory.fieldVar("u");
VarPtr sigma = varFactory.fieldVar("sigma", VECTOR_L2);
//////////////////// BUILD MESH ///////////////////////
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
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 = 4, verticalCells = 4;
// create a pointer to a new mesh:
Teuchos::RCP<Mesh> mesh = Mesh::buildQuadMesh(meshBoundary, horizontalCells, verticalCells,
bf, H1Order, H1Order+pToAdd, false);
vector<double> beta;
beta.push_back(2.0);
beta.push_back(1.0);
//////////////////// DEFINE BILINEAR FORM ///////////////////////
// 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( fhat, 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)
//.........这里部分代码省略.........