Skip to content

Commit

Permalink
Merge Pull Request #4368 from searhein/Trilinos/fix-#4276
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: ShyLU/FROSch: Adding a check for the block coarse map.
PR Author: searhein
  • Loading branch information
trilinos-autotester authored Feb 15, 2019
2 parents d404511 + 8242aea commit 88d1e45
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,17 @@ namespace FROSch {

int checkForLinearDependencies();

bool hasBasisMap() const;

MapPtr getBasisMap() const;

MultiVectorPtr getLocalBasis() const;
bool hasAssembledBasis() const;

CrsMatrixPtr getGlobalBasisMatrix() const;
MultiVectorPtr getAssembledBasis() const;

bool hasAssembledBasis() const;
bool hasGlobalBasisMatrix() const;

CrsMatrixPtr getGlobalBasisMatrix() const;

protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ namespace FROSch {
UN itmp = 0;
LOVecPtr2D partMappings;
AssembledBasisMap_ = AssembleMaps(UnassembledBasesMaps_(),partMappings);
AssembledBasis_ = Xpetra::MultiVectorFactory<SC,LO,GO,NO >::Build(SerialRowMap_,AssembledBasisMap_->getNodeNumElements());
for (UN i=0; i<UnassembledBasesMaps_.size(); i++) {
for (UN j=0; j<UnassembledBasesMaps_[i]->getNodeNumElements(); j++) {
AssembledBasis_->getDataNonConst(itmp).deepCopy(UnassembledSubspaceBases_[i]->getData(j)()); // Here, we copy data. Do we need to do this?
itmp++;
if (!AssembledBasisMap_.is_null()&&!SerialRowMap_.is_null()) {
if (AssembledBasisMap_->getGlobalNumElements()>0) { // AH 02/12/2019: Is this the right condition? Seems to work for now...
AssembledBasis_ = Xpetra::MultiVectorFactory<SC,LO,GO,NO >::Build(SerialRowMap_,AssembledBasisMap_->getNodeNumElements());
for (UN i=0; i<UnassembledBasesMaps_.size(); i++) {
for (UN j=0; j<UnassembledBasesMaps_[i]->getNodeNumElements(); j++) {
AssembledBasis_->getDataNonConst(itmp).deepCopy(UnassembledSubspaceBases_[i]->getData(j)()); // Here, we copy data. Do we need to do this?
itmp++;
}
}
}
}

Expand Down Expand Up @@ -164,6 +168,12 @@ namespace FROSch {
return 0;
}

template <class SC,class LO,class GO,class NO>
bool CoarseSpace<SC,LO,GO,NO>::hasBasisMap() const
{
return !AssembledBasisMap_.is_null();
}

template <class SC,class LO,class GO,class NO>
typename CoarseSpace<SC,LO,GO,NO>::MapPtr CoarseSpace<SC,LO,GO,NO>::getBasisMap() const
{
Expand All @@ -172,23 +182,29 @@ namespace FROSch {
}

template <class SC,class LO,class GO,class NO>
typename CoarseSpace<SC,LO,GO,NO>::MultiVectorPtr CoarseSpace<SC,LO,GO,NO>::getLocalBasis() const
bool CoarseSpace<SC,LO,GO,NO>::hasAssembledBasis() const
{
return !AssembledBasis_.is_null();
}

template <class SC,class LO,class GO,class NO>
typename CoarseSpace<SC,LO,GO,NO>::MultiVectorPtr CoarseSpace<SC,LO,GO,NO>::getAssembledBasis() const
{
FROSCH_ASSERT(!AssembledBasis_.is_null(),"AssembledBasis_.is_null().");
return AssembledBasis_;
}

template <class SC,class LO,class GO,class NO>
typename CoarseSpace<SC,LO,GO,NO>::CrsMatrixPtr CoarseSpace<SC,LO,GO,NO>::getGlobalBasisMatrix() const
bool CoarseSpace<SC,LO,GO,NO>::hasGlobalBasisMatrix() const
{
FROSCH_ASSERT(!GlobalBasisMatrix_.is_null(),"GlobalBasisMatrix_.is_null().");
return GlobalBasisMatrix_;
return !GlobalBasisMatrix_.is_null();
}

template <class SC,class LO,class GO,class NO>
bool CoarseSpace<SC,LO,GO,NO>::hasAssembledBasis() const
typename CoarseSpace<SC,LO,GO,NO>::CrsMatrixPtr CoarseSpace<SC,LO,GO,NO>::getGlobalBasisMatrix() const
{
return !AssembledBasis_.is_null();
FROSCH_ASSERT(!GlobalBasisMatrix_.is_null(),"GlobalBasisMatrix_.is_null().");
return GlobalBasisMatrix_;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ namespace FROSch {
GOVec mapVector(0);
GO tmp = 0;
for (UN i=0; i<NumberOfBlocks_; i++) {
for (UN j=0; j<InterfaceCoarseSpaces_[i]->getBasisMap()->getNodeNumElements(); j++) {
if (InterfaceCoarseSpaces_[i]->hasBasisMap()) {
for (UN j=0; j<InterfaceCoarseSpaces_[i]->getBasisMap()->getNodeNumElements(); j++) {
mapVector.push_back(InterfaceCoarseSpaces_[i]->getBasisMap()->getGlobalElement(j)+tmp);
}
tmp += InterfaceCoarseSpaces_[i]->getBasisMap()->getMaxAllGlobalIndex()+1;
if (InterfaceCoarseSpaces_[i]->getBasisMap()->getMaxAllGlobalIndex()>=0) {
tmp += InterfaceCoarseSpaces_[i]->getBasisMap()->getMaxAllGlobalIndex()+1;
}
}
}
return Xpetra::MapFactory<LO,GO,NO>::Build(DofsMaps_[0][0]->lib(),-1,mapVector(),0,this->MpiComm_);
}

Expand Down Expand Up @@ -381,11 +385,11 @@ namespace FROSch {
UN j = 0;
UN k = 0;
if (InterfaceCoarseSpaces_[i]->hasAssembledBasis()) {
numLocalBlockRows[i] = InterfaceCoarseSpaces_[i]->getLocalBasis()->getNumVectors();
numLocalBlockRows[i] = InterfaceCoarseSpaces_[i]->getAssembledBasis()->getNumVectors();
for (j=0; j<numLocalBlockRows[i]; j++) {
for (k=0; k<InterfaceCoarseSpaces_[i]->getLocalBasis()->getLocalLength(); k++) {
mVPhiGamma->replaceLocalValue(k+kk,j+jj,InterfaceCoarseSpaces_[i]->getLocalBasis()->getData(j)[k]);
mVPhi->replaceLocalValue(indicesGammaDofsAll[k+kk],j+jj,InterfaceCoarseSpaces_[i]->getLocalBasis()->getData(j)[k]);
for (k=0; k<InterfaceCoarseSpaces_[i]->getAssembledBasis()->getLocalLength(); k++) {
mVPhiGamma->replaceLocalValue(k+kk,j+jj,InterfaceCoarseSpaces_[i]->getAssembledBasis()->getData(j)[k]);
mVPhi->replaceLocalValue(indicesGammaDofsAll[k+kk],j+jj,InterfaceCoarseSpaces_[i]->getAssembledBasis()->getData(j)[k]);
}
}
} else { // Das ist für den Fall, dass keine Basisfunktionen für einen Block gebaut werden sollen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace FROSch {
nullspace = Xpetra::MultiVectorFactory<SC,LO,GO,NO>::Build(K_->getRowMap(), 1);
nullspace->putScalar(1.);
}
else if (!ParameterList_->sublist("MueLu").get("NullSpace","Laplace").compare("SPP")) {
else if (!ParameterList_->sublist("MueLu").get("NullSpace","Laplace").compare("SPP")) { // Hier matrix zu block matrix konvertieren
FROSCH_ASSERT(blockCoarseSize.size()==2,"Wrong size of blockCoarseSize for MueLu nullspace...");
unsigned dofs = (unsigned) ParameterList_->sublist("MueLu").get("Dimension",2);
nullspace = Xpetra::MultiVectorFactory<SC,LO,GO,NO>::Build(K_->getRowMap(), dofs+1);
Expand All @@ -146,8 +146,8 @@ namespace FROSch {
}
}
}
MueLuHierarchy_ = MueLuFactory_->CreateHierarchy();
MueLuHierarchy_->GetLevel(0)->Set("A",K_);
MueLuHierarchy_ = MueLuFactory_->CreateHierarchy(); // Das vor den if block
MueLuHierarchy_->GetLevel(0)->Set("A",K_); // Das in den if block
MueLuHierarchy_->GetLevel(0)->Set("Nullspace", nullspace);
#endif
#ifdef HAVE_SHYLU_DDFROSCH_BELOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ int main(int argc, char *argv[])

RCP<CoarseSpace<SC,LO,GO,NO> > coarseSpace = TestBasis.getLocalPartitionOfUnitySpace();

for (UN i=0; i<coarseSpace->getLocalBasis()->getLocalLength(); i++) {
for (UN j=0; j<coarseSpace->getLocalBasis()->getNumVectors(); j++) {
std::cout << coarseSpace->getLocalBasis()->getData(j)[i] << "\t";
for (UN i=0; i<coarseSpace->getAssembledBasis()->getLocalLength(); i++) {
for (UN j=0; j<coarseSpace->getAssembledBasis()->getNumVectors(); j++) {
std::cout << coarseSpace->getAssembledBasis()->getData(j)[i] << "\t";
}
std::cout << "\n";
}
Expand Down

0 comments on commit 88d1e45

Please sign in to comment.