XC Open source finite element analysis program
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 kdtreeNodos;
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_contenedores(void);
89  void alloc_iters(void);
90  bool check_contenedores(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 libera(void);
102  DbTagData &getDbTagData(void) const;
103  int sendData(CommParameters &);
104  int recvData(const CommParameters &);
105  public:
106  Mesh(EntCmd *owr);
107  Mesh(EntCmd *owr,TaggedObjectStorage &theNodesStorage, TaggedObjectStorage &theElementsStorage);
108  Mesh(EntCmd *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  void 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 &s, Mesh &M);
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 } // end of XC namespace
208 
209 #endif
210 
211 
Base class for the element and constraint containers.
Definition: MeshComponentContainer.h:40
void melt_alive_nodes(const std::string &nmbLocker)
Clears the constraints over activated nodes previously created by the freeze method.
Definition: Mesh.cc:484
bool existElement(int tag)
Returns true if the mesh has an element with the tag being passed as parameter.
Definition: Mesh.cc:380
virtual int getNumNodes(void) const
Returns the número de nodos.
Definition: Mesh.cc:506
virtual void clearAll(void)
Deletes from domain all its components (nodes, elements, loads and constraints). GENERAL NOTE ON REMO...
Definition: Mesh.cc:167
virtual bool removeElement(int tag)
Deletes the element identified by the tag being passed as parameter.
Definition: Mesh.cc:318
virtual int revertToStart(void)
Return the mesh into its initial state.
Definition: Mesh.cc:740
virtual bool addElement(Element *)
Appends to the domain the element being passed as parameter.
Definition: Mesh.cc:220
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:1033
void zeroLoads(void)
Loop over nodes and elements getting them to first zero their loads.
Definition: Mesh.cc:663
virtual NodeIter & getNodes()
Returns an iterator a los nodos del domain.
Definition: Mesh.cc:373
Finite element mesh.
Definition: Mesh.h:64
virtual bool addNode(Node *)
Adds to the domain the node being passed as parameter.
Definition: Mesh.cc:298
virtual int recvSelf(const CommParameters &)
Receives object through the channel being passed as parameter.
Definition: Mesh.cc:1017
Definition: Vector.h:82
Vector que almacena los dbTags de los miembros de la clase.
Definition: DbTagData.h:43
virtual int sendSelf(CommParameters &)
Sends object through the channel being passed as parameter.
Definition: Mesh.cc:1004
bool existNode(int tag)
Returns true if the mesh has a node with the tag being passed as parameter.
Definition: Mesh.cc:423
size_t getNumFrozenNodes(void) const
Returns the number of frozen nodes on the mesh.
Definition: Mesh.cc:570
Iterator over an element container.
Definition: ElementIter.h:73
virtual int calculateNodalReactions(bool inclInertia, const double &)
Calculate nodal reaction forces and moments.
Definition: Mesh.cc:1085
virtual const Vector & getPhysicalBounds(void)
Returns the BND del modelo.
Definition: Mesh.cc:600
static void setDeadSRF(const double &)
Assigns Stress Reduction Factor for element deactivation.
Definition: Mesh.cc:189
void freeze_dead_nodes(const std::string &nmbLocker)
Freezes inactive nodes (prescribes zero displacement for all DOFs on inactive nodes).
Definition: Mesh.cc:464
virtual void Print(std::ostream &s, int flag=0)
Imprime el domain.
Definition: Mesh.cc:786
Mesh node.
Definition: Node.h:99
Definition: KDTreeNodes.h:58
virtual int revertToLastCommit(void)
Returns the mesh to its last commited state.
Definition: Mesh.cc:720
Node * getNearestNode(const Pos3d &p)
Returns the nodo closest to the point being passed as parameter.
Definition: Mesh.cc:449
virtual int commit(void)
Commits mesh state.
Definition: Mesh.cc:703
Element * getNearestElement(const Pos3d &p)
Returns a pointer to the nearest element to the point being passed as parameter.
Definition: Mesh.cc:409
Vector getEffectiveModalMasses(const int &numModes) const
Returns the masas modales efectivas.
Definition: Mesh.cc:654
const double getEffectiveModalMass(int mode) const
Return the masa modal efectiva correspondiente al modo i.
Definition: Mesh.cc:642
virtual int buildEleGraph(Graph &theEleGraph)
Builds the element&#39;s graph.
Definition: Mesh.cc:805
Base calass for the finite elements.
Definition: Element.h:104
Definition: KDTreeElements.h:59
void libera(void)
Frees memory occupied by mesh components. this calls delete on all components of the model...
Definition: Mesh.cc:62
virtual Node * getNode(int tag)
Returns a pointer to the nodo cuyo tag being passed as parameter.
Definition: Mesh.cc:427
size_t getNumDeadNodes(void) const
Returns the number of inactive nodes on the mesh.
Definition: Mesh.cc:555
Iterador sobre el conteedor de nodos.
Definition: NodeIter.h:73
virtual ElementIter & getElements()
Returns an iterator to the mesh elements.
Definition: Mesh.cc:366
void setNodeReactionException(const int &)
Asigna la excepción para comprobación de reacciones (ver Mesh::checkNodalReactions).
Definition: Mesh.cc:1061
virtual Element * getElement(int tag)
Returns a pointer to the element identified by the tag being passed as parameter. ...
Definition: Mesh.cc:385
DbTagData & getDbTagData(void) const
Returns a vector para almacenar los dbTags de los miembros de la clase.
Definition: Mesh.cc:972
size_t getNumLiveNodes(void) const
Returns the number of active nodes on the mesh.
Definition: Mesh.cc:540
int sendData(CommParameters &)
Send object members through the channel being passed as parameter.
Definition: Mesh.cc:979
int update(void)
Update the element&#39;s state.
Definition: Mesh.cc:761
int recvData(const CommParameters &)
Receives object members through the channel being passed as parameter.
Definition: Mesh.cc:990
Definition: SingleDomEleIter.h:71
void checkNodalReactions(const double &)
Comprueba que los valores de las reacciones en los nodos sean correctos, esto es, que todos los nodos...
Definition: Mesh.cc:1066
size_t getNumFreeNodes(void) const
Returns the number of free nodes on the mesh.
Definition: Mesh.cc:585
Definition: Matrix.h:82
virtual int setRayleighDampingFactors(const RayleighDampingFactors &rF)
Asigna valores a los coeficientes de amortiguamiento de Rayleigh.
Definition: Mesh.cc:687
TaggedObjectStorage. A TaggedObjectStorage object a container object used to hold objects of type Tag...
Definition: TaggedObjectStorage.h:76
Rayleigh damping factors.
Definition: RayleighDampingFactors.h:45
virtual Graph & getNodeGraph(void)
Builds (if needed) the graph of the domain nodes and returns a reference to it.
Definition: Mesh.cc:624
The Graph class provides the abstraction of a graph, a collection of vertices and edges...
Definition: Graph.h:84
virtual int setMass(const Matrix &mass, int nodeTag)
Asigna la matriz de masas al nudo cuyo tag being passed as parameter.
Definition: Mesh.cc:1052
virtual Graph & getElementGraph(void)
Builds the elements graph of the mesh (if not builded yet) and returns a reference to it...
Definition: Mesh.cc:604
size_t getNumLiveElements(void) const
Returns the number of active elements on the mesh.
Definition: Mesh.cc:510
NodeLocker container.
Definition: NodeLockers.h:41
Definition: SingleDomNodIter.h:70
size_t getNumDeadElements(void) const
Returns the number of inactive elements on the mesh.
Definition: Mesh.cc:525
int initialize(void)
Inicializa.
Definition: Mesh.cc:677
virtual bool removeNode(int tag)
Removes from domain the node identified by the tag being passed as parameter.
Definition: Mesh.cc:337
void clearDOF_GroupPtr(void)
Clears the pointers to node DOF groups.
Definition: Mesh.cc:357
Communication parameters between processes.
Definition: CommParameters.h:65
void setGraphBuiltFlags(const bool &f)
Returns true if the modelo ha cambiado.
Definition: Mesh.cc:779
================================================================================
Definition: ContinuaReprComponent.h:34
virtual ~Mesh(void)
Destructor.
Definition: Mesh.cc:184
virtual int getNumElements(void) const
Returns the number of elements.
Definition: Mesh.cc:502
virtual int buildNodeGraph(Graph &theNodeGraph)
Construye el grafo de nodos.
Definition: Mesh.cc:909