G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsMaterialMatrixIntegrate.hpp
Go to the documentation of this file.
1 
16 /*
17  To Do [updated 16-06-2020]:
18  - Make beta (compressible materials) and material parameters universal for all integration points over the thickness. So get them out of the dPsi functions etc and move them into the integration loops as global variables.
19 
20 */
21 
22 
23 
24 #pragma once
25 
28 
29 namespace gismo
30 {
31 
32 // Linear material models
33 template <class T, enum MaterialOutput out>
35  gsMaterialMatrixBase<T> * materialMatrix, //??
36  const gsFunctionSet<T> * deformed
37  )
38 :
39 m_pIndex(patch),
40 m_materialMat(materialMatrix)
41 {
42  m_materialMat->setDeformed(deformed);
43  // m_materialMat = new gsMaterialMatrix(materialMatrix);
44 }
45 
46 // Linear material models
47 template <class T, enum MaterialOutput out>
49  gsMaterialMatrixBase<T> * materialMatrix, //??
50  const gsFunctionSet<T> * undeformed,
51  const gsFunctionSet<T> * deformed
52  )
53 :
54 m_pIndex(patch),
55 m_materialMat(materialMatrix)
56 {
57  m_materialMat->setUndeformed(undeformed);
58  m_materialMat->setDeformed(deformed);
59  // m_materialMat = new gsMaterialMatrix(materialMatrix);
60 }
61 
62 template <class T, enum MaterialOutput out>
64 {
66 // #pragma omp critical (gsMaterialMatrixIntegrateSingle_eval_into)
67  this->eval_into_impl<out>(u,result);
68 }
69 
70 template <class T, enum MaterialOutput out>
71 template <enum MaterialOutput _out>
72 typename std::enable_if<_out==MaterialOutput::Density, void>::type
74 {
75  m_materialMat->density_into(m_pIndex,u,result);
76 }
77 
78 template <class T, enum MaterialOutput out>
79 template <enum MaterialOutput _out>
80 typename std::enable_if<_out==MaterialOutput::VectorN ||
81  _out==MaterialOutput::CauchyVectorN, void>::type
83 {
84  if (m_materialMat->isVecIntegrated() == MatIntegration::NotIntegrated)
85  this->integrateZ_into(u,getMoment(),result);
86  else if (m_materialMat->isVecIntegrated() == MatIntegration::Integrated)
87  result = this->_eval(u);
88  else if (m_materialMat->isVecIntegrated() == MatIntegration::Constant)
89  this->multiplyZ_into(u,0,result);
90  else if (m_materialMat->isVecIntegrated() == MatIntegration::Linear)
91  this->multiplyLinZ_into(u,getMoment(),result);
92  else
93  GISMO_ERROR("Integration status unknown");
94 }
95 
96 template <class T, enum MaterialOutput out>
97 template <enum MaterialOutput _out>
98 typename std::enable_if<_out==MaterialOutput::VectorM ||
99  _out==MaterialOutput::CauchyVectorM, void>::type
101 {
102  if (m_materialMat->isVecIntegrated() == MatIntegration::NotIntegrated)
103  this->integrateZ_into(u,getMoment(),result);
104  else if (m_materialMat->isVecIntegrated() == MatIntegration::Integrated)
105  result = this->_eval(u);
106  else if (m_materialMat->isVecIntegrated() == MatIntegration::Constant)
107  this->multiplyZ_into(u,2,result);
108  else if (m_materialMat->isVecIntegrated() == MatIntegration::Linear)
109  this->multiplyLinZ_into(u,getMoment(),result);
110  else
111  GISMO_ERROR("Integration status unknown");
112 }
113 
114 template <class T, enum MaterialOutput out>
115 template <enum MaterialOutput _out>
116 typename std::enable_if< _out==MaterialOutput::MatrixA || _out==MaterialOutput::MatrixB
117  || _out==MaterialOutput::MatrixC || _out==MaterialOutput::MatrixD, void>::type
119 {
120  if (m_materialMat->isMatIntegrated() == MatIntegration::NotIntegrated)
121  this->integrateZ_into(u,getMoment(),result);
122  else if (m_materialMat->isMatIntegrated() == MatIntegration::Integrated)
123  result = this->_eval(u);
124  else if (m_materialMat->isMatIntegrated() == MatIntegration::Constant)
125  this->multiplyZ_into(u,getMoment(),result);
126  else if (m_materialMat->isMatIntegrated() == MatIntegration::Linear)
127  this->multiplyLinZ_into(u,getMoment(),result);
128  else
129  GISMO_ERROR("Integration status unknown");
130 }
131 
132 template <class T, enum MaterialOutput out>
133 template <enum MaterialOutput _out>
134 typename std::enable_if<_out==MaterialOutput::PStressN || _out==MaterialOutput::PStressM, void>::type
136 {
137  if (m_materialMat->isMatIntegrated() == MatIntegration::NotIntegrated)
138  this->integrateZ_into(u,getMoment(),result);
139  else if (m_materialMat->isMatIntegrated() == MatIntegration::Integrated)
140  result = this->_eval(u);
141  else if (m_materialMat->isMatIntegrated() == MatIntegration::Constant)
142  this->multiplyZ_into(u,getMoment(),result);
143  else if (m_materialMat->isMatIntegrated() == MatIntegration::Linear)
144  this->multiplyLinZ_into(u,getMoment(),result);
145  else
146  GISMO_ERROR("Integration status unknown");
147 }
148 
149 template <class T, enum MaterialOutput out>
150 template <enum MaterialOutput _out>
151 typename std::enable_if<_out==MaterialOutput::PStrainN || _out==MaterialOutput::PStrainM, void>::type
153 {
154  if (m_materialMat->isMatIntegrated() == MatIntegration::NotIntegrated)
155  this->integrateZ_into(u,getMoment(),result);
156  else if (m_materialMat->isMatIntegrated() == MatIntegration::Integrated)
157  result = this->_eval(u);
158  else if (m_materialMat->isMatIntegrated() == MatIntegration::Constant)
159  this->multiplyZ_into(u,getMoment(),result);
160  else if (m_materialMat->isMatIntegrated() == MatIntegration::Linear)
161  this->multiplyLinZ_into(u,getMoment(),result);
162  else
163  GISMO_ERROR("Integration status unknown");
164 }
165 
166 template <class T, enum MaterialOutput out>
167 template <enum MaterialOutput _out>
168 typename std::enable_if<_out==MaterialOutput::Stretch, void>::type
170 {
171  m_materialMat->stretch_into(m_pIndex,u,result);
172 }
173 
174 template <class T, enum MaterialOutput out>
175 template <enum MaterialOutput _out>
176 typename std::enable_if<_out==MaterialOutput::StretchDir, void>::type
178 {
179  m_materialMat->stretchDir_into(m_pIndex,u,result);
180 }
181 
182 template <class T, enum MaterialOutput out>
184 {
185  // Input: points in R2
186  // Ouput: results in targetDim
187 
188  // Perform integration
189  index_t numGauss = m_materialMat->options().askInt("NumGauss",4);
190 
191  result.resize(this->targetDim(),u.cols());
192  result.setZero();
193 
194  gsGaussRule<T> gauss(numGauss);
195  gsMatrix<T> z(numGauss,u.cols());
196  gsMatrix<T> w(numGauss,u.cols());
197  gsMatrix<T> vals;
198  // m_points3D.resize(1,numGauss);
199 
200  gsMatrix<T> Tmat;
201  m_materialMat->thickness_into(m_pIndex,u,Tmat);
202  T Thalf;
203  // pre-compute Z
204  for (index_t k = 0; k != u.cols(); ++k) // for all points
205  {
206  gsMatrix<T> quNodes(1,numGauss);
207  gsVector<T> quWeights(numGauss);
208  // set new integration point
209  // Thalf = Tmat(0,k)/2.0;
210  Thalf = 0.5;
211  gauss.mapTo(-Thalf,Thalf,quNodes,quWeights);
212  w.col(k)=quWeights;
213  z.col(k)=quNodes.transpose();
214  }
215  vals = this->_eval3D(u,z);
216  T res;
217  for (index_t k = 0; k != u.cols(); ++k) // for all points
218  {
219  for (index_t i=0; i!=this->targetDim(); ++i) // components
220  {
221  res = 0.0;
222  for (index_t j = 0; j != numGauss; ++j) // compute integral
223  res += w(j, k) * math::pow(z(j, k) * Tmat(0, k), moment) * vals(i, j * u.cols() + k) * Tmat(0, k); // int_z=[-1/2,1/2] (xi*t)^moment * <quantity(xi)> * t
224  result(i,k) = res;
225  }
226 
227  }
228 }
229 
230 
231 /*
232  * WARNING: This function assumes the function to be integrated: f(z,...) = g(,...) + z h(...)
233  Note: z is assumed to be [-1,1]
234  */
235 template <class T, enum MaterialOutput out>
237 {
238  // Input: points in R2
239  // Ouput: results in targetDim
240  result.resize(this->targetDim(),u.cols());
241 
242  gsMatrix<T> z(2,u.cols());
243  gsMatrix<T> Tmat;
244  m_materialMat->thickness_into(m_pIndex,u,Tmat);
245 
246  T Thalf;
247  // pre-compute Z
248  for (index_t k = 0; k != u.cols(); ++k) // for all points
249  {
250  Thalf = 1.0 / 2.0;
251  // Thalf = Tmat(0, k) / 2.0;
252  z.col(k)<<Thalf,-Thalf;
253  }
254 
255  T fac = (moment % 2 == 0) ? 0. : 1.;
256 
257  gsMatrix<T> vals = this->_eval3D(u,z);
258  for (index_t k = 0; k != u.cols(); ++k) // for all points
259  {
260  // 1/(alpha+1) * [ (t/2)^(alpha+1) * g(...) - (-t/2)^(alpha+1) * g(...) ]
261  // 1/(alpha+2) * [ (t/2)^(alpha+1) * h(...) - (-t/2)^(alpha+1) * h(...) ]
262  result.col(k) = 1.0/(moment+fac+1) *
263  ( math::pow( z(0,k) * Tmat(0, k), moment + 1) * vals.col(0*u.cols() + k)
264  - math::pow( z(1,k) * Tmat(0, k), moment + 1) * vals.col(1*u.cols() + k) );
265  }
266 
267 }
268 
269 template <class T, enum MaterialOutput out>
271 {
272  // Input: points in R2
273  // Ouput: results in targetDim
274  result.resize(this->targetDim(),u.cols());
275 
276  if (moment % 2 != 0) //then the moment is odd
277  result.setZero();
278  else // then the moment is even
279  {
280  T fac;
281  gsMatrix<T> Tmat;
282  m_materialMat->thickness_into(m_pIndex,u,Tmat);
283  T Thalf;
284  gsMatrix<T> vals = this->_eval(u);
285  for (index_t k = 0; k != u.cols(); ++k) // for all points
286  {
287  Thalf = Tmat(0, k) / 2.0;
288  fac = 2.0/(moment+1) * math::pow( Thalf , moment + 1);
289  result.col(k) = vals.col(k) * fac;
290  }
291 
292  }
293 }
294 
295 template <class T, enum MaterialOutput out>
297 {
298  gsMatrix<T> Z(1,u.cols());
299  Z.setZero();
300  return this->_eval3D(u,Z);
301 }
302 
303 template <class T, enum MaterialOutput out>
305 {
306  return this->eval3D_impl<out>(u,Z);
307 }
308 
309 template <class T, enum MaterialOutput out>
310 template <enum MaterialOutput _out>
311 typename std::enable_if< _out==MaterialOutput::MatrixA || _out==MaterialOutput::MatrixB
312  || _out==MaterialOutput::MatrixC || _out==MaterialOutput::MatrixD, gsMatrix<T>>::type
314 {
315  return m_materialMat->eval3D_matrix(m_pIndex,u,Z,_out);
316 }
317 
318 template <class T, enum MaterialOutput out>
319 template <enum MaterialOutput _out>
320 typename std::enable_if<_out==MaterialOutput::VectorN ||
321  _out==MaterialOutput::VectorM , gsMatrix<T>>::type
323 {
324  return m_materialMat->eval3D_vector(m_pIndex,u,Z,_out);
325 }
326 
327 template <class T, enum MaterialOutput out>
328 template <enum MaterialOutput _out>
329 typename std::enable_if<_out==MaterialOutput::CauchyVectorN ||
330  _out==MaterialOutput::CauchyVectorM, gsMatrix<T>>::type
332 {
333  return m_materialMat->eval3D_CauchyVector(m_pIndex,u,Z,_out);
334 }
335 
336 
337 template <class T, enum MaterialOutput out>
338 template <enum MaterialOutput _out>
339 typename std::enable_if<_out==MaterialOutput::PStress ||
340  _out==MaterialOutput::PStressN ||
341  _out==MaterialOutput::PStressM, gsMatrix<T>>::type
343 {
344  return m_materialMat->eval3D_pstress(m_pIndex,u,Z,_out);
345 }
346 
347 } // end namespace
Provides an evaluator for material matrices for thin shells.
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
Provides the Gauss-Legendre quadrature rule.
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
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::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
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
virtual void mapTo(const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
Maps quadrature rule (i.e., points and weights) from the reference domain to an element.
Definition: gsQuadRule.h:177
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
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
gsMatrix< T > _eval3D(const gsMatrix< T > &u, const gsMatrix< T > &Z) const
Integrateuates the base class in 3D.
Definition: gsMaterialMatrixIntegrate.hpp:304
Class that represents the (tensor) Gauss-Legendre quadrature rule.
Definition: gsGaussRule.h:27