xc
SetMeshComp.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 // 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 //SetMeshComp.h
28 
29 #ifndef SETMESHCOMP_H
30 #define SETMESHCOMP_H
31 
32 #include "SetBase.h"
33 #include "DqPtrs.h"
34 #include "DqPtrsNode.h"
35 #include "DqPtrsElem.h"
36 #include "DqPtrsConstraint.h"
37 #include <set>
38 
39 class Pos3d;
41 class Plane;
42 
43 namespace XC {
44 class TrfGeom;
45 class SFreedom_Constraint;
46 class ID;
47 class Element;
48 class Node;
49 class Constraint;
50 
59 class SetMeshComp: public SetBase
60  {
61  protected:
62  template <class L>
63  static void numerate_list(L &l);
64  void numerate(void);
65  public:
66  //Nodes.
67  typedef DqPtrsNode::iterator nod_iterator;
68  typedef DqPtrsNode::const_iterator nod_const_iterator;
69 
70  //Elements.
71  typedef DqPtrsElem::iterator elem_iterator;
72  typedef DqPtrsElem::const_iterator elem_const_iterator;
73 
74  //Constraints.
76  typedef DqPtrsConstraint::iterator constraint_iterator;
77  typedef DqPtrsConstraint::const_iterator constraint_const_iterator;
78 
79  private:
80  DqPtrsNode nodes;
81  DqPtrsElem elements;
82  lst_ptr_constraints constraints;
83 
84  protected:
85  void extend_lists(const SetMeshComp &);
86  void substract_lists(const SetMeshComp &);
87  void intersect_lists(const SetMeshComp &);
88  void copy_lists(const SetMeshComp &);
89 
90  void clearAll(void);
91 
92  DbTagData &getDbTagData(void) const;
93  int sendData(Communicator &);
94  int recvData(const Communicator &);
95 
96 
97  void calc_resisting_force(void);
98 
99  void move(const Vector3d &);
100  public:
101  SetMeshComp(const std::string &nmb="",Preprocessor *preprocessor= nullptr);
102  SetMeshComp(const SetMeshComp &);
103  ~SetMeshComp(void);
104 
109 
110  void extend(const DqPtrsNode &);
111  void extend(const DqPtrsElem &);
112  void extend(const lst_ptr_constraints &);
113  void extend(const SetMeshComp &);
114  void substract(const DqPtrsNode &);
115  void substract(const DqPtrsElem &);
116  void substract(const lst_ptr_constraints &);
117  void substract(const SetMeshComp &);
118 
119  std::string getStrName(void) const;
120  void newName(const std::string &);
121  void rename(const std::string &);
122 
124  size_t getNumberOfNodes(void) const
125  { return nodes.size(); }
127  void addNode(Node *nPtr);
129  virtual const DqPtrsNode &getNodes(void) const
130  { return nodes; }
132  virtual DqPtrsNode &getNodes(void)
133  { return nodes; }
135  void setNodes(const DqPtrsNode &nds)
136  { nodes= nds; }
138  void clearNodes(void)
139  { nodes.clearAll(); }
140  void sel_nodes_from_list(const ID &);
141  bool In(const Node *) const;
142  bool isCloserThan(const Pos3d &, const double &) const;
143  bool remove(Node *);
144  SetMeshComp pickNodesInside(const std::string &, const GeomObj3d &, const double &tol= 0.0);
145  SetMeshComp pickNodesInside(const std::string &, const GeomObj2d &, const double &tol= 0.0);
146  BND3d Bnd(const double &) const;
147  PrincipalAxes3D getOrientation(const double &) const;
148 
150  size_t getNumberOfElements(void) const
151  { return elements.size(); }
153  void addElement(Element *);
155  virtual const DqPtrsElem &getElements(void) const
156  { return elements; }
158  virtual DqPtrsElem &getElements(void)
159  { return elements; }
161  void setElements(const DqPtrsElem &els)
162  { elements= els; }
164  void clearElements(void)
165  { elements.clearAll(); }
166  void sel_elements_from_list(const ID &tags);
167  bool In(const Element *) const;
168  bool isCloserThan(const GeomObj::list_Pos3d &, const double &) const;
169  bool remove(Element *);
170  SetMeshComp pickElemsInside(const std::string &, const GeomObj3d &, const double &tol= 0.0);
171  SetMeshComp pickElemsInside(const std::string &, const GeomObj2d &, const double &tol= 0.0);
172  SetMeshComp pickElemsCrossing(const std::string &, const GeomObj3d &, const double &tol= 0.0);
173  SetMeshComp pickElemsCrossing(const std::string &, const GeomObj2d &, const double &tol= 0.0);
174  SetMeshComp pickElemsOfType(const std::string &, const std::string &);
175  SetMeshComp pickElemsOfDimension(const std::string &, const size_t &);
176  inline boost::python::list getElementTypesPy(void) const
177  { return elements.getTypesPy(); }
178  inline boost::python::list getElementDimensionsPy(void) const
179  { return elements.getDimensionsPy(); }
180  inline boost::python::list getElementMaterialNamesPy(void) const
181  { return elements.getMaterialNamesPy(); }
182  SetMeshComp pickElemsOfMaterial(const std::string &, const std::string &);
183 
185  size_t getNumberOfConstraints(void) const
186  { return constraints.size(); }
188  void addConstraint(Constraint *);
189  bool remove(Constraint *);
191  virtual const DqPtrsConstraint &getConstraints(void) const
192  { return constraints; }
195  { return constraints; }
198  { constraints= cts; }
200  void clearConstraints(void)
201  { constraints.clearAll(); }
202  bool In(const Constraint *) const;
203  void sel_constraints_from_list(const ID &tags, const ID &types);
204 
205  void appendFromGeomEntity(const SetBase &);
206 
207  void clear(void);
208  bool empty(void) const;
209 
210  void fix(const SFreedom_Constraint &);
211 
212  //nod_iterator nodes_begin(void);
213  nod_const_iterator nodes_begin(void) const;
214  //nod_iterator nodes_end(void);
215  nod_const_iterator nodes_end(void) const;
216  Node *findNode(const int &tag);
217  const Node *findNode(const int &tag) const;
218  bool InNodeTag(const int) const;
219  bool InNodeTags(const ID &) const;
220  std::set<int> getNodeTags(void) const;
221  std::set<int> getElementTags(void) const;
222  std::set<int> getConstraintTags(void) const;
223  Node *getNearestNode(const Pos3d &p);
224  const Node *getNearestNode(const Pos3d &p) const;
225 
226 
227  elem_iterator elem_begin(void);
228  elem_const_iterator elem_begin(void) const;
229  elem_iterator elem_end(void);
230  elem_const_iterator elem_end(void) const;
231  Element *findElement(const int &);
232  const Element *findElement(const int &) const;
233  Element *getNearestElement(const Pos3d &);
234  const Element *getNearestElement(const Pos3d &) const;
235 
236  void kill_elements(void);
237  void alive_elements(void);
238  size_t getNumDeadElements(void) const;
239  size_t getNumLiveElements(void) const;
240  size_t getNumDeadNodes(void) const;
241  size_t getNumLiveNodes(void) const;
242 
243  constraint_iterator constraints_begin(void);
244  constraint_const_iterator constraints_begin(void) const;
245  constraint_iterator constraints_end(void);
246  constraint_const_iterator constraints_end(void) const;
247  Constraint *buscaConstraint(const int &tag);
248  const Constraint *buscaConstraint(const int &tag) const;
249 
250  void fillUpwards(void);
251  void fillDownwards(void);
252 
253  virtual void Transform(const TrfGeom &trf);
254 
255  SlidingVectorsSystem3d getResistingSlidingVectorsSystem3d(const Plane &,const Pos3d &,const double &,const bool &) const;
256  Matrix getTangentStiff(const Node &);
257  Matrix getInitialStiff(const Node &);
258 
259  boost::python::list createInertiaLoads(const Vector &);
260 
261  // mass distribution
262  Matrix getTotalMass(void) const;
263  double getTotalMassComponent(const int &) const;
264 
265  virtual int sendSelf(Communicator &);
266  virtual int recvSelf(const Communicator &);
267 
268  SetMeshComp operator+(const SetMeshComp &) const;
269  SetMeshComp operator-(const SetMeshComp &) const;
270  SetMeshComp operator*(const SetMeshComp &) const;
271 
272  boost::python::dict getPyDict(void) const;
273  void setPyDict(const boost::python::dict &);
274  };
275 
276 
278 template <class L>
280  {
281  size_t idx= 0;
282  typedef typename L::iterator iterator;
283  typedef typename L::reference reference;
284  for(iterator i= l.begin();i!=l.end();i++,idx++)
285  {
286  reference ptr= *i;
287  ptr->set_index(idx);
288  }
289  }
290 
291 } //end of XC namespace
292 #endif
Element * findElement(const int &)
Returns (if it exists) a pointer to the node identified by the tag being passed as parameter...
Definition: SetMeshComp.cc:391
Node * getNearestNode(const Pos3d &p)
Returns the node closest to the point being passed as parameter.
Definition: SetMeshComp.cc:576
void alive_elements(void)
Reactivates the elements.
Definition: SetMeshComp.cc:463
Pointers to node container.
Definition: DqPtrsNode.h:54
Float vector abstraction.
Definition: Vector.h:94
Element * getNearestElement(const Pos3d &)
Returns the element closest to the point being passed as parameter.
Definition: SetMeshComp.cc:591
SetMeshComp & operator*=(const SetMeshComp &)
*= operator (intersection).
Definition: SetMeshComp.cc:94
Matrix getTotalMass(void) const
Return the total mass matrix.
Definition: SetMeshComp.cc:541
~SetMeshComp(void)
Destructor.
Definition: SetMeshComp.cc:923
void sel_constraints_from_list(const ID &tags, const ID &types)
Select the constraints identified by the tags.
Definition: SetMeshComp.cc:840
Communication parameters between processes.
Definition: Communicator.h:66
void kill_elements(void)
Deactivates the elements.
Definition: SetMeshComp.cc:459
SetMeshComp pickElemsInside(const std::string &, const GeomObj3d &, const double &tol=0.0)
Return a new set that contains the elements that lie inside of the geometric object.
Definition: SetMeshComp.cc:744
Finite element model generation tools.
Definition: Preprocessor.h:59
std::string getStrName(void) const
Return a copy of the object name.
Definition: SetMeshComp.cc:106
constraint_iterator constraints_begin(void)
Returns an iterator which points to principio de la lista de constraints.
Definition: SetMeshComp.cc:377
void clearNodes(void)
Clears out the nodes.
Definition: SetMeshComp.h:138
virtual void Transform(const TrfGeom &trf)
Aplies the transformation to the positions of the nodes.
Definition: SetMeshComp.cc:326
boost::python::list getDimensionsPy(void) const
Return the dimensions of the elements.
Definition: DqPtrsElem.cc:595
void substract(const DqPtrsNode &)
Removes from this set the nodes from the argument.
Definition: SetMeshComp.cc:161
void extend(const DqPtrsNode &)
Appends to this set the nodes from the argument.
Definition: SetMeshComp.cc:145
void setElements(const DqPtrsElem &els)
Sets the elements.
Definition: SetMeshComp.h:161
BND3d Bnd(const double &) const
Return the nodes current position boundary.
Definition: SetMeshComp.cc:702
virtual int recvSelf(const Communicator &)
Receives object through the communicator argument.
Definition: SetMeshComp.cc:943
size_t getNumLiveElements(void) const
Returns the number of active elements.
Definition: SetMeshComp.cc:442
SetMeshComp operator-(const SetMeshComp &) const
Return the difference.
Definition: SetMeshComp.cc:974
SetMeshComp pickElemsOfMaterial(const std::string &, const std::string &)
Return a new set that contains the elements who have the material being passed as parameter...
Definition: SetMeshComp.cc:825
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:44
SetMeshComp pickElemsOfType(const std::string &, const std::string &)
Return a new set that contains the elements that match the type.
Definition: SetMeshComp.cc:799
void clearAll(void)
Clears out the list of pointers and erases the properties of the object (if any). ...
Definition: DqPtrsKDTree.h:175
void fix(const SFreedom_Constraint &)
Applies the single freedom constraint being passed as parameter to the nodes.
Definition: SetMeshComp.cc:330
void addElement(Element *)
Adds an element.
Definition: SetMeshComp.cc:255
Vector of integers.
Definition: ID.h:95
Plane in a three-dimensional space.
Definition: Plane.h:49
bool empty(void) const
Return true if the set is empty.
Definition: SetMeshComp.cc:237
Base de las clases Set y SetEstruct.
Definition: SetBase.h:51
double getTotalMassComponent(const int &) const
Return the total mass matrix component for the DOF argument.
Definition: SetMeshComp.cc:549
Base class for the finite elements.
Definition: Element.h:112
size_t getNumberOfConstraints(void) const
Returns the number of constraints.
Definition: SetMeshComp.h:185
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: SetMeshComp.cc:990
size_t getNumDeadNodes(void) const
Returns the number of inactive nodes.
Definition: SetMeshComp.cc:455
Set of mesh components (nodes, elements and constraints).
Definition: SetMeshComp.h:59
SetMeshComp pickNodesInside(const std::string &, const GeomObj3d &, const double &tol=0.0)
Return a new set that contains the nodes that lie insiof the geometric object.
Definition: SetMeshComp.cc:676
Base class for the two-dimensional geometric objects.
Definition: GeomObj2d.h:37
SetMeshComp pickElemsCrossing(const std::string &, const GeomObj3d &, const double &tol=0.0)
Return a new set with the elements that cross (i.e.
Definition: SetMeshComp.cc:786
DqPtrsConstraint::const_iterator constraint_const_iterator
Iterator over the set de constraints.
Definition: SetMeshComp.h:77
bool isCloserThan(const Pos3d &, const double &) const
Return true if the distance to the given point is smaller than the given one.
Definition: SetMeshComp.cc:266
void move(const Vector3d &)
Moves the nodes.
Definition: SetMeshComp.cc:322
DqPtrsElem::const_iterator elem_const_iterator
Iterator over the element set.
Definition: SetMeshComp.h:72
void appendFromGeomEntity(const SetBase &)
Appends to this set the objects the nodes and elements from the set being passed as parameter...
Definition: SetMeshComp.cc:215
virtual const DqPtrsConstraint & getConstraints(void) const
Return the constraints container.
Definition: SetMeshComp.h:191
SetMeshComp operator*(const SetMeshComp &) const
Return the intersection.
Definition: SetMeshComp.cc:982
SetMeshComp operator+(const SetMeshComp &) const
Return the union of both objects.
Definition: SetMeshComp.cc:966
Constraint * buscaConstraint(const int &tag)
Returns, if it exists, a pointer to the constraint which tag is being passed as parameter.
Definition: SetMeshComp.cc:401
int sendData(Communicator &)
Send members through the communicator argument.
Definition: SetMeshComp.cc:895
bool In(const Node *) const
Returns true if the node belongs to the set.
Definition: SetMeshComp.cc:259
void clearAll(void)
Clears all objects from the set.
Definition: SetMeshComp.cc:242
bool InNodeTag(const int) const
Returns true if the node with the tag being passed as parameter, belongs to the set.
Definition: SetMeshComp.cc:563
nod_const_iterator nodes_begin(void) const
Returns an iterator that points to the first item of the node container.
Definition: SetMeshComp.cc:344
void sel_nodes_from_list(const ID &)
Select the nodes identified by the tags being passed as parameters.
Definition: SetMeshComp.cc:654
bool InNodeTags(const ID &) const
Returns true if the nodes, with the tags being passed as parameter, belongs to the set...
Definition: SetMeshComp.cc:568
virtual const DqPtrsElem & getElements(void) const
Returns the element container.
Definition: SetMeshComp.h:155
void addConstraint(Constraint *)
Adds a constraint.
Definition: SetMeshComp.cc:834
virtual const DqPtrsNode & getNodes(void) const
Return the node container.
Definition: SetMeshComp.h:129
Single freedom constraint.
Definition: SFreedom_Constraint.h:85
void newName(const std::string &)
Set the object name.
Definition: SetMeshComp.cc:110
void intersect_lists(const SetMeshComp &)
Remove the objects that doesn&#39;t also belong to the argument.
Definition: SetMeshComp.cc:202
constraint_iterator constraints_end(void)
Returns an iterator apuntando tras el final de la lista de constraints.
Definition: SetMeshComp.cc:383
void fillUpwards(void)
Appends to this set the objects that make reference to one or more of the objects that already are in...
Definition: SetMeshComp.cc:627
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: SetMeshComp.cc:1044
boost::python::list createInertiaLoads(const Vector &)
Creates the inertia load that corresponds to the acceleration argument.
Definition: SetMeshComp.cc:533
Matrix getTangentStiff(const Node &)
Return the contribution of the elements to the tangent stiffness of the node argument.
Definition: SetMeshComp.cc:519
void substract_lists(const SetMeshComp &)
Remove the objects of the argument.
Definition: SetMeshComp.cc:194
PrincipalAxes3D getOrientation(const double &) const
Return the orientation of the node cloud.
Definition: SetMeshComp.cc:718
SetMeshComp pickElemsOfDimension(const std::string &, const size_t &)
Return a new set that contains the elements of the specified dimension.
Definition: SetMeshComp.cc:812
DqPtrsNode::iterator nod_iterator
Iterator over the node set.
Definition: SetMeshComp.h:67
void setNodes(const DqPtrsNode &nds)
Sets the nodes.
Definition: SetMeshComp.h:135
DbTagData & getDbTagData(void) const
Returns a vector to store the dbTags of the class members.
Definition: SetMeshComp.cc:888
Matrix getInitialStiff(const Node &)
Return the contribution of the elements to the tangent stiffness of the node argument.
Definition: SetMeshComp.cc:528
"boundary" en tres dimensiones.
Definition: BND3d.h:34
void clearElements(void)
Clears out the elements.
Definition: SetMeshComp.h:164
std::set< int > getNodeTags(void) const
Returns node tags.
Definition: SetMeshComp.cc:572
nod_const_iterator nodes_end(void) const
Returns an iterator that points to the past-the-end item in the node container.
Definition: SetMeshComp.cc:350
void clearAll(void)
Clears out the list of pointers and erases the properties of the object (if any). ...
Definition: DqPtrs.h:203
void addNode(Node *nPtr)
Appends a node.
Definition: SetMeshComp.cc:251
SetMeshComp & operator-=(const SetMeshComp &)
-= operator.
Definition: SetMeshComp.cc:82
void extend_lists(const SetMeshComp &)
Removes from this set the objects from the argument set.
Definition: SetMeshComp.cc:186
SetMeshComp(const std::string &nmb="", Preprocessor *preprocessor=nullptr)
Constructor.
Definition: SetMeshComp.cc:53
void fillDownwards(void)
Appends to the set being passed as parameter the nodes that touch any of the elements of the set...
Definition: SetMeshComp.cc:612
size_t getNumLiveNodes(void) const
Returns the number of active nodes.
Definition: SetMeshComp.cc:450
Geometric transformation that can be applied to the components of a set.
Definition: TrfGeom.h:48
DqPtrsConstraint lst_ptr_constraints
Set of constraints.
Definition: SetMeshComp.h:75
Node * findNode(const int &tag)
Returns (if it exists) a pointer to the node which tag is being passed as parameter.
Definition: SetMeshComp.cc:355
virtual DqPtrsElem & getElements(void)
Returns the elements container.
Definition: SetMeshComp.h:158
virtual int sendSelf(Communicator &)
Sends object through the communicator argument.
Definition: SetMeshComp.cc:927
boost::python::list getTypesPy(void) const
Return the types (class names) of the elements.
Definition: DqPtrsElem.cc:571
boost::python::list getMaterialNamesPy(void) const
Return the names of the materials in a python list.
Definition: DqPtrsElem.cc:548
std::set< int > getElementTags(void) const
Returns the element tags.
Definition: SetMeshComp.cc:587
void calc_resisting_force(void)
Compute the internal forces on each element.
Definition: SetMeshComp.cc:467
std::set< int > getConstraintTags(void) const
Returns the tags de los constraints.
Definition: SetMeshComp.cc:602
Posición en tres dimensiones.
Definition: Pos3d.h:44
int recvData(const Communicator &)
Receives members through the communicator argument.
Definition: SetMeshComp.cc:907
static void numerate_list(L &l)
Set indices to the object to allow its use in VTK.
Definition: SetMeshComp.h:279
Sliding vectors system en un espacio tridimensional.
Definition: SlidingVectorsSystem3d.h:39
void rename(const std::string &)
Rename object.
Definition: SetMeshComp.cc:114
void clearConstraints(void)
Clears out the constraints.
Definition: SetMeshComp.h:200
size_t getNumberOfElements(void) const
Returns the number of elements.
Definition: SetMeshComp.h:150
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Principals axes of inertia in planar geometry.
Definition: PrincipalAxes3D.h:34
size_t getNumberOfNodes(void) const
Returns the number of nodes.
Definition: SetMeshComp.h:124
Constraint pointers deque.
Definition: DqPtrsConstraint.h:46
Matrix of floats.
Definition: Matrix.h:111
void clear(void)
Clears all the objects of the lists.
Definition: SetMeshComp.cc:228
void numerate(void)
Assigns index to each object in the set (nodes,elements,points...) to be able to use them in VTK...
Definition: SetMeshComp.cc:314
virtual DqPtrsNode & getNodes(void)
Return the nodes container.
Definition: SetMeshComp.h:132
Base class for model constraints.
Definition: Constraint.h:48
void sel_elements_from_list(const ID &tags)
Selects the elements identified by the tags being passed as parameters.
Definition: SetMeshComp.cc:722
SlidingVectorsSystem3d getResistingSlidingVectorsSystem3d(const Plane &, const Pos3d &, const double &, const bool &) const
Return the resultant of the forces over the nodes near to the plane, of the elements behind the plane...
Definition: SetMeshComp.cc:472
size_t getNumDeadElements(void) const
Returns the number of inactive elements.
Definition: SetMeshComp.cc:446
void copy_lists(const SetMeshComp &)
Copy (into this set) the lists from the set being passed as parameter.
Definition: SetMeshComp.cc:134
Mesh node.
Definition: Node.h:112
SetMeshComp & operator=(const SetMeshComp &)
Assignment operator.
Definition: SetMeshComp.cc:62
DqPtrsConstraint::iterator constraint_iterator
Iterator over the set de constraints.
Definition: SetMeshComp.h:76
void setConstraints(const DqPtrsConstraint &cts)
Sets the constraints.
Definition: SetMeshComp.h:197
Pointer to element container.
Definition: DqPtrsElem.h:52
virtual DqPtrsConstraint & getConstraints(void)
Return the constraints container.
Definition: SetMeshComp.h:194
Vector en tres dimensiones.
Definition: Vector3d.h:39
SetMeshComp & operator+=(const SetMeshComp &)
+= operator.
Definition: SetMeshComp.cc:70
DqPtrsElem::iterator elem_iterator
Iterator over the element set.
Definition: SetMeshComp.h:71
Clase base para los objetos en tres dimensiones.
Definition: GeomObj3d.h:43
DqPtrsNode::const_iterator nod_const_iterator
Iterator over the node set.
Definition: SetMeshComp.h:68