forked from gismo/gsKLShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgsMaterialMatrixEval.h
244 lines (196 loc) · 9.68 KB
/
gsMaterialMatrixEval.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/** @file gsMaterialMatrixEval.h
@brief Provides an evaluator for material matrices for thin shells
This file is part of the G+Smo library.
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Author(s):
H.M. Verhelst (2019-..., TU Delft)
A. Mantzaflaris (2019-..., Inria)
*/
#pragma once
#include <gsCore/gsFunction.h>
#include <gsKLShell/gsMaterialMatrixContainer.h>
#include <gsKLShell/gsMaterialMatrixUtils.h>
#include <gsIO/gsOptionList.h>
namespace gismo
{
template <class T, enum MaterialOutput out> class gsMaterialMatrixEvalSingle;
template <class T, enum MaterialOutput out>
class gsMaterialMatrixEval : public gsFunction<T>
{
public:
/// Constructor
gsMaterialMatrixEval( const gsMaterialMatrixContainer<T> & materialMatrices,
const gsFunctionSet<T> * deformed,
const gsMatrix<T> z)
:
m_materialMatrices(materialMatrices),
m_deformed(deformed),
m_z(z),
m_piece(nullptr)
{
gsDebugVar("Container");
}
/// Constructor
gsMaterialMatrixEval( gsMaterialMatrixBase<T> * materialMatrix,
const gsFunctionSet<T> * deformed,
const gsMatrix<T> z)
:
m_materialMatrices(deformed->nPieces()),
m_deformed(deformed),
m_z(z),
m_piece(nullptr)
{
gsDebugVar("Single");
for (index_t p = 0; p!=deformed->nPieces(); ++p)
m_materialMatrices.add(materialMatrix);
}
/// Domain dimension, always 2 for shells
short_t domainDim() const {return 2;}
/**
* @brief Target dimension
*
* For a scalar (e.g. density) the target dimension is 1, for a vector (e.g. stress tensor in Voight notation) the target dimension is 3 and for a matrix (e.g. the material matrix) the target dimension is 9, which can be reshaped to a 3x3 matrix.
*
* @return Returns the target dimension depending on the specified type (scalar, vector, matrix etc.)
*/
short_t targetDim() const { return this->piece(0).targetDim(); }
/// Implementation of piece, see \ref gsFunction
const gsFunction<T> & piece(const index_t p) const
{
m_piece = new gsMaterialMatrixEvalSingle<T,out>(p,m_materialMatrices.piece(p),m_deformed,m_z);
return *m_piece;
}
/// Destructor
~gsMaterialMatrixEval() { delete m_piece; }
/// Implementation of eval_into, see \ref gsFunction
void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
{ GISMO_NO_IMPLEMENTATION; }
protected:
gsMaterialMatrixContainer<T> m_materialMatrices;
const gsFunctionSet<T> * m_deformed;
gsMatrix<T> m_z;
mutable gsMaterialMatrixEvalSingle<T,out> * m_piece;
};
/**
* @brief This class serves as the evaluator of material matrices, based on \ref gsMaterialMatrixBase
*
* @tparam T Real tyoe
* @tparam out Output type (see \ref MaterialOutput)
*
* @ingroup KLShell
*/
template <class T, enum MaterialOutput out>
class gsMaterialMatrixEvalSingle : public gsFunction<T>
{
public:
/// Constructor
gsMaterialMatrixEvalSingle( index_t patch,
gsMaterialMatrixBase<T> * materialMatrix,
const gsFunctionSet<T> * deformed,
const gsMatrix<T> z);
/// Domain dimension, always 2 for shells
short_t domainDim() const {return 2;}
/**
* @brief Target dimension
*
* For a scalar (e.g. density) the target dimension is 1, for a vector (e.g. stress tensor in Voight notation) the target dimension is 3 and for a matrix (e.g. the material matrix) the target dimension is 9, which can be reshaped to a 3x3 matrix.
*
* @return Returns the target dimension depending on the specified type (scalar, vector, matrix etc.)
*/
short_t targetDim() const { return targetDim_impl<out>(); }
private:
/// Implementation of \ref targetDim for densities
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Density , short_t>::type targetDim_impl() const { return 1; };
/// Implementation of \ref targetDim for stress tensors
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::VectorN ||
_out==MaterialOutput::VectorM ||
_out==MaterialOutput::Generic , short_t>::type targetDim_impl() const { return 3; };
/// Implementation of \ref targetDim for material tensors
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::MatrixA ||
_out==MaterialOutput::MatrixB ||
_out==MaterialOutput::MatrixC ||
_out==MaterialOutput::MatrixD , short_t>::type targetDim_impl() const { return 9; };
/// Implementation of \ref targetDim for principal stress fields
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::PStressN ||
_out==MaterialOutput::PStressM , short_t>::type targetDim_impl() const { return 2; };
/// Implementation of \ref targetDim for principal stretch fields
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Stretch , short_t>::type targetDim_impl() const { return 3; };
/// Implementation of \ref targetDim for principal stress directions
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::StretchDir, short_t>::type targetDim_impl() const { return 9; };
/// Implementation of \ref targetDim for principal stress directions
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Transformation, short_t>::type targetDim_impl() const { return 9; };
/// Implementation of \ref targetDim for the thickness
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Thickness, short_t>::type targetDim_impl() const { return 1; };
/// Implementation of \ref targetDim for the parameters
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Parameters, short_t>::type targetDim_impl() const { return m_materialMat->numParameters(); };
public:
/// Implementation of piece, see \ref gsFunction
const gsFunction<T> & piece(const index_t p) const
{
m_piece = new gsMaterialMatrixEvalSingle(*this);
m_piece->setPatch(p);
return *m_piece;
}
protected:
/// Sets the patch index
void setPatch(index_t p) {m_pIndex = p; }
public:
/// Destructor
~gsMaterialMatrixEvalSingle() { delete m_piece; }
/// Implementation of eval_into, see \ref gsFunction
void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const;
private:
/// Specialisation of \ref eval_into for densities
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Density , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the membrane stress tensor N, M and generic stress
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::VectorN ||
_out==MaterialOutput::VectorM ||
_out==MaterialOutput::Generic , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the moments of the material matrices
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::MatrixA ||
_out==MaterialOutput::MatrixB ||
_out==MaterialOutput::MatrixC ||
_out==MaterialOutput::MatrixD , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the membrane and flexural principle stresses
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::PStressN ||
_out==MaterialOutput::PStressM , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the stretches
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Stretch , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the stretch directions
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::StretchDir, void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the basis transformation
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Transformation, void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the thickness
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Thickness, void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
/// Specialisation of \ref eval_into for the parameters
template<enum MaterialOutput _out>
typename std::enable_if<_out==MaterialOutput::Parameters, void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
protected:
index_t m_pIndex;
gsMaterialMatrixBase<T> * m_materialMat;
mutable gsMaterialMatrixEvalSingle<T,out> * m_piece;
gsMatrix<T> m_z;
};
} // namespace
#ifndef GISMO_BUILD_LIB
#include GISMO_HPP_HEADER(gsMaterialMatrixEval.hpp)
#endif