XC Open source finite element analysis program
MapLoadPatterns.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
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 //MapLoadPatterns.h
28 
29 #ifndef MAPLOADPATTERNS_H
30 #define MAPLOADPATTERNS_H
31 
32 #include "preprocessor/loaders/LoadLoaderMember.h"
33 #include "domain/load/pattern/LoadPattern.h"
34 #include "domain/load/pattern/TimeSeries.h"
35 #include <map>
36 
37 namespace XC {
38 class TimeSeries;
39 class LoadLoader;
40 class Domain;
41 
43 //
46  {
47  typedef std::map<std::string,TimeSeries *> map_timeseries;
48  map_timeseries tseries;
49  std::string nmb_ts;
50 
51  typedef std::map<std::string,LoadPattern *> map_loadpatterns;
52  map_loadpatterns loadpatterns;
53  std::string lpcode;
54  int tag_el;
55  int tag_nl;
56  int tag_spc;
57 
58  template <class TS>
59  TimeSeries *create_time_series(const std::string &);
60  template <class LP>
61  LoadPattern *create_load_pattern(const std::string &);
62  public:
63  typedef map_loadpatterns::iterator iterator;
64  typedef map_loadpatterns::const_iterator const_iterator;
65  protected:
66  friend class LoadLoader;
67  void clear_time_series(void);
68 
69  DbTagData &getDbTagData(void) const;
70  int sendData(CommParameters &cp);
71  int recvData(const CommParameters &cp);
72  public:
74  ~MapLoadPatterns(void);
75 
76  void clear(void);
77 
78  const_iterator begin(void) const
79  { return loadpatterns.begin(); }
80  const_iterator end(void) const
81  { return loadpatterns.end(); }
82  iterator begin(void)
83  { return loadpatterns.begin(); }
84  iterator end(void)
85  { return loadpatterns.end(); }
86  size_t size(void) const
87  { return loadpatterns.size(); }
88  bool empty(void) const
89  { return loadpatterns.empty(); }
90 
91  const std::string getCurrentLoadPatternId(void) const;
92  LoadPattern *getCurrentLoadPatternPtr(void);
93  const LoadPattern *getCurrentLoadPatternPtr(void) const;
94  inline const std::string &getCurrentLoadPattern(void) const
95  { return lpcode; }
96  inline void setCurrentLoadPattern(const std::string &nmb)
97  { lpcode= nmb; }
98  LoadPattern *newLoadPattern(const std::string &,const std::string &);
99  void addToDomain(const std::string &);
100  void removeFromDomain(const std::string &);
101  void removeAllFromDomain(void);
102 
103  TimeSeries *buscaTS(const int &);
104  const TimeSeries *buscaTS(const int &) const;
105  TimeSeries *buscaTS(const std::string &);
106  const TimeSeries *buscaTS(const std::string &) const;
107  LoadPattern *buscaLoadPattern(const std::string &);
108  const LoadPattern *buscaLoadPattern(const std::string &) const;
109  LoadPattern *buscaLoadPattern(const int &);
110  const LoadPattern *buscaLoadPattern(const int &) const;
111  const std::string &getNombreLoadPattern(const LoadPattern *) const;
112  TimeSeries *newTimeSeries(const std::string &,const std::string &);
113  inline const std::string &getCurrentTimeSeries(void) const
114  { return nmb_ts; }
115  inline void setCurrentTimeSeries(const std::string &nmb)
116  { nmb_ts= nmb; }
117 
118  std::deque<std::string> getListaNombres(void) const;
119  boost::python::list getKeys(void) const;
120 
121  inline const int &getCurrentElementLoadTag(void) const
122  { return tag_el; }
123  inline void setCurrentElementLoadTag(const int &n)
124  { tag_el= n; }
125  inline const int &getCurrentNodeLoadTag(void) const
126  { return tag_nl; }
127  inline void setCurrentNodeLoadTag(const int &n)
128  { tag_nl= n; }
129 
130  int sendSelf(CommParameters &);
131  int recvSelf(const CommParameters &);
132 
133 
134  };
135 
137 template <class TS>
138 TimeSeries *XC::MapLoadPatterns::create_time_series(const std::string &cod_ts)
139  {
140  TimeSeries *ts= buscaTS(cod_ts);
141  if(!ts) //No existe.
142  {
143  TS *nts= new TS();
144  assert(nts);
145  tseries[cod_ts]= nts;
146  ts= nts;
147  }
148  nmb_ts= cod_ts;
149  return ts;
150  }
151 
153 template <class LP>
154 LoadPattern *XC::MapLoadPatterns::create_load_pattern(const std::string &cod_lp)
155  {
156  int &tag_lp= this->getTagLP();
157  LoadPattern *lp= buscaLoadPattern(cod_lp);
158  if(!lp) //No existe.
159  {
160  std::map<std::string,TimeSeries *>::const_iterator its= tseries.find(nmb_ts);
161  if(its!= tseries.end())
162  {
163  lp= new LP(tag_lp);
164  tag_lp++;
165  if(lp)
166  {
167  lp->setTimeSeries(its->second);
168  lp->set_owner(this);
169  loadpatterns[cod_lp]= lp;
170  //If there is the only we make it the default case.
171  if(loadpatterns.empty())
172  lpcode= cod_lp;
173  }
174  }
175  else
176  std::cerr << "MapLoadPatterns; ERROR "
177  << ", time series: " << nmb_ts
178  << " not found." << std::endl;
179  }
180  return lp;
181  }
182 
183 
184 
185 } // end of XC namespace
186 
187 #endif
void removeFromDomain(const std::string &)
Elimina el load pattern del domain.
Definition: MapLoadPatterns.cc:195
A LoadPattern object is used to to store reference loads and single point constraints and a TimeSerie...
Definition: LoadPattern.h:87
void clear_time_series(void)
Clears all the load patterns.
Definition: MapLoadPatterns.cc:268
void clear(void)
Clears all the load patterns.
Definition: MapLoadPatterns.cc:277
int & getTagLP(void)
Returns the tag para el siguiente load pattern.
Definition: LoadLoaderMember.cc:67
Vector que almacena los dbTags de los miembros de la clase.
Definition: DbTagData.h:43
std::deque< std::string > getListaNombres(void) const
Returns the nombres de los load patterns.
Definition: MapLoadPatterns.cc:367
~MapLoadPatterns(void)
Destructor.
Definition: MapLoadPatterns.cc:291
boost::python::list getKeys(void) const
Returns load case names.
Definition: MapLoadPatterns.cc:376
const std::string & getNombreLoadPattern(const LoadPattern *) const
Returns the nombre del caso pointed by the parameter.
Definition: MapLoadPatterns.cc:163
LoadPattern * buscaLoadPattern(const std::string &)
Returns a pointer to the load pattern cuyo nombre being passed as parameter.
Definition: MapLoadPatterns.cc:117
int sendData(CommParameters &cp)
Send members through the channel being passed as parameter.
Definition: MapLoadPatterns.cc:312
Load pattern container.
Definition: MapLoadPatterns.h:45
LoadPattern * newLoadPattern(const std::string &, const std::string &)
Define un objeto LoasPattern con el tipo y el nombre being passed as parameters.
Definition: MapLoadPatterns.cc:253
int recvSelf(const CommParameters &)
Receives object through the channel being passed as parameter.
Definition: MapLoadPatterns.cc:349
void addToDomain(const std::string &)
Adds the load pattern to the domain.
Definition: MapLoadPatterns.cc:177
TimeSeries * buscaTS(const int &)
Returns a pointer to the TS cuyo dbTag being passed as parameter. se usa en LoadPattern::recvData.
Definition: MapLoadPatterns.cc:71
DbTagData & getDbTagData(void) const
Returns a vector para almacenar los dbTags de los miembros de la clase.
Definition: MapLoadPatterns.cc:305
void removeAllFromDomain(void)
Elimina las loadpatterns del domain.
Definition: MapLoadPatterns.cc:207
TimeSeries * newTimeSeries(const std::string &, const std::string &)
Define un objeto TimeSeries con el tipo y el nombre being passed as parameters. Interpreta los siguie...
Definition: MapLoadPatterns.cc:224
??.
Definition: LoadLoaderMember.h:42
int recvData(const CommParameters &cp)
Send members through the channel being passed as parameter.
Definition: MapLoadPatterns.cc:323
Lee load patterns desde archivo. Load definition manager.
Definition: LoadLoader.h:44
Communication parameters between processes.
Definition: CommParameters.h:65
================================================================================
Definition: ContinuaReprComponent.h:34
Time variation of loads.A TimeSeries object is used to determine the load factor to be applied to the...
Definition: TimeSeries.h:81
int sendSelf(CommParameters &)
Sends object through the channel being passed as parameter.
Definition: MapLoadPatterns.cc:337
MapLoadPatterns(LoadLoader *owr)
Default constructor.
Definition: MapLoadPatterns.cc:66