xc
MapLoadPatterns.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 //MapLoadPatterns.h
29 
30 #ifndef MAPLOADPATTERNS_H
31 #define MAPLOADPATTERNS_H
32 
33 #include "preprocessor/prep_handlers/LoadHandlerMember.h"
34 #include "domain/load/pattern/LoadPattern.h"
35 #include "domain/load/pattern/TimeSeries.h"
36 #include <map>
37 
38 namespace XC {
39 class TimeSeries;
40 class LoadHandler;
41 class Domain;
42 
44 //
47  {
48  typedef std::map<std::string,TimeSeries *> map_timeseries;
49  map_timeseries tseries;
50  typedef map_timeseries::iterator time_series_iterator;
51  typedef map_timeseries::const_iterator time_series_const_iterator;
52 
53  std::string time_series_name;
54 
55  typedef std::map<std::string,LoadPattern *> map_loadpatterns;
56  map_loadpatterns loadpatterns;
57  std::string lpcode;
58  int tag_el;
59  int tag_nl;
60  int tag_spc;
61 
62  template <class TS>
63  TimeSeries *create_time_series(const std::string &);
64  template <class LP>
65  LoadPattern *create_load_pattern(const std::string &);
66  public:
67  typedef map_loadpatterns::iterator iterator;
68  typedef map_loadpatterns::const_iterator const_iterator;
69  protected:
70  friend class LoadHandler;
71  void clear_time_series(void);
72 
73  DbTagData &getDbTagData(void) const;
74  int sendData(Communicator &comm);
75  int recvData(const Communicator &comm);
76  public:
78  ~MapLoadPatterns(void);
79 
80  void clear(void);
81 
82  const_iterator begin(void) const
83  { return loadpatterns.begin(); }
84  const_iterator end(void) const
85  { return loadpatterns.end(); }
86  iterator begin(void)
87  { return loadpatterns.begin(); }
88  iterator end(void)
89  { return loadpatterns.end(); }
90  size_t size(void) const
91  { return loadpatterns.size(); }
92  bool empty(void) const
93  { return loadpatterns.empty(); }
94 
95  const std::string getCurrentLoadPatternId(void) const;
96  LoadPattern *getCurrentLoadPatternPtr(void);
97  const LoadPattern *getCurrentLoadPatternPtr(void) const;
98  inline const std::string &getCurrentLoadPattern(void) const
99  { return lpcode; }
100  inline void setCurrentLoadPattern(const std::string &nmb)
101  { lpcode= nmb; }
102  LoadPattern *newLoadPattern(const std::string &,const std::string &);
103  bool removeLoadPattern(const std::string &);
104  void addToDomain(const std::string &);
105  void removeFromDomain(const std::string &);
106  void removeAllFromDomain(void);
107 
108  TimeSeries *findTS(const int &);
109  const TimeSeries *findTS(const int &) const;
110  TimeSeries *findTS(const std::string &);
111  const TimeSeries *findTS(const std::string &) const;
112  LoadPattern *findLoadPattern(const std::string &);
113  const LoadPattern *findLoadPattern(const std::string &) const;
114  LoadPattern *findLoadPattern(const int &);
115  const LoadPattern *findLoadPattern(const int &) const;
116  const std::string &getLoadPatternName(const LoadPattern *) const;
117  TimeSeries *newTimeSeries(const std::string &,const std::string &);
118  inline const std::string &getCurrentTimeSeries(void) const
119  { return time_series_name; }
120  inline void setCurrentTimeSeries(const std::string &nmb)
121  { time_series_name= nmb; }
122  const std::string &getTimeSeriesName(const TimeSeries *) const;
123 
124  std::deque<std::string> getNamesList(void) const;
125  boost::python::list getKeys(void) const;
126 
127  inline const int &getCurrentElementLoadTag(void) const
128  { return tag_el; }
129  inline void setCurrentElementLoadTag(const int &n)
130  { tag_el= n; }
131  inline const int &getCurrentNodeLoadTag(void) const
132  { return tag_nl; }
133  inline void setCurrentNodeLoadTag(const int &n)
134  { tag_nl= n; }
135 
136  std::list<LoadPattern *> getLoadPatternsActingOn(const Node *);
137  boost::python::list getLoadPatternsActingOnPy(const Node *);
138  void removeLoadsOn(const Node *);
139  void copyLoads(const Node *, const Node *);
140  std::list<LoadPattern *> getLoadPatternsActingOn(const Element *);
141  boost::python::list getLoadPatternsActingOnPy(const Element *);
142  void removeLoadsOn(const Element *);
143  void copyLoads(const Element *, const Element *);
144 
145  int sendSelf(Communicator &);
146  int recvSelf(const Communicator &);
147  boost::python::dict getPyDict(void) const;
148  void setPyDict(const boost::python::dict &);
149  };
150 
152 template <class TS>
153 TimeSeries *XC::MapLoadPatterns::create_time_series(const std::string &cod_ts)
154  {
155  TimeSeries *ts= findTS(cod_ts);
156  if(!ts) //Doesn't exist.
157  {
158  TS *nts= new TS();
159  assert(nts);
160  tseries[cod_ts]= nts;
161  ts= nts;
162  }
163  ts->set_owner(this);
164  time_series_name= cod_ts;
165  return ts;
166  }
167 
169 template <class LP>
170 LoadPattern *XC::MapLoadPatterns::create_load_pattern(const std::string &cod_lp)
171  {
172  int &tag_lp= this->getTagLP();
173  LoadPattern *lp= findLoadPattern(cod_lp);
174  if(!lp) //Doesn't exist.
175  {
176  std::map<std::string,TimeSeries *>::const_iterator its= tseries.find(time_series_name);
177  if(its!= tseries.end())
178  {
179  lp= new LP(tag_lp);
180  tag_lp++;
181  if(lp)
182  {
183  lp->setTimeSeries(its->second);
184  lp->set_owner(this);
185  loadpatterns[cod_lp]= lp;
186  //If there is the only we make it the default case.
187  if(loadpatterns.empty())
188  lpcode= cod_lp;
189  }
190  }
191  else
192  std::cerr << "MapLoadPatterns; ERROR "
193  << ", time series: " << time_series_name
194  << " not found." << std::endl;
195  }
196  return lp;
197  }
198 
199 
200 
201 } // end of XC namespace
202 
203 #endif
LoadPattern * newLoadPattern(const std::string &, const std::string &)
Define a LoadPattern object with the type and the name being passed as parameters.
Definition: MapLoadPatterns.cc:276
LoadPattern * findLoadPattern(const std::string &)
Returns a pointer to the load pattern which name being passed as parameter.
Definition: MapLoadPatterns.cc:116
void clear(void)
Clears all the load patterns.
Definition: MapLoadPatterns.cc:332
Communication parameters between processes.
Definition: Communicator.h:66
void copyLoads(const Node *, const Node *)
Copy the loads from the first node to the second one.
Definition: MapLoadPatterns.cc:399
TimeSeries * findTS(const int &)
Returns a pointer to the TS cuyo dbTag being passed as parameter.
Definition: MapLoadPatterns.cc:70
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: MapLoadPatterns.cc:525
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:44
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: MapLoadPatterns.cc:493
MapLoadPatterns(LoadHandler *owr)
Default constructor.
Definition: MapLoadPatterns.cc:65
??.
Definition: LoadHandlerMember.h:43
A load pattern is the spatial distribution as well as its variation in time of a specific set of forc...
Definition: LoadPattern.h:97
virtual void setTimeSeries(TimeSeries *theSeries)
Set the time series for the pattern.
Definition: LoadPattern.cpp:165
const std::string & getTimeSeriesName(const TimeSeries *) const
Returns the name of the time series pointed by the parameter.
Definition: MapLoadPatterns.cc:261
Base class for the finite elements.
Definition: Element.h:112
int & getTagLP(void)
Returns the tag para el siguiente load pattern.
Definition: LoadHandlerMember.cc:77
std::list< LoadPattern * > getLoadPatternsActingOn(const Node *)
Return the load patterns that act on the given node.
Definition: MapLoadPatterns.cc:359
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
void removeLoadsOn(const Node *)
Removes the given node from all the load patterns.
Definition: MapLoadPatterns.cc:386
std::deque< std::string > getNamesList(void) const
Return the names of the load patterns.
Definition: MapLoadPatterns.cc:614
void clear_time_series(void)
Clears all the load patterns.
Definition: MapLoadPatterns.cc:323
boost::python::list getLoadPatternsActingOnPy(const Node *)
Return the load patterns that act on the given node.
Definition: MapLoadPatterns.cc:372
int recvSelf(const Communicator &)
Receives object through the communicator argument.
Definition: MapLoadPatterns.cc:596
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Load pattern container.
Definition: MapLoadPatterns.h:46
void addToDomain(const std::string &)
Adds the load pattern to the domain.
Definition: MapLoadPatterns.cc:178
Time variation of loads.
Definition: TimeSeries.h:85
DbTagData & getDbTagData(void) const
Return a vector to store the dbTags of the class members.
Definition: MapLoadPatterns.cc:462
void set_owner(EntityWithOwner *owr)
Assigns the owner of the object.
Definition: EntityWithOwner.cc:111
int recvData(const Communicator &comm)
Send members through the communicator argument.
Definition: MapLoadPatterns.cc:480
TimeSeries * newTimeSeries(const std::string &, const std::string &)
Define a TimeSeries object with the type and name passed as parameters.
Definition: MapLoadPatterns.cc:225
Load definition manager.
Definition: LoadHandler.h:45
Mesh node.
Definition: Node.h:111
int sendSelf(Communicator &)
Sends object through the communicator argument.
Definition: MapLoadPatterns.cc:584
int sendData(Communicator &comm)
Send members through the communicator argument.
Definition: MapLoadPatterns.cc:469
void removeFromDomain(const std::string &)
Remove the load pattern del domain.
Definition: MapLoadPatterns.cc:196
bool removeLoadPattern(const std::string &)
Remove the load pattern with the given name.
Definition: MapLoadPatterns.cc:299
boost::python::list getKeys(void) const
Return load case names.
Definition: MapLoadPatterns.cc:623
~MapLoadPatterns(void)
Destructor.
Definition: MapLoadPatterns.cc:346