1 #ifndef Sacado_Wrapper_H 2 #define Sacado_Wrapper_H 6 #include <deal.II/base/symmetric_tensor.h> 24 void get_index_map( std::map<
unsigned int,std::pair<unsigned int,unsigned int>> &std_map_indicies )
26 std::pair<unsigned int, unsigned int> tmp_pair;
31 tmp_pair.first=0; tmp_pair.second=0;
32 std_map_indicies[0] = tmp_pair;
34 tmp_pair.first=0; tmp_pair.second=1;
35 std_map_indicies[1] = tmp_pair;
37 tmp_pair.first=1; tmp_pair.second=1;
38 std_map_indicies[2] = tmp_pair;
41 tmp_pair.first=0; tmp_pair.second=0;
42 std_map_indicies[0] = tmp_pair;
44 tmp_pair.first=0; tmp_pair.second=1;
45 std_map_indicies[1] = tmp_pair;
47 tmp_pair.first=0; tmp_pair.second=2;
48 std_map_indicies[2] = tmp_pair;
50 tmp_pair.first=1; tmp_pair.second=1;
51 std_map_indicies[3] = tmp_pair;
53 tmp_pair.first=1; tmp_pair.second=2;
54 std_map_indicies[4] = tmp_pair;
56 tmp_pair.first=2; tmp_pair.second=2;
57 std_map_indicies[5] = tmp_pair;
66 class SymTensor:
public SymmetricTensor<2,dim, fad_double>
71 get_index_map<dim>( std_map_indicies );
77 unsigned int start_index = 0;
78 static const unsigned int n_dofs = ((dim==2)?3:6);
80 void init ( SymmetricTensor<2,dim> &tensor_double );
82 void set_dofs(
unsigned int nbr_total_dofs=n_dofs );
84 void get_tangent (SymmetricTensor<4,dim> &Tangent, SymmetricTensor<2,dim, fad_double> &sigma);
86 void get_tangent( SymmetricTensor<2,dim> &Tangent,
fad_double &argument );
88 void get_values ( SymmetricTensor<2,dim> &tensor_double );
90 SymmetricTensor<2,dim> get_value ();
100 for (
unsigned int i=0; i<dim; ++i)
101 for (
unsigned int j=0; j<dim; ++j )
102 (*
this)[i][j] = tensor_double[i][j];
114 for (
unsigned int x=start_index; x<(start_index+n_dofs); ++x )
116 unsigned int i=std_map_indicies[x].first;
117 unsigned int j=std_map_indicies[x].second;
118 (*this)[i][j].diff(x,nbr_total_dofs);
131 for (
unsigned int i=0; i<dim; ++i)
132 for (
unsigned int j=0; j<dim; ++j )
134 double *derivs = &sigma[i][j].fastAccessDx(0);
138 for(
unsigned int x=start_index;x<(start_index+n_dofs);++x)
140 unsigned int k=std_map_indicies[x].first;
141 unsigned int l=std_map_indicies[x].second;
145 Tangent[i][j][k][l] = 0.5*derivs[x];
146 Tangent[i][j][l][k] = 0.5*derivs[x];
149 Tangent[i][j][k][l] = derivs[x];
157 double *derivs = &argument.fastAccessDx(0);
158 for(
unsigned int x=start_index;x<(start_index+n_dofs);++x)
160 unsigned int k=std_map_indicies[x].first;
161 unsigned int l=std_map_indicies[x].second;
163 Tangent[k][l] = derivs[x];
167 Tangent[k][l] *= 0.5;
175 for (
unsigned int i=0; i<dim; ++i)
176 for (
unsigned int j=0; j<dim; ++j )
177 tensor_double[i][j] = ((*
this)[i][j]).val();
183 SymmetricTensor<2,dim> tmp;
193 class SymTensor2:
public SymmetricTensor<2,dim, Sacado::Fad::DFad<DFadType> >
198 get_index_map<dim>( std_map_indicies );
204 unsigned int start_index = 0;
205 static const unsigned int n_dofs = ((dim==2)?3:6);
207 void init_set_dofs ( SymmetricTensor<2,dim> &tensor_double,
const unsigned int nbr_total_dofs=n_dofs );
209 void get_tangent (SymmetricTensor<4,dim> &Tangent, SymmetricTensor<2,dim, Sacado::Fad::DFad<DFadType> > &sigma);
211 void get_tangent( SymmetricTensor<2,dim> &Tangent, Sacado::Fad::DFad<DFadType> &argument );
213 void get_tangent( SymmetricTensor<2,dim, Sacado::Fad::DFad<DFadType> > &Tangent, Sacado::Fad::DFad<DFadType> &argument );
215 void get_curvature( SymmetricTensor<4,dim> &Curvature, Sacado::Fad::DFad<DFadType> &argument );
227 for (
unsigned int x=0; x<n_dofs; ++x )
229 unsigned int i=std_map_indicies[x].first;
230 unsigned int j=std_map_indicies[x].second;
231 ((*this)[i][j]).diff( x, nbr_total_dofs);
232 ((*this)[i][j]).val() =
fad_double(nbr_total_dofs, x, tensor_double[i][j]);
240 for (
unsigned int x=0; x<n_dofs; ++x )
242 unsigned int i=std_map_indicies[x].first;
243 unsigned int j=std_map_indicies[x].second;
245 Tangent[i][j] = 0.5 * argument.dx(x).val();
247 Tangent[i][j] = argument.dx(x).val();
254 for(
unsigned int x=0;x<n_dofs;++x)
255 for(
unsigned int y=0;y<n_dofs;++y)
257 const unsigned int i=std_map_indicies[y].first;
258 const unsigned int j=std_map_indicies[y].second;
259 const unsigned int k=std_map_indicies[x].first;
260 const unsigned int l=std_map_indicies[x].second;
263 Tangent[i][j][k][l] = 0.5 * argument[k][l].dx(y).val();
265 Tangent[i][j][k][l] = argument[k][l].dx(y).val();
276 for (
unsigned int x=0; x<n_dofs; ++x )
278 unsigned int i=std_map_indicies[x].first;
279 unsigned int j=std_map_indicies[x].second;
281 Tangent[i][j] = 0.5 * argument.dx(x);
283 Tangent[i][j] = argument.dx(x);
291 for(
unsigned int x=0;x<n_dofs;++x)
292 for(
unsigned int y=0;y<n_dofs;++y)
294 const unsigned int i=std_map_indicies[y].first;
295 const unsigned int j=std_map_indicies[y].second;
296 const unsigned int k=std_map_indicies[x].first;
297 const unsigned int l=std_map_indicies[x].second;
299 double deriv = argument.dx(x).dx(y);
302 Curvature[i][j][k][l] = 0.25* deriv;
305 Curvature[i][j][k][l] = 0.5*deriv;
306 Curvature[i][j][l][k] = 0.5*deriv;
309 Curvature[i][j][k][l] = deriv;
336 static const unsigned int n_dofs = 1;
337 unsigned int start_index = 0;
339 void init (
const double &double_init );
341 void set_dofs (
unsigned int nbr_total_dofs=n_dofs );
343 void get_tangent (SymmetricTensor<2,dim> &Tangent, SymmetricTensor<2,dim, fad_double> &sigma);
345 void get_tangent (
double &Tangent,
fad_double &argument );
347 void get_values (
double &return_double );
353 (*this) = double_init;
359 (*this).diff( this->start_index, nbr_total_dofs );
366 for (
unsigned int i=0; i<dim; ++i)
367 for (
unsigned int j=0; j<dim; ++j )
369 double *derivs = &sigma[i][j].fastAccessDx(0);
370 Tangent[i][j] = derivs[ this->start_index ];
377 double *derivs = &argument.fastAccessDx(0);
378 Tangent = derivs[ this->start_index ];
384 return_double = (*this).val();
407 SW_double2 &
operator=(
double double_init) { Sacado::Fad::DFad<DFadType>::operator =( double_init ) ;
return *
this;}
408 SW_double2 &
operator=(Sacado::Fad::DFad<DFadType> fad_assignment) { Sacado::Fad::DFad<DFadType>::operator =( fad_assignment ) ;
return *
this;}
410 static const unsigned int n_dofs = 1;
411 unsigned int start_index = 0;
413 void init_set_dofs (
const double &double_init,
unsigned int nbr_total_dofs=n_dofs );
415 void get_tangent (
double &Tangent, Sacado::Fad::DFad<DFadType> &argument);
416 void get_tangent (SymmetricTensor<2,dim> &Tangent, SymmetricTensor<2,dim, Sacado::Fad::DFad<DFadType> > &argument,
SymTensor2<dim> &eps);
419 void get_curvature (
double &Curvature, Sacado::Fad::DFad<DFadType> &argument);
421 void get_curvature (SymmetricTensor<2,dim> &Curvature, SymmetricTensor<2,dim, Sacado::Fad::DFad<DFadType> > &argument,
SymTensor2<dim> &eps );
422 void get_curvature (SymmetricTensor<2,dim> &Curvature, Sacado::Fad::DFad<DFadType> &argument,
SymTensor2<dim> &eps );
430 (*this).diff( start_index , nbr_total_dofs );
431 (*this).val() =
fad_double(nbr_total_dofs, start_index, double_init);
438 Tangent = argument.dx(this->start_index).val();
445 for(
unsigned int x=0;x<eps.
n_dofs;++x)
450 Tangent[i][j] = argument[i][j].dx(start_index).val();
458 Curvature = argument.dx(this->start_index).dx(this->start_index);
468 for(
unsigned int x=0;x<eps.
n_dofs;++x)
476 Curvature[i][j] = argument[i][j].val().dx(start_index);
486 for(
unsigned int x=0;x<eps.
n_dofs;++x)
492 Curvature[i][j] = 0.5 * argument.dx(start_index).dx(x);
494 Curvature[i][j] = argument.dx(start_index).dx(x);
511 void get_curvature( SymmetricTensor<2,dim> &Curvature, Sacado::Fad::DFad<DFadType> &argument,
SymTensor2<dim> &eps,
SW_double2<dim> &double_arg );
512 void get_curvature( SymmetricTensor<2,dim> &Curvature, Sacado::Fad::DFad<DFadType> &argument,
SW_double2<dim> &double_arg,
SymTensor2<dim> &eps );
523 const unsigned int nbr_total_dofs = eps.
n_dofs + double_arg.
n_dofs;
529 double_arg.
set_dofs( nbr_total_dofs );
536 const unsigned int nbr_total_dofs = eps.
n_dofs + double_arg.
n_dofs;
556 double_arg1.
set_dofs( nbr_total_dofs );
557 double_arg2.
set_dofs( nbr_total_dofs );
558 double_arg3.
set_dofs( nbr_total_dofs );
564 const unsigned int nbr_total_dofs = eps.
n_dofs + double_arg1.
n_dofs + double_arg2.
n_dofs ;
571 double_arg1.
set_dofs( nbr_total_dofs );
572 double_arg2.
set_dofs( nbr_total_dofs );
582 SymmetricTensor<2,dim, Sacado::Fad::DFad<DFadType> > d_arg_d_eps;
604 #endif // Sacado_Wrapper_H Definition: Sacado_Wrapper.h:66
std::map< unsigned int, std::pair< unsigned int, unsigned int > > std_map_indicies
Definition: Sacado_Wrapper.h:202
void get_index_map(std::map< unsigned int, std::pair< unsigned int, unsigned int >> &std_map_indicies)
Definition: Sacado_Wrapper.h:24
unsigned int start_index
Definition: Sacado_Wrapper.h:337
static const unsigned int n_dofs
Definition: Sacado_Wrapper.h:78
static const unsigned int n_dofs
Definition: Sacado_Wrapper.h:205
Sacado::Fad::DFad< double > DFadType
Definition: Sacado_Wrapper.h:19
SW_double & operator=(fad_double fad_assignment)
Definition: Sacado_Wrapper.h:334
SW_double2 & operator=(double double_init)
Definition: Sacado_Wrapper.h:407
void set_dofs(unsigned int nbr_total_dofs=n_dofs)
Definition: Sacado_Wrapper.h:357
void init_set_dofs(SymmetricTensor< 2, dim > &tensor_double, const unsigned int nbr_total_dofs=n_dofs)
Definition: Sacado_Wrapper.h:225
Definition: Sacado_Wrapper.h:395
void get_tangent(SymmetricTensor< 4, dim > &Tangent, SymmetricTensor< 2, dim, Sacado::Fad::DFad< DFadType > > &sigma)
Definition: Sacado_Wrapper.h:252
void get_curvature(double &Curvature, Sacado::Fad::DFad< DFadType > &argument)
Definition: Sacado_Wrapper.h:456
void init_set_dofs(const double &double_init, unsigned int nbr_total_dofs=n_dofs)
Definition: Sacado_Wrapper.h:428
Definition: Sacado_Wrapper.h:505
unsigned int start_index
Definition: Sacado_Wrapper.h:77
SW_double & operator=(double double_init)
Definition: Sacado_Wrapper.h:333
std::map< unsigned int, std::pair< unsigned int, unsigned int > > std_map_indicies
Definition: Sacado_Wrapper.h:75
SymTensor()
Definition: Sacado_Wrapper.h:69
Sacado::Fad::DFad< double > fad_double
Definition: Sacado_Wrapper.h:18
unsigned int start_index
Definition: Sacado_Wrapper.h:204
static const unsigned int n_dofs
Definition: Sacado_Wrapper.h:410
SymTensor2()
Definition: Sacado_Wrapper.h:196
Sacado::Fad::DFad< double > fad_double
Definition: Sacado-auxiliary_functions.h:7
Definition: Sacado_Wrapper.h:321
Definition: Sacado_Wrapper.h:63
unsigned int start_index
Definition: Sacado_Wrapper.h:411
Definition: Sacado_Wrapper.h:193
void set_dofs(unsigned int nbr_total_dofs=n_dofs)
Definition: Sacado_Wrapper.h:110
void get_values(SymmetricTensor< 2, dim > &tensor_double)
Definition: Sacado_Wrapper.h:173
static const unsigned int n_dofs
Definition: Sacado_Wrapper.h:336
SW_double2 & operator=(Sacado::Fad::DFad< DFadType > fad_assignment)
Definition: Sacado_Wrapper.h:408