Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
MeshInterface_def.hpp
1#ifndef MESHINTERFACE_def_hpp
2#define MESHINTERFACE_def_hpp
3
12
13
14//search all code for these functions and move them to Tools file.
15template <typename T>
16std::vector<T> sort_from_ref(
17 std::vector<T> const& in,
18 std::vector<int> const& reference
19 ) {
20 std::vector<T> ret(in.size());
21
22 int const size = in.size();
23 for (int i = 0; i < size; ++i)
24 ret[i] = in[reference[i]];
25
26 return ret;
27};
28
29template <typename T>
30std::vector<T> sort_from_ref(
31 std::vector<T> const& in,
32 std::vector<long long> const& reference
33 ) {
34 std::vector<T> ret(in.size());
35
36 int const size = in.size();
37 for (long long i = 0; i < size; ++i)
38 ret[i] = in[reference[i]];
39
40 return ret;
41};
42
43namespace FEDD {
44
45template <class SC, class LO, class GO, class NO>
46MeshInterface<SC,LO,GO,NO>::MeshInterface():
47indicesGlobalMatched_(),
48indicesGlobalMatchedOrigin_(),
49indicesGlobalMatchedUnique_(),
50isPartitioned_(false),
51partialCouplingFlag_(0),
52partialCouplingType_(0),
53comm_()
54{
55
56}
57
58template <class SC, class LO, class GO, class NO>
59MeshInterface<SC,LO,GO,NO>::MeshInterface(CommConstPtr_Type comm):
60indicesGlobalMatched_(),
61indicesGlobalMatchedOrigin_(),
62indicesGlobalMatchedUnique_(),
63isPartitioned_(false),
64partialCouplingFlag_(0),
65partialCouplingType_(0),
66comm_(comm)
67{
68
69}
70
71template <class SC, class LO, class GO, class NO>
72void MeshInterface<SC,LO,GO,NO>::partitionMeshInterface(MapPtr_Type mapRepeated, MapPtr_Type mapUnique){
73
74 // TODO: irgenwann mal in indicesGlobalMatchedOrigin_ abaendern
75 vec3D_GO_ptr_Type indicesSerial = indicesGlobalMatchedOrigin_;
76
77 // Das ist der repated Vektor
78 indicesGlobalMatched_.reset(new vec3D_GO_Type ( indicesSerial->size() , vec2D_GO_Type( 2 , vec_GO_Type(0) ) ) );
79
80 // Das ist der unique Vektor
81 indicesGlobalMatchedUnique_.reset(new vec3D_GO_Type ( indicesSerial->size() , vec2D_GO_Type( 2 , vec_GO_Type(0) ) ) );
82
83 for (int flag=0; flag<indicesSerial->size(); flag++) {
84 for (int i=0; i<indicesSerial->at(flag).at(0).size(); i++) {
85 // Fuer den repated Vektor
86 GO indexThis = mapRepeated->getLocalElement( indicesSerial->at(flag).at(0).at(i) );
87 if ( indexThis != Teuchos::OrdinalTraits<LO>::invalid() ) {
88 indicesGlobalMatched_->at(flag).at(0).push_back( indicesSerial->at(flag).at(0).at(i) );
89 indicesGlobalMatched_->at(flag).at(1).push_back( indicesSerial->at(flag).at(1).at(i) );
90 }
91
92 GO indexThisUni = mapUnique->getLocalElement( indicesSerial->at(flag).at(0).at(i) );
93 // Fuer den unique Vektor
94 if ( indexThisUni != Teuchos::OrdinalTraits<LO>::invalid() ) {
95 indicesGlobalMatchedUnique_->at(flag).at(0).push_back( indicesSerial->at(flag).at(0).at(i) );
96 indicesGlobalMatchedUnique_->at(flag).at(1).push_back( indicesSerial->at(flag).at(1).at(i) );
97 }
98
99 }
100 }
101
102 isPartitioned_ = true;
103}
104
105
106template <class SC, class LO, class GO, class NO>
107void MeshInterface<SC,LO,GO,NO>::determineInterface( vec2D_dbl_ptr_Type pointsRepThis, vec2D_dbl_ptr_Type pointsRepOther, vec_int_ptr_Type flagThis, vec_int_ptr_Type flagOther, vec_int_Type relevant_flag_vec ){
108
109 indicesGlobalMatched_.reset(new vec3D_GO_Type( relevant_flag_vec.size(), vec2D_GO_Type(2) ) );
110
111 // Damit wir auf den nicht-partionierten Vektor zugreifen koennen.
112 indicesGlobalMatchedOrigin_.reset(new vec3D_GO_Type( relevant_flag_vec.size(), vec2D_GO_Type(2) ) );
113
114 // Points N x dim vectors
115 for (int flag=0; flag<relevant_flag_vec.size(); flag++) {
116 vec2D_dbl_Type pointThis(0);
117 vec2D_dbl_Type pointOther(0);
118 vec_GO_Type indexGlobalThis(0);
119 vec_GO_Type indexGlobalOther(0);
120 vec_int_Type indexThis(0);
121 vec_int_Type indexOther(0);
122 int counter = 0;
123 for (int i=0; i<pointsRepThis->size(); i++) {
124 if (flagThis->at(i) == relevant_flag_vec.at(flag)) {
125 pointThis.push_back( pointsRepThis->at(i) );
126 indexGlobalThis.push_back(i);
127 indexThis.push_back(counter);
128 counter++;
129 }
130 }
131 counter = 0;
132 for (int i=0; i<pointsRepOther->size(); i++) {
133 if (flagOther->at(i) == relevant_flag_vec.at(flag)) {
134 pointOther.push_back( pointsRepOther->at(i) );
135 indexGlobalOther.push_back(i);
136 indexOther.push_back(counter);
137 counter++;
138 }
139 }
140
141 // std::cout << "serial determineInterface - number flag nodes this:" << indexThis.size()<< " other:" << indexOther.size() << std::endl;
142
143 sort(indexThis.begin(), indexThis.end(),
144 [&](const int& a, const int& b) {
145 return pointThis[a] < pointThis[b];
146 }
147 );
148
149 sort(indexOther.begin(), indexOther.end(),
150 [&](const int& a, const int& b) {
151 return pointOther[a] < pointOther[b];
152 }
153 );
154
155 indexGlobalThis = sort_from_ref(indexGlobalThis, indexThis);
156 indexGlobalOther = sort_from_ref(indexGlobalOther, indexOther);
157
158 TEUCHOS_TEST_FOR_EXCEPTION( indexGlobalThis.size()!=indexGlobalOther.size(), std::logic_error, "Interfaces do not have the same length!");
159
160
161 indicesGlobalMatched_->at(flag).at(0) = indexGlobalThis;
162 indicesGlobalMatched_->at(flag).at(1) = indexGlobalOther;
163
164 indicesGlobalMatchedOrigin_->at(flag).at(0) = indexGlobalThis;
165 indicesGlobalMatchedOrigin_->at(flag).at(1) = indexGlobalOther;
166
167 }
168
169}
170
171template <class SC, class LO, class GO, class NO>
172int MeshInterface<SC,LO,GO,NO>::isPartialCouplingFlag(int flag){
173
174 auto it = std::find( partialCouplingFlag_.begin(), partialCouplingFlag_.end(), flag );
175 if ( it!=partialCouplingFlag_.end() )
176 return std::distance( partialCouplingFlag_.begin(), it );
177 else
178 return -1;
179}
180
181template <class SC, class LO, class GO, class NO>
182void MeshInterface<SC,LO,GO,NO>::setPartialCoupling(int flag, std::string type){
183 partialCouplingFlag_.push_back(flag);
184 partialCouplingType_.push_back(type);
185
186}
187
188template <class SC, class LO, class GO, class NO>
189int MeshInterface<SC,LO,GO,NO>::getPartialCouplingFlag(int i){
190 TEUCHOS_TEST_FOR_EXCEPTION(sizePartialCoupling()-1 < i, std::runtime_error, "There is no partial coupling for this index");
191 return partialCouplingFlag_[i];
192}
193
194template <class SC, class LO, class GO, class NO>
195std::string MeshInterface<SC,LO,GO,NO>::getPartialCouplingType(int i){
196 TEUCHOS_TEST_FOR_EXCEPTION(sizePartialCoupling()-1 < i, std::runtime_error, "There is no partial coupling for this index");
197 return partialCouplingType_[i];
198}
199
200template <class SC, class LO, class GO, class NO>
201int MeshInterface<SC,LO,GO,NO>::sizePartialCoupling(){
202 return partialCouplingFlag_.size();
203}
204
205template <class SC, class LO, class GO, class NO>
206void MeshInterface<SC,LO,GO,NO>::determineInterfaceParallelAndDistance( vec2D_dbl_ptr_Type pointsUniThis, vec2D_dbl_ptr_Type pointsUniOther, vec_int_ptr_Type flagUniThis, vec_int_ptr_Type flagUniOther, vec_int_Type relevant_flag_vec, MapConstPtr_Type mapUniThis, MapConstPtr_Type mapUniOther, vec_dbl_ptr_Type &distancesToInterface, vec2D_dbl_ptr_Type pointsRepThis, int dim ) {
207
208 SC eps100 = 100. * Teuchos::ScalarTraits<SC>::eps();
209 GO invalid = Teuchos::OrdinalTraits<GO>::invalid();
210
211 indicesGlobalMatched_.reset(new vec3D_GO_Type( relevant_flag_vec.size(), vec2D_GO_Type(2) ) );
212
213 // Damit wir auf den nicht-partionierten Vektor zugreifen koennen.
214 // Build in parallel first and then build this global index vector
215 // Adjust size
216 indicesGlobalMatchedOrigin_.reset(new vec3D_GO_Type( relevant_flag_vec.size(), vec2D_GO_Type(2) ) );
217
218 // send data for the relevant flag
219 for (int flagIndex=0; flagIndex<relevant_flag_vec.size(); flagIndex++) {
220 int flag = relevant_flag_vec[flagIndex];
221 //Warning !!! The following information is local!
222 vec_GO_Type indexGlobalCommThis(0);
223 vec_GO_Type indexGlobalCommOther(0);
224
225 for (int i=0; i<pointsUniThis->size(); i++) {
226 if ( flagUniThis->at(i) == flag ) {
227 indexGlobalCommThis.push_back( mapUniThis->getGlobalElement( i ) );
228 }
229 }
230
231 for (int i=0; i<pointsUniOther->size(); i++) {
232 if ( flagUniOther->at(i) == flag ) {
233 indexGlobalCommOther.push_back( mapUniOther->getGlobalElement( i ) );
234 }
235 }
236
237 //Communicate everything with MultiVectors.
238 //First determine the length of the new global vector
239 GO numInterfaceGlobalThis = 0;
240 GO numInterfaceGlobalOther = 0;
241
242 Teuchos::reduceAll( *this->comm_, Teuchos::REDUCE_SUM, (GO) indexGlobalCommThis.size(), Teuchos::ptrFromRef( numInterfaceGlobalThis ) );
243
244 Teuchos::reduceAll( *this->comm_, Teuchos::REDUCE_SUM, (GO) indexGlobalCommOther.size(), Teuchos::ptrFromRef( numInterfaceGlobalOther ) );
245
246 MapPtr_Type mapThis = Teuchos::rcp( new Map_Type( -1, Teuchos::arrayViewFromVector( indexGlobalCommThis ), 0, this->comm_ ) );
247
248 MapPtr_Type mapOther = Teuchos::rcp( new Map_Type( -1, Teuchos::arrayViewFromVector( indexGlobalCommOther ), 0, this->comm_ ) );
249
250 // std::cout << "numInterfaceGlobalThis:" << numInterfaceGlobalThis << std::endl;
251 // std::cout << "numInterfaceGlobalOther:" << numInterfaceGlobalOther << std::endl;
252 TEUCHOS_TEST_FOR_EXCEPTION( numInterfaceGlobalThis != numInterfaceGlobalOther, std::runtime_error, "DetermineInterfaceInParallel failed. ThisMesh and OtherMesh seem to have different numbers of interface nodes." );
253
254 std::vector<GO> gatherAllIndices(numInterfaceGlobalThis);
255 std::iota ( std::begin( gatherAllIndices ), std::end( gatherAllIndices ), 0 );
256
257 MapPtr_Type linearMapThis = Teuchos::rcp( new Map_Type( numInterfaceGlobalThis, indexGlobalCommThis.size(), 0, this->comm_ ) );
258 MapPtr_Type linearMapOther = Teuchos::rcp( new Map_Type(numInterfaceGlobalThis, indexGlobalCommOther.size(), 0, this->comm_ ) );
259 MapPtr_Type gatherAllMap = Teuchos::rcp( new Map_Type( invalid, Teuchos::arrayViewFromVector( gatherAllIndices ), 0, this->comm_ ) );
260
261 // We would like to use the Teuchos version of MPI_Allgatherv, which does not exist. Therefore we gatherv on a root and broadcast afterwards
262 // Gather local lengths first
263 vec_int_Type localSizeThis( this->comm_->getSize(),0 );
264 vec_int_Type localSizeOther( this->comm_->getSize(),0 );
265 int root = 0;
266
267 int sizeThis = indexGlobalCommThis.size();
268 int sizeOther = indexGlobalCommOther.size();
269 Teuchos::gather<int, int>( &sizeThis, 1, &localSizeThis[0], 1, root, *this->comm_ );
270 Teuchos::gather<int, int>( &sizeOther, 1, &localSizeOther[0], 1, root, *this->comm_ );
271
272 GO* sendThis = NULL;
273 if (indexGlobalCommThis.size()>0)
274 sendThis = &indexGlobalCommThis[0];
275 GO* sendOther = NULL;
276 if (indexGlobalCommOther.size()>0)
277 sendOther = &indexGlobalCommOther[0];
278
279 vec_GO_Type gatheredThis( numInterfaceGlobalThis , -1);
280 vec_GO_Type gatheredOther( numInterfaceGlobalThis, -1);
281
282 vec_int_Type displacementsThis( ((int) this->comm_->getRank()==root ) * this->comm_->getSize(),0 );
283 vec_int_Type displacementsOther( ((int) this->comm_->getRank()==root ) * this->comm_->getSize(),0 );
284 int* displThis = NULL;
285 if (displacementsThis.size()>0)
286 displThis = &displacementsThis[0];
287 int* displOther = NULL;
288 if (displacementsOther.size()>0)
289 displOther = &displacementsOther[0];
290
291 for (int i=1; i<displacementsThis.size(); i++)
292 displacementsThis[i] = displacementsThis[i-1] + localSizeThis[i-1];
293 for (int i=1; i<displacementsOther.size(); i++)
294 displacementsOther[i] = displacementsOther[i-1] + localSizeOther[i-1];
295
296 Teuchos::gatherv<int,GO>( sendThis, indexGlobalCommThis.size(), &gatheredThis[0], &localSizeThis[0], displThis, root, *this->comm_ );
297 Teuchos::gatherv<int,GO>( sendOther, indexGlobalCommOther.size(), &gatheredOther[0], &localSizeOther[0], displOther, root, *this->comm_ );
298
299 //Now we broadcast from root
300 Teuchos::broadcast<int,GO>( *this->comm_, root, Teuchos::arrayViewFromVector( gatheredThis ) );
301 Teuchos::broadcast<int,GO>( *this->comm_, root, Teuchos::arrayViewFromVector( gatheredOther ) );
302
303 MapPtr_Type mapAllThis = Teuchos::rcp( new Map_Type(invalid, Teuchos::arrayViewFromVector( gatheredThis ), 0, this->comm_ ) );
304 MapPtr_Type mapAllOther = Teuchos::rcp( new Map_Type( invalid, Teuchos::arrayViewFromVector( gatheredOther ), 0, this->comm_ ) );
305
306 bool meshOnRank = false;
307 if (pointsUniThis->size() > 0)
308 meshOnRank = true;
309
310 MultiVectorPtr_Type mvLocalThis;
311 MultiVectorPtr_Type mvLocalOther;
312
313 mvLocalThis = Teuchos::rcp( new MultiVector_Type( mapThis, dim + 1 ) );
314 mvLocalOther = Teuchos::rcp( new MultiVector_Type( mapOther, dim + 1 ) );
315
316 // Fill local vectors with node coordinates and global index; last column is the global index
317 // This
318 for (int j=0; j<dim; j++) {
319 Teuchos::ArrayRCP< SC > data = mvLocalThis->getDataNonConst(j);
320 for (int i=0; i<data.size(); i++) {
321 LO index = mapUniThis->getLocalElement( indexGlobalCommThis[i] );
322 data[i] = pointsUniThis->at( index )[j];
323 }
324 }
325
326 Teuchos::ArrayRCP< SC > dataThis = mvLocalThis->getDataNonConst( dim );
327 for (int i=0; i<dataThis.size(); i++)
328 dataThis[i] = indexGlobalCommThis[i];
329
330
331 // Other
332 for (int j=0; j<dim; j++) {
333 Teuchos::ArrayRCP< SC > data = mvLocalOther->getDataNonConst(j);
334 for (int i=0; i<data.size(); i++) {
335 LO index = mapUniOther->getLocalElement( indexGlobalCommOther[i] );
336 data[i] = pointsUniOther->at( index )[j];
337 }
338 }
339
340 Teuchos::ArrayRCP< SC > dataOther = mvLocalOther->getDataNonConst( dim );
341 for (int i=0; i<dataOther.size(); i++)
342 dataOther[i] = indexGlobalCommOther[i];
343
344
345 MultiVectorPtr_Type mvGlobalThis;
346 MultiVectorPtr_Type mvGlobalOther;
347
348 mvGlobalThis = Teuchos::rcp( new MultiVector_Type( mapAllThis, dim + 1 ) );
349 mvGlobalOther = Teuchos::rcp( new MultiVector_Type( mapAllOther, dim + 1 ) );
350 // Communicate, we might want to use gatherv and broadcast here aswell
351 mvGlobalThis->exportFromVector( mvLocalThis, true, "Insert", "Reverse" );
352 mvGlobalOther->exportFromVector( mvLocalOther, true, "Insert", "Reverse" );
353
354 // now we can go through the same data on every rank like in the serial case
355 // copy to std::vectors first; we should try to avoid this in a optimized implementation
356 // Points N x dim vectors
357
358 vec_int_Type indexThis( numInterfaceGlobalThis );
359 vec_int_Type indexOther( numInterfaceGlobalThis );
360 std::iota ( std::begin( indexThis ), std::end( indexThis ), 0 );
361 std::iota ( std::begin( indexOther ), std::end( indexOther ), 0 );
362
363 vec2D_dbl_Type pointThis( numInterfaceGlobalThis, vec_dbl_Type(dim) );
364 vec2D_dbl_Type pointOther( numInterfaceGlobalThis, vec_dbl_Type(dim) );
365
366 vec_GO_Type indexGlobalThis( numInterfaceGlobalThis );
367 vec_GO_Type indexGlobalOther( numInterfaceGlobalThis );
368
369
370 int counter = 0;
371 {
372 Teuchos::ArrayRCP< const SC > dataX = mvGlobalThis->getData(0);
373 Teuchos::ArrayRCP< const SC > dataY = mvGlobalThis->getData(1);
374 Teuchos::ArrayRCP< const SC > dataZ;
375 Teuchos::ArrayRCP< const SC > dataGlob;
376 if (dim==3) {
377 dataZ = mvGlobalThis->getData(2);
378 dataGlob = mvGlobalThis->getData(dim);
379 }
380 else if (dim==2)
381 dataGlob = mvGlobalThis->getData(dim);
382
383 for (int i=0; i<pointThis.size(); i++) {
384 pointThis[i][0] = dataX[i];
385 pointThis[i][1] = dataY[i];
386 if (dim==3)
387 pointThis[i][2] = dataZ[i];
388 indexGlobalThis[i] = (GO) dataGlob[i] + eps100;
389 }
390 }
391 {
392 Teuchos::ArrayRCP< const SC > dataX = mvGlobalOther->getData(0);
393 Teuchos::ArrayRCP< const SC > dataY = mvGlobalOther->getData(1);
394 Teuchos::ArrayRCP< const SC > dataZ;
395 Teuchos::ArrayRCP< const SC > dataGlob;
396 if (dim==3) {
397 dataZ = mvGlobalOther->getData(2);
398 dataGlob = mvGlobalOther->getData(dim);
399 }
400 else if (dim==2)
401 dataGlob = mvGlobalOther->getData(dim);
402
403 for (int i=0; i<pointOther.size(); i++) {
404 pointOther[i][0] = dataX[i];
405 pointOther[i][1] = dataY[i];
406 if (dim==3)
407 pointOther[i][2] = dataZ[i];
408 indexGlobalOther[i] = (GO) dataGlob[i] + eps100;
409
410 }
411 }
412
413 sort(indexThis.begin(), indexThis.end(),
414 [&](const int& a, const int& b) {
415 return pointThis[a] < pointThis[b];
416 }
417 );
418
419 sort(indexOther.begin(), indexOther.end(),
420 [&](const int& a, const int& b) {
421 return pointOther[a] < pointOther[b];
422 }
423 );
424
425 indexGlobalThis = sort_from_ref(indexGlobalThis, indexThis);
426 indexGlobalOther = sort_from_ref(indexGlobalOther, indexOther);
427
428
429 indicesGlobalMatched_->at(flagIndex).at(0) = indexGlobalThis;
430 indicesGlobalMatched_->at(flagIndex).at(1) = indexGlobalOther;
431// std::cout << "indexGlobalThis->size():" << indexGlobalThis.size() << std::endl;
432// std::cout << "indexGlobalOther->size():" << indexGlobalOther.size() << std::endl;
433 indicesGlobalMatchedOrigin_->at(flagIndex).at(0) = indexGlobalThis;
434 indicesGlobalMatchedOrigin_->at(flagIndex).at(1) = indexGlobalOther;
435
436 //determine distance for this flag.
437 calculateDistancesToInterfaceParallel( distancesToInterface, pointThis, pointsRepThis );
438 }
439}
440
441
442template <class SC, class LO, class GO, class NO>
443void MeshInterface<SC,LO,GO,NO>::calculateDistancesToInterfaceParallel( vec_dbl_ptr_Type &distancesToInterface, vec2D_dbl_Type &pointThis/*global interface, every proc has same information*/, vec2D_dbl_ptr_Type sourceNodesRep /*partitioned points*/)
444{
445
446 int dim = -1;
447 if (pointThis.size() > 0)
448 dim = pointThis[0].size();
449
450 // See comments for calculateDistancesToInterface() in class Domain.
451 // This is the parallel version
452
453 // Not partitioned interfaces
454 vec3D_GO_ptr_Type indicesGlobalMatched = this->indicesGlobalMatched_;
455
456 // SourceNodes (z.B. Fluidgebiet) aus dem Gitter ziehen
457 // Gefaehrlich, da Veraenderungen an SourceNodesRep auch PointsRep_ veraendern;
458 // Sonst auf 0.0 setzen und dann Werte reinschreiben.
459 // Am besten waere es Getter zu haben mit return vec2D_dbl_ptr_Type bzw. const vec2vec2D_dbl_ptr_Type, damit nichts passieren kann.
460
461 // Zaehle mit Hilfe von indicesGlobalMatched wie viele Interfaceknoten es insgesamt gibt.
462 // Here we should loop over all flags in the case of more than one flag.
463 int numberInterfaceNodes = indicesGlobalMatched->at(0).at(0).size();
464
465 // EndNodes (Interfaceknoten) aus dem Gitter ziehen; mit Hilfe von IndicesGlobalMatched
466 vec2D_dbl_ptr_Type endNodesRep = Teuchos::rcpFromRef(pointThis);
467
468 // Distanz zum Interface auf eine unrealistisch grosse Zahl setzen.
469 // In DistancesToInterface_->at(i) steht die Distanz der globalen Knoten-ID i zum Interface
470
471 if ( distancesToInterface.is_null() )
472 distancesToInterface = Teuchos::rcp( new vec_dbl_Type( sourceNodesRep->size(), 1000.0 ) );
473
474 // Berechne nun den Abstand von den sourceNodesRep zu den EndNodesRep
475 double distance = 0.0;
476 for(int i = 0; i < sourceNodesRep->size(); i++)
477 {
478 for(int j = 0; j < endNodesRep->size(); j++)
479 {
480 for(int k = 0; k < dim; k++)
481 {
482 distance = distance + std::pow( sourceNodesRep->at(i).at(k) - endNodesRep->at(j).at(k), 2.0 );
483 }
484
485 // Noch die Wurzel ziehen
486 distance = std::sqrt(distance);
487
488 if(distancesToInterface->at(i) > distance)
489 distancesToInterface->at(i) = distance;
490
491 // Reseten
492 distance = 0.0;
493 }
494 }
495}
496
497
498template <class SC, class LO, class GO, class NO>
499void MeshInterface<SC,LO,GO,NO>::buildFromOtherInterface( Teuchos::RCP<MeshInterface> otherMeshInterface){
500
501 TEUCHOS_TEST_FOR_EXCEPTION( otherMeshInterface->indicesGlobalMatched_->size()<=0, std::logic_error, "MeshInterface given is empty.");
502 TEUCHOS_TEST_FOR_EXCEPTION( otherMeshInterface->indicesGlobalMatched_->at(0).size()<=0, std::logic_error, "MeshInterface given is empty.");
503 TEUCHOS_TEST_FOR_EXCEPTION( otherMeshInterface->isPartitioned_, std::logic_error, "Other MeshInterface already partitioned.");
504 TEUCHOS_TEST_FOR_EXCEPTION( isPartitioned_, std::logic_error, "This MeshInterface already partitioned.");
505
506 indicesGlobalMatched_.reset(new vec3D_GO_Type( otherMeshInterface->indicesGlobalMatched_->size(), vec2D_GO_Type ( 2 , vec_GO_Type( 0 ) ) ) );
507
508 indicesGlobalMatchedOrigin_.reset(new vec3D_GO_Type( otherMeshInterface->indicesGlobalMatchedOrigin_->size(), vec2D_GO_Type ( 2 , vec_GO_Type( 0 ) ) ) );
509
510 for (int i=0; i<otherMeshInterface->indicesGlobalMatched_->size(); i++) {
511 indicesGlobalMatched_->at(i).at(0).resize( otherMeshInterface->indicesGlobalMatched_->at(i).at(0).size() );
512 indicesGlobalMatched_->at(i).at(1).resize( otherMeshInterface->indicesGlobalMatched_->at(i).at(1).size() );
513 indicesGlobalMatchedOrigin_->at(i).at(0).resize( otherMeshInterface->indicesGlobalMatchedOrigin_->at(i).at(0).size() );
514 indicesGlobalMatchedOrigin_->at(i).at(1).resize( otherMeshInterface->indicesGlobalMatchedOrigin_->at(i).at(1).size() );
515 for (int j=0; j<otherMeshInterface->indicesGlobalMatched_->at(i).at(0).size(); j++) {
516 indicesGlobalMatched_->at(i).at(0).at(j) = otherMeshInterface->indicesGlobalMatched_->at(i).at(1).at(j);
517 indicesGlobalMatched_->at(i).at(1).at(j) = otherMeshInterface->indicesGlobalMatched_->at(i).at(0).at(j);
518
519 indicesGlobalMatchedOrigin_->at(i).at(0).at(j) = otherMeshInterface->indicesGlobalMatchedOrigin_->at(i).at(1).at(j);
520 indicesGlobalMatchedOrigin_->at(i).at(1).at(j) = otherMeshInterface->indicesGlobalMatchedOrigin_->at(i).at(0).at(j);
521
522 }
523 }
524}
525
526template <class SC, class LO, class GO, class NO>
527void MeshInterface<SC,LO,GO,NO>::print(CommConstPtr_Type comm){
528
529 for (int i=0; i<indicesGlobalMatched_->size(); i++) {
530 for (int j=0; j<indicesGlobalMatched_->at(i).at(0).size(); j++) {
531 std::cout << comm->getRank()<<" Matched IDs for flag " << i << " :" << indicesGlobalMatched_->at(i).at(0).at(j) << " - " << indicesGlobalMatched_->at(i).at(0).at(j) << std::endl;
532 }
533 }
534}
535
536template <class SC, class LO, class GO, class NO>
537typename MeshInterface<SC,LO,GO,NO>::vec3D_GO_ptr_Type MeshInterface<SC,LO,GO,NO>::getIndicesGlobalMatched(){
538 return indicesGlobalMatched_;
539}
540
541template <class SC, class LO, class GO, class NO>
542typename MeshInterface<SC,LO,GO,NO>::vec3D_GO_ptr_Type MeshInterface<SC,LO,GO,NO>::getIndicesGlobalMatchedOrigin()
543{
544 return indicesGlobalMatchedOrigin_;
545}
546
547template <class SC, class LO, class GO, class NO>
548typename MeshInterface<SC,LO,GO,NO>::vec3D_GO_ptr_Type MeshInterface<SC,LO,GO,NO>::getIndicesGlobalMatchedUnique()
549{
550 return indicesGlobalMatchedUnique_;
551}
552
553
554}
555#endif
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36