xc
Mesh.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 //Mesh.h
28 
29 #ifndef Mesh_h
30 #define Mesh_h
31 
32 #include "domain/mesh/MeshComponentContainer.h"
33 #include "utility/matrix/Vector.h"
34 #include "NodeLockers.h"
35 #include "solution/graph/graph/Graph.h"
36 #include "node/KDTreeNodes.h"
37 #include "element/utils/KDTreeElements.h"
38 
39 class Pos3d;
40 
41 namespace XC {
42 class Element;
43 class Node;
44 
45 class ElementIter;
46 class NodeIter;
47 class SingleDomEleIter;
48 class SingleDomNodIter;
49 
50 class Graph;
51 class NodeGraph;
52 class ElementGraph;
53 class FEM_ObjectBroker;
54 class TaggedObjectStorage;
55 class RayleighDampingFactors;
56 
58 //
60 //
62 //
65  {
66  private:
67  bool eleGraphBuiltFlag;
68  bool nodeGraphBuiltFlag;
69 
70  Graph theNodeGraph;
71  Graph theElementGraph;
72 
73  TaggedObjectStorage *theNodes;
74  SingleDomNodIter *theNodIter;
75  KDTreeNodes kdtreeNodes;
76  std::vector<std::string> nombresCoordenadas;
77  std::string nombreUnidades;
78 
79  TaggedObjectStorage *theElements;
80  SingleDomEleIter *theEleIter;
81  KDTreeElements kdtreeElements;
82 
83  Vector theBounds;
84  int tagNodeCheckReactionException;
85 
86  NodeLockers lockers;
87 
88  void alloc_containers(void);
89  void alloc_iters(void);
90  bool check_containers(void) const;
91  void init_bounds(void);
92  void update_bounds(const Vector &);
93  void add_node_to_domain(Node *);
94  void add_element_to_domain(Element *);
95  void add_nodes_to_domain(void);
96  void add_elements_to_domain(void);
97 
98  Mesh(const Mesh &otra);
99  Mesh &operator=(const Mesh &otra);
100  protected:
101  void free_mem(void);
102  DbTagData &getDbTagData(void) const;
103  int sendData(CommParameters &);
104  int recvData(const CommParameters &);
105  public:
106  Mesh(CommandEntity *owr);
107  Mesh(CommandEntity *owr,TaggedObjectStorage &theNodesStorage, TaggedObjectStorage &theElementsStorage);
108  Mesh(CommandEntity *owr,TaggedObjectStorage &theStorageType);
109  virtual ~Mesh(void);
110 
111  // methods to populate a mesh
112  virtual bool addNode(Node *);
113  virtual bool removeNode(int tag);
114 
115  virtual bool addElement(Element *);
116  virtual bool removeElement(int tag);
117 
118  virtual void clearAll(void);
119 
120  void setNodeReactionException(const int &);
121  bool checkNodalReactions(const double &);
122 
123  void clearDOF_GroupPtr(void);
124 
125  void setGraphBuiltFlags(const bool &f);
126 
127  int initialize(void);
128  virtual int setRayleighDampingFactors(const RayleighDampingFactors &rF);
129 
130  // methods to access the components of a mesh
131  inline const TaggedObjectStorage *nodes(void) const
132  { return theNodes; }
133  inline TaggedObjectStorage *nodes(void)
134  { return theNodes; }
135  inline const TaggedObjectStorage *elements(void) const
136  { return theElements; }
137  inline TaggedObjectStorage *elements(void)
138  { return theElements; }
139  virtual ElementIter &getElements();
140  virtual NodeIter &getNodes();
141  inline const NodeLockers &getNodeLockers(void) const
142  { return lockers; }
143  inline NodeLockers &getNodeLockers(void)
144  { return lockers; }
145 
146  bool existElement(int tag);
147  virtual Element *getElement(int tag);
148  virtual const Element *getElement(int tag) const;
149  Element *getNearestElement(const Pos3d &p);
150  const Element *getNearestElement(const Pos3d &p) const;
151  bool existNode(int tag);
152  virtual Node *getNode(int tag);
153  virtual const Node *getNode(int tag) const;
154  Node *getNearestNode(const Pos3d &p);
155  const Node *getNearestNode(const Pos3d &p) const;
156 
157  // methods to query the state of the mesh
158  virtual int getNumElements(void) const;
159  virtual int getNumNodes(void) const;
160  size_t getNumDeadElements(void) const;
161  size_t getNumLiveElements(void) const;
162  size_t getNumDeadNodes(void) const;
163  size_t getNumLiveNodes(void) const;
164  size_t getNumFrozenNodes(void) const;
165  size_t getNumFreeNodes(void) const;
166  virtual const Vector &getPhysicalBounds(void);
167 
168  inline const std::vector<std::string> &getNombresCoordenadas(void) const
169  { return nombresCoordenadas; }
170  inline std::string getNombreUnidades(void) const
171  { return nombreUnidades; }
172 
173 
174  // methods to get element and node graphs
175  virtual int buildEleGraph(Graph &theEleGraph);
176  virtual int buildNodeGraph(Graph &theNodeGraph);
177  virtual Graph &getElementGraph(void);
178  virtual Graph &getNodeGraph(void);
179 
180  virtual int commit(void);
181  virtual int revertToLastCommit(void);
182  virtual int revertToStart(void);
183  int update(void);
184 
185  void freeze_dead_nodes(const std::string &nmbLocker);
186  void melt_alive_nodes(const std::string &nmbLocker);
187 
188  const double getEffectiveModalMass(int mode) const;
189  Vector getEffectiveModalMasses(const int &numModes) const;
190 
191  void zeroLoads(void);
192 
193  virtual void Print(std::ostream &s, int flag =0);
194  friend std::ostream &operator<<(std::ostream &, Mesh &);
195 
196  virtual int sendSelf(CommParameters &);
197  virtual int recvSelf(const CommParameters &);
198 
199  // nodal methods required in mesh interface for parallel interprter
200  virtual double getNodeDisp(int nodeTag, int dof, int &errorFlag);
201  virtual int setMass(const Matrix &mass, int nodeTag);
202 
203  virtual int calculateNodalReactions(bool inclInertia, const double &);
204 
205  static void setDeadSRF(const double &);
206  };
207 
208 std::ostream &operator<<(std::ostream &, Mesh &);
209 } // end of XC namespace
210 
211 #endif
212 
213 
int sendData(CommParameters &)
Send object members through the channel being passed as parameter.
Definition: Mesh.cc:1063
void zeroLoads(void)
Loop over nodes and elements getting them to first zero their loads.
Definition: Mesh.cc:731
void setNodeReactionException(const int &)
Assign the exception for reaction checking (see Mesh::checkNodalReactions).
Definition: Mesh.cc:1147
Float vector abstraction.
Definition: Vector.h:93
virtual int revertToStart(void)
Return the mesh into its initial state.
Definition: Mesh.cc:808
static void setDeadSRF(const double &)
Assigns Stress Reduction Factor for element deactivation.
Definition: Mesh.cc:189
virtual int revertToLastCommit(void)
Returns the mesh to its last commited state.
Definition: Mesh.cc:788
Vector getEffectiveModalMasses(const int &numModes) const
Returns the masas modales efectivas.
Definition: Mesh.cc:722
void clearDOF_GroupPtr(void)
Clears the pointers to node DOF groups.
Definition: Mesh.cc:400
virtual int recvSelf(const CommParameters &)
Receives object through the channel being passed as parameter.
Definition: Mesh.cc:1102
virtual double getNodeDisp(int nodeTag, int dof, int &errorFlag)
Returns the component of the displacement of the node wich the tag is being passed as parameter...
Definition: Mesh.cc:1119
NodeLocker container.
Definition: NodeLockers.h:41
bool existNode(int tag)
Returns true if the mesh has a node with the tag being passed as parameter.
Definition: Mesh.cc:466
DbTagData & getDbTagData(void) const
Returns a vector to store the dbTags de los miembros of the clase.
Definition: Mesh.cc:1056
Definition: SingleDomNodIter.h:70
size_t getNumDeadNodes(void) const
Returns the number of inactive nodes on the mesh.
Definition: Mesh.cc:600
int initialize(void)
Inicializa.
Definition: Mesh.cc:745
size_t getNumLiveNodes(void) const
Returns the number of active nodes on the mesh.
Definition: Mesh.cc:585
Node * getNearestNode(const Pos3d &p)
Returns the node closest to the point being passed as parameter.
Definition: Mesh.cc:492
virtual void clearAll(void)
Deletes from domain all its components (nodes, elements, loads and constraints).
Definition: Mesh.cc:167
Iterator over an element container.
Definition: ElementIter.h:73
virtual int sendSelf(CommParameters &)
Sends object through the channel being passed as parameter.
Definition: Mesh.cc:1088
virtual int commit(void)
Commits mesh state.
Definition: Mesh.cc:771
virtual const Vector & getPhysicalBounds(void)
Definition: Mesh.cc:651
size_t getNumFrozenNodes(void) const
Returns the number of frozen nodes on the mesh.
Definition: Mesh.cc:615
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:43
virtual int getNumNodes(void) const
Returns the number of nodes.
Definition: Mesh.cc:551
virtual ElementIter & getElements()
Returns an iterator to the mesh elements.
Definition: Mesh.cc:409
size_t getNumDeadElements(void) const
Returns the number of inactive elements on the mesh.
Definition: Mesh.cc:570
virtual Element * getElement(int tag)
Returns a pointer to the element identified by the tag being passed as parameter. ...
Definition: Mesh.cc:428
virtual NodeIter & getNodes()
Returns an iterator a the nodes del domain.
Definition: Mesh.cc:416
const double getEffectiveModalMass(int mode) const
Return the masa modal efectiva corresponding to the mode i.
Definition: Mesh.cc:710
virtual int buildEleGraph(Graph &theEleGraph)
Builds the element&#39;s graph.
Definition: Mesh.cc:882
Base class for the finite elements.
Definition: Element.h:109
virtual ~Mesh(void)
Destructor.
Definition: Mesh.cc:184
virtual Node * getNode(int tag)
Returns a pointer to the node which tag being passed as parameter.
Definition: Mesh.cc:470
virtual bool addElement(Element *)
Appends to the mesh the element being passed as parameter.
Definition: Mesh.cc:230
void melt_alive_nodes(const std::string &nmbLocker)
Clears the constraints over activated nodes previously created by the freeze method.
Definition: Mesh.cc:528
bool existElement(int tag)
Returns true if the mesh has an element with the tag being passed as parameter.
Definition: Mesh.cc:423
void free_mem(void)
Frees memory occupied by mesh components.
Definition: Mesh.cc:62
bool checkNodalReactions(const double &)
Checks that all free nodes have zero reactions.
Definition: Mesh.cc:1151
int recvData(const CommParameters &)
Receives object members through the channel being passed as parameter.
Definition: Mesh.cc:1074
The Graph class provides the abstraction of a graph.
Definition: Graph.h:93
Element * getNearestElement(const Pos3d &p)
Returns a pointer to the nearest element to the point being passed as parameter.
Definition: Mesh.cc:452
virtual bool removeElement(int tag)
Deletes the element identified by the tag being passed as parameter.
Definition: Mesh.cc:355
virtual Graph & getElementGraph(void)
Builds the elements graph of the mesh (if not builded yet) and returns a reference to it...
Definition: Mesh.cc:663
void setGraphBuiltFlags(const bool &f)
Returns true if the modelo ha cambiado.
Definition: Mesh.cc:851
int update(void)
Update the element&#39;s state.
Definition: Mesh.cc:832
Base class for the element and constraint containers.
Definition: MeshComponentContainer.h:40
virtual int buildNodeGraph(Graph &theNodeGraph)
Builds the node graph.
Definition: Mesh.cc:993
size_t getNumFreeNodes(void) const
Returns the number of free nodes on the mesh.
Definition: Mesh.cc:630
Rayleigh damping factors.
Definition: RayleighDampingFactors.h:58
size_t getNumLiveElements(void) const
Returns the number of active elements on the mesh.
Definition: Mesh.cc:555
Definition: KDTreeElements.h:59
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
virtual Graph & getNodeGraph(void)
Builds (if needed) the graph of the domain nodes and returns a reference to it.
Definition: Mesh.cc:691
Iterator over the nodes.
Definition: NodeIter.h:73
Communication parameters between processes.
Definition: CommParameters.h:65
Matrix of floats.
Definition: Matrix.h:108
Definition: SingleDomEleIter.h:71
virtual void Print(std::ostream &s, int flag=0)
Imprime el domain.
Definition: Mesh.cc:858
void freeze_dead_nodes(const std::string &nmbLocker)
Freezes inactive nodes (prescribes zero displacement for all DOFs on inactive nodes).
Definition: Mesh.cc:507
virtual int getNumElements(void) const
Returns the number of elements.
Definition: Mesh.cc:547
virtual int setRayleighDampingFactors(const RayleighDampingFactors &rF)
Set Rayleigh damping factors.
Definition: Mesh.cc:755
Mesh node.
Definition: Node.h:110
Definition: KDTreeNodes.h:58
virtual int calculateNodalReactions(bool inclInertia, const double &)
Calculate nodal reaction forces and moments.
Definition: Mesh.cc:1176
Finite element mesh.
Definition: Mesh.h:64
virtual bool removeNode(int tag)
Remove from mesh the node identified by the argument.
Definition: Mesh.cc:380
virtual int setMass(const Matrix &mass, int nodeTag)
Set the mass matrix for the node identified by the argument.
Definition: Mesh.cc:1138
virtual bool addNode(Node *)
Adds to the domain the node being passed as parameter.
Definition: Mesh.cc:322