XC Open source finite element analysis program
FVectorData.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 //FVectorData.h
28 
29 #ifndef FVectorData_h
30 #define FVectorData_h
31 
32 #include "FVector.h"
33 #include "utility/matrix/Vector.h"
34 #include "utility/actor/actor/MovableVector.h"
35 #include <typeinfo>
36 
37 namespace XC {
38 
39 template <size_t SZ>
41 //
43 class FVectorData: public FVector
44  {
45  protected:
46  double p[SZ];
47  public:
48  inline const double &operator[](size_t i) const
49  { return p[i]; }
50  inline double &operator[](size_t i)
51  { return p[i]; }
52  inline size_t size(void) const
53  { return SZ; }
54  inline virtual double *getPtr(void)
55  { return p; }
56  inline virtual const double *getPtr(void) const
57  { return p; }
58  const Vector &getVector(void) const;
59  void putVector(const Vector &v);
60  std::string getClassName(void) const;
61  int sendData(CommParameters &cp,DbTagData &dt,const CommMetaData &);
62  int receiveData(const CommParameters &cp,DbTagData &dt,const CommMetaData &);
63 
64  };
65 
66 template <size_t SZ>
67 const Vector &FVectorData<SZ>::getVector(void) const
68  {
69  static Vector retval(SZ);
70  double *tmp= const_cast<double *>(p);
71  retval= Vector(tmp,SZ);
72  return retval;
73  }
74 
75 template <size_t SZ>
77  {
78  const size_t sz= std::min(size_t(v.Size()),SZ);
79  for(size_t i=0;i<sz;i++)
80  p[i]= v[i];
81  }
82 
83 template <size_t SZ>
84 std::string FVectorData<SZ>::getClassName(void) const
85  { return typeid(*this).name(); }
86 
87 template <size_t SZ>
89  { return cp.sendVector(getVector(),dt,md); }
90 
91 template <size_t SZ>
93  {
94  Vector tmp= getVector();
95  int res= cp.receiveVector(tmp,dt,md);
96  putVector(tmp);
97  return res;
98  }
99 
100 } // end of XC namespace
101 
102 #endif
103 
104 
Element internal forces.
Definition: FVector.h:44
int receiveVector(Vector &v, const int &) const
Recibe el vector.
Definition: CommParameters.cc:407
int sendVector(const Vector &, const int &)
Sends vector.
Definition: CommParameters.cc:400
Definition: Vector.h:82
Vector que almacena los dbTags de los miembros de la clase.
Definition: DbTagData.h:43
Auxiliary class for the internal forces in a beam-column element.
Definition: FVectorData.h:43
Communication parameters between processes.
Definition: CommParameters.h:65
================================================================================
Definition: ContinuaReprComponent.h:34
Data about the index, size,,... of the object to transmit.
Definition: CommMetaData.h:38