xc
SurfaceLoadBase.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 /* ****************************************************************** **
29 ** OpenSees - Open System for Earthquake Engineering Simulation **
30 ** Pacific Earthquake Engineering Research Center **
31 ** **
32 ** **
33 ** (C) Copyright 1999, The Regents of the University of California **
34 ** All Rights Reserved. **
35 ** **
36 ** Commercial use of this program without express permission of the **
37 ** University of California, Berkeley, is strictly prohibited. See **
38 ** file 'COPYRIGHT' in main directory for information on usage and **
39 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
40 ** **
41 ** Developed by: **
42 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
43 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
44 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
45 ** **
46 ** ****************************************************************** */
47 
48 #ifndef SurfaceLoadBase_h
49 #define SurfaceLoadBase_h
50 
51 // Written: Chris McGann
52 // Created: 04.2009
53 // Modified: Chris McGann, 11.2010
54 // Chris McGann, 02.2011 -> added elemental load
55 
56 // Description: This file contains the class definition for SurfaceLoadBase.
57 
58 #include "domain/mesh/element/ElementBase.h"
59 #include "domain/load/ElementalLoad.h"
60 #include "utility/utils/misc_utils/colormod.h"
61 
62 namespace XC {
63 
64 template <int NNODES>
65 class SurfaceLoadBase: public ElementBase<NNODES>
66  {
67  protected:
68  double my_pressure;
69  double mLoadFactor;
70  protected:
71  int sendData(Communicator &);
72  int recvData(const Communicator &);
73  public:
74  SurfaceLoadBase(int tag, int classTag, double pressure, double loadFactor);
75 
76  double getLoadFactor(void) const;
77  void setLoadFactor(const double &);
78  double getPressure(void) const;
79  void setPressure(const double &);
80 
81  // public methods to set the state of the element
82  int commitState(void);
83  int revertToLastCommit(void);
84  int revertToStart(void);
85  int update(void);
86 
87  void zeroLoad(void);
88  int addInertiaLoadToUnbalance(const Vector &accel);
89  int addLoad(ElementalLoad *theLoad, double loadFactor);
90 
91  void Print(std::ostream &, int flag =0);
92  };
93 
94 template <int NNODES>
96 SurfaceLoadBase<NNODES>::SurfaceLoadBase(int tag, int classTag, double pressure, double loadFactor)
97  : ElementBase<NNODES>(tag, classTag),
98  my_pressure(pressure),
99  mLoadFactor(loadFactor)
100  {}
101 
102 template <int NNODES>
104  {
105  int retVal = 0;
106  // call element commitState to do any base class stuff
107  if((retVal = this->ElementBase<NNODES>::commitState()) != 0)
108  {
109  std::cerr << Color::red << this->getClassName() << "::" << __FUNCTION__
110  << "; failed in base class"
111  << Color::def << std::endl;
112  }
113 
114  return retVal;
115  }
116 
117 template <int NNODES>
119  { return 0; }
120 
121 template <int NNODES>
123  { return 0; }
124 
125 template <int NNODES>
127  { return 0; }
128 
129 
130 template <int NNODES>
132  { return this->mLoadFactor; }
133 
134 template <int NNODES>
135 void SurfaceLoadBase<NNODES>::setLoadFactor(const double &d)
136  { this->mLoadFactor= d; }
137 
138 template <int NNODES>
141  { return this->my_pressure; }
142 
143 template <int NNODES>
146  { this->my_pressure= d; }
147 
148 template <int NNODES>
149 int SurfaceLoadBase<NNODES>::addLoad(ElementalLoad *theLoad, double loadFactor)
150  {
151  int type(0);
152  const Vector &data= theLoad->getData(type, loadFactor);
153 
154  if(type == LOAD_TAG_SurfaceLoad)
155  {
156  mLoadFactor = loadFactor;
157  this->my_pressure+= data[0]; // Set pressure.
158  return 0;
159  }
160  else
161  {
162  std::cerr << Color::red << this->getClassName() << "::" << __FUNCTION__
163  << "; ele with tag: " << this->getTag()
164  << " does not accept load type: " << type
165  << Color::def << std::endl;
166  return -1;
167  }
168  return -1;
169  }
170 
171 template <int NNODES>
173  {
174  this->my_pressure= 0.0;
175  }
176 
177 template <int NNODES>
179  { return 0; }
180 
181 template <int NNODES>
184  {
185  int res= ElementBase<NNODES>::sendData(comm);
186  res+=comm.sendDoubles(this->mLoadFactor, this->my_pressure, this->getDbTagData(),CommMetaData(7));
187  return res;
188  }
189 
190 template <int NNODES>
193  {
194  int res= ElementBase<NNODES>::recvData(comm);
195  res+=comm.receiveDoubles(this->mLoadFactor, this->my_pressure, this->getDbTagData(),CommMetaData(7));
196  return res;
197  }
198 
199 template <int NNODES>
200 void SurfaceLoadBase<NNODES>::Print(std::ostream &os, int flag)
201  {
202  os << this->getClassName() << ", element id: "
203  << this->getTag() << std::endl
204  << " Connected external nodes: " << this->theNodes << std::endl;
205  }
206 
207 
208 
209 } //end of XC namespace
210 #endif
int receiveDoubles(double &, double &, DbTagData &, const CommMetaData &) const
Receives the doubles through the communicator argument.
Definition: Communicator.cc:675
Float vector abstraction.
Definition: Vector.h:94
int update(void)
Updates the element state.
Definition: SurfaceLoadBase.h:126
Definition: SurfaceLoadBase.h:65
Communication parameters between processes.
Definition: Communicator.h:66
int commitState(void)
Commit the current element state.
Definition: SurfaceLoadBase.h:103
Data about the index, size,,...
Definition: CommMetaData.h:39
void zeroLoad(void)
Zeroes the loads over the element.
Definition: SurfaceLoadBase.h:172
int recvData(const Communicator &)
Receives object members through the communicator argument.
Definition: SurfaceLoadBase.h:192
double getPressure(void) const
Set the pressure.
Definition: SurfaceLoadBase.h:140
int sendDoubles(const double &, const double &, DbTagData &, const CommMetaData &)
Send the doubles through the communicator argument.
Definition: Communicator.cc:612
double mLoadFactor
factor from load pattern
Definition: SurfaceLoadBase.h:69
int revertToStart(void)
Reverts the element to its initial state.
Definition: SurfaceLoadBase.h:122
int revertToLastCommit(void)
Revert to the last committed state.
Definition: SurfaceLoadBase.h:118
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Base class for finite element with pointer to nodes container.
Definition: ElementBase.h:47
int sendData(Communicator &)
Send object members through the communicator argument.
Definition: SurfaceLoadBase.h:183
Base class for loads over elements.
Definition: ElementalLoad.h:79
SurfaceLoadBase(int tag, int classTag, double pressure, double loadFactor)
Constructor.
Definition: SurfaceLoadBase.h:96
double my_pressure
pressure applied to surface of element
Definition: SurfaceLoadBase.h:68
void setPressure(const double &)
Get the pressure.
Definition: SurfaceLoadBase.h:145