xc
BodyMap.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 //BodyMap.h
29 
30 #ifndef BodyMap_H
31 #define BodyMap_H
32 
33 #include "EntityMap.h"
34 #include "preprocessor/multi_block_topology/entities/3d/Body.h"
35 
36 namespace XC {
37 
38 class Block;
39 
41 //
43 class BodyMap: public EntityMap<Body>
44  {
45  private:
46  void updateSets(Body *) const;
47  protected:
48 
49 
50  public:
51  BodyMap(MultiBlockTopology *mbt= nullptr);
52 
53  bool conciliaNDivs(void);
54  std::deque<const Edge *> getNDivErrors(void) const;
55  std::deque<int> getNDivErrorTags(void) const;
56  boost::python::list getNDivErrorTagsPy(void) const;
57  bool checkNDivs(void) const;
58 
59  template <class B>
60  Body *New(void);
61  template <class B>
62  Body *New(const size_t &);
63  Body *New(const size_t &, const std::string &);
64 
65  Block *newBlockPts(const size_t &, const size_t &,const size_t &,const size_t &,const size_t &, const size_t &,const size_t &,const size_t &);
66  double getAverageVolume(void) const;
67 
68  boost::python::dict getPyDict(void) const;
69  void setPyDict(const boost::python::dict &);
70  };
71 
72 
74 template <class B>
76  {
77  Body *retval= busca(getTag());
78  if(!retval) //It doesn't already exist.
79  {
80  Preprocessor *preprocessor= getPreprocessor();
81  retval= new B(preprocessor);
82  if(retval)
83  {
84  retval->Name()= "f"+boost::lexical_cast<std::string>(getTag());
85  (*this)[getTag()]= retval;
86  updateSets(retval);
87  tag++;
88  }
89  }
90  return retval;
91  }
92 
94 template <class B>
95 XC::Body *BodyMap::New(const size_t &tag)
96  {
97  size_t old_tag= getTag();
98  Body *retval= nullptr;
99  setTag(tag); // Edge identifier.
100  retval= busca(getTag());
101  if(retval)
102  {
103  std::cerr << getClassName() << "::" << __FUNCTION__
104  << "; body with identifier: " << tag
105  << " already exists. Command ignored." << std::endl;
106  }
107  else
108  { retval= New<B>(); }
109  setTag(old_tag);
110  return retval;
111  }
112 } //end of XC namespace
113 #endif
BodyMap(MultiBlockTopology *mbt=nullptr)
Constructor.
Definition: BodyMap.cc:42
Geometric entities container (points, lines, surfaces,...).
Definition: EntityMap.h:43
Finite element model generation tools.
Definition: Preprocessor.h:59
Model geometry manager.
Definition: MultiBlockTopology.h:68
bool conciliaNDivs(void)
Conciliates the number of divisions of the lines.
Definition: BodyMap.cc:74
std::deque< int > getNDivErrorTags(void) const
Returns the indentifiers of the edges that have an incompatible number of divisions.
Definition: BodyMap.cc:106
std::deque< const Edge * > getNDivErrors(void) const
Returns a list with the edges that have an incompatible number of divisions.
Definition: BodyMap.cc:81
std::string & Name(void)
Return a reference to the object name.
Definition: NamedEntity.h:52
Block * newBlockPts(const size_t &, const size_t &, const size_t &, const size_t &, const size_t &, const size_t &, const size_t &, const size_t &)
New block.
Definition: BodyMap.cc:128
boost::python::list getNDivErrorTagsPy(void) const
Returns the indentifiers of the edges that have an incompatible number of divisions.
Definition: BodyMap.cc:116
Six-faced body.
Definition: Block.h:40
virtual std::string getClassName(void) const
Returns demangled class name.
Definition: EntityWithOwner.cc:90
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: BodyMap.cc:150
const Preprocessor * getPreprocessor(void) const
Return a pointer to preprocessor.
Definition: ModelComponentContainerBase.cc:54
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: BodyMap.cc:166
Body container.
Definition: BodyMap.h:43
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Body * New(void)
Creates a new body.
Definition: BodyMap.h:75
Six-faced solid.
Definition: Body.h:71
double getAverageVolume(void) const
Return the average volume of the bodies.
Definition: BodyMap.cc:140
bool checkNDivs(void) const
Checks that the number of divisions of the edges are compatible.
Definition: BodyMap.cc:97
Body * busca(const Indice &)
Return a pointer to the geometry entity whose identifier is passed as parameter.
Definition: ModelComponentContainer.h:78