NeoPZ
pzgnode.cpp
Go to the documentation of this file.
1 
6 #include <stdio.h>
7 #include "pzgnode.h"
8 #include "pzerror.h"
9 #include "pzvec.h"
10 #include "pzgmesh.h"
11 #include "Hash/TPZHash.h"
12 
13 using namespace std;
16  mesh.SetNodeIdUsed(id);
17  fId = id;
18  int i,dim=coord.NElements();
19  if(dim > 3) dim = 3;
20  for(i=0;i<dim;i++) fCoord[i] = coord[i];
21  for(;i<3;i++) fCoord[i] = 0.;
22 }
24  fId = -1;
25  for(int i=0;i<3;i++) fCoord[i] = 0.;
26 }
28  fId = node.Id();
29  for(int i=0;i<3;i++) fCoord[i] = node.Coord(i);
30 }
31 
33  fId = node.Id();
34  for(int i=0;i<3;i++) fCoord[i] = node.Coord(i);
35  return *this;
36 }
37 
39  fId = mesh.CreateUniqueNodeId();
40  int i,dim = coord.NElements();
41  if(dim > 3) dim = 3;
42  for(i=0;i<dim;i++) fCoord[i]=coord[i];
43  for(;i<3;i++) fCoord[i]=0.;
44 }
45 void TPZGeoNode::Initialize(int id,TPZVec<REAL> &coord,TPZGeoMesh &mesh) {
46  fId = id;
47  mesh.SetNodeIdUsed(id);
48  int i,dim = coord.NElements();
49  if(dim > 3) dim = 3;
50  for(i=0;i<dim;i++) fCoord[i]=coord[i];
51  for(;i<3;i++) fCoord[i]=0.;
52 }
53 void TPZGeoNode::Initialize(const TPZGeoNode &node,TPZGeoMesh &mesh) {
54  fId = node.fId;
55  mesh.SetNodeIdUsed(fId);
56  int i;
57  for(i=0;i<3;i++) fCoord[i]=node.fCoord[i];
58 }
59 
61  const int dim = x.NElements();
62 #ifdef PZDEBUG
63  if(dim > 3 || dim < 1) {
64  PZError << "TPZGeoNode::SetCoord with bad parameter dim." << endl;
65  DebugStop();
66  return;
67  }
68 #endif
69  int i;
70  for(i=0;i<dim;i++) fCoord[i] = x[i];
71  for(;i<3;i++) fCoord[i] = 0.;
72 }
73 
74 void TPZGeoNode::SetCoord(int i,REAL coord) {
75  if(i > 2 || i < 0) {
76  PZError << "TPZGeoNode::SetCoord with bad parameter i-th coordinate." << endl;
77  return;
78  }
79  fCoord[i] = coord;
80 }
81 
82 // fill the coordinates of the node
84 {
85  for(int i=0; i<3; i++) co[i] = fCoord[i];
86 }
87 
88 void TPZGeoNode::Print(ostream & out) {
89  out << "Node : fId = " << fId;
90  out << " Coordinates";
91  for(int i=0;i<3;i++) out << "\t" << fCoord[i];
92  out << "\n";
93 }
94 
95 // return the id of the class (used for writing reading the object)
96 int TPZGeoNode::ClassId() const{
97  return Hash("TPZGeoNode");
98 }
99 
100 #ifndef BORLAND
101 template class TPZRestoreClass<TPZGeoNode>;
102 #endif
103 
void SetCoord(const TPZVec< REAL > &x)
Sets all coordinates into the current node. It gets the dim values from x.
Definition: pzgnode.cpp:60
int64_t CreateUniqueNodeId()
Returns ++fNodeMaxId.
Definition: pzgmesh.h:114
Contains declaration of TPZGeoNode class which defines a geometrical node.
REAL Coord(int i) const
Returns i-th coordinate of the current node.
Definition: pzgnode.h:99
Templated vector implementation.
Defines PZError.
TPZGeoNode & operator=(const TPZGeoNode &node)
Definition: pzgnode.cpp:32
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
TPZGeoNode()
Constructor to new node.
Definition: pzgnode.cpp:23
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
int fId
Identity of node.
Definition: pzgnode.h:34
REAL co[8][3]
Coordinates of the eight nodes.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
void Print(std::ostream &out=std::cout)
Print the node data into out.
Definition: pzgnode.cpp:88
void SetNodeIdUsed(int64_t id)
Indicates that a node with id was created.
Definition: pzgmesh.h:108
int ClassId() const override
Returns the id of the class (used for writing reading the object)
Definition: pzgnode.cpp:96
Implements a geometric node in the pz environment. Geometry.
Definition: pzgnode.h:31
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
void Initialize(TPZVec< REAL > &coord, TPZGeoMesh &mesh)
Initialize the data structure of the node. Creates a unique id for the node automatically.
Definition: pzgnode.cpp:38
int Id() const
Returns the identity of the current node.
Definition: pzgnode.h:68
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
void GetCoordinates(TPZVec< REAL > &co)
Fill the coordinates of the node.
Definition: pzgnode.cpp:83
Implements an interface to register a class id and a restore function. Persistence.
Definition: TPZSavable.h:150
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
REAL fCoord[3]
Node coordinates.
Definition: pzgnode.h:36