本文整理汇总了C++中BCPtr::coefficientsForBC方法的典型用法代码示例。如果您正苦于以下问题:C++ BCPtr::coefficientsForBC方法的具体用法?C++ BCPtr::coefficientsForBC怎么用?C++ BCPtr::coefficientsForBC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BCPtr
的用法示例。
在下文中一共展示了BCPtr::coefficientsForBC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bcsToImpose
void Boundary::bcsToImpose( map< GlobalIndexType, Scalar > &globalDofIndicesAndValues, TBC<Scalar> &bc,
GlobalIndexType cellID, DofInterpreter* dofInterpreter)
{
// this is where we actually compute the BCs; the other bcsToImpose variants call this one.
CellPtr cell = _mesh->getTopology()->getCell(cellID);
// define a couple of important inner products:
TIPPtr<Scalar> ipL2 = Teuchos::rcp( new TIP<Scalar> );
TIPPtr<Scalar> ipH1 = Teuchos::rcp( new TIP<Scalar> );
VarFactoryPtr varFactory = VarFactory::varFactory();
VarPtr trace = varFactory->traceVar("trace");
VarPtr flux = varFactory->traceVar("flux");
ipL2->addTerm(flux);
ipH1->addTerm(trace);
ipH1->addTerm(trace->grad());
ElementTypePtr elemType = _mesh->getElementType(cellID);
DofOrderingPtr trialOrderingPtr = elemType->trialOrderPtr;
vector< int > trialIDs = _mesh->bilinearForm()->trialIDs();
vector<unsigned> boundarySides = cell->boundarySides();
if (boundarySides.size() > 0)
{
BasisCachePtr basisCache = BasisCache::basisCacheForCell(_mesh, cellID);
for (vector< int >::iterator trialIt = trialIDs.begin(); trialIt != trialIDs.end(); trialIt++)
{
int trialID = *(trialIt);
if ( bc.bcsImposed(trialID) )
{
// // DEBUGGING: keep track of which sides we impose BCs on:
// set<unsigned> bcImposedSides;
//
// Determine global dof indices and values, in one pass per side
for (int i=0; i<boundarySides.size(); i++)
{
unsigned sideOrdinal = boundarySides[i];
// TODO: here, we need to treat the volume basis case.
/*
To do this:
1. (Determine which dofs in the basis have support on the side.)
2. (Probably should resize dirichletValues to match number of dofs with support on the side.)
3. (Within coefficientsForBC, and the projection method it calls, when it's a side cache, check whether the basis being projected has a higher dimension. If so, do the same determination regarding the support of basis on the side as #1.)
4. DofInterpreter::interpretLocalBasisCoefficients() needs to handle the case that trialID has volume support, and in this case interpret the provided data appropriately.
*/
BasisPtr basis;
int numDofsSide;
if (trialOrderingPtr->getSidesForVarID(trialID).size() == 1)
{
// volume basis
basis = trialOrderingPtr->getBasis(trialID);
// get the dof ordinals for the side (interpreted as a "continuous" basis)
numDofsSide = basis->dofOrdinalsForSide(sideOrdinal).size();
}
else if (! trialOrderingPtr->hasBasisEntry(trialID, sideOrdinal))
{
continue;
}
else
{
basis = trialOrderingPtr->getBasis(trialID,sideOrdinal);
numDofsSide = basis->getCardinality();
}
GlobalIndexType numCells = 1;
if (numCells > 0)
{
FieldContainer<double> dirichletValues(numCells,numDofsSide);
// project bc function onto side basis:
BCPtr bcPtr = Teuchos::rcp(&bc, false);
Teuchos::RCP<BCFunction<double>> bcFunction = BCFunction<double>::bcFunction(bcPtr, trialID);
bcPtr->coefficientsForBC(dirichletValues, bcFunction, basis, basisCache->getSideBasisCache(sideOrdinal));
dirichletValues.resize(numDofsSide);
if (bcFunction->imposeOnCell(0))
{
FieldContainer<double> globalData;
FieldContainer<GlobalIndexType> globalDofIndices;
dofInterpreter->interpretLocalBasisCoefficients(cellID, trialID, sideOrdinal, dirichletValues, globalData, globalDofIndices);
for (int globalDofOrdinal=0; globalDofOrdinal<globalDofIndices.size(); globalDofOrdinal++)
{
GlobalIndexType globalDofIndex = globalDofIndices(globalDofOrdinal);
Scalar value = globalData(globalDofOrdinal);
// sanity check: if this has been previously set, do the two values roughly agree?
if (globalDofIndicesAndValues.find(globalDofIndex) != globalDofIndicesAndValues.end())
{
double tol = 1e-10;
Scalar prevValue = globalDofIndicesAndValues[globalDofIndex];
double absDiff = abs(prevValue - value);
if (absDiff > tol)
{
double relativeDiff = absDiff / max(abs(prevValue),abs(value));
int rank = _mesh->Comm()->MyPID();
if (relativeDiff > tol)
{
cout << "WARNING: in Boundary::bcsToImpose(), inconsistent values for BC: " << prevValue << " and ";
cout << value << " prescribed for global dof index " << globalDofIndex;
cout << " on rank " << rank << endl;
}
}
//.........这里部分代码省略.........