本文整理汇总了C++中MeshPtr::elementsInPartition方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::elementsInPartition方法的具体用法?C++ MeshPtr::elementsInPartition怎么用?C++ MeshPtr::elementsInPartition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::elementsInPartition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeMaxLocalConditionNumber
double MeshUtilities::computeMaxLocalConditionNumber(Teuchos::RCP< DPGInnerProduct > ip, MeshPtr mesh, bool jacobiScaling, string sparseFileToWriteTo) {
int rank = Teuchos::GlobalMPISession::getRank();
int numProcs = Teuchos::GlobalMPISession::getNProc();
vector< ElementPtr > elements = mesh->elementsInPartition(rank);
// cout << "Checking condition numbers on rank " << rank << endl;
FieldContainer<double> maxConditionNumberIPMatrix;
int maxCellID = -1;
double myMaxConditionNumber = -1;
for (vector< ElementPtr >::iterator elemIt = elements.begin(); elemIt != elements.end(); elemIt++) {
int cellID = (*elemIt)->cellID();
bool testVsTest = true;
BasisCachePtr cellBasisCache = BasisCache::basisCacheForCell(mesh, cellID, testVsTest);
DofOrderingPtr testSpace = (*elemIt)->elementType()->testOrderPtr;
int testDofs = testSpace->totalDofs();
int numCells = 1;
FieldContainer<double> innerProductMatrix(numCells,testDofs,testDofs);
ip->computeInnerProductMatrix(innerProductMatrix, testSpace, cellBasisCache);
// reshape:
innerProductMatrix.resize(testDofs,testDofs);
if (jacobiScaling)
SerialDenseMatrixUtility::jacobiScaleMatrix(innerProductMatrix);
// double conditionNumber = SerialDenseMatrixUtility::estimate1NormConditionNumber(innerProductMatrix);
double conditionNumber = SerialDenseMatrixUtility::estimate2NormConditionNumber(innerProductMatrix);
if (conditionNumber > myMaxConditionNumber) {
myMaxConditionNumber = conditionNumber;
maxConditionNumberIPMatrix = innerProductMatrix;
maxCellID = cellID;
} else if (maxConditionNumberIPMatrix.size()==0) {
// could be that the estimation failed--we still want a copy of the matrix written to file.
maxConditionNumberIPMatrix = innerProductMatrix;
}
}
// cout << "Determined condition numbers on rank " << rank << endl;
FieldContainer<double> maxConditionNumbers(numProcs);
maxConditionNumbers[rank] = myMaxConditionNumber;
MPIWrapper::entryWiseSum(maxConditionNumbers);
double maxConditionNumber = maxConditionNumbers[0];
int maxConditionNumberOwner = 0; // the MPI node with the max condition number
for (int i=1; i<numProcs; i++) {
if (maxConditionNumber < maxConditionNumbers[i]) {
maxConditionNumber = maxConditionNumbers[i];
maxConditionNumberOwner = i;
}
}
if (rank==maxConditionNumberOwner) { // owner is responsible for writing to file
// cout << "max condition number is on rank " << rank << endl;
if (sparseFileToWriteTo.length() > 0) {
if (maxConditionNumberIPMatrix.size() > 0) {
DataIO::writeMatrixToSparseDataFile(maxConditionNumberIPMatrix, sparseFileToWriteTo);
}
}
}
// cout << "max condition number occurs in cellID " << maxCellID << endl;
return maxConditionNumber;
}