xc
Face.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 //Face.h
29 //Face entities.
30 
31 #ifndef FACE_H
32 #define FACE_H
33 
34 #include "preprocessor/multi_block_topology/entities/1d/CmbEdge.h"
35 
36 class Polygon3d;
37 class Ref2d3d;
38 namespace XC {
39 class Body;
40 class PolygonalFace;
41 
45 class Face: public CmbEdge
46  {
47  friend class Edge;
48  friend class Body;
49  friend class SetEntities;
50  std::set<const Body *> bodies_surf;
51 
52  void insert_body(Body *b);
53  Node *getNode(const size_t &i);
54  const Node *getNode(const size_t &i) const;
55  public:
56  typedef std::deque<PolygonalFace *> dq_holes;
57  typedef dq_holes::iterator hole_iterator;
58  typedef dq_holes::const_iterator hole_const_iterator;
59  protected:
60  bool hole;
61  size_t ndivj;
62  dq_holes holes;
63  int get_index_opposite_side(const int &) const;
64  virtual const Edge *get_opposite_side(const Edge *l) const;
65  Edge *get_opposite_side(const Edge *l);
66  size_t calc_ndiv_opposite_sides(const Edge *, const size_t &) const;
67  void set_ndiv_opposite_sides(const size_t &, const size_t &);
68  void set_ndiv_i(const size_t &);
69  void set_ndiv_j(const size_t &);
70 
71  std::vector<XC::Node *> create_interior_nodes(const std::vector<Pos3d> &);
72  int create_elements_from_quads(const std::deque<std::vector<int> > &);
73  void create_line_nodes(void);
74  int create_gmsh_loop(void) const;
75  std::vector<int> create_gmsh_loops_for_holes(void) const;
76  std::vector<int> create_gmsh_loops(void) const;
77  int create_gmsh_surface(void) const;
78  public:
79  Face(void);
80  Face(Preprocessor *m,const size_t &ndivI= 4, const size_t &ndivJ= 4);
81  Face(const std::string &name,Preprocessor *m,const size_t &ndivI= 4, const size_t &ndivJ= 4);
82  virtual bool operator==(const Face &) const;
84  inline virtual unsigned short int GetDimension(void) const
85  { return 2; }
86 
87  // Topology
88  void update_topology(void);
89  const Edge *getOppositeEdge(const Edge &) const;
90  Edge *getOppositeEdge(const Edge &);
91  std::deque<std::pair<const Edge *, const Edge *> > getOppositeEdges(void) const;
92 
93  // Surface orientation.
94  Vector3d getKVector(void) const;
95  Matrix getLocalAxes(void) const;
96  Ref2d3d getRef(void) const;
97 
98  // Number of divisions
99  void setNDiv(const size_t &);
100  inline size_t NDivI(void) const
101  { return ndiv; }
102  virtual void setNDivI(const size_t &);
103  inline size_t NDivJ(void) const
104  { return ndivj; }
105  virtual void setNDivJ(const size_t &);
106  virtual void ConciliaNDivIJ(void);
107  virtual void SetElemSizeI(const double &sz);
108  virtual void SetElemSizeJ(const double &sz);
109  virtual void SetElemSizeIJ(const double &,const double &);
110  virtual void SetElemSize(const double &sz, bool mustBeEven= true);
111 
112  bool isHole(void) const;
113  void setHole(const bool &);
114  void addHole(PolygonalFace *);
115  hole_iterator findHole(PolygonalFace *);
116  hole_const_iterator findHole(PolygonalFace *) const;
117  const PolygonalFace *findHolePtr(PolygonalFace *) const;
119  const std::deque<PolygonalFace *> &getHoles(void) const;
120  boost::python::list getPyHoles(void) const;
121  std::deque<Side *> findSides(const Pos3d &);
122 
124  size_t getNumberOfVertices(void) const
125  { return getNumberOfEdges(); }
126  virtual const Pnt *getVertex(const size_t &i) const;
127  virtual Pnt *getVertex(const size_t &i);
128  Pnt *findVertex(const Pos3d &);
129  Pos3d getCentroid(void) const;
130  Plane getPlane(void) const;
131  bool isFlat(const double &tol= 1e-6) const;
132  bool isWarped(const double &tol= 1e-6) const;
133  Polyline3d getContour(void) const;
134  Polygon3d getPolygon(void) const;
135  double getSquaredDistanceTo(const Pos3d &pt) const;
136  double getArea(void) const;
138  const std::set<const Body *> &getConnectedBodies(void) const
139  { return bodies_surf; }
140  size_t CommonEdge(const Face &other) const;
141  int SenseOfEdge(const Edge *l,const Face &other) const;
142  bool isConnectedTo(const Body &b) const;
143  std::deque<const Edge *> getNDivErrors(const size_t &) const;
144  bool checkNDivs(const size_t &) const;
145  std::deque<const Edge *> getNDivErrors(void) const;
146  virtual bool checkNDivs(void) const;
147 
148  virtual Node *getNode(const size_t &i1,const size_t &j,const size_t &k);
149  virtual const Node *getNode(const size_t &i,const size_t &j,const size_t &k) const;
150  virtual Node *getNode(const size_t &i,const size_t &j);
151  virtual const Node *getNode(const size_t &i,const size_t &j) const;
152 
153  std::set<SetBase *> get_sets(void) const;
154  void add_to_sets(std::set<SetBase *> &);
155 
156  //Surface orientation.
157  bool clockwise(const Pos3d &) const;
158  bool counterclockwise(const Pos3d &) const;
159  std::string orientation(const Pos3d &) const;
160  virtual void reverse(void);
161  void revolve(const int &);
162  void setKOrientation(const Vector3d &);
163  int setIOrientation(const Vector3d &);
164 
165  int getVtkCellType(void) const;
166 
167  boost::python::dict getPyDict(void) const;
168  void setPyDict(const boost::python::dict &);
169  };
170 
171 std::set<const Face *> getConnectedSurfaces(const Edge &l);
172 std::set<const Pnt *> getCommonVertex(const Face &,const Face &, const Face &);
173 
174 } //end of XC namespace.
175 
176 #endif
size_t getNumberOfEdges(void) const
Return the number of edges.
Definition: CmbEdge.h:152
virtual void setNDivI(const size_t &)
Set the number of divisions on the i axis.
Definition: Face.cc:216
int get_index_opposite_side(const int &) const
Return the index of th opposite side with respect to the one being passed as parameter.
Definition: Face.cc:87
std::set< SetBase * > get_sets(void) const
Returns the sets that contains this surface.
Definition: Face.cc:1055
dq_holes holes
holes in this surface.
Definition: Face.h:62
void setKOrientation(const Vector3d &)
Set the orientation of the face normal according to the vector argument.
Definition: Face.cc:872
void add_to_sets(std::set< SetBase *> &)
Appends the surface to each of the sets being passed as parameter.
Definition: Face.cc:1072
hole_iterator findHole(PolygonalFace *)
Return an iterator to the hole corresponding to the argument return holes.end() if not found...
Definition: Face.cc:499
virtual void setNDivJ(const size_t &)
Set the number of divisions on the j axis.
Definition: Face.cc:238
Plane polygon in a 3D space.
Definition: Polygon3d.h:35
std::string orientation(const Pos3d &) const
Return the orientation of the face.
Definition: Face.cc:976
bool isConnectedTo(const Body &b) const
Returns true if the lines touches the body (neighbor).
Definition: Face.cc:1048
Base class for one-dimensional geometry objects.
Definition: Edge.h:48
const Edge * getOppositeEdge(const Edge &) const
Return the opposite side with respect to the one being passed as parameter.
Definition: Face.cc:766
virtual void ConciliaNDivIJ(void)
Conciliate lines division numbers with those of the surface.
Definition: Face.cc:377
Polygonal face defined by an arbitrary number of vertices.
Definition: PolygonalFace.h:45
int create_elements_from_quads(const std::deque< std::vector< int > > &)
Create nodes from quad tags (i.e. [tagI, tagJ, tagK, tagL].
Definition: Face.cc:704
Finite element model generation tools.
Definition: Preprocessor.h:59
void setNDiv(const size_t &)
Sets the number of divisions for all its sides.
Definition: Face.cc:200
bool counterclockwise(const Pos3d &) const
Return true if the points are counter-clockwise ordered with respect to the element.
Definition: Face.cc:986
std::deque< std::pair< const Edge *, const Edge * > > getOppositeEdges(void) const
Return a deque of opposite edge pairs.
Definition: Face.cc:775
void set_ndiv_j(const size_t &)
Sets the number of divisions for direction J.
Definition: Face.cc:194
Polyline in a three-dimensional space.
Definition: Polyline3d.h:37
Plane in a three-dimensional space.
Definition: Plane.h:49
Face(void)
Constructor.
Definition: Face.cc:50
virtual void SetElemSizeJ(const double &sz)
Computes the number of divisions on the j axis for an element edge size equal or lesser than the size...
Definition: Face.cc:443
bool isHole(void) const
Return true if the face corresponds to a hole.
Definition: Face.cc:539
Matrix getLocalAxes(void) const
Returns a matrix with the axes of the surface as matrix rows [[x1,y1,z1],[x2,y2,z2],...·].
Definition: Face.cc:1000
int setIOrientation(const Vector3d &)
Set the orientation of the face i unit vector as close as possible to the given vector.
Definition: Face.cc:883
Plane getPlane(void) const
Return the plane containing the face.
Definition: Face.cc:913
virtual bool checkNDivs(void) const
Verifies that the number of divisions of the lines are compatible.
Definition: Face.cc:355
void setHole(const bool &)
Return true if the face corresponds to a hole.
Definition: Face.cc:543
void set_ndiv_i(const size_t &)
Sets the number of divisions for direction I.
Definition: Face.cc:190
const std::deque< PolygonalFace * > & getHoles(void) const
Return a list of the face holes.
Definition: Face.cc:565
void set_ndiv_opposite_sides(const size_t &, const size_t &)
Set the number of divisions for the edge argument and its opposite side.
Definition: Face.cc:261
virtual void SetElemSizeI(const double &sz)
Computes the number of divisions on the i axis for an element edge size equal or lesser than the size...
Definition: Face.cc:410
size_t calc_ndiv_opposite_sides(const Edge *, const size_t &) const
Computes a suitable number of divisions for the edge argument and its opposite side.
Definition: Face.cc:145
virtual void SetElemSizeIJ(const double &, const double &)
Computes the number of divisions on the i and j axis for an element edges sizes equal or lesser than ...
Definition: Face.cc:477
std::deque< const Edge * > getNDivErrors(void) const
Returns a list with the edges that have an incompatible number of divisions.
Definition: Face.cc:336
bool isFlat(const double &tol=1e-6) const
return true if the surface is flat.
Definition: Face.cc:928
int create_gmsh_loop(void) const
Create a Gmsh curve loop from the face sides.
Definition: Face.cc:582
size_t CommonEdge(const Face &other) const
Returns the index of the edge in common with the surface being passed as parameter (if it exists)...
Definition: Face.cc:795
int SenseOfEdge(const Edge *l, const Face &other) const
Returns:
Definition: Face.cc:815
int getVtkCellType(void) const
Interfaz con VTK.
Definition: Face.cc:1132
std::deque< Side * > findSides(const Pos3d &)
Return a pointer to the side at the position argument.
Definition: Face.cc:645
virtual void reverse(void)
Reverse the verrtex sequence.
Definition: Face.cc:850
bool hole
true if the face is a hole.
Definition: Face.h:60
bool isWarped(const double &tol=1e-6) const
return true if the surface is warped.
Definition: Face.cc:950
Compound line.
Definition: CmbEdge.h:46
void create_line_nodes(void)
Triggers node creation on the edges.
Definition: Face.cc:741
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: Face.cc:1190
virtual bool operator==(const Face &) const
Comparison operator.
Definition: Face.cc:69
Polyline3d getContour(void) const
Returns the contour of the face as a 3D polyline.
Definition: Face.cc:909
virtual unsigned short int GetDimension(void) const
Returns the dimension of the object.
Definition: Face.h:84
Point (KPoint).
Definition: Pnt.h:50
double getArea(void) const
Returns the face area.
Definition: Face.cc:1025
const std::set< const Body * > & getConnectedBodies(void) const
Return the bodies that touch this surface (neighbors).
Definition: Face.h:138
const std::set< const Face * > & getConnectedSurfaces(void) const
Return the surfaces that touch the line.
Definition: Edge.cc:502
virtual void SetElemSize(const double &sz, bool mustBeEven=true)
Computes the number of divisions on the i axis for an element edge size equal or lesser than the size...
Definition: Face.cc:393
Vector3d getKVector(void) const
Returns a vector in the direction of the local Z axis.
Definition: Face.cc:991
virtual const Pnt * getVertex(const size_t &i) const
Returns the i-th vertex.
Definition: Face.cc:901
void addHole(PolygonalFace *)
Add a hole to the face.
Definition: Face.cc:549
Posición en tres dimensiones.
Definition: Pos3d.h:44
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
void revolve(const int &)
Move forward or backwards the sequence of vertexes.
Definition: Face.cc:861
Matrix of floats.
Definition: Matrix.h:111
Six-faced solid.
Definition: Body.h:71
bool clockwise(const Pos3d &) const
Return true if the point list is oriented clockwise.
Definition: Face.cc:968
double getSquaredDistanceTo(const Pos3d &pt) const
Return the squared distance to the point.
Definition: Face.cc:962
size_t getNumberOfVertices(void) const
Returns the number of vertices.
Definition: Face.h:124
Polygon3d getPolygon(void) const
Return the surface contour as a polygon.
Definition: Face.cc:954
void update_topology(void)
Updates topology.
Definition: Face.cc:758
Mesh node.
Definition: Node.h:111
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: Face.cc:1167
Pos3d getCentroid(void) const
Returns the centroid of the quad surface.
Definition: Face.cc:1013
std::vector< XC::Node * > create_interior_nodes(const std::vector< Pos3d > &)
Creates interior nodes at the positions being passed as parameters.
Definition: Face.cc:677
std::vector< int > create_gmsh_loops(void) const
Create the curve loops for the outer face and the holes.
Definition: Face.cc:611
Surface.
Definition: Face.h:45
Pnt * findVertex(const Pos3d &)
Return a pointer to the vertex at the position argument.
Definition: Face.cc:660
Vector en tres dimensiones.
Definition: Vector3d.h:39
size_t ndivj
number of divisions in the j axis.
Definition: Face.h:61
int create_gmsh_surface(void) const
Ask Gmsh to create the surface corresponding to this face.
Definition: Face.cc:628
Two-dimensional reference system defined in a three-dimensional space.
Definition: Ref2d3d.h:41
Object set.
Definition: SetEntities.h:77
virtual const Edge * get_opposite_side(const Edge *l) const
Return the opposite side with respect to the one being passed as parameter.
Definition: Face.cc:107
std::vector< int > create_gmsh_loops_for_holes(void) const
Create the curve loops of the face holes.
Definition: Face.cc:600
boost::python::list getPyHoles(void) const
Return a list of the face holes.
Definition: Face.cc:569
const PolygonalFace * findHolePtr(PolygonalFace *) const
Return a pointer to the hole corresponding to the argument return nullptr if not found.
Definition: Face.cc:532