G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsVisitorElUtils.h
Go to the documentation of this file.
1
15#pragma once
16
17namespace gismo
18{
19
20// Indices of the Voigt notation
21inline short_t voigt(short_t dim, short_t I, short_t J)
22{
23 if (dim == 2)
24 switch(I)
25 {
26 case 0: return J == 0 ? 0 : 0;
27 case 1: return J == 0 ? 1 : 1;
28 case 2: return J == 0 ? 0 : 1;
29 }
30 else if (dim == 3)
31 switch (I)
32 {
33 case 0: return J == 0 ? 0 : 0;
34 case 1: return J == 0 ? 1 : 1;
35 case 2: return J == 0 ? 2 : 2;
36 case 3: return J == 0 ? 0 : 1;
37 case 4: return J == 0 ? 1 : 2;
38 case 5: return J == 0 ? 0 : 2;
39 }
40 GISMO_ERROR("voigt notation indices error");
41}
42
43// construct a fourth order symmetric identity tensor C based on a second order symmetric tensor R
44// C_ijkl = (R_ik*R_jl + R_il*R_jk)/2 in Voigt notation
45template <class T>
46inline void symmetricIdentityTensor(gsMatrix<T> & C, const gsMatrix<T> & R)
47{
48 short_t dim = R.cols();
49 short_t dimTensor = dim*(dim+1)/2;
50 C.setZero(dimTensor,dimTensor);
51 // componentwise definition
52 for (short_t i = 0; i < dimTensor; ++i)
53 for (short_t j = 0; j < dimTensor; ++j)
54 C(i,j) = (R(voigt(dim,i,0),voigt(dim,j,0))*R(voigt(dim,i,1),voigt(dim,j,1)) +
55 R(voigt(dim,i,0),voigt(dim,j,1))*R(voigt(dim,i,1),voigt(dim,j,0)));
56}
57
58// construct a fourth order matrix-trace tensor C based on two second order symmetric tensors R and S
59// C_ijkl = R_ij*S_kl in Voigt notation
60template <class T>
61inline void matrixTraceTensor(gsMatrix<T> & C, const gsMatrix<T> & R, const gsMatrix<T> & S)
62{
63 short_t dim = R.cols();
64 short_t dimTensor = dim*(dim+1)/2;
65 C.setZero(dimTensor,dimTensor);
66 // componentwise definition
67 for (short_t i = 0; i < dimTensor; ++i)
68 for (short_t j = 0; j < dimTensor; ++j)
69 C(i,j) = R(voigt(dim,i,0),voigt(dim,i,1))*S(voigt(dim,j,0),voigt(dim,j,1));
70}
71
72// transform stress tensor S to a vector in Voigt notation
73template <class T>
74inline void voigtStress(gsVector<T> & Svec, const gsMatrix<T> & S)
75{
76 short_t dim = S.cols();
77 short_t dimTensor = dim*(dim+1)/2;
78 Svec.resize(dimTensor);
79 for (short i = 0; i < dimTensor; ++i)
80 Svec(i) = S(voigt(dim,i,0),voigt(dim,i,1));
81}
82
83// auxiliary matrix B such that E:S = B*Svec in the weak form
84// (see Bernal, Calo, Collier, et. at., "PetIGA", ICCS 2013, p. 1610)
85template <class T>
86inline void setB( gsMatrix<T> & B, const gsMatrix<T> & F, const gsVector<T> & bGrad)
87{
88 short_t dim = F.cols();
89 short_t dimTensor = dim*(dim+1)/2;
90 B.resize(dimTensor,dim);
91
92 for (short_t j = 0; j < dim; ++j)
93 {
94 for (short_t i = 0; i < dim; ++i)
95 B(i,j) = F(j,i) * bGrad(i);
96 if (dim == 2)
97 B(2,j) = F(j,0) * bGrad(1) + F(j,1) * bGrad(0);
98 if (dim == 3)
99 for (short_t i = 0; i < dim; ++i)
100 {
101 short_t k = (i+1)%dim;
102 B(i+dim,j) = F(j,i) * bGrad(k) + F(j,k) * bGrad(i);
103 }
104 }
105}
106
107} // namespace gismo
#define short_t
Definition gsConfig.h:35
#define GISMO_ERROR(message)
Definition gsDebug.h:118
The G+Smo namespace, containing all definitions for the library.