Debian Codegraph @

packages/shylu/shylu_dd/frosch/src/CoarseSpaces/FROSch_GDSWInterfacePartitionOfUnity_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_GDSWINTERFACEPARTITIONOFUNITY_DEF_HPP
11 #define _FROSCH_GDSWINTERFACEPARTITIONOFUNITY_DEF_HPP
12
13 #include <FROSch_GDSWInterfacePartitionOfUnity_decl.hpp>
14
15
16 namespace FROSch {
17
18 using namespace Teuchos;
19 using namespace Xpetra;
20
21 template <class SC,class LO,class GO,class NO>
22 GDSWInterfacePartitionOfUnity<SC,LO,GO,NO>::GDSWInterfacePartitionOfUnity(CommPtr mpiComm,
23 CommPtr serialComm,
24 UN dimension,
25 UN dofsPerNode,
26 ConstXMapPtr nodesMap,
27 ConstXMapPtrVecPtr dofsMaps,
28 ParameterListPtr parameterList,
29 Verbosity verbosity,
30 UN levelID) :
31 InterfacePartitionOfUnity<SC,LO,GO,NO> (mpiComm,serialComm,dimension,dofsPerNode,nodesMap,dofsMaps,parameterList,verbosity,levelID)
32 {
33 FROSCH_DETAILTIMER_START_LEVELID(gDSWInterfacePartitionOfUnityTime,"GDSWInterfacePartitionOfUnity::GDSWInterfacePartitionOfUnity");
34 if (!this->ParameterList_->get("Type","Full").compare("Full")) {
35 UseVertices_ = true;
36 UseShortEdges_ = true;
37 UseStraightEdges_ = true;
38 UseEdges_ = true;
39 UseFaces_ = true;
40 } else if (!this->ParameterList_->get("Type","Full").compare("Vertices")) {
41 UseVertices_ = true;
42 } else if (!this->ParameterList_->get("Type","Full").compare("ShortEdges")) {
43 UseShortEdges_ = true;
44 } else if (!this->ParameterList_->get("Type","Full").compare("StraightEdges")) {
45 UseStraightEdges_ = true;
46 } else if (!this->ParameterList_->get("Type","Full").compare("Edges")) {
47 UseEdges_ = true;
48 } else if (!this->ParameterList_->get("Type","Full").compare("AllEdges")) {
49 UseFaces_ = true;
50 } else if (!this->ParameterList_->get("Type","Full").compare("NoVertices")) {
51 UseShortEdges_ = true;
52 UseStraightEdges_ = true;
53 UseEdges_ = true;
54 UseFaces_ = true;
55 } else if (!this->ParameterList_->get("Type","Full").compare("NoShortEdges")) {
56 UseVertices_ = true;
57 UseStraightEdges_ = true;
58 UseEdges_ = true;
59 UseFaces_ = true;
60 } else if (!this->ParameterList_->get("Type","Full").compare("NoStraightEdges")) {
61 UseVertices_ = true;
62 UseShortEdges_ = true;
63 UseEdges_ = true;
64 UseFaces_ = true;
65 } else if (!this->ParameterList_->get("Type","Full").compare("NoEdges")) {
66 UseVertices_ = true;
67 UseShortEdges_ = true;
68 UseStraightEdges_ = true;
69 UseFaces_ = true;
70 } else if (!this->ParameterList_->get("Type","Full").compare("NoAllEdges")) {
71 UseVertices_ = true;
72 UseFaces_ = true;
73 } else if (!this->ParameterList_->get("Type","Full").compare("NoFaces")) {
74 UseVertices_ = true;
75 UseShortEdges_ = true;
76 UseStraightEdges_ = true;
77 UseEdges_ = true;
78 } else if (!this->ParameterList_->get("Type","Full").compare("Custom")) {
79 UseVertices_ = this->ParameterList_->sublist("Custom").get("Vertices",false);
80 UseShortEdges_ = this->ParameterList_->sublist("Custom").get("Vertices",false);
81 UseStraightEdges_ = this->ParameterList_->sublist("Custom").get("Vertices",false);
82 UseEdges_ = this->ParameterList_->sublist("Custom").get("Vertices",false);
83 UseFaces_ = this->ParameterList_->sublist("Custom").get("Vertices",false);
84 } else {
85 FROSCH_ASSERT(false,"FROSch::GDSWInterfacePartitionOfUnity: Specify a valid Type.");
86 }
87 this->LocalPartitionOfUnity_ = ConstXMultiVectorPtrVecPtr(5);
88 this->PartitionOfUnityMaps_ = ConstXMapPtrVecPtr(5);
89 }
90
91 template <class SC,class LO,class GO,class NO>
92 GDSWInterfacePartitionOfUnity<SC,LO,GO,NO>::~GDSWInterfacePartitionOfUnity()
93 {
94
95 }
96
97 template <class SC,class LO,class GO,class NO>
98 int GDSWInterfacePartitionOfUnity<SC,LO,GO,NO>::removeDirichletNodes(GOVecView dirichletBoundaryDofs,
99 ConstXMultiVectorPtr nodeList)
100 {
101 FROSCH_DETAILTIMER_START_LEVELID(removeDirichletNodesTime,"GDSWInterfacePartitionOfUnity::removeDirichletNodes");
102 if (!dirichletBoundaryDofs.is_null()) {
103 GOVec tmpDirichletBoundaryDofs(dirichletBoundaryDofs());
104 sortunique(tmpDirichletBoundaryDofs);
105 this->DDInterface_->removeDirichletNodes(tmpDirichletBoundaryDofs());
106 this->DDInterface_->sortVerticesEdgesFaces(nodeList);
107 }
108 return 0;
109 }
110
111 template <class SC,class LO,class GO,class NO>
112 int GDSWInterfacePartitionOfUnity<SC,LO,GO,NO>::sortInterface(ConstXMatrixPtr matrix,
113 ConstXMultiVectorPtr nodeList)
114 {
115 FROSCH_DETAILTIMER_START_LEVELID(sortInterfaceTime,"GDSWInterfacePartitionOfUnity::sortInterface");
116 if (this->ParameterList_->get("Test Unconnected Interface",true)) {
117 if (matrix.is_null()) {
118 FROSCH_WARNING("FROSch::GDSWInterfacePartitionOfUnity",this->Verbose_,"divideUnconnectedEntities() cannot be performed without the matrix.");
119 } else this->DDInterface_->divideUnconnectedEntities(matrix);
120 }
121 this->DDInterface_->sortVerticesEdgesFaces(nodeList);
122
123 return 0;
124 }
125
126 template <class SC,class LO,class GO,class NO>
127 int GDSWInterfacePartitionOfUnity<SC,LO,GO,NO>::computePartitionOfUnity(ConstXMultiVectorPtr nodeList)
128 {
129 FROSCH_DETAILTIMER_START_LEVELID(computePartitionOfUnityTime,"GDSWInterfacePartitionOfUnity::computePartitionOfUnity");
130 // Interface
131 UN dofsPerNode = this->DDInterface_->getInterface()->getEntity(0)->getDofsPerNode();
132 UN numInterfaceDofs = dofsPerNode*this->DDInterface_->getInterface()->getEntity(0)->getNumNodes();
133
134 this->DDInterface_->buildEntityMaps(UseVertices_,
135 UseShortEdges_,
136 UseStraightEdges_,
137 UseEdges_,
138 UseFaces_,
139 false,
140 false);
141
142 // Maps
143 if (UseVertices_) {
144 Vertices_ = this->DDInterface_->getVertices();
145 this->PartitionOfUnityMaps_[0] = Vertices_->getEntityMap();
146 }
147
148 if (UseShortEdges_) {
149 ShortEdges_ = this->DDInterface_->getShortEdges();
150 this->PartitionOfUnityMaps_[1] = ShortEdges_->getEntityMap();
151 }
152
153 if (UseStraightEdges_) {
154 StraightEdges_ = this->DDInterface_->getStraightEdges();
155 this->PartitionOfUnityMaps_[2] = StraightEdges_->getEntityMap();
156 }
157
158 if (UseEdges_) {
159 Edges_ = this->DDInterface_->getEdges();
160 this->PartitionOfUnityMaps_[3] = Edges_->getEntityMap();
161 }
162
163 if (UseFaces_) {
164 Faces_ = this->DDInterface_->getFaces();
165 this->PartitionOfUnityMaps_[4] = Faces_->getEntityMap();
166 }
167
168 if (this->Verbose_) {
169 cout
170 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
171 << setw(89) << "-----------------------------------------------------------------------------------------"
172 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
173 << "| "
174 << left << setw(74) << "> GDSW Interface Partition Of Unity " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" << right
175 << " |"
176 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
177 << setw(89) << "========================================================================================="
178 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
179 << "| " << left << setw(41) << "Vertices" << right
180 << " | " << setw(41) << boolalpha << UseVertices_ << noboolalpha
181 << " |"
182 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
183 << "| " << left << setw(41) << "Short edges" << right
184 << " | " << setw(41) << boolalpha << UseShortEdges_ << noboolalpha
185 << " |"
186 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
187 << "| " << left << setw(41) << "Straight edges" << right
188 << " | " << setw(41) << boolalpha << UseStraightEdges_ << noboolalpha
189 << " |"
190 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
191 << "| " << left << setw(41) << "Edges" << right
192 << " | " << setw(41) << boolalpha << UseEdges_ << noboolalpha
193 << " |"
194 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
195 << "| " << left << setw(41) << "Faces" << right
196 << " | " << setw(41) << boolalpha << UseFaces_ << noboolalpha
197 << " |"
198 << "\n" << setw(FROSCH_OUTPUT_INDENT) << " "
199 << setw(89) << "-----------------------------------------------------------------------------------------"
200 << endl;
201 }
202
203 // Build Partition Of Unity Vectors
204 XMapPtr serialInterfaceMap = MapFactory<LO,GO,NO>::Build(this->DDInterface_->getNodesMap()->lib(),numInterfaceDofs,0,this->SerialComm_);
205
206 if (UseVertices_ && Vertices_->getNumEntities()>0) {
207 XMultiVectorPtr tmpVector = MultiVectorFactory<SC,LO,GO,NO>::Build(serialInterfaceMap,Vertices_->getNumEntities());
208
209 for (UN i=0; i<Vertices_->getNumEntities(); i++) {
210 for (UN j=0; j<Vertices_->getEntity(i)->getNumNodes(); j++) {
211 for (UN k=0; k<dofsPerNode; k++) {
212 tmpVector->replaceLocalValue(Vertices_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits<SC>::one());
213 }
214 }
215 }
216
217 this->LocalPartitionOfUnity_[0] = tmpVector;
218 }
219
220 if (UseShortEdges_ && ShortEdges_->getNumEntities()>0) {
221 XMultiVectorPtr tmpVector = MultiVectorFactory<SC,LO,GO,NO>::Build(serialInterfaceMap,ShortEdges_->getNumEntities());
222
223 for (UN i=0; i<ShortEdges_->getNumEntities(); i++) {
224 for (UN j=0; j<ShortEdges_->getEntity(i)->getNumNodes(); j++) {
225 for (UN k=0; k<dofsPerNode; k++) {
226 tmpVector->replaceLocalValue(ShortEdges_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits<SC>::one());
227 }
228 }
229 }
230
231 this->LocalPartitionOfUnity_[1] = tmpVector;
232 }
233
234 if (UseStraightEdges_ && StraightEdges_->getNumEntities()>0) {
235 XMultiVectorPtr tmpVector = MultiVectorFactory<SC,LO,GO,NO>::Build(serialInterfaceMap,StraightEdges_->getNumEntities());
236
237 for (UN i=0; i<StraightEdges_->getNumEntities(); i++) {
238 for (UN j=0; j<StraightEdges_->getEntity(i)->getNumNodes(); j++) {
239 for (UN k=0; k<dofsPerNode; k++) {
240 tmpVector->replaceLocalValue(StraightEdges_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits<SC>::one());
241 }
242 }
243 }
244 this->LocalPartitionOfUnity_[2] = tmpVector;
245 }
246
247 if (UseEdges_ && Edges_->getNumEntities()>0) {
248 XMultiVectorPtr tmpVector = MultiVectorFactory<SC,LO,GO,NO>::Build(serialInterfaceMap,Edges_->getNumEntities());
249
250 for (UN i=0; i<Edges_->getNumEntities(); i++) {
251 for (UN j=0; j<Edges_->getEntity(i)->getNumNodes(); j++) {
252 for (UN k=0; k<dofsPerNode; k++) {
253 tmpVector->replaceLocalValue(Edges_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits<SC>::one());
254 }
255 }
256 }
257
258 this->LocalPartitionOfUnity_[3] = tmpVector;
259 }
260
261 if (UseFaces_ && Faces_->getNumEntities()>0) {
262 XMultiVectorPtr tmpVector = MultiVectorFactory<SC,LO,GO,NO>::Build(serialInterfaceMap,Faces_->getNumEntities());
263
264 for (UN i=0; i<Faces_->getNumEntities(); i++) {
265 for (UN j=0; j<Faces_->getEntity(i)->getNumNodes(); j++) {
266 for (UN k=0; k<dofsPerNode; k++) {
267 tmpVector->replaceLocalValue(Faces_->getEntity(i)->getGammaDofID(j,k),i,ScalarTraits<SC>::one());
268 }
269 }
270 }
271
272 this->LocalPartitionOfUnity_[4] = tmpVector;
273 }
274
275 return 0;
276 }
277
278 }
279
280 #endif