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