From 17f10197b7428d64200dfb3c5e3e819af00f5a3c Mon Sep 17 00:00:00 2001 From: iyamazaki Date: Wed, 11 Sep 2024 16:05:57 -0600 Subject: [PATCH 1/2] FROSch : fix issues with multiple blocks --- .../FROSch_GDSWCoarseOperator_def.hpp | 378 +++++++++--------- .../FROSch_HarmonicCoarseOperator_def.hpp | 89 +++-- .../FROSch_IPOUHarmonicCoarseOperator_def.hpp | 39 +- .../FROSch_RGDSWCoarseOperator_def.hpp | 29 +- 4 files changed, 266 insertions(+), 269 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp index 8b9bd5feaa0e..0ad1c90b789d 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_GDSWCoarseOperator_def.hpp @@ -247,14 +247,7 @@ namespace FROSch { // Das könnte man noch ändern // TODO: DAS SOLLTE ALLES IN EINE FUNKTION IN HARMONICCOARSEOPERATOR - this->GammaDofs_.resize(this->GammaDofs_.size()+1); - this->IDofs_.resize(this->IDofs_.size()+1); - this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); - this->DofsMaps_.resize(this->DofsMaps_.size()+1); - this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); - this->NumberOfBlocks_++; - - resetCoarseSpaceBlock(this->NumberOfBlocks_-1,dimension,dofsPerNode,nodesMap,dofsMaps,dirichletBoundaryDofs,nodeList); + resetCoarseSpaceBlock(this->NumberOfBlocks_,dimension,dofsPerNode,nodesMap,dofsMaps,dirichletBoundaryDofs,nodeList); return 0; } @@ -273,13 +266,7 @@ namespace FROSch { // Das könnte man noch ändern // TODO: DAS SOLLTE ALLES IN EINE FUNKTION IN HARMONICCOARSEOPERATOR for (UN i=0; iGammaDofs_.resize(this->GammaDofs_.size()+1); - this->IDofs_.resize(this->IDofs_.size()+1); - this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); - this->DofsMaps_.resize(this->DofsMaps_.size()+1); - this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); - this->NumberOfBlocks_++; - resetCoarseSpaceBlock(this->NumberOfBlocks_-1,dimension,dofsPerNodeVec[i],repeatedNodesMapVec[i],repeatedDofMapsVec[i],dirichletBoundaryDofsVec[i],nodeListVec[i]); + resetCoarseSpaceBlock(this->NumberOfBlocks_,dimension,dofsPerNodeVec[i],repeatedNodesMapVec[i],repeatedDofMapsVec[i],dirichletBoundaryDofsVec[i],nodeListVec[i]); } return 0; } @@ -296,7 +283,7 @@ namespace FROSch { { FROSCH_DETAILTIMER_START_LEVELID(resetCoarseSpaceBlockTime,"GDSWCoarseOperator::resetCoarseSpaceBlock"); FROSCH_ASSERT(dofsMaps.size()==dofsPerNode,"dofsMaps.size()!=dofsPerNode"); - FROSCH_ASSERT(blockIdNumberOfBlocks_,"Block does not exist yet and can therefore not be reset."); + FROSCH_ASSERT(blockId<=this->NumberOfBlocks_,"Block does not exist yet and can therefore not be reset("+to_string(blockId)+" <= "+to_string(this->NumberOfBlocks_)+". "); if (!this->DistributionList_->get("Type","linear").compare("ZoltanDual")) { FROSCH_ASSERT(false,"RGDSWCoarseOperator:: Distribution Type ZoltanDual only works for IPOUHarmonicCoarseOperator"); @@ -356,155 +343,28 @@ namespace FROSch { useFaceRotations = false; } - this->DofsMaps_[blockId] = dofsMaps; - this->DofsPerNode_[blockId] = dofsPerNode; - - Array tmpDirichletBoundaryDofs(dirichletBoundaryDofs()); // Here, we do a copy. Maybe, this is not necessary - sortunique(tmpDirichletBoundaryDofs); - - DDInterface_.reset(new DDInterface(dimension,this->DofsPerNode_[blockId],nodesMap.getConst(),verbosity,this->LevelID_,communicationStrategy)); - DDInterface_->resetGlobalDofs(dofsMaps); - DDInterface_->removeDirichletNodes(tmpDirichletBoundaryDofs()); - - EntitySetPtr interface = this->DDInterface_->getInterface(); - EntitySetPtr interior = this->DDInterface_->getInterior(); - - if (useForCoarseSpace && (useVertexTranslations||useShortEdgeTranslations||useShortEdgeRotations||useStraightEdgeTranslations||useStraightEdgeRotations||useEdgeTranslations||useEdgeRotations||useFaceTranslations||useFaceRotations)) { - - if (this->Verbose_) { - cout - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << setw(89) << "-----------------------------------------------------------------------------------------" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " - << left << setw(74) << "GDSWCoarseOperator " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << setw(89) << "=========================================================================================" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(41) << "Block" << right - << " | " << setw(41) << blockId - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(41) << "Spatial dimensions" << right - << " | " << setw(41) << dimension - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(41) << "Number of degrees of freedom per node" << right - << " | " << setw(41) << dofsPerNode - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << setw(89) << "-----------------------------------------------------------------------------------------" - << endl; - } + if (useForCoarseSpace) { + this->NumberOfBlocks_++; - // Check for interface - if (interface->getEntity(0)->getNumNodes()==0) { - FROSCH_NOTIFICATION("FROSch::GDSWCoarseOperator",this->Verbose_,"No interface found => Volume functions will be used instead."); - this->computeVolumeFunctions(blockId,dimension,nodesMap,nodeList,interior); - } else { - this->GammaDofs_[blockId] = LOVecPtr(this->DofsPerNode_[blockId]*interface->getEntity(0)->getNumNodes()); - this->IDofs_[blockId] = LOVecPtr(this->DofsPerNode_[blockId]*interior->getEntity(0)->getNumNodes()); - for (UN k=0; kDofsPerNode_[blockId]; k++) { - for (UN i=0; igetEntity(0)->getNumNodes(); i++) { - this->GammaDofs_[blockId][this->DofsPerNode_[blockId]*i+k] = interface->getEntity(0)->getLocalDofID(i,k); - } - for (UN i=0; igetEntity(0)->getNumNodes(); i++) { - this->IDofs_[blockId][this->DofsPerNode_[blockId]*i+k] = interior->getEntity(0)->getLocalDofID(i,k); - } - } + this->GammaDofs_.resize(this->GammaDofs_.size()+1); + this->IDofs_.resize(this->IDofs_.size()+1); + this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); + this->DofsMaps_.resize(this->DofsMaps_.size()+1); + this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); - this->InterfaceCoarseSpaces_[blockId].reset(new CoarseSpace(this->MpiComm_,this->SerialComm_)); + this->DofsMaps_[blockId] = dofsMaps; + this->DofsPerNode_[blockId] = dofsPerNode; - if (this->ParameterList_->get("Test Unconnected Interface",true)) { - DDInterface_->divideUnconnectedEntities(this->K_); - } + Array tmpDirichletBoundaryDofs(dirichletBoundaryDofs()); // Here, we do a copy. Maybe, this is not necessary + sortunique(tmpDirichletBoundaryDofs); - DDInterface_->sortVerticesEdgesFaces(nodeList); - - EntitySetPtr interface = DDInterface_->getInterface(); - EntitySetPtr interior = DDInterface_->getInterior(); - - //////////////////////////////// - // Build Processor Map Coarse // - //////////////////////////////// - DDInterface_->buildEntityMaps(useVertexTranslations, - useShortEdgeTranslations||useShortEdgeRotations, - useStraightEdgeTranslations || useStraightEdgeRotations, - useEdgeTranslations || useEdgeRotations, - useFaceTranslations || useFaceRotations, - false); - - // Vertices - if (useVertexTranslations) { - XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getVertices()); - ConstXMapPtr verticesEntityMap = DDInterface_->getVertices()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(verticesEntityMap,null,translations[i]); - } - } - // ShortEdges - if (useShortEdgeTranslations) { - XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getShortEdges()); - ConstXMapPtr shortEdgesEntityMap = DDInterface_->getShortEdges()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(shortEdgesEntityMap,null,translations[i]); - } - } - if (useShortEdgeRotations) { - XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getShortEdges(),(dimension==3)); - ConstXMapPtr shortEdgesEntityMap = DDInterface_->getShortEdges()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(shortEdgesEntityMap,null,rotations[i]); - } - } - // StraightEdges - if (useStraightEdgeTranslations) { - XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getStraightEdges()); - ConstXMapPtr straightEdgesEntityMap = DDInterface_->getStraightEdges()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(straightEdgesEntityMap,null,translations[i]); - } - } - if (useStraightEdgeRotations) { - XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getStraightEdges(),(dimension==3)); - ConstXMapPtr straightEdgesEntityMap = DDInterface_->getStraightEdges()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(straightEdgesEntityMap,null,rotations[i]); - } - } - // Edges - if (useEdgeTranslations) { - XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getEdges()); - ConstXMapPtr edgesEntityMap = DDInterface_->getEdges()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(edgesEntityMap,null,translations[i]); - } - } - if (useEdgeRotations) { - XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getEdges()); - ConstXMapPtr edgesEntityMap = DDInterface_->getEdges()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(edgesEntityMap,null,rotations[i]); - } - } - // Faces - if (useFaceTranslations) { - XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getFaces()); - ConstXMapPtr facesEntityMap = DDInterface_->getFaces()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(facesEntityMap,null,translations[i]); - } - } - if (useFaceRotations) { - XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getFaces()); - ConstXMapPtr facesEntityMap = DDInterface_->getFaces()->getEntityMap(); - for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(facesEntityMap,null,rotations[i]); - } - } + DDInterface_.reset(new DDInterface(dimension,this->DofsPerNode_[blockId],nodesMap.getConst(),verbosity,this->LevelID_,communicationStrategy)); + DDInterface_->resetGlobalDofs(dofsMaps); + DDInterface_->removeDirichletNodes(tmpDirichletBoundaryDofs()); - this->InterfaceCoarseSpaces_[blockId]->assembleCoarseSpace(); + if (useVertexTranslations||useShortEdgeTranslations||useShortEdgeRotations||useStraightEdgeTranslations||useStraightEdgeRotations||useEdgeTranslations||useEdgeRotations||useFaceTranslations||useFaceRotations) { + EntitySetPtr interface = this->DDInterface_->getInterface(); + EntitySetPtr interior = this->DDInterface_->getInterior(); if (this->Verbose_) { cout @@ -512,50 +372,186 @@ namespace FROSch { << setw(89) << "-----------------------------------------------------------------------------------------" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " - << left << setw(74) << "> GDSW coarse space " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" + << left << setw(74) << "GDSWCoarseOperator " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << setw(89) << "=========================================================================================" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "Vertices " << " | " << setw(19) << "Translations " << right - << " | " << setw(41) << boolalpha << useVertexTranslations << noboolalpha - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "ShortEdges " << " | " << setw(19) << "Translations " << right - << " | " << setw(41) << boolalpha << useShortEdgeTranslations << noboolalpha - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "ShortEdges " << " | " << setw(19) << "Rotations " << right - << " | " << setw(41) << boolalpha << useShortEdgeRotations << noboolalpha - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "StraightEdges " << " | " << setw(19) << "Translations " << right - << " | " << setw(41) << boolalpha << useStraightEdgeTranslations << noboolalpha + << "| " << left << setw(41) << "Block" << right + << " | " << setw(41) << blockId << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "StraightEdges " << " | " << setw(19) << "Rotations " << right - << " | " << setw(41) << boolalpha << useStraightEdgeRotations << noboolalpha + << "| " << left << setw(41) << "Spatial dimensions" << right + << " | " << setw(41) << dimension << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "Edges " << " | " << setw(19) << "Translations " << right - << " | " << setw(41) << boolalpha << useEdgeTranslations << noboolalpha - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "Edges " << " | " << setw(19) << "Rotations " << right - << " | " << setw(41) << boolalpha << useEdgeRotations << noboolalpha - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "Faces " << " | " << setw(19) << "Translations " << right - << " | " << setw(41) << boolalpha << useFaceTranslations << noboolalpha - << " |" - << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " - << "| " << left << setw(19) << "Faces " << " | " << setw(19) << "Rotations " << right - << " | " << setw(41) << boolalpha << useFaceRotations << noboolalpha + << "| " << left << setw(41) << "Number of degrees of freedom per node" << right + << " | " << setw(41) << dofsPerNode << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << setw(89) << "-----------------------------------------------------------------------------------------" << endl; } + + // Check for interface + if (interface->getEntity(0)->getNumNodes()==0) { + FROSCH_NOTIFICATION("FROSch::GDSWCoarseOperator",this->Verbose_,"No interface found => Volume functions will be used instead."); + this->computeVolumeFunctions(blockId,dimension,nodesMap,nodeList,interior); + } else { + this->GammaDofs_[blockId] = LOVecPtr(this->DofsPerNode_[blockId]*interface->getEntity(0)->getNumNodes()); + this->IDofs_[blockId] = LOVecPtr(this->DofsPerNode_[blockId]*interior->getEntity(0)->getNumNodes()); + for (UN k=0; kDofsPerNode_[blockId]; k++) { + for (UN i=0; igetEntity(0)->getNumNodes(); i++) { + this->GammaDofs_[blockId][this->DofsPerNode_[blockId]*i+k] = interface->getEntity(0)->getLocalDofID(i,k); + } + for (UN i=0; igetEntity(0)->getNumNodes(); i++) { + this->IDofs_[blockId][this->DofsPerNode_[blockId]*i+k] = interior->getEntity(0)->getLocalDofID(i,k); + } + } + + this->InterfaceCoarseSpaces_[blockId].reset(new CoarseSpace(this->MpiComm_,this->SerialComm_)); + + if (this->ParameterList_->get("Test Unconnected Interface",true)) { + DDInterface_->divideUnconnectedEntities(this->K_); + } + + DDInterface_->sortVerticesEdgesFaces(nodeList); + + EntitySetPtr interface = DDInterface_->getInterface(); + EntitySetPtr interior = DDInterface_->getInterior(); + + //////////////////////////////// + // Build Processor Map Coarse // + //////////////////////////////// + DDInterface_->buildEntityMaps(useVertexTranslations, + useShortEdgeTranslations||useShortEdgeRotations, + useStraightEdgeTranslations || useStraightEdgeRotations, + useEdgeTranslations || useEdgeRotations, + useFaceTranslations || useFaceRotations, + false); + + // Vertices + if (useVertexTranslations) { + XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getVertices()); + ConstXMapPtr verticesEntityMap = DDInterface_->getVertices()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(verticesEntityMap,null,translations[i]); + } + } + // ShortEdges + if (useShortEdgeTranslations) { + XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getShortEdges()); + ConstXMapPtr shortEdgesEntityMap = DDInterface_->getShortEdges()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(shortEdgesEntityMap,null,translations[i]); + } + } + if (useShortEdgeRotations) { + XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getShortEdges(),(dimension==3)); + ConstXMapPtr shortEdgesEntityMap = DDInterface_->getShortEdges()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(shortEdgesEntityMap,null,rotations[i]); + } + } + // StraightEdges + if (useStraightEdgeTranslations) { + XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getStraightEdges()); + ConstXMapPtr straightEdgesEntityMap = DDInterface_->getStraightEdges()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(straightEdgesEntityMap,null,translations[i]); + } + } + if (useStraightEdgeRotations) { + XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getStraightEdges(),(dimension==3)); + ConstXMapPtr straightEdgesEntityMap = DDInterface_->getStraightEdges()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(straightEdgesEntityMap,null,rotations[i]); + } + } + // Edges + if (useEdgeTranslations) { + XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getEdges()); + ConstXMapPtr edgesEntityMap = DDInterface_->getEdges()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(edgesEntityMap,null,translations[i]); + } + } + if (useEdgeRotations) { + XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getEdges()); + ConstXMapPtr edgesEntityMap = DDInterface_->getEdges()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(edgesEntityMap,null,rotations[i]); + } + } + // Faces + if (useFaceTranslations) { + XMultiVectorPtrVecPtr translations = this->computeTranslations(blockId,DDInterface_->getFaces()); + ConstXMapPtr facesEntityMap = DDInterface_->getFaces()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(facesEntityMap,null,translations[i]); + } + } + if (useFaceRotations) { + XMultiVectorPtrVecPtr rotations = this->computeRotations(blockId,dimension,nodeList,DDInterface_->getFaces()); + ConstXMapPtr facesEntityMap = DDInterface_->getFaces()->getEntityMap(); + for (UN i=0; iInterfaceCoarseSpaces_[blockId]->addSubspace(facesEntityMap,null,rotations[i]); + } + } + + this->InterfaceCoarseSpaces_[blockId]->assembleCoarseSpace(); + + if (this->Verbose_) { + cout + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << setw(89) << "-----------------------------------------------------------------------------------------" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " + << left << setw(74) << "> GDSW coarse space " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << setw(89) << "=========================================================================================" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "Vertices " << " | " << setw(19) << "Translations " << right + << " | " << setw(41) << boolalpha << useVertexTranslations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "ShortEdges " << " | " << setw(19) << "Translations " << right + << " | " << setw(41) << boolalpha << useShortEdgeTranslations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "ShortEdges " << " | " << setw(19) << "Rotations " << right + << " | " << setw(41) << boolalpha << useShortEdgeRotations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "StraightEdges " << " | " << setw(19) << "Translations " << right + << " | " << setw(41) << boolalpha << useStraightEdgeTranslations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "StraightEdges " << " | " << setw(19) << "Rotations " << right + << " | " << setw(41) << boolalpha << useStraightEdgeRotations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "Edges " << " | " << setw(19) << "Translations " << right + << " | " << setw(41) << boolalpha << useEdgeTranslations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "Edges " << " | " << setw(19) << "Rotations " << right + << " | " << setw(41) << boolalpha << useEdgeRotations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "Faces " << " | " << setw(19) << "Translations " << right + << " | " << setw(41) << boolalpha << useFaceTranslations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << "| " << left << setw(19) << "Faces " << " | " << setw(19) << "Rotations " << right + << " | " << setw(41) << boolalpha << useFaceRotations << noboolalpha + << " |" + << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " + << setw(89) << "-----------------------------------------------------------------------------------------" + << endl; + } + } } } return 0; diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp index 03dfaf46f1ef..b9b6b12303df 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp @@ -109,10 +109,10 @@ namespace FROSch { if (InterfaceCoarseSpaces_[i]->hasBasisMap()) { FROSCH_ASSERT(InterfaceCoarseSpaces_[i]->hasBasisMapUnique(),"FROSch::HarmonicCoarseOperator: !InterfaceCoarseSpaces_[i]->hasAssembledBasis()"); this->AssembledInterfaceCoarseSpace_->addSubspace(InterfaceCoarseSpaces_[i]->getBasisMap(),InterfaceCoarseSpaces_[i]->getBasisMapUnique(),InterfaceCoarseSpaces_[i]->getAssembledBasis(),ii); + ii += InterfaceCoarseSpaces_[i]->getAssembledBasis()->getLocalLength(); } + InterfaceCoarseSpaces_[i].reset(); } - ii += InterfaceCoarseSpaces_[i]->getAssembledBasis()->getLocalLength(); - InterfaceCoarseSpaces_[i].reset(); } return this->AssembledInterfaceCoarseSpace_->assembleCoarseSpace(); } @@ -121,60 +121,61 @@ namespace FROSch { int HarmonicCoarseOperator::addZeroCoarseSpaceBlock(ConstXMapPtr dofsMap) { FROSCH_DETAILTIMER_START_LEVELID(addZeroCoarseSpaceBlockTime,"HarmonicCoarseOperator::addZeroCoarseSpaceBlock"); - // Das könnte man noch ändern - GammaDofs_->resize(GammaDofs_.size()+1); - IDofs_->resize(IDofs_.size()+1); - InterfaceCoarseSpaces_->resize(InterfaceCoarseSpaces_.size()+1); - DofsMaps_->resize(DofsMaps_.size()+1); - DofsPerNode_->resize(DofsPerNode_.size()+1); + bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",true); - NumberOfBlocks_++; + if (useForCoarseSpace) { + // Das könnte man noch ändern + GammaDofs_->resize(GammaDofs_.size()+1); + IDofs_->resize(IDofs_.size()+1); + InterfaceCoarseSpaces_->resize(InterfaceCoarseSpaces_.size()+1); + DofsMaps_->resize(DofsMaps_.size()+1); + DofsPerNode_->resize(DofsPerNode_.size()+1); - ///// - int blockId = NumberOfBlocks_-1; + NumberOfBlocks_++; - // Process the parameter list - stringstream blockIdStringstream; - blockIdStringstream << blockId+1; - string blockIdString = blockIdStringstream.str(); - RCP coarseSpaceList = sublist(sublist(this->ParameterList_,"Blocks"),blockIdString.c_str()); + ///// + int blockId = NumberOfBlocks_-1; - bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",true); + // Process the parameter list + stringstream blockIdStringstream; + blockIdStringstream << blockId+1; + string blockIdString = blockIdStringstream.str(); + RCP coarseSpaceList = sublist(sublist(this->ParameterList_,"Blocks"),blockIdString.c_str()); - GammaDofs_[blockId] = LOVecPtr(0); + GammaDofs_[blockId] = LOVecPtr(0); - XMultiVectorPtr mVPhiGamma; - XMapPtr blockCoarseMap; - if (useForCoarseSpace) { - InterfaceCoarseSpaces_[blockId].reset(new CoarseSpace(this->MpiComm_,this->SerialComm_)); + XMultiVectorPtr mVPhiGamma; + XMapPtr blockCoarseMap; + if (useForCoarseSpace) { + InterfaceCoarseSpaces_[blockId].reset(new CoarseSpace(this->MpiComm_,this->SerialComm_)); - //Epetra_SerialComm serialComm; - XMapPtr serialGammaMap = MapFactory::Build(dofsMap->lib(),dofsMap->getLocalNumElements(),0,this->SerialComm_); - mVPhiGamma = MultiVectorFactory::Build(serialGammaMap,dofsMap->getLocalNumElements()); - } + //Epetra_SerialComm serialComm; + XMapPtr serialGammaMap = MapFactory::Build(dofsMap->lib(),dofsMap->getLocalNumElements(),0,this->SerialComm_); + mVPhiGamma = MultiVectorFactory::Build(serialGammaMap,dofsMap->getLocalNumElements()); + } - for (int i=0; igetLocalNumElements(); i++) { - GammaDofs_[blockId]->push_back(i); + for (int i=0; igetLocalNumElements(); i++) { + GammaDofs_[blockId]->push_back(i); - if (useForCoarseSpace) { - mVPhiGamma->replaceLocalValue(i,i,ScalarTraits::one()); + if (useForCoarseSpace) { + mVPhiGamma->replaceLocalValue(i,i,ScalarTraits::one()); + } } - } - - IDofs_[blockId] = LOVecPtr(0); - if (useForCoarseSpace) { - blockCoarseMap = MapFactory::Build(dofsMap->lib(),-1,GammaDofs_[blockId](),0,this->MpiComm_); + IDofs_[blockId] = LOVecPtr(0); - InterfaceCoarseSpaces_[blockId]->addSubspace(blockCoarseMap,mVPhiGamma); - InterfaceCoarseSpaces_[blockId]->assembleCoarseSpace(); - } + if (useForCoarseSpace) { + blockCoarseMap = MapFactory::Build(dofsMap->lib(),-1,GammaDofs_[blockId](),0,this->MpiComm_); - DofsMaps_[blockId] = XMapPtrVecPtr(0); - DofsMaps_[blockId].push_back(dofsMap); + InterfaceCoarseSpaces_[blockId]->addSubspace(blockCoarseMap,mVPhiGamma); + InterfaceCoarseSpaces_[blockId]->assembleCoarseSpace(); + } - DofsPerNode_[blockId] = 1; + DofsMaps_[blockId] = XMapPtrVecPtr(0); + DofsMaps_[blockId].push_back(dofsMap); + DofsPerNode_[blockId] = 1; + } return 0; } @@ -832,7 +833,7 @@ namespace FROSch { LO itmp = 0; ConstUNVecView numLocalBlockColumns = AssembledInterfaceCoarseSpace_->getLocalSubspaceSizes(); - FROSCH_ASSERT(numLocalBlockColumns.size()==NumberOfBlocks_,"FROSch::HarmonicCoarseOperator: numLocalBlockColumns.size()!=NumberOfBlocks_"); + FROSCH_ASSERT(numLocalBlockColumns.size()==NumberOfBlocks_,"FROSch::HarmonicCoarseOperator: numLocalBlockColumns.size()!=NumberOfBlocks_("+to_string(numLocalBlockColumns.size())+", "+to_string(NumberOfBlocks_)+") "); for (UN i=0; iisConstantStride() ? j : mvPhiICols[j]; - int col_out = mVPhiTpetraMVector->isConstantStride() ? j : mvPhiCols[j]; + int col_in = mVPhiITpetraMVector->isConstantStride() ? itmp : mvPhiICols[itmp]; + int col_out = mVPhiTpetraMVector->isConstantStride() ? itmp : mvPhiCols[itmp]; CopyPhiViewFunctor functor(col_in, indicesIDofsAllData, mvPhiIView, col_out, mvPhiView); for (UN ii=0; ii policy (bound[extensionBlocks[ii]], bound[extensionBlocks[ii]+1]); diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp index 1d0dd5e6aecf..a9e717c4fd78 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_IPOUHarmonicCoarseOperator_def.hpp @@ -168,14 +168,7 @@ namespace FROSch { // Das könnte man noch ändern // Todo: Check the lengths of the vectors against NumberOfBlocks_ - this->GammaDofs_.resize(this->GammaDofs_.size()+1); - this->IDofs_.resize(this->IDofs_.size()+1); - this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); - this->DofsMaps_.resize(this->DofsMaps_.size()+1); - this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); - this->NumberOfBlocks_++; - - return resetCoarseSpaceBlock(this->NumberOfBlocks_-1,dimension,dofsPerNode,nodesMap,dofsMaps,nullSpaceBasis,dirichletBoundaryDofs,nodeList); + return resetCoarseSpaceBlock(this->NumberOfBlocks_,dimension,dofsPerNode,nodesMap,dofsMaps,nullSpaceBasis,dirichletBoundaryDofs,nodeList); } template @@ -189,27 +182,21 @@ namespace FROSch { { FROSCH_DETAILTIMER_START_LEVELID(buildCoarseSpaceTime,"IPOUHarmonicCoarseOperator::buildCoarseSpace"); - this->NumberOfBlocks_ = repeatedNodesMapVec.size(); + UN TotalNumberOfBlocks = repeatedNodesMapVec.size(); - FROSCH_ASSERT(dofsPerNodeVec.size()==this->NumberOfBlocks_,"dofsPerNodeVec.size()!=this->NumberOfBlocks_"); - FROSCH_ASSERT(repeatedDofMapsVec.size()==this->NumberOfBlocks_,"repeatedDofMapsVec.size()!=this->NumberOfBlocks_"); - FROSCH_ASSERT(nullSpaceBasisVec.size()==this->NumberOfBlocks_,"nullSpaceBasisVec.size()!=this->NumberOfBlocks_"); - FROSCH_ASSERT(dirichletBoundaryDofsVec.size()==this->NumberOfBlocks_,"dirichletBoundaryDofsVec.size()!=this->NumberOfBlocks_"); - FROSCH_ASSERT(nodeListVec.size()==this->NumberOfBlocks_,"nodeListVec.size()!=this->NumberOfBlocks_"); + FROSCH_ASSERT(dofsPerNodeVec.size()==TotalNumberOfBlocks,"dofsPerNodeVec.size()!=TotalNumberOfBlocks"); + FROSCH_ASSERT(repeatedDofMapsVec.size()==TotalNumberOfBlocks,"repeatedDofMapsVec.size()!=TotalNumberOfBlocks"); + FROSCH_ASSERT(nullSpaceBasisVec.size()==TotalNumberOfBlocks,"nullSpaceBasisVec.size()!=TotalNumberOfBlocks"); + FROSCH_ASSERT(dirichletBoundaryDofsVec.size()==TotalNumberOfBlocks,"dirichletBoundaryDofsVec.size()!=TotalNumberOfBlocks"); + FROSCH_ASSERT(nodeListVec.size()==TotalNumberOfBlocks,"nodeListVec.size()!=TotalNumberOfBlocks"); // Todo: Move this to a function in HarmonicCoarseOperator at some point - for (UN i=0; iNumberOfBlocks_; i++) { + for (UN i=0; iGammaDofs_.resize(this->GammaDofs_.size()+1); - this->IDofs_.resize(this->IDofs_.size()+1); - this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); - this->DofsMaps_.resize(this->DofsMaps_.size()+1); - this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); - - resetCoarseSpaceBlock(i, + resetCoarseSpaceBlock(this->NumberOfBlocks_, dimension, dofsPerNodeVec[i], repeatedNodesMapVec[i], @@ -234,7 +221,7 @@ namespace FROSch { { FROSCH_DETAILTIMER_START_LEVELID(resetCoarseSpaceBlockTime,"IPOUHarmonicCoarseOperator::resetCoarseSpaceBlock"); FROSCH_ASSERT(dofsMaps.size()==dofsPerNode,"dofsMaps.size()!=dofsPerNode"); - FROSCH_ASSERT(blockIdNumberOfBlocks_,"Block does not exist yet and can therefore not be reset."); + FROSCH_ASSERT(blockId<=this->NumberOfBlocks_,"Block does not exist yet and can therefore not be reset ("+to_string(blockId)+", "+to_string(this->NumberOfBlocks_)+")."); // Process the parameter list stringstream blockIdStringstream; @@ -254,6 +241,12 @@ namespace FROSch { bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",true); if (useForCoarseSpace) { + this->GammaDofs_.resize(this->GammaDofs_.size()+1); + this->IDofs_.resize(this->IDofs_.size()+1); + this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); + this->DofsMaps_.resize(this->DofsMaps_.size()+1); + this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); + this->NumberOfBlocks_++; if (this->Verbose_) { cout diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp index f14d2aca439f..233c5e133363 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_RGDSWCoarseOperator_def.hpp @@ -38,7 +38,7 @@ namespace FROSch { { FROSCH_DETAILTIMER_START_LEVELID(resetCoarseSpaceBlockTime,"RGDSWCoarseOperator::resetCoarseSpaceBlock"); FROSCH_ASSERT(dofsMaps.size()==dofsPerNode,"dofsMaps.size()!=dofsPerNode"); - FROSCH_ASSERT(blockIdNumberOfBlocks_,"Block does not exist yet and can therefore not be reset."); + FROSCH_ASSERT(blockId<=this->NumberOfBlocks_,"Block does not exist yet and can therefore not be reset."); if (!this->DistributionList_->get("Type","linear").compare("ZoltanDual")) { FROSCH_ASSERT(false,"RGDSWCoarseOperator:: Distribution Type ZoltanDual only works for IPOUHarmonicCoarseOperator"); @@ -88,20 +88,27 @@ namespace FROSch { FROSCH_WARNING("FROSch::RGDSWCoarseOperator",this->Verbose_,"Rotations cannot be used since nodeList.is_null()."); } - this->DofsMaps_[blockId] = dofsMaps; - this->DofsPerNode_[blockId] = dofsPerNode; + if (useForCoarseSpace) { + this->NumberOfBlocks_++; - Array tmpDirichletBoundaryDofs(dirichletBoundaryDofs()); // Here, we do a copy. Maybe, this is not necessary - sortunique(tmpDirichletBoundaryDofs); + this->GammaDofs_.resize(this->GammaDofs_.size()+1); + this->IDofs_.resize(this->IDofs_.size()+1); + this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); + this->DofsMaps_.resize(this->DofsMaps_.size()+1); + this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); - this->DDInterface_.reset(new DDInterface(dimension,this->DofsPerNode_[blockId],nodesMap.getConst(),verbosity,this->LevelID_,communicationStrategy)); - this->DDInterface_->resetGlobalDofs(dofsMaps); - this->DDInterface_->removeDirichletNodes(tmpDirichletBoundaryDofs); + this->DofsMaps_[blockId] = dofsMaps; + this->DofsPerNode_[blockId] = dofsPerNode; - EntitySetPtr interface = this->DDInterface_->getInterface(); - EntitySetPtr interior = this->DDInterface_->getInterior(); + Array tmpDirichletBoundaryDofs(dirichletBoundaryDofs()); // Here, we do a copy. Maybe, this is not necessary + sortunique(tmpDirichletBoundaryDofs); - if (useForCoarseSpace) { + this->DDInterface_.reset(new DDInterface(dimension,this->DofsPerNode_[blockId],nodesMap.getConst(),verbosity,this->LevelID_,communicationStrategy)); + this->DDInterface_->resetGlobalDofs(dofsMaps); + this->DDInterface_->removeDirichletNodes(tmpDirichletBoundaryDofs); + + EntitySetPtr interface = this->DDInterface_->getInterface(); + EntitySetPtr interior = this->DDInterface_->getInterior(); if (this->Verbose_) { cout From 1ba71f5491075d75755aaeb81808fd7e91e1a0c7 Mon Sep 17 00:00:00 2001 From: iyamazaki Date: Wed, 11 Sep 2024 20:34:29 -0600 Subject: [PATCH 2/2] FROSch : compile error.. --- .../FROSch_HarmonicCoarseOperator_def.hpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp index b9b6b12303df..ed3db33e573c 100644 --- a/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp +++ b/packages/shylu/shylu_dd/frosch/src/SchwarzOperators/FROSch_HarmonicCoarseOperator_def.hpp @@ -121,27 +121,20 @@ namespace FROSch { int HarmonicCoarseOperator::addZeroCoarseSpaceBlock(ConstXMapPtr dofsMap) { FROSCH_DETAILTIMER_START_LEVELID(addZeroCoarseSpaceBlockTime,"HarmonicCoarseOperator::addZeroCoarseSpaceBlock"); + ///// + int blockId = NumberOfBlocks_-1; + + // Process the parameter list + stringstream blockIdStringstream; + blockIdStringstream << blockId+1; + string blockIdString = blockIdStringstream.str(); + RCP coarseSpaceList = sublist(sublist(this->ParameterList_,"Blocks"),blockIdString.c_str()); bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",true); if (useForCoarseSpace) { // Das könnte man noch ändern - GammaDofs_->resize(GammaDofs_.size()+1); - IDofs_->resize(IDofs_.size()+1); - InterfaceCoarseSpaces_->resize(InterfaceCoarseSpaces_.size()+1); - DofsMaps_->resize(DofsMaps_.size()+1); - DofsPerNode_->resize(DofsPerNode_.size()+1); - NumberOfBlocks_++; - ///// - int blockId = NumberOfBlocks_-1; - - // Process the parameter list - stringstream blockIdStringstream; - blockIdStringstream << blockId+1; - string blockIdString = blockIdStringstream.str(); - RCP coarseSpaceList = sublist(sublist(this->ParameterList_,"Blocks"),blockIdString.c_str()); - GammaDofs_[blockId] = LOVecPtr(0); XMultiVectorPtr mVPhiGamma; @@ -162,6 +155,12 @@ namespace FROSch { } } + GammaDofs_->resize(GammaDofs_.size()+1); + IDofs_->resize(IDofs_.size()+1); + InterfaceCoarseSpaces_->resize(InterfaceCoarseSpaces_.size()+1); + DofsMaps_->resize(DofsMaps_.size()+1); + DofsPerNode_->resize(DofsPerNode_.size()+1); + IDofs_[blockId] = LOVecPtr(0); if (useForCoarseSpace) {