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