本文整理汇总了C++中teuchos::RCP::MinAll方法的典型用法代码示例。如果您正苦于以下问题:C++ RCP::MinAll方法的具体用法?C++ RCP::MinAll怎么用?C++ RCP::MinAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::RCP
的用法示例。
在下文中一共展示了RCP::MinAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: minElementRadius
PeridigmNS::TextFileDiscretization::TextFileDiscretization(const Teuchos::RCP<const Epetra_Comm>& epetra_comm,
const Teuchos::RCP<Teuchos::ParameterList>& params) :
minElementRadius(1.0e50),
maxElementRadius(0.0),
maxElementDimension(0.0),
numBonds(0),
maxNumBondsPerElem(0),
myPID(epetra_comm->MyPID()),
numPID(epetra_comm->NumProc()),
bondFilterCommand("None"),
comm(epetra_comm)
{
TEUCHOS_TEST_FOR_EXCEPT_MSG(params->get<string>("Type") != "Text File", "Invalid Type in TextFileDiscretization");
string meshFileName = params->get<string>("Input Mesh File");
if(params->isParameter("Omit Bonds Between Blocks"))
bondFilterCommand = params->get<string>("Omit Bonds Between Blocks");
// Set up bond filters
createBondFilters(params);
QUICKGRID::Data decomp = getDecomp(meshFileName, params);
// \todo Refactor; the createMaps() call is currently inside getDecomp() due to order-of-operations issues with tracking element blocks.
//createMaps(decomp);
createNeighborhoodData(decomp);
// \todo Move this functionality to base class, it's currently duplicated in PdQuickGridDiscretization.
// Create the bondMap, a local map used for constitutive data stored on bonds.
// Due to Epetra_BlockMap restrictions, there can not be any entries with length zero.
// This means that points with no neighbors can not appear in the bondMap.
int numMyElementsUpperBound = oneDimensionalMap->NumMyElements();
int numGlobalElements = -1;
int numMyElements = 0;
int maxNumBonds = 0;
int* oneDimensionalMapGlobalElements = oneDimensionalMap->MyGlobalElements();
int* myGlobalElements = new int[numMyElementsUpperBound];
int* elementSizeList = new int[numMyElementsUpperBound];
int* const neighborhood = neighborhoodData->NeighborhoodList();
int neighborhoodIndex = 0;
int numPointsWithZeroNeighbors = 0;
for(int i=0 ; i<neighborhoodData->NumOwnedPoints() ; ++i){
int numNeighbors = neighborhood[neighborhoodIndex];
if(numNeighbors > 0){
numMyElements++;
myGlobalElements[i-numPointsWithZeroNeighbors] = oneDimensionalMapGlobalElements[i];
elementSizeList[i-numPointsWithZeroNeighbors] = numNeighbors;
}
else{
numPointsWithZeroNeighbors++;
}
numBonds += numNeighbors;
if(numNeighbors>maxNumBonds) maxNumBonds = numNeighbors;
neighborhoodIndex += 1 + numNeighbors;
}
maxNumBondsPerElem = maxNumBonds;
int indexBase = 0;
bondMap = Teuchos::rcp(new Epetra_BlockMap(numGlobalElements, numMyElements, myGlobalElements, elementSizeList, indexBase, *comm));
delete[] myGlobalElements;
delete[] elementSizeList;
// 3D only
TEUCHOS_TEST_FOR_EXCEPT_MSG(decomp.dimension != 3, "Invalid dimension in decomposition (only 3D is supported)");
// fill the x vector with the current positions (owned positions only)
initialX = Teuchos::rcp(new Epetra_Vector(Copy, *threeDimensionalMap, decomp.myX.get()));
// fill cell volumes
cellVolume = Teuchos::rcp(new Epetra_Vector(Copy,*oneDimensionalMap,decomp.cellVolume.get()) );
// find the minimum element radius
for(int i=0 ; i<cellVolume->MyLength() ; ++i){
double radius = pow(0.238732414637843*(*cellVolume)[i], 0.33333333333333333);
if(radius < minElementRadius)
minElementRadius = radius;
if(radius > maxElementRadius)
maxElementRadius = radius;
}
vector<double> localMin(1);
vector<double> globalMin(1);
localMin[0] = minElementRadius;
epetra_comm->MinAll(&localMin[0], &globalMin[0], 1);
minElementRadius = globalMin[0];
localMin[0] = maxElementRadius;
epetra_comm->MaxAll(&localMin[0], &globalMin[0], 1);
maxElementRadius = globalMin[0];
}