本文整理汇总了C++中SolutionPtr::mesh方法的典型用法代码示例。如果您正苦于以下问题:C++ SolutionPtr::mesh方法的具体用法?C++ SolutionPtr::mesh怎么用?C++ SolutionPtr::mesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolutionPtr
的用法示例。
在下文中一共展示了SolutionPtr::mesh方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
int rank = 0;
#ifdef HAVE_MPI
// TODO: figure out the right thing to do here...
// may want to modify argc and argv before we make the following call:
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
rank=mpiSession.getRank();
#else
#endif
bool useLineSearch = false;
int pToAdd = 2; // for optimal test function approximation
int pToAddForStreamFunction = 2;
double nonlinearStepSize = 1.0;
double dt = 0.5;
double nonlinearRelativeEnergyTolerance = 0.015; // used to determine convergence of the nonlinear solution
// double nonlinearRelativeEnergyTolerance = 0.15; // used to determine convergence of the nonlinear solution
double eps = 1.0/64.0; // width of ramp up to 1.0 for top BC; eps == 0 ==> soln not in H1
// epsilon above is chosen to match our initial 16x16 mesh, to avoid quadrature errors.
// double eps = 0.0; // John Evans's problem: not in H^1
bool enforceLocalConservation = false;
bool enforceOneIrregularity = true;
bool reportPerCellErrors = true;
bool useMumps = true;
int horizontalCells, verticalCells;
int maxIters = 50; // for nonlinear steps
vector<double> ReValues;
// usage: polyOrder [numRefinements]
// parse args:
if (argc < 6)
{
cout << "Usage: NavierStokesCavityFlowContinuationFixedMesh fieldPolyOrder hCells vCells energyErrorGoal Re0 [Re1 ...]\n";
return -1;
}
int polyOrder = atoi(argv[1]);
horizontalCells = atoi(argv[2]);
verticalCells = atoi(argv[3]);
double energyErrorGoal = atof(argv[4]);
for (int i=5; i<argc; i++)
{
ReValues.push_back(atof(argv[i]));
}
if (rank == 0)
{
cout << "L^2 order: " << polyOrder << endl;
cout << "initial mesh size: " << horizontalCells << " x " << verticalCells << endl;
cout << "energy error goal: " << energyErrorGoal << endl;
cout << "Reynolds number values for continuation:\n";
for (int i=0; i<ReValues.size(); i++)
{
cout << ReValues[i] << ", ";
}
cout << endl;
}
FieldContainer<double> quadPoints(4,2);
quadPoints(0,0) = 0.0; // x1
quadPoints(0,1) = 0.0; // y1
quadPoints(1,0) = 1.0;
quadPoints(1,1) = 0.0;
quadPoints(2,0) = 1.0;
quadPoints(2,1) = 1.0;
quadPoints(3,0) = 0.0;
quadPoints(3,1) = 1.0;
// define meshes:
int H1Order = polyOrder + 1;
bool useTriangles = false;
bool meshHasTriangles = useTriangles;
double minL2Increment = 1e-8;
// get variable definitions:
VarFactory varFactory = VGPStokesFormulation::vgpVarFactory();
u1 = varFactory.fieldVar(VGP_U1_S);
u2 = varFactory.fieldVar(VGP_U2_S);
sigma11 = varFactory.fieldVar(VGP_SIGMA11_S);
sigma12 = varFactory.fieldVar(VGP_SIGMA12_S);
sigma21 = varFactory.fieldVar(VGP_SIGMA21_S);
sigma22 = varFactory.fieldVar(VGP_SIGMA22_S);
p = varFactory.fieldVar(VGP_P_S);
u1hat = varFactory.traceVar(VGP_U1HAT_S);
u2hat = varFactory.traceVar(VGP_U2HAT_S);
t1n = varFactory.fluxVar(VGP_T1HAT_S);
t2n = varFactory.fluxVar(VGP_T2HAT_S);
v1 = varFactory.testVar(VGP_V1_S, HGRAD);
v2 = varFactory.testVar(VGP_V2_S, HGRAD);
tau1 = varFactory.testVar(VGP_TAU1_S, HDIV);
tau2 = varFactory.testVar(VGP_TAU2_S, HDIV);
q = varFactory.testVar(VGP_Q_S, HGRAD);
FunctionPtr u1_0 = Teuchos::rcp( new U1_0(eps) );
//.........这里部分代码省略.........
示例2: main
int main(int argc, char *argv[])
{
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
int rank=mpiSession.getRank();
int numProcs=mpiSession.getNProc();
int spaceDim = 2;
#ifdef HAVE_MPI
choice::MpiArgs args( argc, argv );
#else
choice::Args args(argc, argv );
#endif
int minPolyOrder = args.Input<int>("--minPolyOrder", "L^2 (field) minimum polynomial order",0);
int maxPolyOrder = args.Input<int>("--maxPolyOrder", "L^2 (field) maximum polynomial order",1);
int minLogElements = args.Input<int>("--minLogElements", "base 2 log of the minimum number of elements in one mesh direction", 0);
int maxLogElements = args.Input<int>("--maxLogElements", "base 2 log of the maximum number of elements in one mesh direction", 4);
double Re = args.Input<double>("--Re", "Reynolds number", 40);
// bool outputStiffnessMatrix = args.Input<bool>("--writeFinalStiffnessToDisk", "write the final stiffness matrix to disk.", false);
bool computeMaxConditionNumber = args.Input<bool>("--computeMaxConditionNumber", "compute the maximum Gram matrix condition number for final mesh.", false);
int maxIters = args.Input<int>("--maxIters", "maximum number of Newton-Raphson iterations to take to try to match tolerance", 50);
double minL2Increment = args.Input<double>("--NRtol", "Newton-Raphson tolerance, L^2 norm of increment", 1e-12);
string normChoice = args.Input<string>("--norm", "norm choice: graph, compliantGraph, stokesGraph, or stokesCompliantGraph", "graph");
bool useCondensedSolve = args.Input<bool>("--useCondensedSolve", "use static condensation", true);
double dt = args.Input<double>("--timeStep", "time step (0 for none)", 0);
double zmcRho = args.Input<double>("--zmcRho", "zero-mean constraint rho (stabilization parameter)", -1);
// string replayFile = args.Input<string>("--replayFile", "file with refinement history to replay", "");
// string saveFile = args.Input<string>("--saveReplay", "file to which to save refinement history", "");
args.Process();
int pToAdd = 2; // for optimal test function approximation
bool useLineSearch = false;
bool computeRelativeErrors = true; // we'll say false when one of the exact solution components is 0
bool useEnrichedTraces = true; // enriched traces are the right choice, mathematically speaking
BasisFactory::basisFactory()->setUseEnrichedTraces(useEnrichedTraces);
// parse args:
bool useTriangles = false, useGraphNorm = false, useCompliantNorm = false, useStokesCompliantNorm = false, useStokesGraphNorm = false;
if (normChoice=="graph")
{
useGraphNorm = true;
}
else if (normChoice=="compliantGraph")
{
useCompliantNorm = true;
}
else if (normChoice=="stokesGraph")
{
useStokesGraphNorm = true;
}
else if (normChoice=="stokesCompliantGraph")
{
useStokesCompliantNorm = true;
}
else
{
if (rank==0) cout << "unknown norm choice. Exiting.\n";
exit(-1);
}
bool artificialTimeStepping = (dt > 0);
if (rank == 0)
{
cout << "pToAdd = " << pToAdd << endl;
cout << "useTriangles = " << (useTriangles ? "true" : "false") << "\n";
cout << "norm = " << normChoice << endl;
}
// define Kovasznay domain:
FieldContainer<double> quadPointsKovasznay(4,2);
// domain from Cockburn Kanschat for Stokes:
quadPointsKovasznay(0,0) = -0.5; // x1
quadPointsKovasznay(0,1) = 0.0; // y1
quadPointsKovasznay(1,0) = 1.5;
quadPointsKovasznay(1,1) = 0.0;
quadPointsKovasznay(2,0) = 1.5;
quadPointsKovasznay(2,1) = 2.0;
quadPointsKovasznay(3,0) = -0.5;
quadPointsKovasznay(3,1) = 2.0;
// Domain from Evans Hughes for Navier-Stokes:
// quadPointsKovasznay(0,0) = 0.0; // x1
// quadPointsKovasznay(0,1) = -0.5; // y1
// quadPointsKovasznay(1,0) = 1.0;
// quadPointsKovasznay(1,1) = -0.5;
// quadPointsKovasznay(2,0) = 1.0;
// quadPointsKovasznay(2,1) = 0.5;
// quadPointsKovasznay(3,0) = 0.0;
// quadPointsKovasznay(3,1) = 0.5;
// double Re = 10.0; // Cockburn Kanschat Stokes
// double Re = 40.0; // Evans Hughes Navier-Stokes
// double Re = 1000.0;
string formulationTypeStr = "vgp";
//.........这里部分代码省略.........
示例3: main
//.........这里部分代码省略.........
// let's draw a little house
vector<double> v0 = makeVertex(-1,0);
vector<double> v1 = makeVertex(1,0);
vector<double> v2 = makeVertex(1,2);
vector<double> v3 = makeVertex(-1,2);
vector<double> v4 = makeVertex(0.0,3);
vector< vector<double> > vertices;
vertices.push_back(v0);
vertices.push_back(v1);
vertices.push_back(v2);
vertices.push_back(v3);
vertices.push_back(v4);
vector<unsigned> quadVertexList;
quadVertexList.push_back(0);
quadVertexList.push_back(1);
quadVertexList.push_back(2);
quadVertexList.push_back(3);
vector<unsigned> triVertexList;
triVertexList.push_back(3);
triVertexList.push_back(2);
triVertexList.push_back(4);
vector< vector<unsigned> > elementVertices;
elementVertices.push_back(quadVertexList);
elementVertices.push_back(triVertexList);
// 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);
示例4: main
int main(int argc, char *argv[])
{
#ifdef ENABLE_INTEL_FLOATING_POINT_EXCEPTIONS
cout << "NOTE: enabling floating point exceptions for divide by zero.\n";
_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
#endif
Teuchos::GlobalMPISession mpiSession(&argc, &argv);
int rank = Teuchos::GlobalMPISession::getRank();
Teuchos::CommandLineProcessor cmdp(false,true); // false: don't throw exceptions; true: do return errors for unrecognized options
const static double PI = 3.141592653589793238462;
bool useCondensedSolve = true; // condensed solve not yet compatible with minimum rule meshes
int k = 2; // poly order for u in every direction, including temporal
int numCells = 32; // in x, y
int numTimeCells = 1;
int numTimeSlabs = -1;
int numFrames = 201;
int delta_k = 3; // test space enrichment: should be 3 for 3D
int maxRefinements = 0; // maximum # of refinements on each time slab
bool useMumpsIfAvailable = true;
bool useConstantConvection = false;
double refinementTolerance = 0.1;
int checkPointFrequency = 50; // output solution and mesh every 50 time slabs
int previousSolutionTimeSlabNumber = -1;
string previousSolutionFile = "";
string previousMeshFile = "";
cmdp.setOption("polyOrder",&k,"polynomial order for field variable u");
cmdp.setOption("delta_k", &delta_k, "test space polynomial order enrichment");
cmdp.setOption("numCells",&numCells,"number of cells in x and y directions");
cmdp.setOption("numTimeCells",&numTimeCells,"number of time axis cells");
cmdp.setOption("numTimeSlabs",&numTimeSlabs,"number of time slabs");
cmdp.setOption("numFrames",&numFrames,"number of frames for export");
cmdp.setOption("useConstantConvection", "useVariableConvection", &useConstantConvection);
cmdp.setOption("useCondensedSolve", "useUncondensedSolve", &useCondensedSolve, "use static condensation to reduce the size of the global solve");
cmdp.setOption("useMumps", "useKLU", &useMumpsIfAvailable, "use MUMPS (if available)");
cmdp.setOption("refinementTolerance", &refinementTolerance, "relative error beyond which to stop refining");
cmdp.setOption("maxRefinements", &maxRefinements, "maximum # of refinements on each time slab");
cmdp.setOption("previousSlabNumber", &previousSolutionTimeSlabNumber, "time slab number of previous solution");
cmdp.setOption("previousSolution", &previousSolutionFile, "file with previous solution");
cmdp.setOption("previousMesh", &previousMeshFile, "file with previous mesh");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL)
{
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return -1;
}
int H1Order = k + 1;
VarFactory varFactory;
// traces:
VarPtr qHat = varFactory.fluxVar("\\widehat{q}");
// fields:
VarPtr u = varFactory.fieldVar("u", L2);
// test functions:
VarPtr v = varFactory.testVar("v", HGRAD);
FunctionPtr x = Function::xn(1);
FunctionPtr y = Function::yn(1);
FunctionPtr c;
if (useConstantConvection)
{
c = Function::vectorize(Function::constant(0.5), Function::constant(0.5), Function::constant(1.0));
}
else
{
c = Function::vectorize(y-0.5, 0.5-x, Function::constant(1.0));
}
FunctionPtr n = Function::normal();
BFPtr bf = Teuchos::rcp( new BF(varFactory) );
bf->addTerm( u, c * v->grad());
bf->addTerm(qHat, v);
double width = 2.0, height = 2.0;
int horizontalCells = numCells, verticalCells = numCells;
int depthCells = numTimeCells;
double x0 = -0.5;
double y0 = -0.5;
double t0 = 0;
double totalTime = 2.0 * PI;
//.........这里部分代码省略.........