xc
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/prep_handlers/LoadHandlerMember.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 LoadHandler;
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 LoadHandler;
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 &getLoadPatternName(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> getNamesList(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) //Doesn't exist.
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) //Doesn't exist.
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
LoadPattern * newLoadPattern(const std::string &, const std::string &)
Define a LoadPattern object withe the type and the name being passed as parameters.
Definition: MapLoadPatterns.cc:255
void clear(void)
Clears all the load patterns.
Definition: MapLoadPatterns.cc:279
LoadPattern * buscaLoadPattern(const std::string &)
Returns a pointer to the load pattern cuyo nombre being passed as parameter.
Definition: MapLoadPatterns.cc:117
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:43
MapLoadPatterns(LoadHandler *owr)
Default constructor.
Definition: MapLoadPatterns.cc:66
int recvSelf(const CommParameters &)
Receives object through the channel passed as parameter.
Definition: MapLoadPatterns.cc:351
??.
Definition: LoadHandlerMember.h:42
A LoadPattern object is used to to store reference loads and single point constraints and a TimeSerie...
Definition: LoadPattern.h:93
virtual void setTimeSeries(TimeSeries *theSeries)
Set the time series for the pattern.
Definition: LoadPattern.cpp:146
int & getTagLP(void)
Returns the tag para el siguiente load pattern.
Definition: LoadHandlerMember.cc:77
int recvData(const CommParameters &cp)
Send members through the channel passed as parameter.
Definition: MapLoadPatterns.cc:325
const std::string & getLoadPatternName(const LoadPattern *) const
Returns the name of the load pattern pointed by the parameter.
Definition: MapLoadPatterns.cc:164
void removeAllFromDomain(void)
Remove the loadpatterns del domain.
Definition: MapLoadPatterns.cc:208
std::deque< std::string > getNamesList(void) const
Return the names of the load patterns.
Definition: MapLoadPatterns.cc:369
void clear_time_series(void)
Clears all the load patterns.
Definition: MapLoadPatterns.cc:270
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
Load pattern container.
Definition: MapLoadPatterns.h:45
void addToDomain(const std::string &)
Adds the load pattern to the domain.
Definition: MapLoadPatterns.cc:178
TimeSeries * buscaTS(const int &)
Returns a pointer to the TS cuyo dbTag being passed as parameter.
Definition: MapLoadPatterns.cc:71
Time variation of loads.
Definition: TimeSeries.h:81
DbTagData & getDbTagData(void) const
Return a vector to store the dbTags of the class members.
Definition: MapLoadPatterns.cc:307
Communication parameters between processes.
Definition: CommParameters.h:65
TimeSeries * newTimeSeries(const std::string &, const std::string &)
Define a TimeSeries object with the type and name passed as parameters.
Definition: MapLoadPatterns.cc:225
Lee load patterns desde archivo.
Definition: LoadHandler.h:44
void removeFromDomain(const std::string &)
Remove the load pattern del domain.
Definition: MapLoadPatterns.cc:196
int sendSelf(CommParameters &)
Sends object through the channel passed as parameter.
Definition: MapLoadPatterns.cc:339
int sendData(CommParameters &cp)
Send members through the channel passed as parameter.
Definition: MapLoadPatterns.cc:314
boost::python::list getKeys(void) const
Return load case names.
Definition: MapLoadPatterns.cc:378
~MapLoadPatterns(void)
Destructor.
Definition: MapLoadPatterns.cc:293