Debian Codegraph @

packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_RGDSWInterfacePartitionOfUnity_def.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // ShyLU: Scalable Hybrid LU Preconditioner and Solver
4 //
5 // Copyright 2011 NTESS and the ShyLU contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef _FROSCH_RGDSWINTERFACEPARTITIONOFUNITY_DEF_HPP
11 #define _FROSCH_RGDSWINTERFACEPARTITIONOFUNITY_DEF_HPP
12
13 #include <FROSch_RGDSWInterfacePartitionOfUnity_decl.hpp>
14
15
16 namespace FROSch {
17
18 using namespace std;
19 using namespace Teuchos;
20 using namespace Xpetra;
21
22 template <class SC,class LO,class GO,class NO>
23 RGDSWInterfacePartitionOfUnity<SC,LO,GO,NO>::RGDSWInterfacePartitionOfUnity(CommPtr mpiComm,
24 CommPtr serialComm,
25 UN dimension,
26 UN dofsPerNode,
27 ConstXMapPtr nodesMap,
28 ConstXMapPtrVecPtr dofsMaps,
29 ParameterListPtr parameterList,
30 Verbosity verbosity,
31 UN levelID) :
32 GDSWInterfacePartitionOfUnity<SC,LO,GO,NO> (mpiComm,serialComm,dimension,dofsPerNode,nodesMap,dofsMaps,parameterList,verbosity,levelID)
33 {
34 FROSCH_DETAILTIMER_START_LEVELID(rGDSWInterfacePartitionOfUnityTime,"RGDSWInterfacePartitionOfUnity::RGDSWInterfacePartitionOfUnity");
35 this->UseVertices_ = false;
36 this->UseShortEdges_ = false;
37 this->UseStraightEdges_ = false;
38 this->UseEdges_ = false;
39 this->UseFaces_ = false;
40
41 if (!this->ParameterList_->get("Type","Full").compare("Full")) {
42 UseRoots_ = true;
43 } else if (!this->ParameterList_->get("Type","Full").compare("Roots")) {
44 UseRoots_ = true;
45 } else if (!this->ParameterList_->get("Type","Full").compare("Custom")) {
46 UseRoots_ = this->ParameterList_->sublist("Custom").get("Roots",false);
47 } else {
48 FROSCH_ASSERT(false,"FROSch::RGDSWInterfacePartitionOfUnity: Specify a valid Type.");
49 }
50
51 if (!this->ParameterList_->get("Distance Function","Constant").compare("Constant")) {
52 DistanceFunction_ = ConstantDistanceFunction;
53 } else if (!this->ParameterList_->get("Distance Function","Constant").compare("Inverse Euclidean")) {
54 DistanceFunction_ = InverseEuclideanDistanceFunction;
55 } else {
56 FROSCH_ASSERT(false,"FROSch::RGDSWInterfacePartitionOfUnity: Specify a valid Distance Function.");
57 }
58 this->LocalPartitionOfUnity_ = ConstXMultiVectorPtrVecPtr(1);
59 this->PartitionOfUnityMaps_ = ConstXMapPtrVecPtr(1);
60 }
61
62 template <class SC,class LO,class GO,class NO>
63 int RGDSWInterfacePartitionOfUnity<SC,LO,GO,NO>::computePartitionOfUnity(ConstXMultiVectorPtr nodeList)
64 {
65 FROSCH_DETAILTIMER_START_LEVELID(computePartitionOfUnityTime,"RGDSWInterfacePartitionOfUnity::computePartitionOfUnity");
66 // Interface
67 UN dofsPerNode = this->DDInterface_->getInterface()->getEntity(0)->getDofsPerNode();
68 UN numInterfaceDofs = dofsPerNode*this->DDInterface_->getInterface()->getEntity(0)->getNumNodes();
69
70 this->DDInterface_->buildEntityHierarchy();
71
72 this->DDInterface_->computeDistancesToRoots(this->DDInterface_->getDimension(),nodeList,DistanceFunction_);
73
74 this->DDInterface_->buildEntityMaps(false,
75 false,
76 false,
77 false,
78 false,
79 UseRoots_,
80 false);
81
82 EntitySetVector_ = this->DDInterface_->getEntitySetVector();
83
84 // Map
85 if (UseRoots_) {
86 Roots_ = this->DDInterface_->getRoots();
87 this->PartitionOfUnityMaps_[0] = Roots_->getEntityMap();
88 }
89
90 if (this->Verbose_) {
91 cout
92 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
93 << setw(89) << "-----------------------------------------------------------------------------------------"
94 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
95 << "| "
96 << left << setw(74) << "> RGDSW Interface Partition Of Unity " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" << right
97 << " |"
98 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
99 << setw(89) << "========================================================================================="
100 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
101 << "| " << left << setw(41) << "Roots" << right
102 << " | " << setw(41) << boolalpha << UseRoots_ << noboolalpha
103 << " |"
104 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
105 << setw(89) << "-----------------------------------------------------------------------------------------"
106 << endl;
107 }
108
109 // Build Partition Of Unity Vectors
110 XMapPtr serialInterfaceMap = MapFactory<LO,GO,NO>::Build(this->DDInterface_->getNodesMap()->lib(),numInterfaceDofs,0,this->SerialComm_);
111
112 if (UseRoots_ && Roots_->getNumEntities()>0) {
113 XMultiVectorPtr tmpVector = MultiVectorFactory<SC,LO,GO,NO>::Build(serialInterfaceMap,Roots_->getNumEntities());
114
115 // Loop over EntitySetVector_
116 for (UN i=0; i<EntitySetVector_.size(); i++) {
117 // Loop over entities
118 for (UN j=0; j<EntitySetVector_[i]->getNumEntities(); j++) {
119 InterfaceEntityPtr tmpEntity = EntitySetVector_[i]->getEntity(j);
120 LO rootID = tmpEntity->getRootID();
121 UN numRoots = tmpEntity->getRoots()->getNumEntities();
122 if (rootID==-1) {
123 FROSCH_ASSERT(numRoots!=0,"rootID==-1 but numRoots==0!");
124 for (UN m=0; m<numRoots; m++) {
125 InterfaceEntityPtr tmpRoot = tmpEntity->getRoots()->getEntity(m);
126 LO index = tmpRoot->getRootID();
127 // Offspring: loop over nodes
128 for (UN l=0; l<tmpEntity->getNumNodes(); l++) {
129 SC value = tmpEntity->getDistanceToRoot(l,m)/tmpEntity->getDistanceToRoot(l,numRoots);
130 for (UN k=0; k<dofsPerNode; k++) {
131 tmpVector->replaceLocalValue(tmpEntity->getGammaDofID(l,k),index,value*ScalarTraits<SC>::one());
132 }
133 }
134 }
135 } else {
136 // Coarse node: loop over nodes
137 for (UN l=0; l<EntitySetVector_[i]->getEntity(j)->getNumNodes(); l++) {
138 for (UN k=0; k<dofsPerNode; k++) {
139 tmpVector->replaceLocalValue(tmpEntity->getGammaDofID(l,k),rootID,ScalarTraits<SC>::one());
140 }
141 }
142 }
143 }
144 }
145 this->LocalPartitionOfUnity_[0] = tmpVector;
146 }
147
148 return 0;
149 }
150
151 }
152
153 #endif