本文整理汇总了C++中Epetra_BlockMap::ElementSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_BlockMap::ElementSize方法的具体用法?C++ Epetra_BlockMap::ElementSize怎么用?C++ Epetra_BlockMap::ElementSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_BlockMap
的用法示例。
在下文中一共展示了Epetra_BlockMap::ElementSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
int
LOCA::Epetra::AugmentedOp::blockMap2PointMap(const Epetra_BlockMap& BlockMap,
Epetra_Map*& PointMap) const
{
// Generate an Epetra_Map that has the same number and distribution of points
// as the input Epetra_BlockMap object. The global IDs for the output PointMap
// are computed by using the MaxElementSize of the BlockMap. For variable block
// sizes this will create gaps in the GID space, but that is OK for Epetra_Maps.
int MaxElementSize = BlockMap.MaxElementSize();
int PtNumMyElements = BlockMap.NumMyPoints();
int * PtMyGlobalElements = 0;
if (PtNumMyElements>0) PtMyGlobalElements = new int[PtNumMyElements];
int NumMyElements = BlockMap.NumMyElements();
int curID = 0;
for (int i=0; i<NumMyElements; i++) {
int StartID = BlockMap.GID(i)*MaxElementSize;
int ElementSize = BlockMap.ElementSize(i);
for (int j=0; j<ElementSize; j++) PtMyGlobalElements[curID++] = StartID+j;
}
assert(curID==PtNumMyElements); // Sanity test
PointMap = new Epetra_Map(-1, PtNumMyElements, PtMyGlobalElements, BlockMap.IndexBase(), BlockMap.Comm());
if (PtNumMyElements>0) delete [] PtMyGlobalElements;
if (!BlockMap.PointSameAs(*PointMap)) {EPETRA_CHK_ERR(-1);} // Maps not compatible
return(0);
}
示例2: return
//=========================================================================
int Ifpack_CrsRiluk::BlockMap2PointMap(const Epetra_BlockMap & BlockMap, Teuchos::RefCountPtr<Epetra_Map>* PointMap) {
// Generate an Epetra_Map that has the same number and distribution of points
// as the input Epetra_BlockMap object. The global IDs for the output PointMap
// are computed by using the MaxElementSize of the BlockMap. For variable block
// sizes this will create gaps in the GID space, but that is OK for Epetra_Maps.
int MaxElementSize = BlockMap.MaxElementSize();
int PtNumMyElements = BlockMap.NumMyPoints();
vector<int> PtMyGlobalElements;
if (PtNumMyElements>0) PtMyGlobalElements.resize(PtNumMyElements);
int NumMyElements = BlockMap.NumMyElements();
int curID = 0;
for (int i=0; i<NumMyElements; i++) {
int StartID = BlockMap.GID(i)*MaxElementSize;
int ElementSize = BlockMap.ElementSize(i);
for (int j=0; j<ElementSize; j++) PtMyGlobalElements[curID++] = StartID+j;
}
assert(curID==PtNumMyElements); // Sanity test
(*PointMap) = Teuchos::rcp( new Epetra_Map(-1, PtNumMyElements, &PtMyGlobalElements[0], BlockMap.IndexBase(), BlockMap.Comm()) );
if (!BlockMap.PointSameAs(*(*PointMap))) {EPETRA_CHK_ERR(-1);} // Maps not compatible
return(0);
}
示例3: rcp
Teuchos::RCP<Epetra_Map> mapDowncast(const Epetra_BlockMap &in)
{
if (in.ConstantElementSize() && in.ElementSize() == 1) {
return Teuchos::rcp(new Epetra_Map(static_cast<const Epetra_Map &>(in)));
}
return Teuchos::null;
}
示例4: BlockMapToHandle
int BlockMapToHandle(FILE * handle, const Epetra_BlockMap & map) {
const Epetra_Comm & comm = map.Comm();
int numProc = comm.NumProc();
bool doSizes = !map.ConstantElementSize();
if (numProc==1) {
int * myElements = map.MyGlobalElements();
int * elementSizeList = 0;
if (doSizes) elementSizeList = map.ElementSizeList();
return(writeBlockMap(handle, map.NumGlobalElements(), myElements, elementSizeList, doSizes));
}
int numRows = map.NumMyElements();
Epetra_Map allGidsMap(-1, numRows, 0,comm);
Epetra_IntVector allGids(allGidsMap);
for (int i=0; i<numRows; i++) allGids[i] = map.GID(i);
Epetra_IntVector allSizes(allGidsMap);
for (int i=0; i<numRows; i++) allSizes[i] = map.ElementSize(i);
// Now construct a Map on PE 0 by strip-mining the rows of the input matrix map.
int numChunks = numProc;
int stripSize = allGids.GlobalLength()/numChunks;
int remainder = allGids.GlobalLength()%numChunks;
int curStart = 0;
int curStripSize = 0;
Epetra_IntSerialDenseVector importGidList;
Epetra_IntSerialDenseVector importSizeList;
if (comm.MyPID()==0) {
importGidList.Size(stripSize+1); // Set size of vector to max needed
if (doSizes) importSizeList.Size(stripSize+1); // Set size of vector to max needed
}
for (int i=0; i<numChunks; i++) {
if (comm.MyPID()==0) { // Only PE 0 does this part
curStripSize = stripSize;
if (i<remainder) curStripSize++; // handle leftovers
for (int j=0; j<curStripSize; j++) importGidList[j] = j + curStart;
curStart += curStripSize;
}
// The following import map will be non-trivial only on PE 0.
Epetra_Map importGidMap(-1, curStripSize, importGidList.Values(), 0, comm);
Epetra_Import gidImporter(importGidMap, allGidsMap);
Epetra_IntVector importGids(importGidMap);
if (importGids.Import(allGids, gidImporter, Insert)) return(-1);
Epetra_IntVector importSizes(importGidMap);
if (doSizes) if (importSizes.Import(allSizes, gidImporter, Insert)) return(-1);
// importGids (and importSizes, if non-trivial block map)
// now have a list of GIDs (and sizes, respectively) for the current strip of map.
int * myElements = importGids.Values();
int * elementSizeList = 0;
if (doSizes) elementSizeList = importSizes.Values();
// Finally we are ready to write this strip of the map to file
writeBlockMap(handle, importGids.MyLength(), myElements, elementSizeList, doSizes);
}
return(0);
}
示例5: MultiVectorTests
//.........这里部分代码省略.........
delete [] dotvec_AB;
delete [] norm1_A;
delete [] norm2_sqrtA;
delete [] norminf_A;
delete [] normw_A;
delete [] minval_A;
delete [] maxval_A;
delete [] meanval_A;
delete [] residual;
//*******************************************************************
// Post-construction modification tests
//*******************************************************************
if (verbose) cout << "\n\nXXXXX Testing Post-construction modification of a multivector"
<<endl<<endl;
err = 0;
Epetra_MultiVector X(Map, NumVectors);
X.Random();
// Pick middle range values for GID, LID and Vector Index
int testGID = Map.NumGlobalElements()/2;
int testVecIndex = NumVectors/2;
int GIDSize = 1;
int LIDOfGID = 0;
int FirstEntryOfGID = 0;
if (Map.MyGID(testGID)) {
LIDOfGID = Map.LID(testGID);
GIDSize = Map.ElementSize(LIDOfGID);
FirstEntryOfGID = Map.FirstPointInElement(LIDOfGID);
}
// ========================================================================
// Test int ReplaceGlobalValue (int GlobalRow, int VectorIndex, double ScalarValue)
// ========================================================================
double newGIDValue = 4.0;
locerr = X.ReplaceGlobalValue(testGID, testVecIndex, newGIDValue);
if (Map.MyGID(testGID)) {
if (X[testVecIndex][FirstEntryOfGID]!=newGIDValue) err++;
if (verbose) cout << "X["<<testVecIndex<<"]["<<FirstEntryOfGID<<"] = "
<< X[testVecIndex][FirstEntryOfGID]
<< " should = " << newGIDValue << endl;
}
else
if (locerr!=1) err++; // Test for GID out of range error (=1)
// ========================================================================
// Test int ReplaceGlobalValue (int GlobalRow, intBlockRowOffset, int VectorIndex, double ScalarValue)
// ========================================================================
newGIDValue = 8.0;
locerr = X.ReplaceGlobalValue(testGID, GIDSize-1, testVecIndex, newGIDValue);
if (Map.MyGID(testGID)) {
if (X[testVecIndex][FirstEntryOfGID+GIDSize-1]!=newGIDValue) err++;
if (verbose) cout << "X["<<testVecIndex<<"]["<<FirstEntryOfGID+GIDSize-1<<"] = "
<< X[testVecIndex][FirstEntryOfGID+GIDSize-1]
<< " should = " << newGIDValue << endl;
}
else
示例6: checkmap
int checkmap(Epetra_BlockMap & Map, int NumGlobalElements, int NumMyElements,
int *MyGlobalElements, int ElementSize, int * ElementSizeList,
int NumGlobalPoints, int NumMyPoints,
int IndexBase, Epetra_Comm& Comm,
bool DistributedGlobal,
bool IsOneToOne)
{
int i, ierr=0, forierr=0;// forierr is used in for loops, then is tested
// after for loop completes to see if it is non zero - potentially prevents
// thousands of error messages
if (ElementSizeList==0)
{
EPETRA_TEST_ERR(!Map.ConstantElementSize(),ierr);
}
else
EPETRA_TEST_ERR(Map.ConstantElementSize(),ierr);
EPETRA_TEST_ERR(DistributedGlobal!=Map.DistributedGlobal(),ierr);
EPETRA_TEST_ERR(IsOneToOne!=Map.IsOneToOne(),ierr);
int *MyElementSizeList;
if (ElementSizeList==0)
{
EPETRA_TEST_ERR(Map.ElementSize()!=ElementSize,ierr);
MyElementSizeList = new int[NumMyElements];
EPETRA_TEST_ERR(Map.ElementSizeList(MyElementSizeList)!=0,ierr);
forierr = 0;
for (i=0; i<NumMyElements; i++)
forierr += MyElementSizeList[i]!=ElementSize;
EPETRA_TEST_ERR(forierr,ierr);
EPETRA_TEST_ERR(Map.MaxMyElementSize() != ElementSize,ierr);
EPETRA_TEST_ERR(Map.MinMyElementSize() != ElementSize,ierr);
}
else
{
MyElementSizeList = new int[NumMyElements];
EPETRA_TEST_ERR(Map.ElementSizeList(MyElementSizeList)!=0,ierr);
int MaxSize = MyElementSizeList[0];
int MinSize = MyElementSizeList[0];
forierr=0;
for (i=0; i<NumMyElements; i++) {
forierr += MyElementSizeList[i]!=ElementSizeList[i];
if (MyElementSizeList[i] > MaxSize)
MaxSize = MyElementSizeList[i];
if (MyElementSizeList[i] < MinSize)
MinSize = MyElementSizeList[i];
// Test ElementSize(int LID) method
forierr += Map.ElementSize(Map.LID(MyGlobalElements[i])) != ElementSizeList[i];
}
EPETRA_TEST_ERR(forierr,ierr);
EPETRA_TEST_ERR(MaxSize !=Map.MaxMyElementSize(),ierr);
EPETRA_TEST_ERR(MinSize !=Map.MinMyElementSize(),ierr);
}
const Epetra_Comm & Comm1 = Map.Comm();
EPETRA_TEST_ERR(Comm1.NumProc()!=Comm.NumProc(),ierr);
EPETRA_TEST_ERR(Comm1.MyPID()!=Comm.MyPID(),ierr);
EPETRA_TEST_ERR(Map.IndexBase()!=IndexBase,ierr);
EPETRA_TEST_ERR(!Map.LinearMap() && MyGlobalElements==0,ierr);
EPETRA_TEST_ERR(Map.LinearMap() && MyGlobalElements!=0,ierr);
EPETRA_TEST_ERR(Map.MaxAllGID()!=NumGlobalElements-1+IndexBase,ierr);
EPETRA_TEST_ERR(Map.MaxElementSize()!=ElementSize,ierr);
int MaxLID = Map.MaxLID();
EPETRA_TEST_ERR(MaxLID!=NumMyElements-1,ierr);
int MaxMyGID = (Comm.MyPID()+1)*NumMyElements-1+IndexBase;
if (Comm.MyPID()>2) MaxMyGID+=3;
if (!DistributedGlobal) MaxMyGID = NumMyElements-1+IndexBase;
EPETRA_TEST_ERR(Map.MaxMyGID()!=MaxMyGID,ierr);
EPETRA_TEST_ERR(Map.MinAllGID()!=IndexBase,ierr);
if (ElementSizeList==0)
{
EPETRA_TEST_ERR(Map.MinElementSize()!=ElementSize,ierr);
}
else EPETRA_TEST_ERR(Map.MinElementSize()!=2,ierr);
int MinLID = Map.MinLID();
EPETRA_TEST_ERR(MinLID!=0,ierr);
int MinMyGID = Comm.MyPID()*NumMyElements+IndexBase;
//.........这里部分代码省略.........
示例7: SameAs
//==============================================================================
bool Epetra_BlockMap::SameAs(const Epetra_BlockMap & Map) const {
// Quickest test: See if both maps share an inner data class
if (this->BlockMapData_ == Map.BlockMapData_)
return(true);
if(!GlobalIndicesTypeMatch(Map))
return(false);
// Next check other global properties that are easy global attributes
if (BlockMapData_->MinAllGID_ != Map.MinAllGID64() ||
BlockMapData_->MaxAllGID_ != Map.MaxAllGID64() ||
BlockMapData_->NumGlobalElements_ != Map.NumGlobalElements64() ||
BlockMapData_->IndexBase_ != Map.IndexBase())
return(false);
// Last possible global check for constant element sizes
if (BlockMapData_->ConstantElementSize_ && BlockMapData_->ElementSize_!=Map.ElementSize())
return(false);
// If we get this far, we need to check local properties and then check across
// all processors to see if local properties are all true
int numMyElements = BlockMapData_->NumMyElements_;
int MySameMap = 1; // Assume not needed
// First check if number of element is the same in each map
if (numMyElements != Map.NumMyElements()) MySameMap = 0;
// If numMyElements is the same, check to see that list of GIDs is the same
if (MySameMap==1) {
if (LinearMap() && Map.LinearMap() ) {
// For linear maps, just need to check whether lower bound is the same
if (MinMyGID64() != Map.MinMyGID64() )
MySameMap = 0;
}
else {
for (int i = 0; i < numMyElements; i++) {
if (GID64(i) != Map.GID64(i)) {
MySameMap = 0;
break;
}
}
}
}
// for (int i = 0; i < numMyElements; i++)
// if (GID64(i) != Map.GID64(i)) MySameMap = 0;
// If GIDs are the same, check to see element sizes are the same
if (MySameMap==1 && !BlockMapData_->ConstantElementSize_) {
int * sizeList1 = ElementSizeList();
int * sizeList2 = Map.ElementSizeList();
for (int i = 0; i < numMyElements; i++) if (sizeList1[i] != sizeList2[i]) MySameMap=0;
}
// Now get min of MySameMap across all processors
int GlobalSameMap = 0;
int err = Comm().MinAll(&MySameMap, &GlobalSameMap, 1);
assert(err==0);
return(GlobalSameMap==1);
}