Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
ExporterParaViewAMR_def.hpp
1#ifndef ExporterParaViewAMR_def_hpp
2#define ExporterParaViewAMR_def_hpp
3
4#include "ExporterParaViewAMR_decl.hpp"
5
13
14namespace FEDD {
15
16template<class SC,class LO,class GO,class NO>
17ExporterParaViewAMR<SC,LO,GO,NO>::ExporterParaViewAMR():
18ExporterParaView<SC,LO,GO,NO>()
19{
20
21}
22
23template<class SC,class LO,class GO,class NO>
24void ExporterParaViewAMR<SC,LO,GO,NO>::reSetup(MeshPtr_Type mesh){
25
26 this->mesh_ = mesh;
27 this->nmbElementsGlob_ = this->mesh_->getNumElementsGlobal();
28 this->pointsUnique_ = this->mesh_->getPointsUnique();
29 this->nmbPointsGlob_ = this->mesh_->getMapUnique()->getGlobalNumElements();
30
31 MapConstPtr_Type elementMap = this->mesh_->getElementMap();
32 Teuchos::ArrayView<const GO> nodeElementList = elementMap->getNodeElementList();
33 vec_int_Type nodeElementListInteger( this->nmbPointsPerElement_ * nodeElementList.size() );
34 int counter=0;
35
36 for (int i=0; i<nodeElementList.size(); i++) {
37 for (int j=0; j< this->nmbPointsPerElement_; j++){
38 nodeElementListInteger[counter] = (int) this->nmbPointsPerElement_*nodeElementList[i] + j;
39 counter++;
40 }
41 }
42 Teuchos::RCP<Epetra_BlockMap> mapElements;
43
44 if (nodeElementListInteger.size()>0)
45 mapElements.reset(new Epetra_BlockMap( (int) (this->nmbPointsPerElement_*this->nmbElementsGlob_), (int) nodeElementListInteger.size(), &nodeElementListInteger[0],1, 0, *this->commEpetra_));
46 else
47 mapElements.reset(new Epetra_BlockMap( (int) (this->nmbPointsPerElement_*this->nmbElementsGlob_), (int) nodeElementListInteger.size(), NULL,1, 0, *this->commEpetra_));
48
49 this->elementsHDF_.reset(new Epetra_IntVector(*mapElements));
50
51 ElementsPtr_Type elements = this->mesh_->getElementsC();
52
53 counter = 0;
54 for (int i=0; i<elements->numberElements(); i++) {
55 for (int j=0; j<this->nmbPointsPerElement_; j++) {
56 int globalIndex = (int) mesh->getMapRepeated()->getGlobalElement( elements->getElement(i).getNode(j) );
57 (*this->elementsHDF_)[counter] = globalIndex;
58 counter++;
59 }
60 }
61
62 Teuchos::ArrayView< const GO > indices = this->mesh_->getMapUnique()->getNodeElementList();
63 int* intGlobIDs = new int[indices.size()];
64 for (int i=0; i<indices.size(); i++) {
65 intGlobIDs[i] = (int) indices[i];
66 }
67
68 EpetraMapPtr_Type mapEpetra = Teuchos::rcp(new Epetra_Map((int)this->nmbPointsGlob_,indices.size(),intGlobIDs,0,*this->commEpetra_));
69 delete [] intGlobIDs;
70
71 this->pointsHDF_.reset(new Epetra_MultiVector(*mapEpetra,this->dim_));
72
73 this->updatePoints();
74
75 this->redo_=true;
76 std::string nameConn = "Connections" + std::to_string(this->timeIndex_);
77 this->writeMeshElements(nameConn);
78
79
80}
81
82template<class SC,class LO,class GO,class NO>
83void ExporterParaViewAMR<SC,LO,GO,NO>::updateVariables(MultiVectorConstPtr_Type &u, std::string varName){
84
85 for (int i=0; i<this->variables_.size(); i++) {
86 if(this->varNames_[i] == varName){
87 this->variables_[i] = u;
88 if (this->FEType_ == "P0") {
89 this->mapUniqueVariables_ = this->mesh_->getElementMap();
90 }
91 else
92 this->mapUniqueVariables_= this->mesh_->getMapUnique();
93
94 this->nmbExportValuesGlob_ = this->mapUniqueVariables_->getGlobalNumElements();
95 Teuchos::ArrayView< const GO > indices = this->mapUniqueVariables_->getNodeElementList();
96 int* intGlobIDs = new int[indices.size()];
97 for (int j=0; j<indices.size(); j++) {
98 intGlobIDs[j] = (int) indices[j];
99 }
100
101 EpetraMapPtr_Type mapToStore = Teuchos::rcp(new Epetra_Map( (int) this->mapUniqueVariables_->getGlobalNumElements(), indices.size(), intGlobIDs,0, *this->commEpetra_ ) );
102
103 this->uniqueMaps_[i] =mapToStore;
104 delete [] intGlobIDs;
105 }
106 }
107
108}
109
110
111
112
113}
114#endif
Definition ExporterParaView_decl.hpp:44
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5