Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
Domain_def.hpp
1#ifndef Domain_def_hpp
2#define Domain_def_hpp
3
12
13namespace FEDD {
14template <class SC, class LO, class GO, class NO>
16comm_(),
17mesh_(),
18mapVecFieldUnique_(),
19mapVecFieldRepeated_(),
20geometries2DVec_(),
21geometries3DVec_(),
22distancesToInterface_(),
23interfaceMapUnique_(),
24interfaceMapVecFieldUnique_(),
25globalInterfaceMapUnique_(),
26globalInterfaceMapVecFieldUnique_(),
27partialGlobalInterfaceVecFieldMap_(),
28otherGlobalInterfaceMapUnique_(),
29otherGlobalInterfaceMapVecFieldUnique_(),
30otherPartialGlobalInterfaceVecFieldMap_()
31{
32
33}
34
35template <class SC, class LO, class GO, class NO>
36Domain<SC,LO,GO,NO>::Domain(CommConstPtr_Type comm):
37comm_(comm),
38mesh_(),
39mapVecFieldUnique_(),
40mapVecFieldRepeated_(),
41geometries2DVec_(),
42geometries3DVec_(),
43distancesToInterface_(),
44interfaceMapUnique_(),
45interfaceMapVecFieldUnique_(),
46globalInterfaceMapUnique_(),
47globalInterfaceMapVecFieldUnique_(),
48partialGlobalInterfaceVecFieldMap_(),
49otherGlobalInterfaceMapUnique_(),
50otherGlobalInterfaceMapVecFieldUnique_(),
51otherPartialGlobalInterfaceVecFieldMap_()
52{
53
54}
55
56template <class SC, class LO, class GO, class NO>
57Domain<SC,LO,GO,NO>::Domain(CommConstPtr_Type comm, int dimension):
58comm_(comm),
59mesh_(),
60dim_(dimension),
61mapVecFieldUnique_(),
62mapVecFieldRepeated_(),
63geometries2DVec_(),
64geometries3DVec_(),
65distancesToInterface_(),
66interfaceMapUnique_(),
67interfaceMapVecFieldUnique_(),
68globalInterfaceMapUnique_(),
69globalInterfaceMapVecFieldUnique_(),
70partialGlobalInterfaceVecFieldMap_(),
71otherGlobalInterfaceMapUnique_(),
72otherGlobalInterfaceMapVecFieldUnique_(),
73otherPartialGlobalInterfaceVecFieldMap_()
74{
75
76}
77
78// Constructor for structured 2D Meshes.
79template <class SC, class LO, class GO, class NO>
80Domain<SC,LO,GO,NO>::Domain(vec_dbl_Type coor, double l, double h, CommConstPtr_Type comm):
81comm_(comm),
82mesh_(),
83mapVecFieldUnique_(),
84mapVecFieldRepeated_(),
85geometries2DVec_(),
86geometries3DVec_(),
87distancesToInterface_(),
88interfaceMapUnique_(),
89interfaceMapVecFieldUnique_(),
90globalInterfaceMapUnique_(),
91globalInterfaceMapVecFieldUnique_(),
92partialGlobalInterfaceVecFieldMap_(),
93 otherGlobalInterfaceMapUnique_(),
94 otherGlobalInterfaceMapVecFieldUnique_(),
95 otherPartialGlobalInterfaceVecFieldMap_()
96{
97 coorRec = coor;
98 length = l;
99 height = h;
100 width = -1;
101 // Available 2D geometries
102 geometries2DVec_.reset(new string_vec_Type(0));
103 geometries2DVec_->push_back("Square");
104 geometries2DVec_->push_back("BFS");
105 // geometries2DVec_->push_back("SquareTPM");
106 geometries2DVec_->push_back("structuredMiniTest");
107// geometries2DVec->push_back("REC");
108}
109
110// Constructor for 3D structured meshes
111template <class SC, class LO, class GO, class NO>
112Domain<SC,LO,GO,NO>::Domain(vec_dbl_Type coor, double l, double w, double h, CommConstPtr_Type comm):
113comm_(comm),
114mesh_(),
115mapVecFieldUnique_(),
116mapVecFieldRepeated_(),
117geometries2DVec_(),
118geometries3DVec_(),
119distancesToInterface_(),
120interfaceMapUnique_(),
121interfaceMapVecFieldUnique_(),
122globalInterfaceMapUnique_(),
123globalInterfaceMapVecFieldUnique_(),
124partialGlobalInterfaceVecFieldMap_()
125{
126 coorRec = coor;
127 length = l;
128 width = w;
129 height = h;
130 // Different geometries available as geometries.
131 geometries3DVec_.reset(new string_vec_Type(0));
132 geometries3DVec_->push_back("Square"); // for 3D this is synonymous to Cube with 6-Element subcube structure
133 geometries3DVec_->push_back("BFS"); // Backward-facing step geometry
134 geometries3DVec_->push_back("Square5Element"); // this is a cube with different 5-Element per subcube structure
135
136
137}
138
139template <class SC, class LO, class GO, class NO>
141
142 LO minNumberNodes;
143 LO maxNumberNodes;
144 LO numberNodes = this->getMapUnique()->getNodeNumElements();
145 Teuchos::reduceAll( *this->comm_, Teuchos::REDUCE_MIN, numberNodes, Teuchos::ptrFromRef(minNumberNodes) );
146 Teuchos::reduceAll( *this->comm_, Teuchos::REDUCE_MAX, numberNodes, Teuchos::ptrFromRef(maxNumberNodes) );
147
148 bool verbose(comm_->getRank()==0);
149 if (verbose) {
150 std::cout << "\t### Domain ###" << std::endl;
151 std::cout << "\t### Dimension: "<< dim_ << std::endl;
152 std::cout << "\t### Mesh type: "<< meshType_ << std::endl;
153 std::cout << "\t### Mesh flags: "<< flagsOption_ << std::endl;
154 std::cout << "\t### Subdomains: "<< n_ << std::endl;
155 std::cout << "\t### H/h: "<< m_ << std::endl;
156 std::cout << "\t### FE type: "<< FEType_ << std::endl;
157 std::cout << "\t### Number Nodes: "<< mesh_->getMapUnique()->getMaxAllGlobalIndex()+1 << std::endl;
158 std::cout << "\t### Minimum number of nodes: "<< minNumberNodes << " Maximum number of nodes: " << maxNumberNodes << std::endl;
159 std::cout << "\t### Empty ranks for coarse solves: "<< numProcsCoarseSolve_ << std::endl;
160 }
161}
162
163template <class SC, class LO, class GO, class NO>
165
166 this->getElementsC()->initializeFEData( this->getPointsRepeated() );
167}
168
169template <class SC, class LO, class GO, class NO>
171 return mesh_->getElementsFlag();
172}
173
174
175template <class SC, class LO, class GO, class NO>
177 if (this->dim_ == 2) {
178 if ( this->FEType_ == "P1" ) {
179 return 50;
180 }
181 else if ( this->FEType_ == "P2" ) {
182 return 100;
183 }
184 else {
185 return 200;
186 }
187 } else {
188 if ( this->FEType_ == "P1" ) {
189 return 100;
190 }
191 else if ( this->FEType_ == "P2" ) {
192 return 200;
193 }
194 else {
195 return 300;
196 }
197 }
199
200
201
202template <class SC, class LO, class GO, class NO>
203void Domain<SC,LO,GO,NO>::buildMesh(int flagsOption , std::string meshType, int dim, std::string FEType, int N, int M, int numProcsCoarseSolve){
204
205 int geoNumber = checkGeomentry(meshType, dim);
206
207#ifdef ASSERTS_WARNINGS
208 MYASSERT(geoNumber!=-1, "Geometry not known for this Dimension.")
209#endif
210
211 MeshStrPtr_Type meshStructured = Teuchos::rcp(new MeshStr_Type(comm_));
212 n_ = N;
213 m_ = M;
214 dim_ = dim;
215 FEType_ = FEType;
216 numProcsCoarseSolve_ = numProcsCoarseSolve;
217 meshType_ = meshType;
218 flagsOption_ = flagsOption;
220 switch (dim) {
221 case 2:
222 switch (geoNumber) {
223 case 0:
224 meshStructured->setGeometry2DRectangle(coorRec, length, height);
225 meshStructured->buildMesh2D(FEType, n_, m_, numProcsCoarseSolve);
226 break;
227 case 1:
228 meshStructured->setGeometry2DRectangle(coorRec, length, height);
229 meshStructured->buildMesh2DBFS(FEType, n_, m_, numProcsCoarseSolve);
230 break;
231 default:
232 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"Select valid mesh. Structured types are 'structured' and 'structured_bfs' in 2D.");
233 break;
234 }
235
236 break;
237 case 3:
238 switch (geoNumber) {
239 case 0:
240 meshStructured->setGeometry3DBox(coorRec, length, width, height);
241 meshStructured->buildMesh3D( FEType, n_, m_, numProcsCoarseSolve);
242 break;
243 case 1:
244 meshStructured->setGeometry3DBox(coorRec, length, width, height);
245 meshStructured->buildMesh3DBFS( FEType, n_, m_, numProcsCoarseSolve);
246 break;
247 case 2:
248 meshStructured->setGeometry3DBox(coorRec, length, width, height);
249 meshStructured->buildMesh3D5Elements( FEType, n_, m_, numProcsCoarseSolve);
250 break;
251 default:
252 TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Select valid mesh. Structured types are 'structured' and 'structured_bfs' in 3D." );
253 break;
255 break;
256 default:
257 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"Select valid mesh dimension. 2 or 3 dimensional meshes can be constructed.");
258 break;
259 }
260 meshStructured->buildElementMap();
261 meshStructured->setStructuredMeshFlags(flagsOption,FEType);
262 meshStructured->buildSurfaces(flagsOption,FEType);
263
264 mesh_ = meshStructured;
265}
266
267template <class SC, class LO, class GO, class NO>
268void Domain<SC,LO,GO,NO>::initializeUnstructuredMesh(int dimension, std::string feType, int volumeID, std::string meshUnit, bool convertToCM){
269
270 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp(new MeshUnstr_Type(comm_, volumeID, meshUnit, convertToCM));
271 mesh_ = meshUnstructured;
272 mesh_->dim_ = dimension;
273 FEType_ = feType;
274 meshType_ = "unstructured";
275 numProcsCoarseSolve_ = 0;
276 n_ = comm_->getSize() - numProcsCoarseSolve_;
277 m_ = -1;
278 flagsOption_ = -1;
279}
281template <class SC, class LO, class GO, class NO>
282void Domain<SC,LO,GO,NO>::readMeshSize(std::string filename, std::string delimiter){
283
284 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( mesh_ );
285 TEUCHOS_TEST_FOR_EXCEPTION( meshUnstructured.is_null(), std::runtime_error, "Unstructured Mesh is null." );
286
287 meshUnstructured->setMeshFileName( filename, delimiter );
288 meshUnstructured->readMeshSize( );
289
290}
292template <class SC, class LO, class GO, class NO>
293void Domain<SC,LO,GO,NO>::partitionMesh( bool partitionDistance ){
294
295 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( mesh_ );
296
297 if (partitionDistance)
299
300 mesh_ = meshUnstructured;
301
302}
303
304template <class SC, class LO, class GO, class NO>
306
307 vec_dbl_Type tmp = *distancesToInterface_;
308
309 distancesToInterface_.reset( new vec_dbl_Type ( mesh_->getMapRepeated()->getNodeNumElements() ) );
310
311 for (UN i=0; i<distancesToInterface_->size(); i++) {
312 GO index = mesh_->getMapRepeated()->getGlobalElement(i);
313 distancesToInterface_->at(i) = tmp[index];
314 }
315}
316
317template <class SC, class LO, class GO, class NO>
318void Domain<SC,LO,GO,NO>::readAndPartitionMesh( std::string filename, std::string delimiter, int dim, std::string FEType, int volumeID ){
319
320 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp(new MeshUnstr_Type(comm_, volumeID));
321
322 dim_ = dim;
323 FEType_ = FEType;
324
325 mesh_ = meshUnstructured;
326 mesh_->dim_ = dim_;
327 numProcsCoarseSolve_ = 0;
328 n_ = comm_->getSize() - numProcsCoarseSolve_;
329 m_ = -1;
330 flagsOption_ = -1;
331 meshType_ = "unstructured";
333
334template <class SC, class LO, class GO, class NO>
335void Domain<SC,LO,GO,NO>::buildP2ofP1Domain( DomainPtr_Type domainP1 ){ //P1 mesh must be parallel
336
337 MeshUnstrPtr_Type meshUnstructuredP1 = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( domainP1->mesh_ );
338
339 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp( new MeshUnstr_Type( comm_, meshUnstructuredP1->volumeID_) );
340
341 n_ = domainP1->n_;
342 m_ = domainP1->m_;
343 dim_ = domainP1->dim_;
344 FEType_ = "P2";
345 numProcsCoarseSolve_ = 0;
346 flagsOption_ = -1;
347 meshType_ = "unstructured";
349 meshUnstructured->buildP2ofP1MeshEdge( meshUnstructuredP1 );
350 mesh_ = meshUnstructured;
351}
352
353template <class SC, class LO, class GO, class NO>
354void Domain<SC,LO,GO,NO>::initWithDomain(DomainPtr_Type domainP1){
355
356 n_ = domainP1->n_;
357 m_ = domainP1->m_;
358 dim_ = domainP1->dim_;
359 FEType_ = domainP1->FEType_;
360
361 numProcsCoarseSolve_ = 0;
362 flagsOption_ = -1;
363
364 meshType_ = domainP1->meshType_;
365
366 mesh_ = domainP1->mesh_;
367}
368
369/*template <class SC, class LO, class GO, class NO>
370void Domain<SC,LO,GO,NO>::initMeshRef( DomainPtr_Type domainP1 ){
371 // Initialize MeshRefinementType as through other function like meshPartitioner and buildP2OfP1 Mesh meshUnstr Type is required
373 MeshUnstrPtr_Type meshUnstr = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( domainP1->mesh_ , true);
374 MeshUnstrRefPtr_Type meshUnstrRefTmp = Teuchos::rcp( new MeshUnstrRef_Type( comm_, meshUnstr->volumeID_, meshUnstr ) );
375 mesh_ = meshUnstrRefTmp;
376
377}*/
379template <class SC, class LO, class GO, class NO>
380void Domain<SC,LO,GO,NO>::setMesh(MeshUnstrPtr_Type meshUnstr){
381
382 mesh_ = meshUnstr;
383}
385
386template <class SC, class LO, class GO, class NO>
388{
389 MeshUnstrPtr_Type outputMesh = Teuchos::rcp( new MeshUnstr_Type( comm_) );
391 outputMesh->dim_ = this->dim_ ;
392 outputMesh->FEType_ = this->FEType_ ;
393
394 outputMesh->mapUnique_ = map;
395 outputMesh->mapRepeated_ = map;
397 mesh_ = outputMesh;
398}
399
400template <class SC, class LO, class GO, class NO>
401void Domain<SC,LO,GO,NO>::exportMesh(bool exportEdges, bool exportSurfaces, std::string exportMesh){
403 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( mesh_ );
404
405 meshUnstructured->exportMesh(this->getMapUnique() , this->getMapRepeated(), exportEdges, exportSurfaces, exportMesh);
406}
407
408template <class SC, class LO, class GO, class NO>
409void Domain<SC,LO,GO,NO>::preProcessMesh(bool correctSurfaceNormals, bool correctElementOrientation){
411 if(correctSurfaceNormals)
412 mesh_->correctNormalDirections();
413
414 if(correctElementOrientation)
415 mesh_->correctElementOrientation();
416
418}
419
420
421template <class SC, class LO, class GO, class NO>
423
424 return dim_;
425}
426
427template <class SC, class LO, class GO, class NO>
429
430 return FEType_;
431}
432
433template <class SC, class LO, class GO, class NO>
434typename Domain<SC,LO,GO,NO>::CommConstPtr_Type Domain<SC,LO,GO,NO>::getComm() const{
435 return comm_;
436}
437
438template <class SC, class LO, class GO, class NO>
439typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getMapUnique() const{
440
441 return mesh_->getMapUnique();
442}
443
444template <class SC, class LO, class GO, class NO>
445typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getMapRepeated() const{
446
447 return mesh_->getMapRepeated();
448}
449
450template <class SC, class LO, class GO, class NO>
451typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getElementMap() const{
452
453 return mesh_->getElementMap();
454}
455
456template <class SC, class LO, class GO, class NO>
457typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getEdgeMap() const{
458
459 return mesh_->getEdgeMap();
460}
461
462template <class SC, class LO, class GO, class NO>
463vec2D_dbl_ptr_Type Domain<SC,LO,GO,NO>::getPointsRepeated() const{
464
465 return mesh_->getPointsRepeated();
466}
467
468template <class SC, class LO, class GO, class NO>
469vec2D_dbl_ptr_Type Domain<SC,LO,GO,NO>::getPointsUnique() const{
470
471 return mesh_->getPointsUnique();
472}
474template <class SC, class LO, class GO, class NO>
476
477 return mesh_->getBCFlagRepeated();
478}
479
480template <class SC, class LO, class GO, class NO>
482
483 return mesh_->getBCFlagUnique();
484}
485
486template <class SC, class LO, class GO, class NO>
487vec2D_int_ptr_Type Domain<SC,LO,GO,NO>::getElements() const{
488 TEUCHOS_TEST_FOR_EXCEPTION(mesh_->getElementsC().is_null(), std::runtime_error, "Elements is null for this mesh.");
489 return mesh_->getElements();
490}
491
492template <class SC, class LO, class GO, class NO>
493typename Domain<SC,LO,GO,NO>::ElementsPtr_Type Domain<SC,LO,GO,NO>::getElementsC() const{
494 TEUCHOS_TEST_FOR_EXCEPTION(mesh_->getElementsC().is_null(), std::runtime_error, "Elements is null for this mesh.");
495 return mesh_->getElementsC();
496}
497
498
499template <class SC, class LO, class GO, class NO>
500typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getMapVecFieldUnique() const{
501 if ( mapVecFieldUnique_.is_null() ) {
502 MapConstPtr_Type mapTmp = this->getMapUnique();
503 mapVecFieldUnique_ = mapTmp->buildVecFieldMap(dim_);
504 }
505 return mapVecFieldUnique_;
506}
507
508template <class SC, class LO, class GO, class NO>
509typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getMapVecFieldRepeated() const{
510 if ( mapVecFieldRepeated_.is_null() ) {
511 MapConstPtr_Type mapTmp = this->getMapRepeated();
512 mapVecFieldRepeated_ = mapTmp->buildVecFieldMap(dim_);
513 }
514 return mapVecFieldRepeated_;
515}
516
517template <class SC, class LO, class GO, class NO>
519
520 return mesh_->getNumElementsGlobal();
522
523template <class SC, class LO, class GO, class NO>
526 return mesh_->getNumElements();
527}
528
529template <class SC, class LO, class GO, class NO>
530LO Domain<SC,LO,GO,NO>::getNumPoints(std::string type) const{
531
532 return mesh_->getNumPoints(type);
534
535template <class SC, class LO, class GO, class NO>
536int Domain<SC,LO,GO,NO>::checkGeomentry(std::string meshType, int dim) const{
538 int notfoundLabel;
539 switch (dim) {
540 case 2:
541 for (int i = 0; i<geometries2DVec_->size(); i++) {
542 notfoundLabel = meshType.compare(geometries2DVec_->at(i));
543 if (notfoundLabel==0) {
544 return i;
545 }
546 }
547 break;
548 case 3:
549 for (int i = 0; i<geometries3DVec_->size(); i++) {
550 notfoundLabel = meshType.compare(geometries3DVec_->at(i));
551 if (notfoundLabel==0) {
552 return i;
553 }
554 }
555 break;
556 default:
557 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"Select valid geometry.");
558 break;
559 }
560 return -1;
561}
562
563template <class SC, class LO, class GO, class NO>
564void Domain<SC,LO,GO,NO>::identifyInterfaceParallelAndDistance( DomainPtr_Type domainOther, vec_int_Type interfaceID_vec ){
565
566 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( mesh_ );
567 MeshUnstrPtr_Type meshUnstructuredOther = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( domainOther->mesh_ );
568 meshUnstructured->buildMeshInterfaceParallelAndDistance( meshUnstructuredOther, interfaceID_vec, distancesToInterface_ );
569
570}
571
572// Abstand zum Interface berechnen
573template <class SC, class LO, class GO, class NO>
575{
576 // IdentifyInterface() ist nur fuer unstrukturierte Gitter programmiert
577 // Mesh_->MeshInterface_ gibt es somit nicht.
578 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( mesh_ );
579
580 // Fuer jede Interface-Flag gibt es "aussen" einen Eintrag im Vektor.
581 // Wenn das Interface also fuer 2 Flags bestimmt wird, dann ist IndicesGlobalMatched_.size() = 2.
582 // Danach gibt es zwei Zeilenvektoren mit der globalen ID fuer this (thisMesh) und otherMesh,
583 // also z.B. fuer Fluid (this) und Struktur (other).
584 // Das heisst wir haben IndicesGlobalMatched_.at(0).size() = 2.
585 // Letztlich haben wir NumberOfInterfaceNodesWithFlag = IndicesGlobalMatched_.at(0).at(0).size().
586 // In den Eintragen IndicesGlobalMatched_.at(0).at(0).at(i) steht die globale ID von Interfaceknoten i.
587 vec3D_GO_ptr_Type indicesGlobalMatched = meshUnstructured->meshInterface_->getIndicesGlobalMatched();
588
589 // SourceNodes (z.B. Fluidgebiet) aus dem Gitter ziehen
590 // Gefaehrlich, da Veraenderungen an SourceNodesRep auch PointsRep_ veraendern;
591 // Sonst auf 0.0 setzen und dann Werte reinschreiben.
592 // Am besten waere es Getter zu haben mit return vec2D_dbl_ptr_Type bzw. const vec2vec2D_dbl_ptr_Type, damit nichts passieren kann.
593 vec2D_dbl_ptr_Type sourceNodesRep = meshUnstructured->getPointsRepeated();
594
595 // Zaehle mit Hilfe von indicesGlobalMatched wie viele Interfaceknoten es insgesamt gibt.
596 int numberInterfaceNodes = 0;
597 for(int i = 0; i < indicesGlobalMatched->size(); i++) // Schleife ueber jede Flag
598 {
599 for(int j = 0; j < indicesGlobalMatched->at(i).at(0).size(); j++) // Schleife ueber jeden Interfaceknoten mit der Flag
600 {
601 numberInterfaceNodes = numberInterfaceNodes + 1;
602 }
603 }
604
605 // EndNodes (Interfaceknoten) aus dem Gitter ziehen; mit Hilfe von IndicesGlobalMatched
606 vec2D_dbl_ptr_Type endNodesRep(new vec2D_dbl_Type( numberInterfaceNodes, vec_dbl_Type( dim_, 0.0 ) ) );
607 int counter = 0; // Die Zeile in die bei EndNodesRep hineingeschrieben wird
608 int globalIDOfInterfaceNode;
609 for(int i = 0; i < indicesGlobalMatched->size(); i++)
610 {
611 for(int j = 0; j < indicesGlobalMatched->at(i).at(0).size(); j++)
612 {
613 // ->at(i).at(0) ist this(z.B. Fluid) und ->at(i).at(1) waere other (z.B. Struktur).
614 globalIDOfInterfaceNode = indicesGlobalMatched->at(i).at(0).at(j);
615
616 for(int k = 0; k < dim_; k++) // Schleife ueber x- und y-Koordinate und ggf. z
617 {
618 endNodesRep->at(counter).at(k) = meshUnstructured->getPointsRepeated()->at( globalIDOfInterfaceNode ).at( k );
619 }
620
621 counter = counter + 1;
622 }
623 }
624
625 // Distanz zum Interface auf eine unrealistisch grosse Zahl setzen.
626 // In DistancesToInterface_->at(i) steht die Distanz der globalen Knoten-ID i zum Interface
627 vec_dbl_ptr_Type tempVec( new vec_dbl_Type( meshUnstructured->getPointsRepeated()->size(), 1000.0 ) );
628 distancesToInterface_ = tempVec;
629
630 // Berechne nun den Abstand von den SourceNodesRep zu den EndNodesRep
631 double distance = 0.0;
632 for(int i = 0; i < sourceNodesRep->size(); i++)
633 {
634 for(int j = 0; j < endNodesRep->size(); j++)
635 {
636 for(int k = 0; k < dim_; k++)
637 {
638 distance = distance + std::pow( sourceNodesRep->at(i).at(k) - endNodesRep->at(j).at(k), 2.0 );
639 }
640
641 // Noch die Wurzel ziehen
642 distance = std::sqrt(distance);
643
644 if(distancesToInterface_->at(i) > distance)
645 {
646 distancesToInterface_->at(i) = distance;
647 }
648
649 // Reseten
650 distance = 0.0;
651
652 }
653 }
654}
655
656template <class SC, class LO, class GO, class NO>
658 return distancesToInterface_;
659}
660
661template <class SC, class LO, class GO, class NO>
663{
664 mesh_->setReferenceConfiguration();
665}
666
667template <class SC, class LO, class GO, class NO>
668typename Domain<SC,LO,GO,NO>::MeshPtr_Type Domain<SC,LO,GO,NO>::getMesh(){
669 return mesh_;
670}
671
672template <class SC, class LO, class GO, class NO>
673typename Domain<SC,LO,GO,NO>::MeshConstPtr_Type Domain<SC,LO,GO,NO>::getMesh() const{
674 MeshConstPtr_Type meshConst = mesh_;
675 return meshConst;
676}
677
678template <class SC, class LO, class GO, class NO>
679void Domain<SC,LO,GO,NO>::moveMesh(MultiVectorPtr_Type displacementUnique, MultiVectorPtr_Type displacementRepeated)
680{
681 mesh_->moveMesh(displacementUnique, displacementRepeated);
682}
683
684//only need in geometry problem.
685template <class SC, class LO, class GO, class NO>
687{
688 // Mesh_ umcasten in unstructured und dann meshUnstructured nutzen,
689 // da nur unstructured Attribut MeshInterface_ besitzt.
690 // Jeder Prozessor kennt also das komplette matched Interface
691 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( this->getMesh() );
692
693 vec3D_GO_ptr_Type indicesGlobalMatchedOrigin = meshUnstructured->getMeshInterface()->getIndicesGlobalMatchedOrigin();
694
695 // lokale Interface ID, die ich dem Knoten zuschreibe; Wir zaehlen von 0 bis #\Gamma-1
696 GO localInterfaceID = 0; // long long
697
698 // In diesen beiden Vektoren stehen die Interface IDs in der Interface-Nummerierung,
699 // die der Prozessor haelt. Unique!!!
700 vec_GO_Type vecInterfaceMap; // vec_long ist long long wg. 64
701
702 // indicesGlobalMatchedOrigin sind die IndicesGlobalMatched von this-Sicht aus.
703 // D.h. in indicesGlobalMatchedOrigin.at(0).at(0) ist Fluid GID und
704 // indicesGlobalMatchedOrigin.at(0).at(1) ist Struktur GID aus Fluid-Sicht.
705
706 // Fluid und Struktur (bzw. this und other) haben gleich viele Interfaceknoten, deswegen
707 // muessen wir hier nicht zwischen differenzieren
708 // ACHTUNG: indicesGlobalMatchedOrigin ist hier nicht partitioniert!!!!
709 for(int i = 0; i < indicesGlobalMatchedOrigin->size(); i++) // Schleife ueber jede flag
710 {
711 for(int j = 0; j < indicesGlobalMatchedOrigin->at(i).at(0).size(); j++) // GIDs innerhalb der flag (vom Fluid)
712 {
713 // Wir muessen long long anstatt int nutzen, da MyGID auf 64 gestellt ist/ genutzt wird
714 GO globalIDOfInterfaceNode = indicesGlobalMatchedOrigin->at(i).at(0).at(j);
715 // liefert true, falls Proz. GID besitzt
716 if( this->getMapUnique()->getLocalElement(globalIDOfInterfaceNode) != Teuchos::OrdinalTraits<LO>::invalid())
717 {
718 // Schreibe die lokale Interface ID hinein
719 vecInterfaceMap.push_back(localInterfaceID);
720 }
721
722 localInterfaceID = localInterfaceID + 1;
723
724 }
725 }
726
727 // Am Ende steht in localInterfaceID wie viele Interface-Knoten es insgesamt gibt
728 GO numberInterfaceNodes = localInterfaceID; // long long wg. 64
729
730 // Baue nun die InterfaceMap (node)
731 Teuchos::ArrayView<GO> vecInterfaceMapArray = Teuchos::arrayViewFromVector( vecInterfaceMap );
732 interfaceMapUnique_ = Teuchos::rcp(new Map_Type( numberInterfaceNodes, vecInterfaceMapArray, 0, comm_ ) ); //maybe numberInterfaceNodes instead of -1
733 // dof-Map bauen
734 interfaceMapVecFieldUnique_ = interfaceMapUnique_->buildVecFieldMap(dim_/*dofs*/);
735}
736
737template <class SC, class LO, class GO, class NO>
738typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getInterfaceMapUnique() const
739{
740 return interfaceMapUnique_;
741}
742
743
744template <class SC, class LO, class GO, class NO>
745typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getInterfaceMapVecFieldUnique() const
746{
747 return interfaceMapVecFieldUnique_;
748}
749
750
751template <class SC, class LO, class GO, class NO>
752typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getGlobalInterfaceMapUnique() const
753{
754 return globalInterfaceMapUnique_;
755}
756
757
758template <class SC, class LO, class GO, class NO>
759typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getGlobalInterfaceMapVecFieldUnique() const
760{
761 return globalInterfaceMapVecFieldUnique_;
762}
763
764template <class SC, class LO, class GO, class NO>
765typename Domain<SC,LO,GO,NO>::MapConstPtr_Type Domain<SC,LO,GO,NO>::getOtherGlobalInterfaceMapVecFieldUnique() const
766{
767 return otherGlobalInterfaceMapVecFieldUnique_;
768}
769
770template <class SC, class LO, class GO, class NO>
771void Domain<SC,LO,GO,NO>::setPartialCoupling(int flag, std::string type){
772
773 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( this->getMesh() );
774 meshUnstructured->getMeshInterface()->setPartialCoupling(flag, type);
775
776}
777
778template <class SC, class LO, class GO, class NO>
780{
781 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp_dynamic_cast<MeshUnstr_Type>( this->getMesh() );
782 MeshInterfacePtr_Type interface = meshUnstructured->getMeshInterface();
783 vec3D_GO_ptr_Type indicesMatchedUni = interface->getIndicesGlobalMatchedUnique();
784
785 vec3D_GO_ptr_Type indicesMatchedGlobalSerial = interface->getIndicesGlobalMatchedOrigin();
786
787 MapConstPtr_Type mapUni = this->getMapUnique();
788 vec_int_ptr_Type flagPointsUni = this->getBCFlagUnique();
789 vec_GO_Type vecGlobalInterfaceID(0);
790 vec_GO_Type vecOtherGlobalInterfaceID(0);
791 vec_GO_Type vecInterfaceID(0);
792 vec_int_Type vecInterfaceFlag(0);
793 LO localID = 0;
794
795 for(int i = 0; i < indicesMatchedGlobalSerial->size(); i++) // Schleife ueber jede flag
796 {
797 for(int j = 0; j < indicesMatchedGlobalSerial->at(i).at(0).size(); j++) {// GIDs innerhalb der flag (vom Fluid)
798 LO index = mapUni->getLocalElement( indicesMatchedGlobalSerial->at(i).at(0).at(j) );
799 if ( index != Teuchos::OrdinalTraits<LO>::invalid() ){
800 vecGlobalInterfaceID.push_back( indicesMatchedGlobalSerial->at(i).at(0).at(j) );
801 vecOtherGlobalInterfaceID.push_back( indicesMatchedGlobalSerial->at(i).at(1).at(j) );
802 vecInterfaceID.push_back( (GO) localID );
803 vecInterfaceFlag.push_back( (*flagPointsUni)[index] );
804 }
805 localID++;
806 }
807 }
808// std::sort( vecGlobalInterfaceID.begin(), vecGlobalInterfaceID.end() );
809 // Baue nun die InterfaceMap fuer Fluid oder Struktur
810 Teuchos::ArrayView<GO> vecInterfaceGlobalMapArray = Teuchos::arrayViewFromVector( vecGlobalInterfaceID );
811 Teuchos::ArrayView<GO> vecInterfaceMapArray = Teuchos::arrayViewFromVector( vecInterfaceID );
812 Teuchos::ArrayView<GO> vecOtherInterfaceGlobalMapArray = Teuchos::arrayViewFromVector( vecOtherGlobalInterfaceID );
813
814 globalInterfaceMapUnique_ = Teuchos::rcp(new Map_Type( -1, vecInterfaceGlobalMapArray, 0, comm_ ) );
815 interfaceMapUnique_ = Teuchos::rcp(new Map_Type(-1, vecInterfaceMapArray, 0, comm_ ) );
816
817 otherGlobalInterfaceMapUnique_ = Teuchos::rcp(new Map_Type(-1, vecOtherInterfaceGlobalMapArray, 0, comm_ ) );
818
819
820 if ( interface->sizePartialCoupling() == 0 ) {
821 globalInterfaceMapVecFieldUnique_ = globalInterfaceMapUnique_->buildVecFieldMap(dim_);
822 interfaceMapVecFieldUnique_ = interfaceMapUnique_->buildVecFieldMap(dim_);
823 otherGlobalInterfaceMapVecFieldUnique_ = otherGlobalInterfaceMapUnique_->buildVecFieldMap(dim_);
824 }
825 // we add the dofs which are not part of the interface as dummy interface dofs, which do nothing (unit matrix in the diagonal coupling block). We need to do this for the monolithic use of FROSch, since we need a constant number of dofs for a node for each block
826 else{
827 if (this->comm_->getRank() == 0)
828 std::cout << "-- ### Warning! Unique and unique-vector-field map might not be compatiable due to partial coupling conditions. ### --" << std::endl;
829 int numDofs = dim_;
830 // we use nodewise ordering
831 Teuchos::ArrayView<const GO> elementListGlobal = globalInterfaceMapUnique_->getNodeElementList();
832 Teuchos::ArrayView<const GO> otherElementListGlobal = otherGlobalInterfaceMapUnique_->getNodeElementList();
833
834 Teuchos::Array<GO> elementListFieldGlobal( 0 );
835 Teuchos::Array<GO> elListFieldPartial( 0 );
836
837 Teuchos::Array<GO> otherElementListFieldGlobal( 0 );
838 Teuchos::Array<GO> otherElListFieldPartial( 0 );
839
840 for (UN i=0; i<elementListGlobal.size(); i++) {
841 int loc = interface->isPartialCouplingFlag( vecInterfaceFlag[i] );
842 if ( loc > -1 ) {
843 std::string partialType = interface->getPartialCouplingType( loc );
844 if (partialType == "X_Y" && dim_ == 3) {
845 elementListFieldGlobal.push_back (numDofs * elementListGlobal[i] + 0 );
846 elementListFieldGlobal.push_back (numDofs * elementListGlobal[i] + 1 );
847 elementListFieldGlobal.push_back (numDofs * elementListGlobal[i] + 2 );
848 elListFieldPartial.push_back (numDofs * elementListGlobal[i] + 0 );
849 elListFieldPartial.push_back (numDofs * elementListGlobal[i] + 1 );
850
851 otherElementListFieldGlobal.push_back (numDofs * otherElementListGlobal[i] + 0 );
852 otherElementListFieldGlobal.push_back (numDofs * otherElementListGlobal[i] + 1 );
853 otherElementListFieldGlobal.push_back (numDofs * otherElementListGlobal[i] + 2 );
854 otherElListFieldPartial.push_back (numDofs * otherElementListGlobal[i] + 0 );
855 otherElListFieldPartial.push_back (numDofs * otherElementListGlobal[i] + 1 );
856
857 }
858 else
859 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Implement other partial coupling types.");
860 }
861 else{
862 for (UN dof=0; dof<numDofs; dof++){
863 elementListFieldGlobal.push_back( numDofs * elementListGlobal[i] + dof );
864 elListFieldPartial.push_back ( numDofs * elementListGlobal[i] + dof );
865 otherElementListFieldGlobal.push_back( numDofs * otherElementListGlobal[i] + dof );
866 otherElListFieldPartial.push_back ( numDofs * otherElementListGlobal[i] + dof );
867 }
868 }
869 }
870 globalInterfaceMapVecFieldUnique_ = Teuchos::rcp(new Map_Type( -1, elementListFieldGlobal(), 0/*index base*/, this->getComm() ) );
871 otherGlobalInterfaceMapVecFieldUnique_ = Teuchos::rcp(new Map_Type( -1, otherElementListFieldGlobal(), 0/*index base*/, this->getComm() ) );
872 // This is only a temporary map. We need to make sure that the dummy values have a higher GID, as the real coupling values. Otherwise we might get a problem during the assembly of the coupling matrices
873 interfaceMapVecFieldUnique_ = Teuchos::rcp(new Map_Type(-1, elementListFieldGlobal.size(), 0/*index base*/, this->getComm() ) );
874
875 partialGlobalInterfaceVecFieldMap_ = Teuchos::rcp(new Map_Type( -1, elListFieldPartial(), 0/*index base*/, this->getComm() ) );
876 otherPartialGlobalInterfaceVecFieldMap_ = Teuchos::rcp(new Map_Type(-1, otherElListFieldPartial(), 0/*index base*/, this->getComm() ) );
877
878 }
879
880}
881
882template <class SC, class LO, class GO, class NO>
883void Domain<SC,LO,GO,NO>::toNodeID(UN dim, GO dofID, GO& nodeID, LO& localDofNumber )
884{
885 nodeID = (GO) (dofID/dim);
886 localDofNumber = (LO) (dofID%dim);
887}
888
889template <class SC, class LO, class GO, class NO>
890void Domain<SC,LO,GO,NO>::toDofID(UN dim, GO nodeID, LO localDofNumber, GO& dofID )
891{
892 dofID = (GO) ( dim * nodeID + localDofNumber);
893}
894
895template <class SC, class LO, class GO, class NO>
897{
898 return vecLocalInterfaceIDinGlobal_;
899}
900
901template <class SC, class LO, class GO, class NO>
903{
904 MeshUnstrPtr_Type meshUnstructured = Teuchos::rcp(new MeshUnstr_Type(comm_, 10/*default volume flag*/));
905 mesh_ = meshUnstructured;
906
907 this->dim_ = domain->getDimension();
908 this->mesh_->mapUnique_ = Teuchos::rcp_const_cast<Map_Type>( domain->getInterfaceMapUnique() );
909 this->mesh_->mapRepeated_ = Teuchos::rcp_const_cast<Map_Type>( domain->getInterfaceMapUnique() );
910 this->mapVecFieldRepeated_ = Teuchos::rcp_const_cast<Map_Type>( domain->getInterfaceMapVecFieldUnique() );
911 this->mapVecFieldUnique_ = Teuchos::rcp_const_cast<Map_Type>( domain->getInterfaceMapVecFieldUnique() );
912
913 MapConstPtr_Type mapGI = domain->getGlobalInterfaceMapUnique();
914 MapConstPtr_Type mapD = domain->getMapUnique();
915 this->mesh_->pointsRep_.reset(new std::vector<std::vector<SC> >(mapGI->getNodeNumElements(), std::vector<SC>(this->dim_, 0.0 ) ) );
916 this->mesh_->pointsUni_.reset(new std::vector<std::vector<SC> >(mapGI->getNodeNumElements(), std::vector<SC>(this->dim_, 0.0 ) ) );
917 vec2D_dbl_ptr_Type pointsUni = domain->getPointsUnique();
918 for (int i=0; i<mapGI->getNodeNumElements(); i++) {
919 LO index = mapD->getLocalElement( mapGI->getGlobalElement( i ) );
920 for (int j=0; j<this->dim_; j++){
921 (*this->mesh_->pointsRep_)[i][j] = (*pointsUni)[index][j];
922 (*this->mesh_->pointsUni_)[i][j] = (*pointsUni)[index][j];
923 }
924 }
925
926}
927//template <class SC, class LO, class GO, class NO>
928//void Domain<SC,LO,GO,NO>::setDummyInterfaceMesh( MeshPtr_Type mesh )
929//{
930// this->mesh_ = mesh;
931//}
932template <class SC, class LO, class GO, class NO>
933int Domain<SC,LO,GO,NO>::findInPointsUnique(const vec_dbl_Type& x) const{
934
935 double eps = 0.0000001;
936
937 vec2D_dbl_ptr_Type points = this->getPointsUnique();
938
939 if (this->getDimension()==2) {
940 auto iterator = std::find_if( points->begin(), points->end(),
941 [&] (const std::vector<double>& a){
942 if (a[0] >= x[0]-eps && a[0] <= x[0]+eps
943 && a[1] >= x[1]-eps && a[1] <= x[1]+eps)
944 return true;
945 else
946 return false;
947 }
948 );
949 if ( iterator != points->end() )
950 return std::distance(points->begin(),iterator);
951 else
952 return -1;
953 }
954 else if(this->getDimension()==3) {
955 auto iterator = std::find_if(points->begin(),points->end(),
956 [&] (const std::vector<double>& a){
957 if (a[0] >= x[0]-eps && a[0] <= x[0]+eps
958 && a[1] >= x[1]-eps && a[1] <= x[1]+eps
959 && a[2] >= x[2]-eps && a[2] <= x[2]+eps)
960 return true;
961 else
962 return false;
963 }
964 );
965 if ( iterator != points->end() )
966 return std::distance(points->begin(),iterator);
967 else
968 return -1;
969 }
970 return -1;
971}
972
973template <class SC, class LO, class GO, class NO>
974typename Domain<SC,LO,GO,NO>::MultiVectorPtr_Type Domain<SC,LO,GO,NO>::getNodeListMV() const{
975
976 MapConstPtr_Type map = this->getMapRepeated();
977 MultiVectorPtr_Type nodeList = Teuchos::rcp( new MultiVector_Type ( map, dim_ ) );
978 vec2D_dbl_ptr_Type pointsRepeated = this->getPointsRepeated();
979 for (int i=0; i<nodeList->getLocalLength(); i++) {
980 for (int j=0; j<dim_; j++) {
981 Teuchos::ArrayRCP< SC > values = nodeList->getDataNonConst( j );
982 values[i] = (*pointsRepeated)[i][j];
983 }
984 }
985 return nodeList;
986}
987
988template <class SC, class LO, class GO, class NO>
990{
991 Teuchos::RCP<ExporterParaView<SC,LO,GO,NO> > exPara(new ExporterParaView<SC,LO,GO,NO>());
992
993 Teuchos::RCP<MultiVector<SC,LO,GO,NO> > exportSolution(new MultiVector<SC,LO,GO,NO>(this->getMapUnique()));
994 vec_int_ptr_Type BCFlags = this->getBCFlagUnique(); // Unique flags at points
995
996 Teuchos::ArrayRCP< SC > entries = exportSolution->getDataNonConst(0);
997 for(int i=0; i< entries.size(); i++){
998 entries[i] = BCFlags->at(i);
999 }
1000
1001 Teuchos::RCP<const MultiVector<SC,LO,GO,NO> > exportSolutionConst = exportSolution;
1002
1003 exPara->setup("Mesh_Node_Flags_"+name,this->getMesh(), this->FEType_);
1004
1005 exPara->addVariable(exportSolutionConst, "Flags", "Scalar", 1,this->getMapUnique());
1006 exPara->save(0.0);
1007
1008 exPara->closeExporter();
1009}
1010
1011template <class SC, class LO, class GO, class NO>
1013{
1014 Teuchos::RCP<ExporterParaView<SC,LO,GO,NO> > exPara(new ExporterParaView<SC,LO,GO,NO>());
1015
1016 Teuchos::RCP<MultiVector<SC,LO,GO,NO> > exportSolution(new MultiVector<SC,LO,GO,NO>(this->getElementMap()));
1017 exportSolution->putScalar(comm_->getRank()+1.);
1018
1019 Teuchos::RCP<const MultiVector<SC,LO,GO,NO> > exportSolutionConst = exportSolution;
1020
1021 exPara->setup("Subdomains"+name,this->getMesh(), "P0");
1022
1023 exPara->addVariable(exportSolutionConst, "Core", "Scalar", 1,this->getElementMap());
1024 exPara->save(0.0);
1025
1026 exPara->closeExporter();
1027}
1028
1029
1030template <class SC, class LO, class GO, class NO>
1032{
1033 Teuchos::RCP<ExporterParaView<SC,LO,GO,NO> > exPara(new ExporterParaView<SC,LO,GO,NO>());
1034
1035 Teuchos::RCP<MultiVector<SC,LO,GO,NO> > exportSolution(new MultiVector<SC,LO,GO,NO>(this->getMapVecFieldUnique()));
1036 exportSolution->putScalar(0.);
1037 ElementsPtr_Type elementsC = this->getElementsC(); // Unique flags at points
1038
1039 Teuchos::ArrayRCP< SC > entries = exportSolution->getDataNonConst(0);
1040
1041 // We iterate over all elements and compute the surface normals to export them
1042 for (UN T=0; T<elementsC->numberElements(); T++) {
1043 FiniteElement fe = elementsC->getElement( T );
1044 ElementsPtr_Type subEl = fe.getSubElements(); // might be null
1045 for (int surface=0; surface<fe.numSubElements(); surface++) {
1046 FiniteElement feSub = subEl->getElement( surface );
1047 vec_int_Type nodeListElement = fe.getVectorNodeList();
1048 if(subEl->getDimension() == dim_-1 ){
1049 vec_int_Type nodeList = feSub.getVectorNodeListNonConst();
1050
1051 vec_dbl_Type v_E(dim_,1.);
1052 double norm_v_E=1.;
1053
1054 Helper::computeSurfaceNormal(this->dim_,this->getPointsRepeated(),nodeList,v_E,norm_v_E);
1055
1056 for(int j=0; j< nodeList.size(); j++){
1057 for(int i=0; i< this->dim_; i++){
1058 if(this->getMapUnique()->getLocalElement(this->getMapRepeated()->getGlobalElement(nodeList[j])) != -1 ){ // We only write when we have the node in unique distribution, because we are lazy. Otherwise we would do an import etc. But this will not give us further information.
1059 LO id = this->getMapUnique()->getLocalElement(this->getMapRepeated()->getGlobalElement(nodeList[j]));
1060 entries[id*this->dim_+i] = 1./norm_v_E * v_E[i];
1061 }
1062 }
1063 }
1064 }
1065 }
1066 }
1067
1068 Teuchos::RCP<const MultiVector<SC,LO,GO,NO> > exportSolutionConst = exportSolution;
1069
1070 exPara->setup("Mesh_Surface_Directions_"+name,this->getMesh(), this->FEType_);
1071
1072 exPara->addVariable(exportSolutionConst, "SurfaceNormals", "Vector", this->dim_,this->getMapUnique());
1073 exPara->save(0.0);
1074
1075 exPara->closeExporter();
1076}
1077
1078template <class SC, class LO, class GO, class NO>
1080{
1081 Teuchos::RCP<ExporterParaView<SC,LO,GO,NO> > exPara(new ExporterParaView<SC,LO,GO,NO>());
1082
1083 Teuchos::RCP<MultiVector<SC,LO,GO,NO> > exportSolution(new MultiVector<SC,LO,GO,NO>(this->getElementMap()));
1084 exportSolution->putScalar(0.);
1085 ElementsPtr_Type elementsC = this->getElementsC(); // Unique flags at points
1086
1087 Teuchos::ArrayRCP< SC > entries = exportSolution->getDataNonConst(0);
1088
1089 SC detB;
1090 SmallMatrix<SC> B(this->dim_);
1091 SmallMatrix<SC> Binv(this->dim_);
1092 // We iterate over all elements and compute the surface normals to export them
1093 for (UN T=0; T<elementsC->numberElements(); T++) {
1094 Helper::buildTransformation(elementsC->getElement(T).getVectorNodeList(), this->getPointsRepeated(), B);
1095 detB = B.computeInverse(Binv);
1096 entries[T] = detB;
1097 }
1098
1099 Teuchos::RCP<const MultiVector<SC,LO,GO,NO> > exportSolutionConst = exportSolution;
1100
1101 exPara->setup("Mesh_Element_Orientation_"+name,this->getMesh(), "P0");
1102
1103 exPara->addVariable(exportSolutionConst, "VolElement", "Scalar", 1,this->getElementMap());
1104 exPara->save(0.0);
1105
1106 exPara->closeExporter();
1107}
1108
1109
1110template <class SC, class LO, class GO, class NO>
1112{
1113 Teuchos::RCP<ExporterParaView<SC,LO,GO,NO> > exPara(new ExporterParaView<SC,LO,GO,NO>());
1114
1115 Teuchos::RCP<MultiVector<SC,LO,GO,NO> > exportSolution(new MultiVector<SC,LO,GO,NO>(this->getElementMap()));
1116
1117 Teuchos::ArrayRCP< SC > entries = exportSolution->getDataNonConst(0);
1118 ElementsPtr_Type elements = this->getElementsC(); // element list
1119
1120 for(int i=0; i< entries.size(); i++){
1121 entries[i] = elements->getElement(i).getFlag(); // element flags
1122 }
1123
1124 Teuchos::RCP<const MultiVector<SC,LO,GO,NO> > exportSolutionConst = exportSolution;
1125
1126 exPara->setup("Mesh_Element_Flags_"+name,this->getMesh(), "P0");
1127
1128 exPara->addVariable(exportSolutionConst, "Flags", "Scalar", 1,this->getElementMap());
1129
1130 exPara->save(0.0);
1131
1132 exPara->closeExporter();
1133
1134}
1135
1136}
1137#endif
vec_int_ptr_Type getElementsFlag() const
Returns flags of elements as vector of type int.
Definition Domain_def.hpp:170
UN getDimension() const
Get dimension.
Definition Domain_def.hpp:422
void initDummyMesh(MapPtr_Type map)
Initialize dummy mesh for i.e. lagrange multiplier that only represents on 'point' in that sense....
Definition Domain_def.hpp:387
void exportSurfaceNormals(std::string name="default")
Exporting Paraview file displaying surface normals of the underlying mesh. As we are generally not ab...
Definition Domain_def.hpp:1031
MapConstPtr_Type getMapRepeated() const
void preProcessMesh(bool correctSurfaceNormals, bool correctElementDirection)
Option of preprocessing mesh by making consistent outward normal and/or consistent element orientatio...
Definition Domain_def.hpp:409
CommConstPtr_Type getComm() const
Communicator.
Definition Domain_def.hpp:434
vec_int_ptr_Type getBCFlagUnique() const
Get vector of the flags corrsponding to the unique points (on your processor)
Definition Domain_def.hpp:481
MapConstPtr_Type getMapVecFieldRepeated() const
Definition Domain_def.hpp:509
void exportDistribution(std::string name="default")
Exporting Paraview file displaying distribution of elements to the differnt cores.
Definition Domain_def.hpp:1012
void buildMesh(int flags, std::string meshType, int dim, std::string FEType, int N, int M, int numProcsCoarseSolve=0)
Build structured mesh in FEDDLib.
Definition Domain_def.hpp:203
vec2D_int_ptr_Type getElements() const
Get the elements (on your processor) as vector data type.
Definition Domain_def.hpp:487
void setPartialCoupling(int flag, std::string type)
Set partial coupling.
Definition Domain_def.hpp:771
MeshPtr_Type getMesh()
Get mesh.
Definition Domain_def.hpp:668
void buildInterfaceMaps()
Build interface maps.
Definition Domain_def.hpp:779
void identifyInterfaceParallelAndDistance(DomainPtr_Type domainOther, vec_int_Type interfaceID_vec)
Itentify interface parallal and distance.
Definition Domain_def.hpp:564
void toDofID(UN dim, GO nodeID, LO localDofNumber, GO &dofID)
Hilfsfunktion fuer buildLocalInterfaceIDInGlobal(). Gibt fuer eine gegebene nodeID die entsprechende ...
Definition Domain_def.hpp:890
vec_long_Type getLocalInterfaceIDInGlobal() const
Get local interface id in global.
Definition Domain_def.hpp:896
void readMeshSize(std::string filename, std::string delimiter)
Reading mesh size.
Definition Domain_def.hpp:282
void buildUniqueInterfaceMaps()
Build unique node and dof interfaceMap in interface numbering.
Definition Domain_def.hpp:686
void partitionMesh(bool partitionDistance=false)
Partition mesh according to number of processors. Partition with parmetis.
Definition Domain_def.hpp:293
MapConstPtr_Type getMapUnique() const
MultiVectorPtr_Type getNodeListMV() const
Get node list in multi vector point.
Definition Domain_def.hpp:974
void initializeUnstructuredMesh(int dimension, std::string feType, int volumeID=10, std::string meshUnit="cm", bool convertToCM=false)
Generally the domain object holds only meshes from type 'Mesh'. If we read a mesh from file it become...
Definition Domain_def.hpp:268
MapConstPtr_Type getOtherGlobalInterfaceMapVecFieldUnique() const
Get other interface vec field map unique (for fsi coupling block c4)
Definition Domain_def.hpp:765
LO getNumElements() const
Get local number of elements (on your processor)
Definition Domain_def.hpp:524
void setMesh(MeshUnstrPtr_Type meshUnstr)
Settng mesh from domain.
Definition Domain_def.hpp:380
ElementsPtr_Type getElementsC() const
Get the elements (on your processor) as Elements_Type.
Definition Domain_def.hpp:493
void toNodeID(UN dim, GO dofID, GO &nodeID, LO &localDofNumber)
Hilfsfunktion fuer buildLocalInterfaceIDInGlobal(). Gibt fuer eine gegebene nodeID die entsprechende ...
Definition Domain_def.hpp:883
int findInPointsUnique(const vec_dbl_Type &x) const
Find in points unique.
Definition Domain_def.hpp:933
int checkGeomentry(std::string MeshType, int dim) const
Domain()
Constructor.
Definition Domain_def.hpp:15
vec2D_dbl_ptr_Type getPointsRepeated() const
Get vector of repeated points (on your processor). 2D Vector with size: numPoints x dim.
Definition Domain_def.hpp:463
void initializeFEData()
initializeFEData
Definition Domain_def.hpp:164
void moveMesh(MultiVectorPtr_Type displacementUnique, MultiVectorPtr_Type displacementRepeated)
Move mesh according to displacement (i.e. used in FSI)
Definition Domain_def.hpp:679
std::string getFEType() const
Finite element discretization. Represented as string, i.e., P2.
Definition Domain_def.hpp:428
LO getNumPoints(std::string type="Unique") const
Get local number of points of type 'type' (unique/repeated)
Definition Domain_def.hpp:530
MapConstPtr_Type getEdgeMap() const
Get map of edges.
Definition Domain_def.hpp:457
GO getNumElementsGlobal() const
Get global number of elements.
Definition Domain_def.hpp:518
void initWithDomain(DomainPtr_Type domainsP1)
Initialize domain with already existing domain.
Definition Domain_def.hpp:354
void exportElementFlags(std::string name="default")
Exporting Paraview file displaying element flags of the underlying mesh.
Definition Domain_def.hpp:1111
MapConstPtr_Type getGlobalInterfaceMapUnique() const
Get interface map unique (for fsi coupling block c4)
Definition Domain_def.hpp:752
void buildP2ofP1Domain(DomainPtr_Type domainP1)
Building a P2 mesh from the P1 one mesh. We generally habe P1-input meshes and build the P2 mesh on t...
Definition Domain_def.hpp:335
vec2D_dbl_ptr_Type getPointsUnique() const
Get vector of unique points (on your processor). 2D Vector with size: numPoints x dim.
Definition Domain_def.hpp:469
void exportNodeFlags(std::string name="default")
Exporting Paraview file displaying node flags of the underlying mesh.
Definition Domain_def.hpp:989
MapConstPtr_Type getInterfaceMapVecFieldUnique() const
Get interface vector field map unique.
Definition Domain_def.hpp:745
void exportElementOrientation(std::string name="default")
Exporting Paraview file displaying element volume of underlying mesh.
Definition Domain_def.hpp:1079
void info() const
Information about the domain.
Definition Domain_def.hpp:140
MapConstPtr_Type getElementMap() const
Get map of elements.
Definition Domain_def.hpp:451
vec_int_ptr_Type getBCFlagRepeated() const
Get vector of the flags corrsponding to the repeated points (on your processor)
Definition Domain_def.hpp:475
void setReferenceConfiguration()
Set reference configuration.
Definition Domain_def.hpp:662
MapConstPtr_Type getGlobalInterfaceMapVecFieldUnique() const
Get interface vec field map unique (for fsi coupling block c4)
Definition Domain_def.hpp:759
LO getApproxEntriesPerRow() const
Estimate depending on FEType and dimension for the numer of entries in system matrix,...
Definition Domain_def.hpp:176
vec_dbl_ptr_Type getDistancesToInterface() const
Get distances to interface.
Definition Domain_def.hpp:657
void exportMesh(bool exportEdges=false, bool exportSurfaces=false, std::string exportMesh="export.mesh")
Exporting Mesh.
Definition Domain_def.hpp:401
MapConstPtr_Type getInterfaceMapUnique() const
Get interface map unique.
Definition Domain_def.hpp:738
void setDummyInterfaceDomain(DomainPtr_Type domain)
Set dummy interface domain.
Definition Domain_def.hpp:902
void calculateDistancesToInterface()
Calculate distance to interface.
Definition Domain_def.hpp:574
void readAndPartitionMesh(std::string filename, std::string delimiter, int dim, std::string FEType, int volumeID=10)
Function called when mesh is read and paritioned. In turn it calls readMesh(...) and partitionMesh(....
Definition Domain_def.hpp:318
MapConstPtr_Type getMapVecFieldUnique() const
Get map of all unique (not uniquely distributed) nodes of processors in a vector field point of view....
Definition Domain_def.hpp:500
Definition ExporterParaView_decl.hpp:30
Definition FiniteElement.hpp:17
static void buildTransformation(const vec_int_Type &element, vec2D_dbl_ptr_Type pointsRep, SmallMatrix< SC > &B, std::string FEType="P")
Build transformation of element to reference element depending on FEType.
Definition Helper.cpp:138
static void computeSurfaceNormal(int dim, vec2D_dbl_ptr_Type pointsRep, vec_int_Type nodeList, vec_dbl_Type &v_E, double &norm_v_E)
Compute surface normal of corresponding surface.
Definition Helper.cpp:103
Definition MultiVector_decl.hpp:61
This class represents a templated small Matrix of type T. Primarily created for 2x2 and 3x3 matrices....
Definition SmallMatrix.hpp:20
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36