xc
MultiBlockTopology.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 //MultiBlockTopology.h
29 
30 #ifndef MULTIBLOCKTOPOLOGY_H
31 #define MULTIBLOCKTOPOLOGY_H
32 
33 #include "preprocessor/PreprocessorContainer.h"
34 #include <map>
35 #include "boost/lexical_cast.hpp"
36 #include "preprocessor/multi_block_topology/entities/containers/PntMap.h"
37 #include "preprocessor/multi_block_topology/entities/containers/LineMap.h"
38 #include "preprocessor/multi_block_topology/entities/containers/SurfaceMap.h"
39 #include "preprocessor/multi_block_topology/entities/containers/BodyMap.h"
40 #include "preprocessor/multi_block_topology/entities/containers/UniformGridMap.h"
41 #include "preprocessor/multi_block_topology/ReferenceFrameMap.h"
42 #include "preprocessor/multi_block_topology/matrices/Framework2d.h"
43 #include "preprocessor/multi_block_topology/matrices/Framework3d.h"
44 
45 class Pos3d;
46 class Line3d;
47 class Plane;
48 class Vector3d;
49 
50 namespace XC {
51 
52 class Pnt;
53 class UniformGrid;
54 class SetEstruct;
55 class ReferenceFrame;
56 
60 //
62 //
69  {
70  friend class Preprocessor;
71  protected:
72  DbTagData &getDbTagData(void) const;
73  int sendData(Communicator &);
74  int recvData(const Communicator &);
75  private:
76  template <class L>
77  static void numerate_list(L &l);
78  void numerate(void);
79  ReferenceFrameMap reference_systems;
80 
81  PntMap points;
82  LineMap edges;
83  SurfaceMap faces;
84  BodyMap bodies;
85  UniformGridMap unif_grid;
86  Framework2d framework2d;
87  Framework3d framework3d;
88 
89  protected:
90  SetEstruct *find_struct_set(const UniformGridMap::Indice &nmb);
91  public:
93  MultiBlockTopology(Preprocessor *mod= nullptr);
94 
95  Edge *find_edge_by_endpoints(const Pnt &,const Pnt &);
96  const Edge *find_edge_by_endpoints(const Pnt &,const Pnt &) const;
97  Edge *find_edge_by_endpoints(const PntMap::Indice &,const PntMap::Indice &);
98  const Edge *find_edge_by_endpoints(const PntMap::Indice &,const PntMap::Indice &) const;
99 
100  void conciliaNDivs(void);
101  inline std::set<const XC::Edge *> getHomologousSides(const Edge *e) const
102  { return faces.getHomologousSides(e); }
103 
104  void clearAll(void);
106  virtual ~MultiBlockTopology(void);
107 
108  inline const PntMap &getPoints(void) const
109  { return points; }
110  inline PntMap &getPoints(void)
111  { return points; }
112  inline const LineMap &getLines(void) const
113  { return edges; }
114  inline LineMap &getLines(void)
115  { return edges; }
116  inline const SurfaceMap &getSurfaces(void) const
117  { return faces; }
118  inline SurfaceMap &getSurfaces(void)
119  { return faces; }
120  inline const BodyMap &getBodies(void) const
121  { return bodies; }
122  inline BodyMap &getBodies(void)
123  { return bodies; }
124  inline const ReferenceFrameMap &getReferenceSystems(void) const
125  { return reference_systems; }
126  inline ReferenceFrameMap &getReferenceSystems(void)
127  { return reference_systems; }
128  inline const Framework2d &getFramework2d(void) const
129  { return framework2d; }
130  inline Framework2d &getFramework2d(void)
131  { return framework2d; }
132  inline const Framework3d &getFramework3d(void) const
133  { return framework3d; }
134  inline Framework3d &getFramework3d(void)
135  { return framework3d; }
136  inline const UniformGridMap &getUniformGrids(void) const
137  { return unif_grid; }
138  inline UniformGridMap &getUniformGrids(void)
139  { return unif_grid; }
140 
141  double getAverageSize(void) const;
142 
143  boost::python::dict getPyDict(void) const;
144  void setPyDict(const boost::python::dict &);
145  virtual int sendSelf(Communicator &);
146  virtual int recvSelf(const Communicator &);
147  };
148 
151 template <class FaceContainer, class EdgeContainer>
152 void conciliate_divisions(FaceContainer &faces, EdgeContainer &edges)
153  {
154  typedef typename EdgeContainer::iterator edge_iterator;
155  typedef typename FaceContainer::iterator face_iterator;
156  if(!faces.empty())
157  {
158  std::set<const Edge *> tmp_edges;
159  for(edge_iterator i=edges.begin();i!=edges.end();i++)
160  tmp_edges.insert(*i);
161  const size_t max_num_iter= 1000;
162  size_t conta= 0;
163  while(!tmp_edges.empty())
164  {
165  const Edge *lado= *tmp_edges.begin();
166  std::set<const Edge *> homologous= lado->getHomologousSides();
167  if(homologous.empty()) // nothing to do
168  {
169  Edge *tmp= const_cast<Edge *>(lado);
170  tmp_edges.erase(tmp);
171  }
172  else
173  {
174  homologous.insert(lado);
175  const size_t nd= calcula_ndiv_lados(homologous);
176  for(std::set<const Edge *>::const_iterator i= homologous.begin();i!=homologous.end();i++)
177  {
178  Edge *tmp= const_cast<Edge *>(*i);
179  tmp->setNDiv(nd);
180  tmp_edges.erase(tmp);
181  }
182  conta++;
183  if(conta>max_num_iter)
184  {
185  std::cerr << __FUNCTION__
186  << "; too much iterations." << std::endl;
187  break;
188  }
189  }
190  }
191  for(face_iterator i=faces.begin();i!= faces.end();i++)
192  (*i)->ConciliaNDivIJ();
193  }
194  }
195 
196 } //end of XC namespace
197 #endif
Base class for one-dimensional geometry objects.
Definition: Edge.h:48
Communication parameters between processes.
Definition: Communicator.h:66
std::set< const XC::Edge * > getHomologousSides(const Edge *) const
Return the homologous sides to that passed as a parameter.
Definition: SurfaceMap.cc:151
virtual void setNDiv(const size_t &)
Assigns the number of of divisions if it is compatible with the homologous edges. ...
Definition: Edge.cc:262
DbTagData & getDbTagData(void) const
Return a vector to store the dbTags of the class members.
Definition: MultiBlockTopology.cc:193
Finite element model generation tools.
Definition: Preprocessor.h:59
Object that can move between processes.
Definition: MovableObject.h:100
Model geometry manager.
Definition: MultiBlockTopology.h:68
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:44
virtual int recvSelf(const Communicator &)
Receive object through the communicator argument.
Definition: MultiBlockTopology.cc:277
Model points container.
Definition: SurfaceMap.h:43
Plane in a three-dimensional space.
Definition: Plane.h:49
Reference systems container.
Definition: ReferenceFrameMap.h:42
Edge * find_edge_by_endpoints(const Pnt &, const Pnt &)
Return the «edge» that has as end points those whose indices are passed as parameters.
Definition: MultiBlockTopology.cc:77
Uniform grid container.
Definition: UniformGridMap.h:45
Bidimensional framework container.
Definition: Framework2d.h:43
void conciliaNDivs(void)
Conciliate number of divisions of the lines.
Definition: MultiBlockTopology.cc:132
virtual ~MultiBlockTopology(void)
Destructor.
Definition: MultiBlockTopology.cc:188
Line container.
Definition: LineMap.h:49
int recvData(const Communicator &)
Receive data through the communicator argument.
Definition: MultiBlockTopology.cc:246
void clearAll(void)
Erase all the geometry entities.
Definition: MultiBlockTopology.cc:155
virtual int sendSelf(Communicator &)
Send object through the communicator argument.
Definition: MultiBlockTopology.cc:262
Point container.
Definition: PntMap.h:53
Point (KPoint).
Definition: Pnt.h:50
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: MultiBlockTopology.cc:200
Base class for preprocessor containers i.
Definition: PreprocessorContainer.h:44
structured set, i.
Definition: SetEstruct.h:47
void conciliate_divisions(FaceContainer &faces, EdgeContainer &edges)
Conciliate the number of divisions of the lines shared by faces.
Definition: MultiBlockTopology.h:152
int sendData(Communicator &)
Send data through the communicator argument.
Definition: MultiBlockTopology.cc:229
size_t calcula_ndiv_lados(const std::set< const XC::Edge *> &)
Compute the number of divisions for each line to make it compatible with adjacent surface meshing...
Definition: Edge.cc:532
Posición en tres dimensiones.
Definition: Pos3d.h:44
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: MultiBlockTopology.cc:215
SetEstruct * find_struct_set(const UniformGridMap::Indice &nmb)
Search for the entity whose name is passed as a parameter.
Definition: MultiBlockTopology.cc:146
Body container.
Definition: BodyMap.h:43
Line in a three-dimensional space.
Definition: Line3d.h:62
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
MultiBlockTopology(Preprocessor *mod=nullptr)
Constructor.
Definition: MultiBlockTopology.cc:60
Three dimensional framework container.
Definition: Framework3d.h:42
Vector en tres dimensiones.
Definition: Vector3d.h:39
std::set< const XC::Edge * > getHomologousSides(void) const
Return the homologous sides to that passed as a parameter.
Definition: Edge.cc:522