Memosa-FVM  0.2
StressTensor.h
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #ifndef _STRESSTENSOR_H_
6 #define _STRESSTENSOR_H_
7 
8 #include "NumType.h"
9 #include "Vector.h"
10 #include <sstream>
11 
12 
22 template <class T>
24 {
25 public:
29 
30  static string getTypeName()
31  {
32  return "StressTensor<" + NumTypeTraits<T>::getTypeName() +
33  ">";
34  }
35 
36  // treated as one d for numpy export purposes
37  static int getDimension() {return 1;}
38 
39  static void getShape(int *shp) { *shp = 6;}
40 
41  static int getDataSize()
42  {
44  }
45 
46  T& operator[](int n) {return _data[n];}
47  const T& operator[](int n) const {return _data[n];}
48 
49  StressTensor& operator=(const T& o)
50  {
51  for(int i=0;i<6;i++)
52  _data[i] = o;
53  return *this;
54  }
55 
57  {
58  for(int i=0;i<6;i++)
59  _data[i] = o[i];
60  return *this;
61  }
62 
64  {
65  StressTensor r;
66  for(int i=0;i<6;i++)
67  r[i]=-_data[i];
68  return r;
69  }
70 
72  {
73  for(int i=0;i<6;i++)
74  _data[i] += o[i];
75  return *this;
76  }
77 
79  {
80  for(int i=0;i<6;i++)
81  _data[i] += s;
82  return *this;
83  }
84 
86  {
87  for(int i=0;i<6;i++)
88  _data[i] -= o[i];
89  return *this;
90  }
91 
93  {
94  for(int i=0;i<6;i++)
95  _data[i] -= s;
96  return *this;
97  }
98 
100  {
101  for(int i=0;i<6;i++)
102  _data[i] /= s;
103  return *this;
104  }
105 
107  {
108  throw;
109  }
110 
112  {
113  for(int i=0;i<6;i++)
114  _data[i] *= s;
115  return *this;
116  }
117 
119  {
120  throw;
121  }
122 
123  void zero()
124  {
125  for(int i=0;i<6;i++) _data[i] = NumTypeTraits<T>::getZero();
126  }
127 
128  T mag2() const
129  {
130  throw;
131  }
132 
133  bool operator<(const double tolerance) const
134  {
135  return mag2() < tolerance*tolerance;
136  }
137 
139  {
140  StressTensor z;
141  z.zero();
142  return z;
143  }
144 
145  static double doubleMeasure(const StressTensor& x)
146  {
147  throw;
148  }
149 
151  {
152  throw;
153  }
154 
156  {
157  throw;
158  }
159 
160  static void accumulateOneNorm(StressTensor& sum, const StressTensor& v)
161  {
162  throw;
163  }
164 
165  static void accumulateDotProduct(StressTensor& sum, const StressTensor& v0,
166  const StressTensor& v1)
167  {
168  throw;
169  }
170 
171  static void reduceSum(T_Scalar& sum, const This_T& x)
172  {
173  throw;
174  }
175 
176  static void safeDivide(StressTensor& x, const StressTensor& y)
177  {
178  throw;
179  }
180 
181  static void normalize(StressTensor& x, const StressTensor& y)
182  {
183  throw;
184  }
185 
186  static void setMax(StressTensor& x, const StressTensor& y)
187  {
188  throw;
189  }
190 
191 private:
192  T _data[6];
193 };
194 
195 template<class T>
196 inline ostream& operator<<(ostream &os,
197  const StressTensor<T> &v)
198 {
199  throw;
200 }
201 
202 template<class T>
205 {
206  return StressTensor<T>(a) += b;
207 }
208 
209 template<class T>
212 {
213  return StressTensor<T>(a) -= b;
214 }
215 
216 template<class T>
219 {
220  return -StressTensor<T>(a);
221 }
222 
223 template<class T>
226 {
227  throw;
228 }
229 
230 template<class T>
232 operator*(const T s, const StressTensor<T>& a)
233 {
234  throw;
235 }
236 
237 template<class T>
239 operator*(const StressTensor<T>& a, const T s)
240 {
241  throw;
242 }
243 
244 template<class T>
246 operator/(const StressTensor<T>& a, const T s)
247 {
248  throw;
249 }
250 
251 
252 template<class T>
254 operator/(const T s, const StressTensor<T>& a)
255 {
256  throw;
257 }
258 
259 
260 #endif
static int getDataSize()
Definition: StressTensor.h:41
StressTensor & operator-=(const T s)
Definition: StressTensor.h:92
T & operator[](int n)
Definition: StressTensor.h:46
StressTensor & operator*=(const StressTensor &o)
Definition: StressTensor.h:118
static void setMax(StressTensor &x, const StressTensor &y)
Definition: StressTensor.h:186
static void normalize(StressTensor &x, const StressTensor &y)
Definition: StressTensor.h:181
StressTensor operator-()
Definition: StressTensor.h:63
StressTensor & operator-=(const StressTensor &o)
Definition: StressTensor.h:85
StressTensor< T > operator+(const StressTensor< T > &a, const StressTensor< T > &b)
Definition: StressTensor.h:204
static void safeDivide(StressTensor &x, const StressTensor &y)
Definition: StressTensor.h:176
StressTensor & operator/=(const StressTensor &o)
Definition: StressTensor.h:106
StressTensor & operator/=(const T s)
Definition: StressTensor.h:99
StressTensor & operator=(const StressTensor &o)
Definition: StressTensor.h:56
NumTypeTraits< T >::T_Scalar T_Scalar
Definition: StressTensor.h:27
StressTensor< T > operator/(const StressTensor< T > &a, const T s)
Definition: StressTensor.h:246
static StressTensor getNegativeUnity()
Definition: StressTensor.h:150
NumTypeTraits< T >::T_BuiltIn T_BuiltIn
Definition: StressTensor.h:28
const T & operator[](int n) const
Definition: StressTensor.h:47
T mag2() const
Definition: StressTensor.h:128
static void reduceSum(T_Scalar &sum, const This_T &x)
Definition: StressTensor.h:171
StressTensor & operator+=(const T s)
Definition: StressTensor.h:78
static double doubleMeasure(const StressTensor &x)
Definition: StressTensor.h:145
StressTensor< T > operator-(const StressTensor< T > &a, const StressTensor< T > &b)
Definition: StressTensor.h:211
static string getTypeName()
Definition: StressTensor.h:30
ostream & operator<<(ostream &os, const StressTensor< T > &v)
Definition: StressTensor.h:196
StressTensor< T > operator*(const StressTensor< T > &a, const StressTensor< T > &b)
Definition: StressTensor.h:225
StressTensor & operator+=(const StressTensor &o)
Definition: StressTensor.h:71
static void getShape(int *shp)
Definition: StressTensor.h:39
StressTensor & operator*=(const T s)
Definition: StressTensor.h:111
StressTensor< T > This_T
Definition: StressTensor.h:26
static void accumulateDotProduct(StressTensor &sum, const StressTensor &v0, const StressTensor &v1)
Definition: StressTensor.h:165
static void accumulateOneNorm(StressTensor &sum, const StressTensor &v)
Definition: StressTensor.h:160
static StressTensor getUnity()
Definition: StressTensor.h:155
static StressTensor getZero()
Definition: StressTensor.h:138
bool operator<(const double tolerance) const
Definition: StressTensor.h:133
static int getDimension()
Definition: StressTensor.h:37
StressTensor & operator=(const T &o)
Definition: StressTensor.h:49