mat_vec_types.h
Go to the documentation of this file.
1 //
2 // This file is part of the FFEA simulation package
3 //
4 // Copyright (c) by the Theory and Development FFEA teams,
5 // as they appear in the README.md file.
6 //
7 // FFEA is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // FFEA is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with FFEA. If not, see <http://www.gnu.org/licenses/>.
19 //
20 // To help us fund FFEA development, we humbly ask that you cite
21 // the research papers on the package.
22 //
23 
24 #ifndef MAT_VEC_TYPES_H_INCLUDED
25 #define MAT_VEC_TYPES_H_INCLUDED
26 
27 #include <cstddef>
28 #include <limits>
29 #include <cmath>
30 #include <array>
31 
32 /*
33  * Defines what is meant by a scalar (essentially sets the precision of
34  * the code between float or double).
35  */
36 typedef double scalar;
37 typedef double geoscalar;
38 #ifdef USE_DOUBLE_PLUS
39 typedef double scalar;
40 typedef long double geoscalar;
41 #elif USE_DOUBLE
42 typedef double scalar;
43 typedef double geoscalar;
44 #elif USE_DOUBLE_LESS
45 typedef float scalar;
46 typedef double geoscalar;
47 #endif
48 //typedef long double scalar;
49 
51 namespace ffea_const {
52  const scalar threeErr = 3.0*std::numeric_limits<scalar>::epsilon();
53  const scalar threeGeoErr = 3.0*std::numeric_limits<geoscalar>::epsilon();
54  const scalar pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148;
55  const scalar mOne = -1.0;
56  const scalar zero = 0.0;
57  const scalar half = 0.5;
58  const scalar one = 1.0;
59  const scalar two = 2.0;
60  const scalar eight = 8.0;
61  const geoscalar ten = 10.0;
62  const scalar twentyfour = 24.0;
63  const scalar oneOverThree = 0.33333333333333333;
64  const scalar oneOverSix = 0.166666666666666667;
65  const scalar oneOverEight = 0.12500000000000000;
66  const scalar sphereFactor = 4.0 * 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148 / 3.0;
67 }
68 
70 typedef scalar arr3[3];
71 typedef geoscalar grr3[3];
72 
73 
74 typedef scalar arr4[4];
75 typedef geoscalar grr4[4];
76 
77 /*
78  * The old 3 dimensional vector (x, y, z)
79  * that is responsible of so many .x, .y, and .z,
80  * stopping people from simply looping.
81 typedef struct {
82  scalar x, y, z;
83 } vector3; */
84 
85 // The following class is a temporary replacement
86  // for the old vector3 struct so that we have some
87  // time to change from Whatever.x into Whatever[0]
88  // Then vector3 will become arr3.
89  // Therefore, don't ever populate this class with methods!!
90 class vector3 {
91 public:
93  scalar& x = data[0];
94  scalar& y = data[1];
95  scalar& z = data[2];
96  scalar& operator [](std::size_t i) { return data[i]; }
97  void assign( scalar t0, scalar t1, scalar t2 )
98  { data[0] = t0; data[1] = t1; data[2] = t2; }
99 };
100 
104 template <class t_scalar, class brr3> class arr3_view
105 {
106 public:
107  arr3_view(brr3 (&arr) ) : data(arr) {}
108  arr3_view(t_scalar* data, std::size_t size) : data(data) { }
109 
110  t_scalar* begin() { return data; }
111  t_scalar* end() { return data + 3; }
112  t_scalar& operator [](std::size_t i) { return data[i]; }
113 
114 private:
115  t_scalar* data;
116 };
117 
118 
122 typedef scalar vector12[12];
123 
127 typedef scalar matrix12[12][12];
128 
132 typedef scalar matrix3[3][3];
133 
137 typedef scalar matrix4[4][4];
138 
142 typedef struct {
143  scalar u00, u01, u02, u03,
144  u11, u12, u13,
145  u22, u23,
146  u33;
148 #endif
const scalar threeGeoErr
Definition: mat_vec_types.h:53
arr3_view(t_scalar *data, std::size_t size)
Definition: mat_vec_types.h:108
static const int z
Definition: rod_math_v9.h:54
scalar matrix3[3][3]
Definition: mat_vec_types.h:132
const scalar half
Definition: mat_vec_types.h:57
const scalar zero
Definition: mat_vec_types.h:56
const scalar oneOverThree
Definition: mat_vec_types.h:63
void assign(scalar t0, scalar t1, scalar t2)
Definition: mat_vec_types.h:97
const scalar one
Definition: mat_vec_types.h:58
const scalar twentyfour
Definition: mat_vec_types.h:62
const scalar sphereFactor
Definition: mat_vec_types.h:66
scalar vector12[12]
Definition: mat_vec_types.h:122
arr3_view(brr3(&arr))
Definition: mat_vec_types.h:107
double geoscalar
Definition: mat_vec_types.h:37
static const int y
Definition: rod_math_v9.h:53
static const int x
Definition: rod_math_v9.h:52
geoscalar grr3[3]
Definition: mat_vec_types.h:71
geoscalar grr4[4]
Definition: mat_vec_types.h:75
t_scalar * begin()
Definition: mat_vec_types.h:110
const geoscalar ten
Definition: mat_vec_types.h:61
scalar arr3[3]
Definition: mat_vec_types.h:70
scalar matrix12[12][12]
Definition: mat_vec_types.h:127
scalar u33
Definition: mat_vec_types.h:143
Definition: mat_vec_types.h:142
t_scalar * data
Definition: mat_vec_types.h:115
const scalar oneOverSix
Definition: mat_vec_types.h:64
const scalar eight
Definition: mat_vec_types.h:60
t_scalar * end()
Definition: mat_vec_types.h:111
Definition: mat_vec_types.h:104
static const int i
index of ith thing
Definition: rod_math_v9.h:63
arr3 data
Definition: mat_vec_types.h:92
const scalar pi
Definition: mat_vec_types.h:54
Definition: mat_vec_types.h:90
const scalar threeErr
Definition: mat_vec_types.h:52
scalar matrix4[4][4]
Definition: mat_vec_types.h:137
double scalar
Definition: mat_vec_types.h:36
scalar arr4[4]
Definition: mat_vec_types.h:74
Definition: mat_vec_types.h:51
const scalar mOne
Definition: mat_vec_types.h:55
const scalar oneOverEight
Definition: mat_vec_types.h:65
const scalar two
Definition: mat_vec_types.h:59