NeoPZ
pzgraphel.cpp
Go to the documentation of this file.
1 
6 #include "pzgraphel.h"
7 #include "pzgraphmesh.h"
8 #include "pzcompel.h"
9 #include "pzgeoel.h"
10 #include "TPZMaterial.h"
11 
12 using namespace std;
13 
15 {
16  fCompEl = cel;
17  fGraphMesh = gmesh;
18  fId = cel->Index();
19  TPZGraphNode *gno;
20  for(int j = 0; j < cel->Reference()->NSides(); j++) {
21  TPZConnect &cn = cel->Connect(j);
22  int64_t newsize = cn.SequenceNumber()+1;
23  if( gmesh->NodeMap().NElements() < newsize ) {
24  gmesh->NodeMap().Resize(newsize);
25  }
26  gno = &gmesh->NodeMap()[cn.SequenceNumber()];
27  if(gno->SequenceNumber() ==-1) {
28  gno->SetElement(this);
30  gno->SetConnect(&cn);
31  gno->SetGraphMesh(gmesh);
32  }
33  connectvec[j] = gno;
34  }
35  int64_t index = gmesh->ElementList().AllocateNewElement();
36  gmesh->ElementList()[index] = this;
37 }
38 
40  fCompEl = cel;
41  fGraphMesh = gmesh;
42  fId = cel->Index();
43  int64_t index = gmesh->NodeMap().AllocateNewElement();
44  TPZGraphNode *gno = &gmesh->NodeMap()[index];
45  gno->SetElement(this);
46  gno->SetSequenceNumber(index);
47  gno->SetConnect(0);
48  gno->SetGraphMesh(gmesh);
49  connect = gno;
50 
51  index = gmesh->ElementList().AllocateNewElement();
52  gmesh->ElementList()[index] = this;
53 }
54 
56 }
57 
59 {
60 }
61 
62 void TPZGraphEl::QsiEta(TPZVec<int> &i, int imax, TPZVec<REAL> &qsieta)
63 {
64  int64_t ind,nel=i.NElements();
65  for(ind=0; ind<nel; ind++)
66  {
67  qsieta[ind] = (-1.0+(i[ind]*2.0/imax));
68  }
69 }
70 
71 
73  int nn = NConnects();
74  for(int i=0;i<nn;i++) if(n==Connect(i)) return i;
75  return 0;
76 }
77 
78 
80 {
81  int in = ConnectNum(n);
82  //int i,j,incr;
83  int incr;
84  int dim = this->Dimension();
85  TPZVec<int> co(dim,0);
86  FirstIJ(in,co,incr);
87  // ComputeSequence(n, ibound, incr);
88  int64_t ip = n->FirstPoint();
89  int res = fGraphMesh->Res();
90  int imax;
91  imax = 1 << res;
92  int np = NPoints(n);
93  int point=0;
94  TPZManVector<REAL,3> qsi(dim,0.),x(3,0.);
95  while(point < np) {
96  QsiEta(co,imax,qsi);
97  fCompEl->Reference()->X(qsi,x);
98  if(st == EMVStyle || st == EV3DStyle) fGraphMesh->Out() << ip++ << " ";
99  fGraphMesh->Out() << x[0] << " " << x[1] << " " << x[2] << endl;
100  NextIJ(in,co,incr);
101  point++;
102  }
103 }
104 
106  TPZManVector<int> sol(1,solind);
107  DrawSolution(n,sol,st);
108 }
109 
111 }
112 
114 {
115  int in = ConnectNum(n);
116  //int i,j,incr;
117  int incr;
118  int dim = Dimension();
119  TPZManVector<int,3> co(dim,0);
120  FirstIJ(in,co,incr);
121  // ComputeSequence(n, ibound, incr);
122  int res = fGraphMesh->Res();
123  int imax;
124  int64_t numsol = solind.NElements();
125  int numvar;
126  imax = 1 << res;
127  int np = NPoints(n);
128  int point=0;
129  TPZManVector<REAL,4> qsi(dim,0.),x(4,0.);
130  TPZManVector<STATE,10> sol(6,0.);
131  int64_t ip = n->FirstPoint();
132  while(point < np)
133  {
134  QsiEta(co,imax,qsi);
135  if(st == EMVStyle || st == EV3DStyle) fGraphMesh->Out() << ip++ << " ";
136  for(int64_t is=0; is<numsol; is++)
137  {
138  fCompEl->Solution(qsi,solind[is],sol);
139  numvar = fCompEl->Material()->NSolutionVariables(solind[is]);
140  if(st == EVTKStyle)
141  {
142  if(numvar > 9) numvar = 9; // Because it 3x3 tensor variables
143  }
144  int iv;
145  for(iv=0; iv<numvar;iv++)
146  {
147 #ifdef STATE_COMPLEX //AQUIFRAN
148  if(fabs(sol[iv]) < 1.0e-20) sol[iv] = 0.0;
149  fGraphMesh->Out() << std::real(sol[iv]) << " ";
150 #else
151  if(fabs(sol[iv]) < 1.0e-20)
152  {
153  sol[iv] = 0.0;
154  }
155  fGraphMesh->Out() << sol[iv] << " ";
156 #endif
157  }
158  if((st == EMVStyle || st == EV3DStyle) && numvar ==2) fGraphMesh->Out() << 0. << " ";
159  if(st == EVTKStyle && numvar != 1)
160  {
161  for(; iv<3; iv++) fGraphMesh->Out() << 0. << " ";
162  }
163  }
164  fGraphMesh->Out() << endl;
165  NextIJ(in,co,incr);
166  point++;
167  }
168 }
169 
170 void TPZGraphEl::Print(ostream &out) {
171  out << "TPZGraphEl element id = " << fId << endl;
172  out << "Node numbers : ";
173  int i;
174  for(i=0; i<NConnects(); i++) {
175  out << Connect(i)->SequenceNumber() << " ";
176  }
177  out << endl;
178  for(i=0; i<NConnects(); i++) {
179  out << Connect(i)->FirstPoint() << " ";
180  }
181  out << endl;
182 }
183 
185  return Hash("TPZGraphEl");
186 }
187 
188 int TPZGraphEl::ClassId() const {
189  return StaticClassId();
190 }
191 
192 void TPZGraphEl::Read(TPZStream &buf, void *context) {
193  fCompEl = dynamic_cast<TPZCompEl *>(TPZPersistenceManager::GetInstance(&buf));
194  fGraphMesh = dynamic_cast<TPZGraphMesh *>(TPZPersistenceManager::GetInstance(&buf));
195  buf.Read(&fId);
196 }
197 
198 void TPZGraphEl::Write(TPZStream &buf, int withclassid) const {
200  TPZPersistenceManager::WritePointer(fGraphMesh, &buf);
201  buf.Write(&fId);
202 }
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
int AllocateNewElement()
Makes more room for new elements.
Definition: pzadmchunk.h:184
Represents a set of shape functions associated with a computational element/side. Computational Eleme...
Definition: pzconnect.h:30
void SetGraphMesh(TPZGraphMesh *mesh)
Definition: pzgraphnode.cpp:74
virtual void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzgraphel.cpp:192
Contains declaration of TPZCompEl class which defines the interface of a computational element...
void SetConnect(TPZConnect *connect)
Definition: pzgraphnode.cpp:70
Contains the TPZGraphEl class which implements the graphical one-, two- and three-dimensional element...
int64_t NElements() const
Access method to query the number of elements of the vector.
virtual int NSides() const =0
Returns the number of connectivities of the element.
int64_t FirstPoint()
Definition: pzgraphnode.cpp:55
static TPZSavable * GetInstance(const int64_t &objId)
void DrawCo(TPZGraphNode *n, TPZDrawStyle st)
Draw coordinates of the graphical node.
Definition: pzgraphel.cpp:79
static int StaticClassId()
Definition: pzgraphel.cpp:184
TPZAdmChunkVector< TPZGraphEl * > & ElementList()
Vector of the graphical elements.
Definition: TPZDrawStyle.h:12
void Resize(const int newsize)
Increase the size of the chunk vector.
Definition: pzadmchunk.h:280
virtual void SetNode(int64_t i, TPZGraphNode *n)
Sets a ith graphical node.
Definition: pzgraphel.cpp:55
int64_t SequenceNumber() const
Returns the Sequence number of the connect object.
Definition: pzconnect.h:158
virtual int ClassId() const override
Define the class id associated with the class.
Definition: pzgraphel.cpp:188
virtual void QsiEta(TPZVec< int > &i, int imax, TPZVec< REAL > &qsieta)
This method maps the index of a point to parameter space as a function of the number of divisions...
Definition: pzgraphel.cpp:62
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
Definition: TPZDrawStyle.h:12
int64_t SequenceNumber()
Definition: pzgraphnode.h:38
void SetElement(TPZGraphEl *gel)
Definition: pzgraphnode.cpp:60
TPZAdmChunkVector< TPZGraphNode > & NodeMap()
Vector of the graphical nodes.
string res
Definition: test.py:151
Definition: TPZDrawStyle.h:12
Contains the TPZGraphMesh class which represents a graphical mesh used for post processing purposes...
virtual void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzgraphel.cpp:198
REAL co[8][3]
Coordinates of the eight nodes.
int64_t Index() const
Returns element index of the mesh fELementVec list.
Definition: pzcompel.h:821
virtual TPZConnect & Connect(int i) const
Returns a pointer to the ith node.
Definition: pzcompel.cpp:298
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
void DrawSolution(TPZGraphNode *n, TPZBlock< REAL > &Sol, TPZDrawStyle st)
Draw solution of the graphical node.
Definition: pzgraphel.cpp:110
void Print(std::ostream &out)
Print the information of the graphical element.
Definition: pzgraphel.cpp:170
int ConnectNum(TPZGraphNode *n)
Returns the number of the graphical node in the vector of connects.
Definition: pzgraphel.cpp:72
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Definition: pzcompel.cpp:1137
Implements block matrices. Matrix utility.
TPZGraphEl(TPZCompEl *cel, TPZGraphMesh *gmesh, TPZGraphNode **connectvec)
Constructor of the graphical element.
Definition: pzgraphel.cpp:14
void SetSequenceNumber(int64_t seqnum)
Definition: pzgraphnode.h:39
virtual ~TPZGraphEl(void)
Default destructor.
Definition: pzgraphel.cpp:58
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
To export a graphical node. Post processing.
Definition: pzgraphnode.h:24
static void WritePointer(const TPZSavable *obj, TPZStream *stream)
TPZDrawStyle
Definition: TPZDrawStyle.h:12
virtual void Read(bool &val)
Definition: TPZStream.cpp:91