[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
fe_values_shape_hessian.cpp
1 #include "fe_values_shape_hessian.h"
2 
3 namespace PHiLiP {
4 
5 template<int dim>
6 void FEValuesShapeHessian<dim> :: reinit(const dealii::FEValues<dim,dim> &fe_values_volume, const unsigned int iquad)
7 {
8  jacobian_inverse = dealii::Tensor<2,dim,double>(fe_values_volume.inverse_jacobian(iquad));
9  const dealii::Tensor<3,dim,double> jacobian_pushed_forward_grad = fe_values_volume.jacobian_pushed_forward_grad(iquad);
10 
11  ref_point = fe_values_volume.get_quadrature().point(iquad);
12 
13  // Compute derivative of jacobian inverse w.r.t. physical coordinates.
14  // Using equation from dealii's documentation on Mapping, https://www.dealii.org/current/doxygen/deal.II/classMapping.html.
15  derivative_jacobian_inverse_wrt_phys_q = 0;
16  for(unsigned int i_phys=0; i_phys<dim; ++i_phys)
17  {
18  for(unsigned int j_ref=0; j_ref<dim; ++j_ref)
19  {
20  for(unsigned int k_phys=0; k_phys<dim; ++k_phys)
21  {
22  for(unsigned int n_phys=0; n_phys<dim; ++n_phys)
23  {
24  derivative_jacobian_inverse_wrt_phys_q[j_ref][i_phys][k_phys] -= jacobian_pushed_forward_grad[n_phys][i_phys][k_phys]*jacobian_inverse[j_ref][n_phys];
25  }
26  }
27  }
28  }
29 
30 }
31 
32 // Had to code this up because shape_hessian_component() hasn't been implemented yet by dealii's MappingFEField.
33 // This class can be deprecated in future once dealii's shape hessian with MappingFEField works.
34 template<int dim>
36  const unsigned int idof,
37  const unsigned int /*iquad*/,
38  const unsigned int istate,
39  const dealii::FESystem<dim,dim> &fe_ref) const
40 {
41  dealii::Tensor<1,dim,double> shape_grad_ref = fe_ref.shape_grad_component(idof, ref_point, istate); // \varphi_{\epsilon}
42  dealii::Tensor<2,dim,double> shape_hessian_ref = fe_ref.shape_grad_grad_component(idof, ref_point, istate); // \varphi_{\epsilon \epsilon}
43 
44  // Shape hessian w.r.t. physical x = \varphi_{xx} = J^{-T} \varphi_{\epsilon \epsilon} J^{-1} + \varphi_{\epsilon}^T * d/dx( J^{-1} );
45 
46  // Computing first term: J^{-T} \varphi_{\epsilon \epsilon} J^{-1}.
47  // Using (A^T*B*A)_{i,j} = a_{ki} * b_{kl} * a_{lj}
48  dealii::Tensor<2,dim,double> phys_hessian_term1; // initialized to 0
49  for(unsigned int i_phys=0; i_phys<dim; ++i_phys)
50  {
51  for(unsigned int j_phys=0; j_phys<dim; ++j_phys)
52  {
53  for(unsigned int k_ref=0; k_ref<dim; ++k_ref)
54  {
55  for(unsigned int l_ref=0; l_ref<dim; ++l_ref)
56  {
57  phys_hessian_term1[i_phys][j_phys] += jacobian_inverse[k_ref][i_phys] * shape_hessian_ref[k_ref][l_ref] * jacobian_inverse[l_ref][j_phys];
58  }
59  }
60  }
61  }
62 
63  // Computing second term: \varphi_{\epsilon}^T * d/dx( J^{-1} )
64  // Using v^T*E_xx (i,j) = v_k E_xx(k,i,j) = v_k (d^2 E_k/(dx_i dx_j), with E_xx a third order tensor and v a vector.
65  dealii::Tensor<2,dim,double> phys_hessian_term2; // initilized to 0
66  for(unsigned int i_phys=0; i_phys<dim; ++i_phys)
67  {
68  for(unsigned int j_phys=0; j_phys<dim; ++j_phys)
69  {
70  for(unsigned int k_ref=0; k_ref<dim; ++k_ref)
71  {
72  phys_hessian_term2[i_phys][j_phys] += shape_grad_ref[k_ref] * derivative_jacobian_inverse_wrt_phys_q[k_ref][i_phys][j_phys];
73  }
74  }
75  }
76 
77  dealii::Tensor<2,dim,double> shape_hessian_phys = phys_hessian_term1;
78  shape_hessian_phys += phys_hessian_term2;
79  return shape_hessian_phys;
80 }
81 
83 } // PHiLiP namespace
dealii::Tensor< 2, dim, double > shape_hessian_component(const unsigned int idof, const unsigned int iquad, const unsigned int istate, const dealii::FESystem< dim, dim > &fe_ref) const
Evaluates hessian of shape functions w.r.t. phyical quadrature points.
Files for the baseline physics.
Definition: ADTypes.hpp:10
void reinit(const dealii::FEValues< dim, dim > &fe_values_volume, const unsigned int iquad)
Store inverse jacobian and 3rd order tensors which will be the same for a combination of cell/physica...
Class to evaluate hessians of shape functions w.r.t. physical quadrature points.