NeoPZ
pzmvmesh.cpp
Go to the documentation of this file.
1 
6 #include "pzmvmesh.h"
7 #include "pzcmesh.h"
8 #include "TPZMaterial.h"
9 #include "pzgraphnode.h"
10 #include "pzgraphel.h"
11 
12 using namespace std;
13 
14 TPZMVGraphMesh::TPZMVGraphMesh(TPZCompMesh *cmesh, int dimension, const std::set<int> & matids, const TPZVec<std::string> &scalarnames,
15  const TPZVec<std::string> &vecnames) : TPZGraphMesh(cmesh, dimension, matids, scalarnames,vecnames) {
16  fNumCases = 0;
17  fNumSteps = 0;
18  fStyle = EMVStyle;
19 }
20 
22 TPZGraphMesh(cmesh, dimension,graph->fMaterialIds,graph->ScalarNames(),graph->VecNames()) {
23  fNumCases = graph->fNumCases;
24  fNumSteps = graph->fNumSteps;
25  fStyle = EMVStyle;
26 }
27 
28 void TPZMVGraphMesh::DrawMesh(int numcases) {
29 
30  fNumCases = numcases;
31  fNumSteps = 0;
32  (fOutFile) << "%HEADER" << endl;
33  (fOutFile) << "Arquivo gerado por PZ" << endl;
34  (fOutFile) << "%RESULT\n1" << endl;
35  (fOutFile) << 1 << " 'Caso Unico'" << endl;
36  (fOutFile) << "%RESULT.CASE" << endl;
37  (fOutFile) << 1 << " " << numcases << endl;
38  for(int i=0; i<numcases;i++) {
39  (fOutFile) << (i+1) << " 'step" << i << "'" << endl;
40  }
41  DrawNodes();
43 }
44 
45 void TPZMVGraphMesh::DrawSolution(int step, REAL time){
46 
47  fNumSteps++;
48  int numscal = this->fScalarNames.NElements();
49  int numvec = fVecNames.NElements();
50  TPZVec<int> scalind(0);
51  TPZVec<int> vecind(0);
52  scalind.Resize(numscal);
53  vecind.Resize(numvec);
54  scalind.Fill(-1,0,numscal);
55  vecind.Fill(-1,0,numvec);
56  std::set<int> matids = MaterialIds();
57  if(matids.size() == 0) {
58  cout << "TPZMVGraphMesh no material found\n";
59  return;
60  }
61  set<int>::iterator it = matids.begin();
62  TPZMaterial * matp = fCompMesh->FindMaterial(*it);
63  int n;
64  for(n=0; n<numscal; n++) {
65  scalind[n] = matp->VariableIndex( fScalarNames[n]);
66  }
67  for(n=0; n<numvec; n++) {
68  vecind[n] = matp->VariableIndex(fVecNames[n]);
69  }
70 
71  (fOutFile) << "%RESULT.CASE.STEP\n" << (step+1) << endl;
72  (fOutFile) << "%RESULT.CASE.STEP.TIME\n" << time << endl;
73  int dispind = matp->VariableIndex("Displacement6");
74  TPZVec<REAL> disp(6,0.);
75 
76  (fOutFile) << "%RESULT.CASE.STEP.NODAL.DISPLACEMENT" << endl;
77  (fOutFile) << NPoints() << " 'Nodal Displ'" << endl;
78  int64_t nnod = fNodeMap.NElements(),i;
79  for(i=0;i<nnod;i++) {
80  TPZGraphNode *n = &fNodeMap[i];
81  if(n) n->DrawSolution(dispind, EMVStyle);
82  }
83  (fOutFile) << "%RESULT.CASE.STEP.NODAL.SCALAR" << endl;
84  (fOutFile) << numscal << endl;
85  for(n=0;n<numscal;n++) {
86  (fOutFile) << "'" << fScalarNames[n] << "' ";
87  }
88  (fOutFile) << endl;
89 
90  (fOutFile) << "%RESULT.CASE.STEP.NODAL.SCALAR.DATA" << endl;
91  (fOutFile) << NPoints() << endl;
92  nnod = fNodeMap.NElements();
93  for(i=0;i<nnod;i++) {
94  TPZGraphNode *n = &fNodeMap[i];
95  if(n) n->DrawSolution(scalind, EMVStyle);
96  }
97  (fOutFile) << "%RESULT.CASE.STEP.NODAL.VECTOR" << endl;
98  (fOutFile) << numvec << endl;
99  for(n=0;n<numvec;n++) {
100  (fOutFile) << "'" << fVecNames[n] << "' ";
101  }
102  (fOutFile) << endl;
103  (fOutFile) << "%RESULT.CASE.STEP.NODAL.VECTOR.DATA" << endl;
104  (fOutFile) << NPoints() << endl;
105  nnod = fNodeMap.NElements();
106  for(i=0;i<nnod;i++) {
107  TPZGraphNode *n = &fNodeMap[i];
108  if(n) n->DrawSolution(vecind, EMVStyle);
109  }
110  if(fNumSteps == fNumCases) (fOutFile) << "%END\n";
111 }
112 
113 
116  int dim;
117  for(dim=0; dim<3; dim++) {
118  int64_t nnod = fNodeMap.NElements();
119  for(int64_t i=0;i<nnod;i++) {
120  TPZGraphNode *n = &fNodeMap[i];
121  if(n) n->SetPointNumber(n->FirstPoint()+1);// renumera de 1 para frente
122  } // o valor do id do n�
123  }
124 }
125 
127 
128  int64_t nn = 0L;
129  int64_t nnod = fNodeMap.NElements();
130  int64_t i;
131  for(i=0;i<nnod;i++) {
132  TPZGraphNode *n = &fNodeMap[i];
133  if(n) nn += n->NPoints();
134  }
135  (fOutFile) << "%NODE" << endl;
136  (fOutFile) << nn << endl;
137 
138  (fOutFile) << "%NODE.COORD" << endl;
139  (fOutFile) << nn << endl;
140  for(i=0;i<nnod;i++) {
141  TPZGraphNode *n = &fNodeMap[i];
142  if(n) n->DrawCo(EMVStyle);
143  }
144 }
145 
147 
148  int64_t nel = fElementList.NElements();
149  if(!nel) return;
150  TPZGraphEl *el = (TPZGraphEl *) fElementList[0];
151  int numnodes = el->NConnects();
152  (fOutFile) << "%ELEMENT\n";
153  int imax = (1<<fResolution);
154  (fOutFile) << ((imax*imax)*nel) << endl;
155  if(numnodes == 9) {
156  (fOutFile) << "%ELEMENT.Q4\n";
157  } else {
158  (fOutFile) << "%ELEMENT.T3\n";
159  }
160  (fOutFile) << ((imax*imax)*nel) << endl;
161  for(int64_t i=0;i<nel;i++) {
162  el = (TPZGraphEl *) fElementList[i];
163  if(el) el->Connectivity(EMVStyle);
164  }
165 }
166 
168  cout << "TPZMVGraphMesh::DrawSolution not Implemented\n";
169 }
170 
171 void TPZMVGraphMesh::DrawSolution(char * /*var = 0*/) {
172  cout << "TPZMVGraphMesh::DrawSolution not Implemented\n";
173 }
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
Contains the TPZMVGraphMesh class which implements graphical mesh to MVGraph package.
virtual int NConnects()=0
Number of connects for the element.
virtual void SequenceNodes()
Definition: pzmvmesh.cpp:114
TPZVec< std::string > fScalarNames
Vectors of the variables names (scalar, vectorial, and tensorial)
Definition: pzgraphmesh.h:127
void DrawSolution(int solutionid, TPZDrawStyle st=EDXStyle)
Draw solution on the current connect for solutionid variable.
Definition: pzgraphnode.cpp:89
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
TPZVec< std::string > VecNames()
Return vectorial variable names.
Definition: pzgraphmesh.h:146
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
Contains the TPZGraphEl class which implements the graphical one-, two- and three-dimensional element...
Contains the TPZGraphNode class which implements the graphical node.
TPZMVGraphMesh(TPZCompMesh *cmesh, int dimension, const std::set< int > &matids, const TPZVec< std::string > &scalarnames, const TPZVec< std::string > &vecnames)
Constructor for graphical mesh using MVGraph format.
Definition: pzmvmesh.cpp:14
int64_t NElements() const
Access method to query the number of elements of the vector.
int64_t FirstPoint()
Definition: pzgraphnode.cpp:55
std::set< int > MaterialIds()
Get material ids.
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual void SequenceNodes()
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
Definition: TPZDrawStyle.h:12
void SetPointNumber(int64_t num)
Definition: pzgraphnode.cpp:65
TPZDrawStyle fStyle
Style of the graphical file.
Definition: pzgraphmesh.h:123
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
Definition: pzcmesh.cpp:297
TPZVec< std::string > fVecNames
Definition: pzgraphmesh.h:127
virtual void DrawMesh(int numcases)
Draw graphical mesh.
Definition: pzmvmesh.cpp:28
Contains declaration of TPZCompMesh class which is a repository for computational elements...
std::ofstream fOutFile
Definition: pzgraphmesh.h:124
virtual void DrawSolution(int step, REAL time)
Draw solution depending on the resolution.
Definition: pzmvmesh.cpp:45
virtual void DrawConnectivity(MElementType type)
Draw the connectivity information.
Definition: pzmvmesh.cpp:146
int fResolution
Resolution of the graphical object.
Definition: pzgraphmesh.h:121
virtual void Connectivity(TPZDrawStyle st=EDXStyle)=0
Set dx style for connectivity information.
TPZAdmChunkVector< TPZGraphNode > fNodeMap
Vector of graphical nodes (connects)
Definition: pzgraphmesh.h:119
void DrawCo(TPZDrawStyle st=EDXStyle)
Draw coordinates of the graphical node.
Definition: pzgraphnode.cpp:84
Implements block matrices. Matrix utility.
MElementType
Define the element types.
Definition: pzeltype.h:52
TPZVec< std::string > ScalarNames()
Return scalar variable names.
Definition: pzgraphmesh.h:140
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
Definition: pzeltype.h:61
void Fill(const T &copy, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
Definition: pzvec.h:460
Abstract class to graphical one-, two- and three-dimensional element. Post processing.
Definition: pzgraphel.h:23
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
TPZCompMesh * fCompMesh
Computational mesh associated.
Definition: pzgraphmesh.h:109
std::set< int > fMaterialIds
Set of material ids being post-processed.
Definition: pzgraphmesh.h:113
virtual void DrawNodes()
Draw the graphical nodes information.
Definition: pzmvmesh.cpp:126
int64_t NPoints()
Number of points to drawing, depending on the resolution.
Implements graphical mesh to MVGraph package. Post processing.
Definition: pzmvmesh.h:23
To export a graphical node. Post processing.
Definition: pzgraphnode.h:24
TPZAdmChunkVector< TPZGraphEl * > fElementList
Vector of graphical elements.
Definition: pzgraphmesh.h:117