G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsMaterialMatrixIntegrate.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include <gsCore/gsFunction.h>
20 
21 namespace gismo
22 {
23 
24 template <class T, enum MaterialOutput out> class gsMaterialMatrixIntegrateSingle;
25 
26 template <class T, enum MaterialOutput out>
27 class gsMaterialMatrixIntegrate : public gsFunction<T>
28 {
29 public:
31  gsMaterialMatrixIntegrate( const gsMaterialMatrixContainer<T> & materialMatrices,
32  const gsFunctionSet<T> * deformed)
33  :
34  m_materialMatrices(materialMatrices),
35  m_deformed(deformed)
36  {
37  for (index_t p = 0; p!=m_materialMatrices.size(); p++)
38  {
39  GISMO_ASSERT(materialMatrices.piece(p)!=nullptr,"Material matrix "<<p<<" is incomplete!");
40  GISMO_ASSERT(materialMatrices.piece(p)!=NULL,"Material matrix "<<p<<" is incomplete!");
41  GISMO_ASSERT(materialMatrices.piece(p)->initialized(),"Material matrix "<<p<<" is incomplete!");
42  }
43 
44  this->_makePieces(deformed);
45  }
46 
48  gsMaterialMatrixIntegrate( gsMaterialMatrixBase<T> * materialMatrix,
49  const gsFunctionSet<T> * deformed)
50  :
51  m_materialMatrices(deformed->nPieces()),
52  m_deformed(deformed)
53  {
54  GISMO_ASSERT(materialMatrix->initialized(),"Material matrix is incomplete!");
55  for (index_t p = 0; p!=deformed->nPieces(); ++p)
56  m_materialMatrices.set(p,materialMatrix);
57  this->_makePieces(deformed);
58  }
59 
61  gsMaterialMatrixIntegrate( const gsMaterialMatrixContainer<T> & materialMatrices,
62  const gsFunctionSet<T> * undeformed,
63  const gsFunctionSet<T> * deformed)
64  :
65  m_materialMatrices(materialMatrices),
66  m_deformed(deformed)
67  {
68  this->_makePieces(undeformed,deformed);
69  }
70 
72  gsMaterialMatrixIntegrate( gsMaterialMatrixBase<T> * materialMatrix,
73  const gsFunctionSet<T> * undeformed,
74  const gsFunctionSet<T> * deformed)
75  :
76  m_materialMatrices(deformed->nPieces()),
77  m_deformed(deformed)
78  {
79  for (index_t p = 0; p!=deformed->nPieces(); ++p)
80  {
81  m_materialMatrices.set(p,materialMatrix);
82  this->_makePieces(undeformed,deformed);
83  }
84  }
85 
87  ~gsMaterialMatrixIntegrate()
88  {
89  freeAll(m_pieces);
90  }
91 
93  short_t domainDim() const {return 2;}
94 
102  short_t targetDim() const { return this->piece(0).targetDim(); }
103 
105  const gsFunction<T> & piece(const index_t p) const
106  {
107  return *m_pieces[p];
108  }
109 
111  void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
113 
114 protected:
115  void _makePieces(const gsFunctionSet<T> * deformed)
116  {
117  m_pieces.resize(deformed->nPieces());
118  for (size_t p = 0; p!=m_pieces.size(); ++p)
119  m_pieces.at(p) = new gsMaterialMatrixIntegrateSingle<T,out>(p,m_materialMatrices.piece(p),deformed);
120  }
121 
122  void _makePieces(const gsFunctionSet<T> * undeformed, const gsFunctionSet<T> * deformed)
123  {
124  m_pieces.resize(m_deformed->nPieces());
125  for (size_t p = 0; p!=m_pieces.size(); ++p)
126  m_pieces.at(p) = new gsMaterialMatrixIntegrateSingle<T,out>(p,m_materialMatrices.piece(p),undeformed,deformed);
127  }
128 
129 protected:
130  gsMaterialMatrixContainer<T> m_materialMatrices;
131  const gsFunctionSet<T> * m_deformed;
132  mutable std::vector<gsMaterialMatrixIntegrateSingle<T,out> *> m_pieces;
133 };
134 
143 template <class T, enum MaterialOutput out>
144 class gsMaterialMatrixIntegrateSingle : public gsFunction<T>
145 {
146 public:
147 
150  gsMaterialMatrixBase<T> * materialMatrix,
151  const gsFunctionSet<T> * deformed);
152 
155  gsMaterialMatrixBase<T> * materialMatrix,
156  const gsFunctionSet<T> * undeformed,
157  const gsFunctionSet<T> * deformed);
158 
160 
162  short_t domainDim() const {return 2;}
163 
171  short_t targetDim() const { return targetDim_impl<out>(); }
172 
173 
174 private:
176  template<enum MaterialOutput _out>
177  typename std::enable_if<_out==MaterialOutput::Density , short_t>::type targetDim_impl() const { return 1; };
178 
180  template<enum MaterialOutput _out>
181  typename std::enable_if<_out==MaterialOutput::VectorN ||
182  _out==MaterialOutput::CauchyVectorN ||
183  _out==MaterialOutput::VectorM ||
184  _out==MaterialOutput::CauchyVectorM , short_t>::type targetDim_impl() const { return 3; };
185 
187  template<enum MaterialOutput _out>
188  typename std::enable_if<_out==MaterialOutput::MatrixA ||
189  _out==MaterialOutput::MatrixB ||
190  _out==MaterialOutput::MatrixC ||
191  _out==MaterialOutput::MatrixD , short_t>::type targetDim_impl() const { return 9; };
192 
194  template<enum MaterialOutput _out>
195  typename std::enable_if<_out==MaterialOutput::PStressN ||
196  _out==MaterialOutput::PStressM ||
197  _out==MaterialOutput::PStrainN ||
198  _out==MaterialOutput::PStrainM , short_t>::type targetDim_impl() const { return 2; };
199 
201  template<enum MaterialOutput _out>
202  typename std::enable_if<_out==MaterialOutput::Stretch , short_t>::type targetDim_impl() const { return 3; };
203 
205  template<enum MaterialOutput _out>
206  typename std::enable_if<_out==MaterialOutput::StretchDir, short_t>::type targetDim_impl() const { return 9; };
207 
208 protected:
210  void setPatch(index_t p) {m_pIndex = p; }
211 
212 public:
214  void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const;
215 
216 private:
218  template<enum MaterialOutput _out>
219  typename std::enable_if<_out==MaterialOutput::Density , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
220 
222  template<enum MaterialOutput _out>
223  typename std::enable_if<_out==MaterialOutput::VectorN ||
224  _out==MaterialOutput::CauchyVectorN , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
225 
227  template<enum MaterialOutput _out>
228  typename std::enable_if<_out==MaterialOutput::VectorM ||
229  _out==MaterialOutput::CauchyVectorM , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
230 
232  template<enum MaterialOutput _out>
233  typename std::enable_if<_out==MaterialOutput::MatrixA ||
234  _out==MaterialOutput::MatrixB ||
235  _out==MaterialOutput::MatrixC ||
236  _out==MaterialOutput::MatrixD , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
237 
239  template<enum MaterialOutput _out>
240  typename std::enable_if<_out==MaterialOutput::PStressN ||
241  _out==MaterialOutput::PStressM , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
242 
244  template<enum MaterialOutput _out>
245  typename std::enable_if<_out==MaterialOutput::PStrainN ||
246  _out==MaterialOutput::PStrainM , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
247 
249  template<enum MaterialOutput _out>
250  typename std::enable_if<_out==MaterialOutput::Stretch , void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
251 
253  template<enum MaterialOutput _out>
254  typename std::enable_if<_out==MaterialOutput::StretchDir, void>::type eval_into_impl(const gsMatrix<T>& u, gsMatrix<T>& result) const;
255 
256 protected:
257 
273  T getMoment() const { return getMoment_impl<out>(); }
274 
275 private:
277  template<enum MaterialOutput _out>
278  typename std::enable_if<_out==MaterialOutput::VectorN ||
279  _out==MaterialOutput::PStressN||
280  _out==MaterialOutput::CauchyVectorN, T>::type getMoment_impl() const { return 0; };
281 
283  template<enum MaterialOutput _out>
284  typename std::enable_if<_out==MaterialOutput::VectorM ||
285  _out==MaterialOutput::PStressM||
286  _out==MaterialOutput::CauchyVectorM, T>::type getMoment_impl() const { return 1; };
287 
289  template<enum MaterialOutput _out>
290  typename std::enable_if<_out==MaterialOutput::MatrixA, T>::type getMoment_impl() const { return 0; };
291 
293  template<enum MaterialOutput _out>
294  typename std::enable_if<_out==MaterialOutput::MatrixB, T>::type getMoment_impl() const { return 1; };
295 
297  template<enum MaterialOutput _out>
298  typename std::enable_if<_out==MaterialOutput::MatrixC, T>::type getMoment_impl() const { return 1; }; // must be 1
299 
301  template<enum MaterialOutput _out>
302  typename std::enable_if<_out==MaterialOutput::MatrixD, T>::type getMoment_impl() const { return 2; }; // must be 2
303 
305  template<enum MaterialOutput _out>
306  typename std::enable_if<!(_out==MaterialOutput::VectorN || _out==MaterialOutput::VectorM ||
307  _out==MaterialOutput::CauchyVectorN || _out==MaterialOutput::CauchyVectorM ||
308  _out==MaterialOutput::MatrixA || _out==MaterialOutput::MatrixB ||
309  _out==MaterialOutput::MatrixC || _out==MaterialOutput::MatrixD ||
310  _out==MaterialOutput::PStressN || _out==MaterialOutput::PStressM )
312 
313 protected:
314 
322  void integrateZ_into(const gsMatrix<T> & u, const index_t moment, gsMatrix<T> & result) const;
323 
347  void multiplyLinZ_into(const gsMatrix<T> & u, const index_t moment, gsMatrix<T> & result) const;
348 
363  void multiplyZ_into(const gsMatrix<T> & u, index_t moment, gsMatrix<T> & result) const;
364 
365 protected:
366 
375  gsMatrix<T> _eval3D(const gsMatrix<T>& u, const gsMatrix<T>& Z) const;
376 
377 
387  gsMatrix<T> _eval (const gsMatrix<T>& u) const;
388 
389 private:
391  template<enum MaterialOutput _out>
392  typename std::enable_if<_out==MaterialOutput::VectorN ||
393  _out==MaterialOutput::VectorM , gsMatrix<T>>::type eval3D_impl(const gsMatrix<T>& u, const gsMatrix<T>& Z) const;
394 
396  template<enum MaterialOutput _out>
397  typename std::enable_if<_out==MaterialOutput::CauchyVectorN ||
398  _out==MaterialOutput::CauchyVectorM , gsMatrix<T>>::type eval3D_impl(const gsMatrix<T>& u, const gsMatrix<T>& Z) const;
399 
400 
402  template<enum MaterialOutput _out>
403  typename std::enable_if<_out==MaterialOutput::MatrixA ||
404  _out==MaterialOutput::MatrixB ||
405  _out==MaterialOutput::MatrixC ||
406  _out==MaterialOutput::MatrixD , gsMatrix<T>>::type eval3D_impl(const gsMatrix<T>& u, const gsMatrix<T>& Z) const;
407 
409  template<enum MaterialOutput _out>
410  typename std::enable_if<_out==MaterialOutput::PStress ||
411  _out==MaterialOutput::PStressN ||
412  _out==MaterialOutput::PStressM , gsMatrix<T>>::type eval3D_impl(const gsMatrix<T>& u, const gsMatrix<T>& Z) const;
413 
415  template<enum MaterialOutput _out>
416  typename std::enable_if<!(_out==MaterialOutput::VectorN || _out==MaterialOutput::VectorM ||
417  _out==MaterialOutput::CauchyVectorN || _out==MaterialOutput::CauchyVectorM ||
418  _out==MaterialOutput::MatrixA || _out==MaterialOutput::MatrixB ||
419  _out==MaterialOutput::MatrixC || _out==MaterialOutput::MatrixD ||
420  _out==MaterialOutput::PStressN || _out==MaterialOutput::PStressM )
421  , gsMatrix<T>>::type eval3D_impl(const gsMatrix<T>& u, const gsMatrix<T>& Z) const
423 
424 protected:
425  index_t m_pIndex;
426  gsMaterialMatrixBase<T> * m_materialMat;
427  gsMatrix<T> m_z;
428 };
429 
430 } // namespace
431 
432 
433 #ifndef GISMO_BUILD_LIB
434 #include GISMO_HPP_HEADER(gsMaterialMatrixIntegrate.hpp)
435 #endif
436 
void multiplyZ_into(const gsMatrix< T > &u, index_t moment, gsMatrix< T > &result) const
Multiplies the evaluation at z=0 with 2.0/(moment+1) * Thalf^(moment + 1)
Definition: gsMaterialMatrixIntegrate.hpp:270
void integrateZ_into(const gsMatrix< T > &u, const index_t moment, gsMatrix< T > &result) const
Integrates through-thickness using Gauss integration.
Definition: gsMaterialMatrixIntegrate.hpp:183
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
std::enable_if< _out==MaterialOutput::MatrixA||_out==MaterialOutput::MatrixB||_out==MaterialOutput::MatrixC||_out==MaterialOutput::MatrixD, short_t >::type targetDim_impl() const
Implementation of targetDim for material tensors.
Definition: gsMaterialMatrixIntegrate.h:191
std::enable_if< _out==MaterialOutput::MatrixB, T >::type getMoment_impl() const
Implementation of getMoment for MaterialOutput::MatrixB; the moment is 1.
Definition: gsMaterialMatrixIntegrate.h:294
std::enable_if< _out==MaterialOutput::MatrixD, T >::type getMoment_impl() const
Implementation of getMoment for MaterialOutput::MatrixD; the moment is 2.
Definition: gsMaterialMatrixIntegrate.h:302
#define short_t
Definition: gsConfig.h:35
short_t targetDim() const
Target dimension.
Definition: gsMaterialMatrixIntegrate.h:171
This class serves as the evaluator of material matrices, based on gsMaterialMatrixBase.
Definition: gsMaterialMatrixContainer.h:33
void setPatch(index_t p)
Sets the patch index.
Definition: gsMaterialMatrixIntegrate.h:210
std::enable_if<!(_out==MaterialOutput::VectorN||_out==MaterialOutput::VectorM||_out==MaterialOutput::CauchyVectorN||_out==MaterialOutput::CauchyVectorM||_out==MaterialOutput::MatrixA||_out==MaterialOutput::MatrixB||_out==MaterialOutput::MatrixC||_out==MaterialOutput::MatrixD||_out==MaterialOutput::PStressN||_out==MaterialOutput::PStressM), gsMatrix< T > >::type eval3D_impl(const gsMatrix< T > &u, const gsMatrix< T > &Z) const
Specialisation of eval3D for other types.
Definition: gsMaterialMatrixIntegrate.h:421
gsMatrix< T > _eval(const gsMatrix< T > &u) const
Integrateuates the base class in 3D, but on Z=0.
Definition: gsMaterialMatrixIntegrate.hpp:296
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
std::enable_if< _out==MaterialOutput::PStressN||_out==MaterialOutput::PStressM||_out==MaterialOutput::PStrainN||_out==MaterialOutput::PStrainM, short_t >::type targetDim_impl() const
Implementation of targetDim for principal stress fields.
Definition: gsMaterialMatrixIntegrate.h:198
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
This class defines the base class for material matrices.
Definition: gsMaterialMatrixBase.h:32
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Implementation of eval_into, see gsFunction.
Definition: gsMaterialMatrixIntegrate.hpp:63
std::enable_if< _out==MaterialOutput::MatrixC, T >::type getMoment_impl() const
Implementation of getMoment for MaterialOutput::MatrixC; the moment is 1.
Definition: gsMaterialMatrixIntegrate.h:298
std::enable_if< _out==MaterialOutput::Density, short_t >::type targetDim_impl() const
Implementation of targetDim for densities.
Definition: gsMaterialMatrixIntegrate.h:177
std::enable_if< _out==MaterialOutput::MatrixA, T >::type getMoment_impl() const
Implementation of getMoment for MaterialOutput::MatrixA; the moment is 0.
Definition: gsMaterialMatrixIntegrate.h:290
std::enable_if< _out==MaterialOutput::VectorN||_out==MaterialOutput::VectorM, gsMatrix< T > >::type eval3D_impl(const gsMatrix< T > &u, const gsMatrix< T > &Z) const
Specialisation of eval3D for vectors.
Definition: gsMaterialMatrixIntegrate.hpp:322
void multiplyLinZ_into(const gsMatrix< T > &u, const index_t moment, gsMatrix< T > &result) const
Uses the top and bottom parts of the thickness to compute the integral exactly.
Definition: gsMaterialMatrixIntegrate.hpp:236
std::enable_if<!(_out==MaterialOutput::VectorN||_out==MaterialOutput::VectorM||_out==MaterialOutput::CauchyVectorN||_out==MaterialOutput::CauchyVectorM||_out==MaterialOutput::MatrixA||_out==MaterialOutput::MatrixB||_out==MaterialOutput::MatrixC||_out==MaterialOutput::MatrixD||_out==MaterialOutput::PStressN||_out==MaterialOutput::PStressM), index_t >::type getMoment_impl() const
Implementation of getMoment for MaterialOutput other than VectorN, VectorM, MatrixA, MatrixB, MatrixC, MatrixD, PStressN, PStressM.
Definition: gsMaterialMatrixIntegrate.h:311
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition: gsMemory.h:312
std::enable_if< _out==MaterialOutput::VectorN||_out==MaterialOutput::PStressN||_out==MaterialOutput::CauchyVectorN, T >::type getMoment_impl() const
Implementation of getMoment for MaterialOutput::VectorN; the moment is 0.
Definition: gsMaterialMatrixIntegrate.h:280
short_t domainDim() const
Domain dimension, always 2 for shells.
Definition: gsMaterialMatrixIntegrate.h:162
gsMaterialMatrixIntegrateSingle(index_t patch, gsMaterialMatrixBase< T > *materialMatrix, const gsFunctionSet< T > *deformed)
Constructor.
Definition: gsMaterialMatrixIntegrate.hpp:34
std::enable_if< _out==MaterialOutput::Density, void >::type eval_into_impl(const gsMatrix< T > &u, gsMatrix< T > &result) const
Specialisation of eval_into for densities.
Definition: gsMaterialMatrixIntegrate.hpp:73
This class serves as the integrator of material matrices, based on gsMaterialMatrixBase.
Definition: gsMaterialMatrixIntegrate.h:24
std::enable_if< _out==MaterialOutput::Stretch, short_t >::type targetDim_impl() const
Implementation of targetDim for principal stretch fields.
Definition: gsMaterialMatrixIntegrate.h:202
virtual index_t nPieces() const
Number of pieces in the domain of definition.
Definition: gsFunctionSet.h:584
std::enable_if< _out==MaterialOutput::StretchDir, short_t >::type targetDim_impl() const
Implementation of targetDim for principal stress directions.
Definition: gsMaterialMatrixIntegrate.h:206
Provides a container for material matrices for thin shells.
T getMoment() const
Gets the moment based on the output type.
Definition: gsMaterialMatrixIntegrate.h:273
Provides declaration of Function abstract interface.
gsMatrix< T > _eval3D(const gsMatrix< T > &u, const gsMatrix< T > &Z) const
Integrateuates the base class in 3D.
Definition: gsMaterialMatrixIntegrate.hpp:304
std::enable_if< _out==MaterialOutput::VectorN||_out==MaterialOutput::CauchyVectorN||_out==MaterialOutput::VectorM||_out==MaterialOutput::CauchyVectorM, short_t >::type targetDim_impl() const
Implementation of targetDim for stress tensors.
Definition: gsMaterialMatrixIntegrate.h:184
std::enable_if< _out==MaterialOutput::VectorM||_out==MaterialOutput::PStressM||_out==MaterialOutput::CauchyVectorM, T >::type getMoment_impl() const
Implementation of getMoment for MaterialOutput::VectorM; the moment is 1.
Definition: gsMaterialMatrixIntegrate.h:286