// @HEADER // ***************************************************************************** // ShyLU: Scalable Hybrid LU Preconditioner and Solver // // Copyright 2011 NTESS and the ShyLU contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef _FROSCH_GDSWINTERFACEPARTITIONOFUNITY_DEF_HPP #define _FROSCH_GDSWINTERFACEPARTITIONOFUNITY_DEF_HPP #include namespace FROSch { using namespace Teuchos; using namespace Xpetra; template GDSWInterfacePartitionOfUnity::GDSWInterfacePartitionOfUnity(CommPtr mpiComm, CommPtr serialComm, UN dimension, UN dofsPerNode, ConstXMapPtr nodesMap, ConstXMapPtrVecPtr dofsMaps, ParameterListPtr parameterList, Verbosity verbosity, UN levelID) : InterfacePartitionOfUnity (mpiComm,serialComm,dimension,dofsPerNode,nodesMap,dofsMaps,parameterList,verbosity,levelID) { FROSCH_DETAILTIMER_START_LEVELID(gDSWInterfacePartitionOfUnityTime,"GDSWInterfacePartitionOfUnity::GDSWInterfacePartitionOfUnity"); if (!this->ParameterList_->get("Type","Full").compare("Full")) { UseVertices_ = true; UseShortEdges_ = true; UseStraightEdges_ = true; UseEdges_ = true; UseFaces_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("Vertices")) { UseVertices_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("ShortEdges")) { UseShortEdges_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("StraightEdges")) { UseStraightEdges_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("Edges")) { UseEdges_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("AllEdges")) { UseFaces_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("NoVertices")) { UseShortEdges_ = true; UseStraightEdges_ = true; UseEdges_ = true; UseFaces_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("NoShortEdges")) { UseVertices_ = true; UseStraightEdges_ = true; UseEdges_ = true; UseFaces_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("NoStraightEdges")) { UseVertices_ = true; UseShortEdges_ = true; UseEdges_ = true; UseFaces_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("NoEdges")) { UseVertices_ = true; UseShortEdges_ = true; UseStraightEdges_ = true; UseFaces_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("NoAllEdges")) { UseVertices_ = true; UseFaces_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("NoFaces")) { UseVertices_ = true; UseShortEdges_ = true; UseStraightEdges_ = true; UseEdges_ = true; } else if (!this->ParameterList_->get("Type","Full").compare("Custom")) { UseVertices_ = this->ParameterList_->sublist("Custom").get("Vertices",false); UseShortEdges_ = this->ParameterList_->sublist("Custom").get("Vertices",false); UseStraightEdges_ = this->ParameterList_->sublist("Custom").get("Vertices",false); UseEdges_ = this->ParameterList_->sublist("Custom").get("Vertices",false); UseFaces_ = this->ParameterList_->sublist("Custom").get("Vertices",false); } else { FROSCH_ASSERT(false,"FROSch::GDSWInterfacePartitionOfUnity: Specify a valid Type."); } this->LocalPartitionOfUnity_ = ConstXMultiVectorPtrVecPtr(5); this->PartitionOfUnityMaps_ = ConstXMapPtrVecPtr(5); } template GDSWInterfacePartitionOfUnity::~GDSWInterfacePartitionOfUnity() { } template int GDSWInterfacePartitionOfUnity::removeDirichletNodes(GOVecView dirichletBoundaryDofs, ConstXMultiVectorPtr nodeList) { FROSCH_DETAILTIMER_START_LEVELID(removeDirichletNodesTime,"GDSWInterfacePartitionOfUnity::removeDirichletNodes"); if (!dirichletBoundaryDofs.is_null()) { GOVec tmpDirichletBoundaryDofs(dirichletBoundaryDofs()); sortunique(tmpDirichletBoundaryDofs); this->DDInterface_->removeDirichletNodes(tmpDirichletBoundaryDofs()); this->DDInterface_->sortVerticesEdgesFaces(nodeList); } return 0; } template int GDSWInterfacePartitionOfUnity::sortInterface(ConstXMatrixPtr matrix, ConstXMultiVectorPtr nodeList) { FROSCH_DETAILTIMER_START_LEVELID(sortInterfaceTime,"GDSWInterfacePartitionOfUnity::sortInterface"); if (this->ParameterList_->get("Test Unconnected Interface",true)) { if (matrix.is_null()) { FROSCH_WARNING("FROSch::GDSWInterfacePartitionOfUnity",this->Verbose_,"divideUnconnectedEntities() cannot be performed without the matrix."); } else this->DDInterface_->divideUnconnectedEntities(matrix); } this->DDInterface_->sortVerticesEdgesFaces(nodeList); return 0; } template int GDSWInterfacePartitionOfUnity::computePartitionOfUnity(ConstXMultiVectorPtr nodeList) { FROSCH_DETAILTIMER_START_LEVELID(computePartitionOfUnityTime,"GDSWInterfacePartitionOfUnity::computePartitionOfUnity"); // Interface UN dofsPerNode = this->DDInterface_->getInterface()->getEntity(0)->getDofsPerNode(); UN numInterfaceDofs = dofsPerNode*this->DDInterface_->getInterface()->getEntity(0)->getNumNodes(); this->DDInterface_->buildEntityMaps(UseVertices_, UseShortEdges_, UseStraightEdges_, UseEdges_, UseFaces_, false, false); // Maps if (UseVertices_) { Vertices_ = this->DDInterface_->getVertices(); this->PartitionOfUnityMaps_[0] = Vertices_->getEntityMap(); } if (UseShortEdges_) { ShortEdges_ = this->DDInterface_->getShortEdges(); this->PartitionOfUnityMaps_[1] = ShortEdges_->getEntityMap(); } if (UseStraightEdges_) { StraightEdges_ = this->DDInterface_->getStraightEdges(); this->PartitionOfUnityMaps_[2] = StraightEdges_->getEntityMap(); } if (UseEdges_) { Edges_ = this->DDInterface_->getEdges(); this->PartitionOfUnityMaps_[3] = Edges_->getEntityMap(); } if (UseFaces_) { Faces_ = this->DDInterface_->getFaces(); this->PartitionOfUnityMaps_[4] = Faces_->getEntityMap(); } if (this->Verbose_) { cout << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << setw(89) << "-----------------------------------------------------------------------------------------" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(74) << "> GDSW Interface Partition Of Unity " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" << right << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << setw(89) << "=========================================================================================" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Vertices" << right << " | " << setw(41) << boolalpha << UseVertices_ << noboolalpha << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Short edges" << right << " | " << setw(41) << boolalpha << UseShortEdges_ << noboolalpha << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Straight edges" << right << " | " << setw(41) << boolalpha << UseStraightEdges_ << noboolalpha << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Edges" << right << " | " << setw(41) << boolalpha << UseEdges_ << noboolalpha << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << "| " << left << setw(41) << "Faces" << right << " | " << setw(41) << boolalpha << UseFaces_ << noboolalpha << " |" << "\n" << setw(FROSCH_OUTPUT_INDENT) << " " << setw(89) << "-----------------------------------------------------------------------------------------" << endl; } // Build Partition Of Unity Vectors XMapPtr serialInterfaceMap = MapFactory::Build(this->DDInterface_->getNodesMap()->lib(),numInterfaceDofs,0,this->SerialComm_); if (UseVertices_ && Vertices_->getNumEntities()>0) { XMultiVectorPtr tmpVector = MultiVectorFactory::Build(serialInterfaceMap,Vertices_->getNumEntities()); for (UN i=0; igetNumEntities(); i++) { for (UN j=0; jgetEntity(i)->getNumNodes(); j++) { for (UN k=0; kreplaceLocalValue(Vertices_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits::one()); } } } this->LocalPartitionOfUnity_[0] = tmpVector; } if (UseShortEdges_ && ShortEdges_->getNumEntities()>0) { XMultiVectorPtr tmpVector = MultiVectorFactory::Build(serialInterfaceMap,ShortEdges_->getNumEntities()); for (UN i=0; igetNumEntities(); i++) { for (UN j=0; jgetEntity(i)->getNumNodes(); j++) { for (UN k=0; kreplaceLocalValue(ShortEdges_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits::one()); } } } this->LocalPartitionOfUnity_[1] = tmpVector; } if (UseStraightEdges_ && StraightEdges_->getNumEntities()>0) { XMultiVectorPtr tmpVector = MultiVectorFactory::Build(serialInterfaceMap,StraightEdges_->getNumEntities()); for (UN i=0; igetNumEntities(); i++) { for (UN j=0; jgetEntity(i)->getNumNodes(); j++) { for (UN k=0; kreplaceLocalValue(StraightEdges_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits::one()); } } } this->LocalPartitionOfUnity_[2] = tmpVector; } if (UseEdges_ && Edges_->getNumEntities()>0) { XMultiVectorPtr tmpVector = MultiVectorFactory::Build(serialInterfaceMap,Edges_->getNumEntities()); for (UN i=0; igetNumEntities(); i++) { for (UN j=0; jgetEntity(i)->getNumNodes(); j++) { for (UN k=0; kreplaceLocalValue(Edges_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits::one()); } } } this->LocalPartitionOfUnity_[3] = tmpVector; } if (UseFaces_ && Faces_->getNumEntities()>0) { XMultiVectorPtr tmpVector = MultiVectorFactory::Build(serialInterfaceMap,Faces_->getNumEntities()); for (UN i=0; igetNumEntities(); i++) { for (UN j=0; jgetEntity(i)->getNumNodes(); j++) { for (UN k=0; kreplaceLocalValue(Faces_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits::one()); } } } this->LocalPartitionOfUnity_[4] = tmpVector; } return 0; } } #endif