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;
137 
138  const std::set<const Body *> &getConnectedBodies(void) const;
139  boost::python::list getConnectedBodiesPy(void) const;
140  std::set<const Face *> getConnectedSurfaces(void) const;
141  boost::python::list getConnectedSurfacesPy(void) const;
142 
143  std::set<const Body *> getConnectedBodies(const SetBase *) const;
144  boost::python::list getConnectedBodiesPy(const SetBase *) const;
145  std::set<const Face *> getConnectedSurfaces(const SetBase *) const;
146  boost::python::list getConnectedSurfacesPy(const SetBase *) const;
147 
148  size_t CommonEdge(const Face &) const;
149  std::set<const Edge *> getCommonEdges(const Face &);
150  boost::python::list getCommonEdgesPy(const Face &);
151  int SenseOfEdge(const Edge *l,const Face &other) const;
152  bool isConnectedTo(const Body &b) const;
153  std::deque<const Edge *> getNDivErrors(const size_t &) const;
154  bool checkNDivs(const size_t &) const;
155  std::deque<const Edge *> getNDivErrors(void) const;
156  virtual bool checkNDivs(void) const;
157 
158  virtual Node *getNode(const size_t &i1,const size_t &j,const size_t &k);
159  virtual const Node *getNode(const size_t &i,const size_t &j,const size_t &k) const;
160  virtual Node *getNode(const size_t &i,const size_t &j);
161  virtual const Node *getNode(const size_t &i,const size_t &j) const;
162 
163  std::set<SetBase *> get_sets(void) const;
164  void add_to_sets(std::set<SetBase *> &);
165 
166  //Surface orientation.
167  bool clockwise(const Pos3d &) const;
168  bool counterclockwise(const Pos3d &) const;
169  std::string orientation(const Pos3d &) const;
170  virtual void reverse(void);
171  void revolve(const int &);
172  void setKOrientation(const Vector3d &);
173  int setIOrientation(const Vector3d &);
174 
175  int getVtkCellType(void) const;
176 
177  boost::python::dict getPyDict(void) const;
178  void setPyDict(const boost::python::dict &);
179  };
180 
181 std::set<const Face *> get_connected_surfaces(const Edge &);
182 std::set<const Pnt *> get_common_vertex(const Face &,const Face &, const Face &);
183 
184 } //end of XC namespace.
185 
186 #endif
size_t getNumberOfEdges(void) const
Return the number of edges.
Definition: CmbEdge.h:155
virtual void setNDivI(const size_t &)
Set the number of divisions on the i axis.
Definition: Face.cc:217
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:88
std::set< SetBase * > get_sets(void) const
Returns the sets that contains this surface.
Definition: Face.cc:1210
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:904
void add_to_sets(std::set< SetBase *> &)
Appends the surface to each of the sets being passed as parameter.
Definition: Face.cc:1227
hole_iterator findHole(PolygonalFace *)
Return an iterator to the hole corresponding to the argument return holes.end() if not found...
Definition: Face.cc:500
virtual void setNDivJ(const size_t &)
Set the number of divisions on the j axis.
Definition: Face.cc:239
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:1008
bool isConnectedTo(const Body &b) const
Returns true if the lines touches the body (neighbor).
Definition: Face.cc:1203
Base class for one-dimensional geometry objects.
Definition: Edge.h:49
const Edge * getOppositeEdge(const Edge &) const
Return the opposite side with respect to the one being passed as parameter.
Definition: Face.cc:767
virtual void ConciliaNDivIJ(void)
Conciliate lines division numbers with those of the surface.
Definition: Face.cc:378
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:705
Finite element model generation tools.
Definition: Preprocessor.h:59
std::set< const Face * > get_connected_surfaces(const Edge &)
Return the surfaces that touch the given line.
Definition: Face.cc:1076
void setNDiv(const size_t &)
Sets the number of divisions for all its sides.
Definition: Face.cc:201
bool counterclockwise(const Pos3d &) const
Return true if the points are counter-clockwise ordered with respect to the element.
Definition: Face.cc:1018
std::deque< std::pair< const Edge *, const Edge * > > getOppositeEdges(void) const
Return a deque of opposite edge pairs.
Definition: Face.cc:776
void set_ndiv_j(const size_t &)
Sets the number of divisions for direction J.
Definition: Face.cc:195
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:51
const std::set< const Body * > & getConnectedBodies(void) const
Return the bodies that touch this surface (neighbors).
Definition: Face.cc:1080
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:444
bool isHole(void) const
Return true if the face corresponds to a hole.
Definition: Face.cc:540
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:1032
int setIOrientation(const Vector3d &)
Set the orientation of the face i unit vector as close as possible to the given vector.
Definition: Face.cc:915
Plane getPlane(void) const
Return the plane containing the face.
Definition: Face.cc:945
virtual bool checkNDivs(void) const
Verifies that the number of divisions of the lines are compatible.
Definition: Face.cc:356
void setHole(const bool &)
Return true if the face corresponds to a hole.
Definition: Face.cc:544
void set_ndiv_i(const size_t &)
Sets the number of divisions for direction I.
Definition: Face.cc:191
const std::deque< PolygonalFace * > & getHoles(void) const
Return a list of the face holes.
Definition: Face.cc:566
Base de las clases Set y SetEstruct.
Definition: SetBase.h:51
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:262
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:411
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:146
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:478
std::deque< const Edge * > getNDivErrors(void) const
Returns a list with the edges that have an incompatible number of divisions.
Definition: Face.cc:337
bool isFlat(const double &tol=1e-6) const
return true if the surface is flat.
Definition: Face.cc:960
int create_gmsh_loop(void) const
Create a Gmsh curve loop from the face sides.
Definition: Face.cc:583
int SenseOfEdge(const Edge *l, const Face &other) const
Returns:
Definition: Face.cc:847
int getVtkCellType(void) const
Interfaz con VTK.
Definition: Face.cc:1287
std::deque< Side * > findSides(const Pos3d &)
Return a pointer to the side at the position argument.
Definition: Face.cc:646
virtual void reverse(void)
Reverse the verrtex sequence.
Definition: Face.cc:882
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:982
Compound line.
Definition: CmbEdge.h:45
void create_line_nodes(void)
Triggers node creation on the edges.
Definition: Face.cc:742
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: Face.cc:1345
virtual bool operator==(const Face &) const
Comparison operator.
Definition: Face.cc:70
Polyline3d getContour(void) const
Returns the contour of the face as a 3D polyline.
Definition: Face.cc:941
virtual unsigned short int GetDimension(void) const
Returns the dimension of the object.
Definition: Face.h:84
Point (KPoint).
Definition: Pnt.h:51
std::set< const Face * > getConnectedSurfaces(void) const
Return the surfaces that touch this surface (neighbors).
Definition: Face.cc:1134
double getArea(void) const
Returns the face area.
Definition: Face.cc:1057
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:394
Vector3d getKVector(void) const
Returns a vector in the direction of the local Z axis.
Definition: Face.cc:1023
virtual const Pnt * getVertex(const size_t &i) const
Returns the i-th vertex.
Definition: Face.cc:933
void addHole(PolygonalFace *)
Add a hole to the face.
Definition: Face.cc:550
Posición en tres dimensiones.
Definition: Pos3d.h:44
boost::python::list getCommonEdgesPy(const Face &)
Returns the edges in common with the given surface.
Definition: Face.cc:829
boost::python::list getConnectedSurfacesPy(void) const
Return the surfaces that touch this surface (neighbors).
Definition: Face.cc:1175
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:893
Matrix of floats.
Definition: Matrix.h:111
Six-faced solid.
Definition: Body.h:71
size_t CommonEdge(const Face &) const
Returns the index of the edge in common with the given surface (if it exists).
Definition: Face.cc:796
bool clockwise(const Pos3d &) const
Return true if the point list is oriented clockwise.
Definition: Face.cc:1000
double getSquaredDistanceTo(const Pos3d &pt) const
Return the squared distance to the point.
Definition: Face.cc:994
size_t getNumberOfVertices(void) const
Returns the number of vertices.
Definition: Face.h:124
std::set< const Edge * > getCommonEdges(const Face &)
Returns the edges in common with the given surface.
Definition: Face.cc:813
Polygon3d getPolygon(void) const
Return the surface contour as a polygon.
Definition: Face.cc:986
void update_topology(void)
Updates topology.
Definition: Face.cc:759
Mesh node.
Definition: Node.h:112
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: Face.cc:1322
Pos3d getCentroid(void) const
Returns the centroid of the quad surface.
Definition: Face.cc:1045
std::vector< XC::Node * > create_interior_nodes(const std::vector< Pos3d > &)
Creates interior nodes at the positions being passed as parameters.
Definition: Face.cc:678
boost::python::list getConnectedBodiesPy(void) const
Return the bodies that touch this surface (neighbors).
Definition: Face.cc:1106
std::vector< int > create_gmsh_loops(void) const
Create the curve loops for the outer face and the holes.
Definition: Face.cc:612
Surface.
Definition: Face.h:45
Pnt * findVertex(const Pos3d &)
Return a pointer to the vertex at the position argument.
Definition: Face.cc:661
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:629
Two-dimensional reference system defined in a three-dimensional space.
Definition: Ref2d3d.h:41
Object set.
Definition: SetEntities.h:78
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:108
std::vector< int > create_gmsh_loops_for_holes(void) const
Create the curve loops of the face holes.
Definition: Face.cc:601
boost::python::list getPyHoles(void) const
Return a list of the face holes.
Definition: Face.cc:570
const PolygonalFace * findHolePtr(PolygonalFace *) const
Return a pointer to the hole corresponding to the argument return nullptr if not found.
Definition: Face.cc:533