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