本文整理汇总了C++中SolutionPtr::setBC方法的典型用法代码示例。如果您正苦于以下问题:C++ SolutionPtr::setBC方法的具体用法?C++ SolutionPtr::setBC怎么用?C++ SolutionPtr::setBC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolutionPtr
的用法示例。
在下文中一共展示了SolutionPtr::setBC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
// FunctionPtr u_spacetime = Function::solution(u, soln);
// ostringstream dir_name;
// dir_name << "spacetime_slice_convectingCone_k" << k;
// MeshTools::timeSliceExport(dir_name.str(), mesh, u_spacetime, frameTimes[frameOrdinal], "u_slice");
//
// cout << "Exported frame " << frameOrdinal << ", t=" << frameTimes[frameOrdinal] << endl;
// frameOrdinal++;
// }
// }
do
{
soln->solve(solver);
soln->reportTimings();
#ifdef HAVE_EPETRAEXT_HDF5
ostringstream dir_name;
dir_name << "spacetime_convectingCone_k" << k << "_t" << timeSlab;
HDF5Exporter exporter(soln->mesh(),dir_name.str());
exporter.exportSolution(soln, varFactory);
if (rank==0) cout << "Exported HDF solution for time slab to directory " << dir_name.str() << endl;
// string u_name = "u_spacetime";
// exporter.exportFunction(u_spacetime, u_name);
ostringstream file_name;
file_name << dir_name.str();
bool saveSolutionAndMeshForThisSlab = ((timeSlab + 1) % checkPointFrequency == 0); // +1 so that first output is nth, not first
if (saveSolutionAndMeshForThisSlab)
{
dir_name << ".soln";
soln->saveToHDF5(dir_name.str());
if (rank==0) cout << endl << "wrote " << dir_name.str() << endl;
file_name << ".mesh";
soln->mesh()->saveToHDF5(file_name.str());
}
#endif
FunctionPtr u_soln = Function::solution(u, soln);
double solnNorm = u_soln->l2norm(mesh);
double energyError = soln->energyErrorTotal();
relativeEnergyError = energyError / solnNorm;
if (rank==0)
{
cout << "Relative energy error for refinement " << refNumber++ << ": " << relativeEnergyError << endl;
}
if ((relativeEnergyError > refinementTolerance) && (refNumber < maxRefinements))
{
refinementStrategy->refine();
if (rank==0)
{
cout << "After refinement, mesh has " << mesh->getTopology()->activeCellCount() << " active (leaf) cells " << "and " << mesh->globalDofCount() << " degrees of freedom.\n";
}
}
}
while ((relativeEnergyError > refinementTolerance) && (refNumber < maxRefinements));
double t_slab_final = (timeSlab+1) * timeLengthPerSlab;
int frameOrdinal = lastFrameOutputted + 1;
vector<double> timesForSlab;
while (frameTimes[frameOrdinal] < t_slab_final)
{
double t = frameTimes[frameOrdinal];
if (rank==0) cout << "exporting t=" << t << " on slab " << timeSlab << endl;
FunctionPtr sliceFunction = MeshTools::timeSliceFunction(mesh, cellMap, u_spacetime, t);
sliceExporter.exportFunction(sliceFunction, "u_slice", t);
lastFrameOutputted = frameOrdinal++;
}
// set up next mesh/solution:
FunctionPtr q_prev = Function::solution(qHat, soln);
// cout << "Error in setup of q_prev: simple solution doesn't know about the map from the previous time slab to the current one. (TODO: fix this.)\n";
double tn = (timeSlab+1) * timeLengthPerSlab;
origin[2] = tn;
mesh = MeshFactory::rectilinearMesh(bf, dimensions, elementCounts, H1Order, delta_k, origin);
FunctionPtr q_transfer = Teuchos::rcp( new MeshTransferFunction(-q_prev, soln->mesh(), 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);
// IMPORTANT: now that we are ready to step to next soln, nullify BC. If we do not do this, then we have an RCP chain
// that extends back to the first time slab, effectively a memory leak.
soln->setBC(BC::bc());
soln = Solution::solution(mesh, bc, RHS::rhs(), ip);
soln->setUseCondensedSolve(useCondensedSolve);
}
return 0;
}