elasticity_impl.hpp
Go to the documentation of this file.
1//==============================================================================
11//==============================================================================
12#ifndef OPM_ELASTICITY_IMPL_HPP
13#define OPM_ELASTICITY_IMPL_HPP
14
16
17namespace Opm {
18namespace Elasticity {
19
20 template<class GridType>
21 template<int components, int funcdim>
22void Elasticity<GridType>::getBmatrix(Dune::FieldMatrix<ctype,components,funcdim>& B,
23 const Dune::FieldVector<ctype,dim>& point,
24 const Dune::FieldMatrix<ctype,dim,dim>& Jinv)
25{
28 int funcs = funcdim/dim;
29
30 Dune::FieldMatrix<ctype,funcdim/dim,dim> dNdX;
31 for (int i=0;i < funcs; i++)
32 Jinv.mv(basis[i].evaluateGradient(point),dNdX[i]);
33 static const int rows = 6+(dim-2)*12;
34
35 Dune::FieldMatrix<ctype,rows,funcdim/dim> temp;
36 temp = 0;
37
38 if (dim == 3) {
39#define INDEX(i,j) i+6*j
40 for (int i=0; i < funcs; ++i) {
41 // normal strain part
42 temp[INDEX(0,0)][i] = dNdX[i][0];
43 temp[INDEX(1,1)][i] = dNdX[i][1];
44 temp[INDEX(2,2)][i] = dNdX[i][2];
45
46 // shear strain part
47 temp[INDEX(3,0)][i] = dNdX[i][1];
48 temp[INDEX(3,1)][i] = dNdX[i][0];
49
50 temp[INDEX(4,0)][i] = dNdX[i][2];
51 temp[INDEX(4,2)][i] = dNdX[i][0];
52 temp[INDEX(5,1)][i] = dNdX[i][2];
53 temp[INDEX(5,2)][i] = dNdX[i][1];
54 }
55 } else if (dim == 2) {
56#undef INDEX
57#define INDEX(i,j) i+3*j
58 for (int i=0; i < funcs; ++i) {
59 // normal strain part
60 temp[INDEX(0,0)][i] = dNdX[i][0];
61 temp[INDEX(1,1)][i] = dNdX[i][1];
62
63 // shear strain part
64 temp[INDEX(2,0)][i] = dNdX[i][1];
65 temp[INDEX(2,1)][i] = dNdX[i][0];
66 }
67 }
68 size_t k=0;
69 for (int j=0;j<funcs*dim;++j)
70 for (size_t i=0;i<components;++i,++k)
71 B[i][j] = temp[k%rows][k/rows];
72}
73
74
75 template<class GridType>
76 template<int funcdims>
77void Elasticity<GridType>::getBVector(Dune::FieldVector<ctype,funcdims>& Bvector,
78 const Dune::FieldVector<ctype,dim>& point)
79{
82
83 Dune::FieldMatrix<ctype,funcdims,dim> N;
84 for (int i = 0; i < funcdims; i++) {
85 Bvector[i] = basis[i].evaluateFunction(point);
86 }
87}
88
89 template <class GridType>
90 template<int comp, int funcdim>
92 Dune::FieldMatrix<ctype,funcdim,funcdim>& A,
93 const Dune::FieldMatrix<ctype,comp,funcdim>& B,
94 const Dune::FieldMatrix<ctype,comp,comp>& C,
95 ctype detJW)
96{
97 Dune::FieldMatrix<ctype,funcdim,comp> B2;
98 for (int i=0;i<comp;++i)
99 for (int j=0;j<funcdim;++j)
100 B2[j][i] = B[i][j];
101 A = B.leftmultiplyany(C).leftmultiplyany(B2);
102 A *= detJW;
103}
104
105 template<class GridType>
106 template<int comp, int funcdim>
107void Elasticity<GridType>::getStressVector(Dune::FieldVector<ctype,comp>& sigma,
108 const Dune::FieldVector<ctype,funcdim>& v,
109 const Dune::FieldVector<ctype,comp>& eps0,
110 const Dune::FieldMatrix<ctype,comp,funcdim>& B,
111 const Dune::FieldMatrix<ctype,comp,comp>& C)
112{
113 sigma = Dune::FMatrixHelp::mult(C,Dune::FMatrixHelp::mult(B,v)+eps0);
114}
115
116}}
117
118#endif
Elasticity helper class.
Definition: elasticity.hpp:23
GridType::LeafGridView::ctype ctype
A basic number.
Definition: elasticity.hpp:29
Singleton handler for the set of LinearShapeFunction.
Definition: shapefunctions.hpp:181
static const P1ShapeFunctionSet & instance()
Get the only instance of this class.
Definition: shapefunctions.hpp:193
#define INDEX(i, j)
int j
Definition: elasticity_upscale_impl.hpp:658
Dune::FieldVector< ctype, comp > eps0
Definition: elasticity_upscale_impl.hpp:446
Definition: ImplicitAssembly.hpp:43
Classes for shape functions. Loosely based on code in dune-grid-howto.