xc
Mesh.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 //Mesh.h
29 
30 #ifndef Mesh_h
31 #define Mesh_h
32 
33 #include "domain/mesh/MeshComponentContainer.h"
34 #include "utility/matrix/Vector.h"
35 #include "NodeLockers.h"
36 #include "solution/graph/graph/Graph.h"
37 #include "node/KDTreeNodes.h"
38 #include "element/utils/KDTreeElements.h"
39 
40 class Pos3d;
41 
42 namespace XC {
43 class Element;
44 class Node;
45 
46 class ElementIter;
47 class NodeIter;
48 class SingleDomEleIter;
49 class SingleDomNodIter;
50 
51 class Graph;
52 class NodeGraph;
53 class ElementGraph;
54 class FEM_ObjectBroker;
55 class TaggedObjectStorage;
56 class RayleighDampingFactors;
57 
59 //
61 //
63 //
66  {
67  private:
68  static const double reactionValueThreshold;
69  bool eleGraphBuiltFlag;
70  bool nodeGraphBuiltFlag;
71 
72  Graph theNodeGraph;
73  Graph theElementGraph;
74 
75  TaggedObjectStorage *theNodes;
76  SingleDomNodIter *theNodIter;
77  KDTreeNodes kdtreeNodes;
78  std::vector<std::string> coordinateNames;
79  std::string unitsNames;
80 
81  TaggedObjectStorage *theElements;
82  SingleDomEleIter *theEleIter;
83  KDTreeElements kdtreeElements;
84 
85  Vector theBounds;
86  int tagNodeCheckReactionException;
87 
88  NodeLockers lockers;
89 
90  void alloc_containers(void);
91  void alloc_iters(void);
92  bool check_containers(void) const;
93  void init_bounds(void);
94  void update_bounds(const Vector &);
95  void add_node_to_domain(Node *);
96  void add_element_to_domain(Element *);
97  void add_nodes_to_domain(void);
98  void add_elements_to_domain(void);
99 
100  Mesh(const Mesh &other);
101  Mesh &operator=(const Mesh &other);
102  protected:
103  void free_mem(void);
104  DbTagData &getDbTagData(void) const;
105  int sendData(Communicator &);
106  int recvData(const Communicator &);
107  public:
108  Mesh(CommandEntity *owr);
109  Mesh(CommandEntity *owr,TaggedObjectStorage &theNodesStorage, TaggedObjectStorage &theElementsStorage);
110  Mesh(CommandEntity *owr,TaggedObjectStorage &theStorageType);
111  virtual ~Mesh(void);
112 
113  // methods to populate a mesh
114  virtual bool addNode(Node *);
115  virtual bool removeNode(int tag);
116  bool remove(Node *);
117 
118  virtual bool addElement(Element *);
119  virtual bool removeElement(int tag);
120  bool remove(Element *);
121 
122  virtual void clearAll(void);
123 
124  void setNodeReactionException(const int &);
125  bool checkNodalReactions(const double &);
126 
127  void clearDOF_GroupPtr(void);
128 
129  void setGraphBuiltFlags(const bool &f);
130 
131  int initialize(void);
132  virtual int setRayleighDampingFactors(const RayleighDampingFactors &rF);
133 
134  // methods to access the components of a mesh
135  inline const TaggedObjectStorage *nodes(void) const
136  { return theNodes; }
137  inline TaggedObjectStorage *nodes(void)
138  { return theNodes; }
139  virtual NodeIter &getNodes(void);
140  virtual const NodeIter &getNodes(void) const;
141  int getDefaultNodeTag(void) const;
142  inline const TaggedObjectStorage *elements(void) const
143  { return theElements; }
144  inline TaggedObjectStorage *elements(void)
145  { return theElements; }
146  virtual ElementIter &getElements(void);
147  virtual const ElementIter &getElements(void) const;
148  int getDefaultElementTag(void) const;
149  inline const NodeLockers &getNodeLockers(void) const
150  { return lockers; }
151  inline NodeLockers &getNodeLockers(void)
152  { return lockers; }
153 
154  bool existElement(int tag);
155  virtual Element *getElement(int tag);
156  virtual const Element *getElement(int tag) const;
157  Element *getNearestElement(const Pos3d &p);
158  const Element *getNearestElement(const Pos3d &p) const;
159  bool existNode(int tag);
160  virtual Node *getNode(int tag);
161  virtual const Node *getNode(int tag) const;
162  Node *getNearestNode(const Pos3d &p);
163  const Node *getNearestNode(const Pos3d &p) const;
164 
165  // methods to query the state of the mesh
166  virtual int getNumElements(void) const;
167  virtual int getNumNodes(void) const;
168  size_t getNumDeadElements(void) const;
169  size_t getNumLiveElements(void) const;
170  size_t getNumDeadNodes(void) const;
171  size_t getNumLiveNodes(void) const;
172  size_t getNumFrozenNodes(void) const;
173  size_t getNumFreeNodes(void) const;
174  virtual const Vector &getPhysicalBounds(void);
175 
176  inline const std::vector<std::string> &getCoordinateNames(void) const
177  { return coordinateNames; }
178  inline std::string getUnitsNames(void) const
179  { return unitsNames; }
180 
181 
182  // methods to get element and node graphs
183  virtual int buildEleGraph(Graph &theEleGraph);
184  virtual int buildNodeGraph(Graph &theNodeGraph);
185  virtual Graph &getElementGraph(void);
186  virtual Graph &getNodeGraph(void);
187 
188  virtual int commit(void);
189  virtual int revertToLastCommit(void);
190  virtual int revertToStart(void);
191  int update(void);
192 
193  void freeze_dead_nodes(const std::string &nmbLocker);
194  void melt_alive_nodes(const std::string &nmbLocker);
195 
196  const double getEffectiveModalMass(int mode) const;
197  Vector getEffectiveModalMasses(const int &numModes) const;
198 
199  // mass distribution
200  Matrix getTotalMass(void) const;
201  double getTotalMassComponent(const int &) const;
202 
203  void zeroLoads(void);
204 
205  virtual void Print(std::ostream &s, int flag =0) const;
206  friend std::ostream &operator<<(std::ostream &, const Mesh &);
207 
208  virtual int sendSelf(Communicator &);
209  virtual int recvSelf(const Communicator &);
210  boost::python::dict getPyDict(void) const;
211  void setPyDict(const boost::python::dict &);
212 
213  // nodal methods required in mesh interface for parallel interprter
214  virtual double getNodeDisp(int nodeTag, int dof, int &errorFlag);
215  virtual int setMass(const Matrix &mass, int nodeTag);
216 
217  virtual int calculateNodalReactions(bool inclInertia, const double &);
218  double getEigenvectorsMaxNormInf(int mode) const;
219  double normalizeEigenvectors(int mode);
220  boost::python::list normalizeEigenvectors(void);
221  void clearEigenvectors(void);
222 
223  static void setDeadSRF(const double &);
224  };
225 
226 std::ostream &operator<<(std::ostream &, const Mesh &);
227 } // end of XC namespace
228 
229 #endif
230 
231 
void clearEigenvectors(void)
Remove the stored eigenvectors.
Definition: Mesh.cc:1445
void zeroLoads(void)
Loop over nodes and elements getting them to first zero their loads.
Definition: Mesh.cc:849
void setNodeReactionException(const int &)
Assign the exception for reaction checking (see Mesh::checkNodalReactions).
Definition: Mesh.cc:1316
Float vector abstraction.
Definition: Vector.h:94
virtual int revertToStart(void)
Return the mesh into its initial state.
Definition: Mesh.cc:926
static void setDeadSRF(const double &)
Assigns Stress Reduction Factor for element deactivation.
Definition: Mesh.cc:199
virtual int revertToLastCommit(void)
Returns the mesh to its last committed state.
Definition: Mesh.cc:906
Vector getEffectiveModalMasses(const int &numModes) const
Returns the masas modales efectivas.
Definition: Mesh.cc:804
void clearDOF_GroupPtr(void)
Clears the pointers to node DOF groups.
Definition: Mesh.cc:436
virtual double getNodeDisp(int nodeTag, int dof, int &errorFlag)
Returns the component of the displacement of the node which the tag is being passed as parameter...
Definition: Mesh.cc:1288
boost::python::list normalizeEigenvectors(void)
Normalize the node eigenvectors for all the computed modes.
Definition: Mesh.cc:1428
Communication parameters between processes.
Definition: Communicator.h:66
NodeLocker container.
Definition: NodeLockers.h:42
bool existNode(int tag)
Returns true if the mesh has a node with the tag being passed as parameter.
Definition: Mesh.cc:540
DbTagData & getDbTagData(void) const
Returns a vector to store the dbTags de los miembros of the clase.
Definition: Mesh.cc:1179
virtual int sendSelf(Communicator &)
Sends object through the communicator argument.
Definition: Mesh.cc:1256
Definition: SingleDomNodIter.h:71
size_t getNumDeadNodes(void) const
Returns the number of inactive nodes on the mesh.
Definition: Mesh.cc:680
int initialize(void)
Compute elements initial stiff.
Definition: Mesh.cc:863
size_t getNumLiveNodes(void) const
Returns the number of active nodes on the mesh.
Definition: Mesh.cc:665
Matrix getTotalMass(void) const
Return the total mass matrix.
Definition: Mesh.cc:813
Node * getNearestNode(const Pos3d &p)
Returns the node closest to the point being passed as parameter.
Definition: Mesh.cc:566
virtual void clearAll(void)
Deletes from domain all its components (nodes, elements, loads and constraints).
Definition: Mesh.cc:172
Iterator over an element container.
Definition: ElementIter.h:74
virtual int commit(void)
Commits mesh state.
Definition: Mesh.cc:889
virtual const Vector & getPhysicalBounds(void)
Definition: Mesh.cc:731
size_t getNumFrozenNodes(void) const
Returns the number of frozen nodes on the mesh.
Definition: Mesh.cc:695
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:44
virtual int getNumNodes(void) const
Returns the number of nodes.
Definition: Mesh.cc:631
size_t getNumDeadElements(void) const
Returns the number of inactive elements on the mesh.
Definition: Mesh.cc:650
virtual Element * getElement(int tag)
Returns a pointer to the element identified by the tag being passed as parameter. ...
Definition: Mesh.cc:502
int sendData(Communicator &)
Send object members through the communicator argument.
Definition: Mesh.cc:1186
int getDefaultElementTag(void) const
Get the default tag for the next element.
Definition: Mesh.cc:485
const double getEffectiveModalMass(int mode) const
Return the masa modal efectiva corresponding to the mode i.
Definition: Mesh.cc:792
virtual int buildEleGraph(Graph &theEleGraph)
Builds the element&#39;s graph.
Definition: Mesh.cc:1004
Base class for the finite elements.
Definition: Element.h:112
virtual ~Mesh(void)
Destructor.
Definition: Mesh.cc:194
virtual Node * getNode(int tag)
Returns a pointer to the node which tag being passed as parameter.
Definition: Mesh.cc:544
virtual bool addElement(Element *)
Appends to the mesh the element being passed as parameter.
Definition: Mesh.cc:241
void melt_alive_nodes(const std::string &nmbLocker)
Clears the constraints over activated nodes previously created by the freeze method.
Definition: Mesh.cc:607
bool existElement(int tag)
Returns true if the mesh has an element with the tag being passed as parameter.
Definition: Mesh.cc:497
void free_mem(void)
Frees memory occupied by mesh components.
Definition: Mesh.cc:65
bool checkNodalReactions(const double &)
Checks that all free nodes have zero reactions.
Definition: Mesh.cc:1321
Objet that can execute python scripts.
Definition: CommandEntity.h:40
The Graph class provides the abstraction of a graph.
Definition: Graph.h:94
virtual NodeIter & getNodes(void)
Returns an iterator a the nodes del domain.
Definition: Mesh.cc:459
Element * getNearestElement(const Pos3d &p)
Returns a pointer to the nearest element to the point being passed as parameter.
Definition: Mesh.cc:526
virtual bool removeElement(int tag)
Removes from the domain the element identified by the tag being passed as parameter.
Definition: Mesh.cc:369
virtual int recvSelf(const Communicator &)
Receives object through the communicator argument.
Definition: Mesh.cc:1271
virtual Graph & getElementGraph(void)
Builds the elements graph of the mesh (if not built yet) and returns a reference to it...
Definition: Mesh.cc:743
void setGraphBuiltFlags(const bool &f)
Returns true if the modelo ha cambiado.
Definition: Mesh.cc:970
int update(void)
Update the element&#39;s state.
Definition: Mesh.cc:950
Base class for the element and constraint containers.
Definition: MeshComponentContainer.h:41
int getDefaultNodeTag(void) const
Get the default tag for the next node.
Definition: Mesh.cc:473
virtual int buildNodeGraph(Graph &theNodeGraph)
Builds the node graph.
Definition: Mesh.cc:1116
size_t getNumFreeNodes(void) const
Returns the number of free nodes on the mesh.
Definition: Mesh.cc:710
Rayleigh damping factors.
Definition: RayleighDampingFactors.h:59
virtual ElementIter & getElements(void)
Returns an iterator to the mesh elements.
Definition: Mesh.cc:445
size_t getNumLiveElements(void) const
Returns the number of active elements on the mesh.
Definition: Mesh.cc:635
Posición en tres dimensiones.
Definition: Pos3d.h:44
virtual void Print(std::ostream &s, int flag=0) const
Imprime el domain.
Definition: Mesh.cc:977
double getTotalMassComponent(const int &) const
Return the total mass matrix component for the DOF argument.
Definition: Mesh.cc:836
k-d tree for searching the nearest element to a given position.
Definition: KDTreeElements.h:63
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
virtual Graph & getNodeGraph(void)
Builds (if needed) the graph of the domain nodes and returns a reference to it.
Definition: Mesh.cc:772
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: Mesh.cc:1225
Iterator over the nodes.
Definition: NodeIter.h:74
Matrix of floats.
Definition: Matrix.h:111
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: Mesh.cc:1211
Definition: SingleDomEleIter.h:72
void freeze_dead_nodes(const std::string &nmbLocker)
Freezes inactive nodes (prescribes zero displacement for all DOFs on inactive nodes).
Definition: Mesh.cc:583
virtual int getNumElements(void) const
Returns the number of elements.
Definition: Mesh.cc:627
double getEigenvectorsMaxNormInf(int mode) const
Return the maximum infinity norm of the nodes eigenvectors.
Definition: Mesh.cc:1372
virtual int setRayleighDampingFactors(const RayleighDampingFactors &rF)
Set Rayleigh damping factors.
Definition: Mesh.cc:873
Mesh node.
Definition: Node.h:111
k-d tree for searching the nearest node to a given position.
Definition: KDTreeNodes.h:62
virtual int calculateNodalReactions(bool inclInertia, const double &)
Calculate nodal reaction forces and moments.
Definition: Mesh.cc:1351
Finite element mesh.
Definition: Mesh.h:65
virtual bool removeNode(int tag)
Remove from mesh the node identified by the argument.
Definition: Mesh.cc:405
virtual int setMass(const Matrix &mass, int nodeTag)
Set the mass matrix for the node identified by the argument.
Definition: Mesh.cc:1307
int recvData(const Communicator &)
Receives object members through the communicator argument.
Definition: Mesh.cc:1197
virtual bool addNode(Node *)
Adds to the domain the node being passed as parameter.
Definition: Mesh.cc:334