NeoPZ
pzv3dmesh.cpp
Go to the documentation of this file.
1 
6 #include "pzv3dmesh.h"
7 #include "pzcmesh.h"
8 #include "TPZMaterial.h"
9 #include "pzgraphnode.h"
10 #include "pzgraphel.h"
11 #include "pzvec.h"
12 
13 #include <fstream>
14 
15 using namespace std;
16 
17 TPZV3DGraphMesh::TPZV3DGraphMesh(TPZCompMesh *cmesh, int dimension, const std::set<int> & matids, const TPZVec<std::string> &scalarnames,
18  const TPZVec<std::string> &vecnames) : TPZGraphMesh(cmesh,dimension,matids,scalarnames,vecnames) {
19  fMesh = cmesh;
20  fStyle = EV3DStyle;
21  fNumCases = 0;
22  fTotScal = 0;
23  fInterval = 0;
24  fLoadStep = 0;
25  for(int i=0; i<6; i++) fNumScal[i] = 0;
26 }
27 
29 TPZGraphMesh(cmesh,dimension,graph->fMaterialIds,graph->ScalarNames(),graph->VecNames()) {
30  fMesh = cmesh;
31  fStyle = EV3DStyle;
32  fNumCases = graph->fNumCases;
33  fTotScal = graph->fTotScal;
34  fInterval = graph->fInterval;
35  fLoadStep = graph->fLoadStep;
36  for(int i=0; i<6; i++) fNumScal[i] = graph->fNumScal[i];
37 }
38 
39 void TPZV3DGraphMesh::DrawMesh(int numcases){
40  if(!fOutFile) return;
41  (fOutFile) << "File generated by the PZ environment\n";
42  (fOutFile) << "2 Dimensional grid\n";
43  (fOutFile) << "dim 3\n";
44  (fOutFile) << "coor " << NPoints() << endl;
45  DrawNodes();
46  (fOutFile) << "nomax 4\n";
48  int nel=0,type;
49  for(type=1;type<4;type++)nel+= NElements(eltypes[type]);
50  (fOutFile) << "elem " << nel << endl;
51  for(type=1;type<4;type++)DrawConnectivity(eltypes[type]);
52  fNumCases = numcases;
53  fInterval = ((numcases-1)/5)+1;
54  fLoadStep = 0;
55 }
56 // Draw the nodal coordinates and the connectivity
57 
59  cout << "TPZV3DGraphMesh::DrawSolution(TPZBlock &) not implemented\n";
60 }
61 // Draw the solution associated with Sol (not implemented)
62 void TPZV3DGraphMesh::DrawSolution(char * /*var*/){
63  cout << "TPZV3DGraphMesh::DrawSolution(char *) not implemented\n";
64 }
65 // Draw the solution associated with the variable name
66 void TPZV3DGraphMesh::DrawSolution(int step, REAL /*time*/){
67  if(step+1 != fNumCases && step%fInterval) return;
68  int numscal = fScalarNames.NElements();
69  int numvec = fVecNames.NElements();
70  if(numscal > 6) {
71  cout << "View3d only allows for 6 scalars numscal = " << numscal << endl;
72  numscal = 6;
73  }
74  if(numscal+fTotScal >6) {
75  cout << "View3d total number of cases cannot exceed 6 values\n";
76  numscal = 6-fTotScal;
77  }
78  fTotScal += numscal;
79  if(step < fNumCases-1 && numvec) {
80  cout << "Vector values only allowed at the last step\n";
81  numvec = 0;
82  }
83  if(numvec > 1) {
84  cout << "View3d only allows for 1 vector variable = " << numvec << endl;
85  numvec = 1;
86  }
87  if(fLoadStep < 6) fNumScal[fLoadStep] = numscal;
88  fOutFile.close();
89  char tempfilename[] = "temp0.dat";
90  tempfilename[3] += (char) fLoadStep;
91  fOutFile.open(tempfilename);
92 
93  TPZVec<int> scalind(numscal);
94  TPZVec<int> vecind(numvec);
95  scalind.Fill(-1);
96  vecind.Fill(-1);
97 
98  std::set<int> matids = MaterialIds();
99  if(matids.size() == 0) {
100  cout << "TPZMVGraphMesh no material found\n";
101  return;
102  }
103  set<int>::iterator it = matids.begin();
104  TPZMaterial * matp = fCompMesh->FindMaterial(*it);
105  if(!matp) {
106  cout << "TPZV3DGraphMesh::DrawSolution material not found" << endl;
107  return;
108  }
109  int n;
110  for(n=0; n<numscal; n++) {
111  scalind[n] = matp->VariableIndex(fScalarNames[n]);
112  }
113  for(n=0; n<numvec; n++) {
114  vecind[n] = matp->VariableIndex(fVecNames[n]);
115  }
116  if(numscal > 0) {
117  (fOutFile) << "nosc " << numscal << endl;
118  int64_t nnod = fNodeMap.NElements();
119  for(int64_t i=0;i<nnod;i++) {
120  TPZGraphNode *np = &fNodeMap[i];
121  if(np) np->DrawSolution(scalind, fStyle);
122  }
123  }
124  ifstream *tempread[6];
125  REAL values;
126  int icase;
127  if(fNumCases == step+1 && fNumCases > 1) {
128  for(icase=0; icase<=fLoadStep; icase++) {
129  char fname[] = "temp0.dat";
130  fname[3] += (char) icase;
131  tempread[icase] = new ifstream(fname);
132  }
133  int64_t nump = NPoints();
134  (fOutFile) << "nosc " << fTotScal << endl;
135  char buf[256];
136  for(icase=0; icase<=fLoadStep; icase++) tempread[icase]->getline(buf,255);
137  for(int64_t iv=0; iv<nump; iv++) {
138  for(icase=0; icase<=fLoadStep; icase++) {
139  int64_t nodindex;
140  (*tempread[icase]) >> nodindex;
141  if(icase == 0) (fOutFile) << nodindex << ' ';
142  for(int iscal=0; iscal<fNumScal[icase]; iscal++) {
143  (*tempread[icase]) >> values; (fOutFile) << values << ' ';
144  }
145  }
146  (fOutFile) << endl;
147  }
148  for(icase=0; icase <=fLoadStep; icase++) delete tempread[icase];
149  }
150  if(numvec > 0) {
151  (fOutFile) << "nvec\n";
152  int64_t nnod = fNodeMap.NElements();
153  for(int64_t i=0;i<nnod;i++) {
154  TPZGraphNode *np = &fNodeMap[i];
155  if(np) np->DrawSolution(vecind, fStyle);
156  }
157  }
158  if(step+1 == fNumCases) (fOutFile) << "fim\n";
159  if(fLoadStep <5) fLoadStep++;
160 }
161 
164  int64_t nnod = fNodeMap.NElements();
165  for(int64_t i=0;i<nnod;i++) {
166  TPZGraphNode *n = &fNodeMap[i];
167  if(n) n->SetPointNumber(n->FirstPoint()+1);
168  }
169 }
170 
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
virtual void SequenceNodes()
Definition: pzv3dmesh.cpp:162
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)
virtual void DrawConnectivity(MElementType type)
Draw the connectivity information.
Templated vector implementation.
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.
To export a graphical three dimensional mesh to use at V3D package. Post processing.
Definition: pzv3dmesh.h:20
TPZCompMesh * fMesh
Definition: pzv3dmesh.h:46
Contains the TPZGraphEl class which implements the graphical one-, two- and three-dimensional element...
Contains the TPZGraphNode class which implements the graphical node.
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 DrawNodes()
Draw the graphical nodes information.
virtual void SequenceNodes()
Contains the TPZV3DGraphMesh class which implements the graphical three dimensional mesh to use at V3...
void SetPointNumber(int64_t num)
Definition: pzgraphnode.cpp:65
TPZDrawStyle fStyle
Style of the graphical file.
Definition: pzgraphmesh.h:123
virtual void DrawMesh(int numcases)
Draw the nodal coordinates and the connectivity.
Definition: pzv3dmesh.cpp:39
TPZMaterial * FindMaterial(int id)
Find the material with identity id.
Definition: pzcmesh.cpp:297
Definition: TPZDrawStyle.h:12
TPZVec< std::string > fVecNames
Definition: pzgraphmesh.h:127
Contains declaration of TPZCompMesh class which is a repository for computational elements...
std::ofstream fOutFile
Definition: pzgraphmesh.h:124
TPZV3DGraphMesh(TPZCompMesh *cmesh, int dimension, const std::set< int > &matids, const TPZVec< std::string > &scalarnames, const TPZVec< std::string > &vecnames)
Constructor for graphical mesh using 3D Image Visualization format.
Definition: pzv3dmesh.cpp:17
TPZAdmChunkVector< TPZGraphNode > fNodeMap
Vector of graphical nodes (connects)
Definition: pzgraphmesh.h:119
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
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
int64_t NElements(MElementType type)
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
def values
Definition: rdt.py:119
Definition: pzeltype.h:55
int64_t NPoints()
Number of points to drawing, depending on the resolution.
virtual void DrawSolution(TPZBlock< REAL > &Sol)
Draw the solution associated with Sol (not implemented)
Definition: pzv3dmesh.cpp:58
To export a graphical node. Post processing.
Definition: pzgraphnode.h:24
int fNumScal[6]
Definition: pzv3dmesh.h:51