libMesh
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
libMesh::HDivFETransformation< OutputShape > Class Template Reference

This class handles the computation of the shape functions in the physical domain for HDiv conforming elements. More...

#include <hdiv_fe_transformation.h>

Inheritance diagram for libMesh::HDivFETransformation< OutputShape >:
[legend]

Public Member Functions

 HDivFETransformation ()
 
virtual ~HDivFETransformation ()=default
 
virtual void init_map_phi (const FEGenericBase< OutputShape > &fe) const override
 Pre-requests any necessary data from FEMap.
 
virtual void init_map_dphi (const FEGenericBase< OutputShape > &fe) const override
 Pre-requests any necessary data from FEMap.
 
virtual void init_map_d2phi (const FEGenericBase< OutputShape > &fe) const override
 Pre-requests any necessary data from FEMap.
 
virtual void map_phi (const unsigned int dim, const Elem *const elem, const std::vector< Point > &qp, const FEGenericBase< OutputShape > &fe, std::vector< std::vector< OutputShape > > &phi, bool add_p_level=true) const override
 Evaluates shape functions in physical coordinates for \( H(div) \) conforming elements.
 
virtual void map_dphi (const unsigned int dim, const Elem *const elem, const std::vector< Point > &qp, const FEGenericBase< OutputShape > &fe, std::vector< std::vector< typename FEGenericBase< OutputShape >::OutputGradient > > &dphi, std::vector< std::vector< OutputShape > > &dphidx, std::vector< std::vector< OutputShape > > &dphidy, std::vector< std::vector< OutputShape > > &dphidz) const override
 Evaluates shape function gradients in physical coordinates for \( H(div) \) conforming elements, via the contravariant Piola map's derivative (the gradient of \( \phi = J^{-1} (dx/d\xi) \hat{\phi} \) with respect to physical coordinates).
 
virtual void map_d2phi (const unsigned int, const std::vector< Point > &, const FEGenericBase< OutputShape > &, std::vector< std::vector< typename FEGenericBase< OutputShape >::OutputTensor > > &, std::vector< std::vector< OutputShape > > &, std::vector< std::vector< OutputShape > > &, std::vector< std::vector< OutputShape > > &, std::vector< std::vector< OutputShape > > &, std::vector< std::vector< OutputShape > > &, std::vector< std::vector< OutputShape > > &) const override
 Evaluates shape function Hessians in physical coordinates based on \( H(div) \) conforming finite element transformation.
 
virtual void map_curl (const unsigned int, const Elem *const, const std::vector< Point > &, const FEGenericBase< OutputShape > &, std::vector< std::vector< OutputShape > > &) const override
 Evaluates the shape function curl in physical coordinates based on \( H(div) \) conforming finite element transformation.
 
virtual void map_div (const unsigned int dim, const Elem *const elem, const std::vector< Point > &qp, const FEGenericBase< OutputShape > &fe, std::vector< std::vector< typename FEGenericBase< OutputShape >::OutputDivergence > > &div_phi) const override
 Evaluates the shape function divergence in physical coordinates based on \( H(div) \) conforming finite element transformation.
 
void init_map_phi (const FEGenericBase< Real > &) const
 
void init_map_dphi (const FEGenericBase< Real > &) const
 
void init_map_d2phi (const FEGenericBase< Real > &) const
 
void map_phi (const unsigned int, const Elem *const, const std::vector< Point > &, const FEGenericBase< Real > &, std::vector< std::vector< Real > > &, bool) const
 
void map_dphi (const unsigned int, const Elem *const, const std::vector< Point > &, const FEGenericBase< Real > &, std::vector< std::vector< FEGenericBase< Real >::OutputGradient > > &, std::vector< std::vector< Real > > &, std::vector< std::vector< Real > > &, std::vector< std::vector< Real > > &) const
 
void map_div (const unsigned int, const Elem *const, const std::vector< Point > &, const FEGenericBase< Real > &, std::vector< std::vector< Real > > &) const
 

Static Public Member Functions

static std::unique_ptr< FETransformationBase< OutputShape > > build (const FEType &type)
 Builds an FETransformation object based on the finite element type.
 

Detailed Description

template<typename OutputShape>
class libMesh::HDivFETransformation< OutputShape >

This class handles the computation of the shape functions in the physical domain for HDiv conforming elements.

This class assumes the FEGenericBase object has been initialized in the reference domain (i.e. init_shape_functions has been called).

Author
Nuno Nobre
Date
2023

Definition at line 36 of file hdiv_fe_transformation.h.

Constructor & Destructor Documentation

◆ HDivFETransformation()

template<typename OutputShape >
libMesh::HDivFETransformation< OutputShape >::HDivFETransformation ( )
inline

Definition at line 40 of file hdiv_fe_transformation.h.

41 : FETransformationBase<OutputShape>() {}

◆ ~HDivFETransformation()

template<typename OutputShape >
virtual libMesh::HDivFETransformation< OutputShape >::~HDivFETransformation ( )
virtualdefault

Member Function Documentation

◆ build()

template<typename OutputShape >
std::unique_ptr< FETransformationBase< OutputShape > > libMesh::FETransformationBase< OutputShape >::build ( const FEType &  type)
staticinherited

Builds an FETransformation object based on the finite element type.

Definition at line 32 of file fe_transformation_base.C.

33{
34 switch (fe_type.family)
35 {
36 // H1 Conforming Elements
37 case LAGRANGE:
38 case HIERARCHIC:
39 case BERNSTEIN:
40 case SZABAB:
41 case CLOUGH: // PB: Really H2
42 case HERMITE: // PB: Really H2
43 case SUBDIVISION:
44 case LAGRANGE_VEC:
45 case HIERARCHIC_VEC:
46 case MONOMIAL: // PB: Shouldn't this be L2 conforming?
47 case MONOMIAL_VEC: // PB: Shouldn't this be L2 conforming?
48 case XYZ: // PB: Shouldn't this be L2 conforming?
50 case L2_HIERARCHIC:
52 case SIDE_HIERARCHIC:
53 case L2_LAGRANGE: // PB: Shouldn't this be L2 conforming?
54 case L2_LAGRANGE_GLL:
55 case L2_LAGRANGE_VEC: // PB: Shouldn't this be L2 conforming?
56 case JACOBI_20_00: // PB: For infinite elements...
57 case JACOBI_30_00: // PB: For infinite elements...
58 return std::make_unique<H1FETransformation<OutputShape>>();
59
60 // HCurl Conforming Elements
61 case NEDELEC_ONE:
62 return std::make_unique<HCurlFETransformation<OutputShape>>();
63
64 // HDiv Conforming Elements
65 case RAVIART_THOMAS:
67 return std::make_unique<HDivFETransformation<OutputShape>>();
68
69 // L2 Conforming Elements
70
71 // Other...
72 case SCALAR:
73 // Should never need this for SCALARs
74 return std::make_unique<H1FETransformation<OutputShape>>();
75
76 default:
77 libmesh_error_msg("Unknown family = " << Utility::enum_to_string(fe_type.family));
78 }
79}
std::string enum_to_string(const T e)
@ L2_RAVIART_THOMAS
@ L2_HIERARCHIC_VEC
@ RATIONAL_BERNSTEIN

References libMesh::BERNSTEIN, libMesh::CLOUGH, libMesh::Utility::enum_to_string(), libMesh::FEType::family, libMesh::HERMITE, libMesh::HIERARCHIC, libMesh::HIERARCHIC_VEC, libMesh::JACOBI_20_00, libMesh::JACOBI_30_00, libMesh::L2_HIERARCHIC, libMesh::L2_HIERARCHIC_VEC, libMesh::L2_LAGRANGE, libMesh::L2_LAGRANGE_GLL, libMesh::L2_LAGRANGE_VEC, libMesh::L2_RAVIART_THOMAS, libMesh::LAGRANGE, libMesh::LAGRANGE_VEC, libMesh::MONOMIAL, libMesh::MONOMIAL_VEC, libMesh::NEDELEC_ONE, libMesh::RATIONAL_BERNSTEIN, libMesh::RAVIART_THOMAS, libMesh::SCALAR, libMesh::SIDE_HIERARCHIC, libMesh::SUBDIVISION, libMesh::SZABAB, and libMesh::XYZ.

◆ init_map_d2phi() [1/2]

template<typename OutputShape >
void libMesh::HDivFETransformation< OutputShape >::init_map_d2phi ( const FEGenericBase< OutputShape > &  fe) const
overridevirtual

Pre-requests any necessary data from FEMap.

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 87 of file hdiv_fe_transformation.C.

88{
89 // We choose not to pre-request any computations here since we have not yet implemented
90 // map_d2phi. We don't need to give the map unnecessary work.
91}

◆ init_map_d2phi() [2/2]

void libMesh::HDivFETransformation< Real >::init_map_d2phi ( const FEGenericBase< Real > &  ) const

Definition at line 469 of file hdiv_fe_transformation.C.

470{
471 libmesh_error_msg("HDiv transformations only make sense for vector-valued elements.");
472}

◆ init_map_dphi() [1/2]

template<typename OutputShape >
void libMesh::HDivFETransformation< OutputShape >::init_map_dphi ( const FEGenericBase< OutputShape > &  fe) const
overridevirtual

Pre-requests any necessary data from FEMap.

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 69 of file hdiv_fe_transformation.C.

70{
71 // See above comment in init_map_phi. In map_dphi we actually use both the forward and inverse
72 // first derivative maps so the choice here is a little more arbitrary. We choose to be
73 // consistent with init_map_phi.
75#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
76 // As for first order derivatives, there is only a single boolean flag (calculate_d2xyz)
77 // controlling second order derivative computations in FEMap so we only bother prerequesting
78 // one piece. We document pre-requesting the forward map because those are the second
79 // derivatives used in map_dphi.
81#endif
82}
const FEMap & get_fe_map() const
const std::vector< RealGradient > & get_d2xyzdxi2() const
Definition fe_map.h:264
const std::vector< RealGradient > & get_dxyzdxi() const
Definition fe_map.h:239

References libMesh::FEMap::get_d2xyzdxi2(), libMesh::FEMap::get_dxyzdxi(), and libMesh::FEAbstract::get_fe_map().

◆ init_map_dphi() [2/2]

void libMesh::HDivFETransformation< Real >::init_map_dphi ( const FEGenericBase< Real > &  ) const

Definition at line 463 of file hdiv_fe_transformation.C.

464{
465 libmesh_error_msg("HDiv transformations only make sense for vector-valued elements.");
466}

◆ init_map_phi() [1/2]

template<typename OutputShape >
void libMesh::HDivFETransformation< OutputShape >::init_map_phi ( const FEGenericBase< OutputShape > &  fe) const
overridevirtual

Pre-requests any necessary data from FEMap.

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 56 of file hdiv_fe_transformation.C.

57{
58 // We only need to pre-request one first-order derivative map piece because there is only a
59 // single calculate_dxyz boolean flag that toggles first derivative computations in the FEMap
60 // and in addition to covering all components it also covers both forward and inverse mapping.
61 // We choose to document pre-requesting the forward (reference -> physical) map here because
62 // that is what is used in map_phi (there is no inverse map usage).
64}

References libMesh::FEMap::get_dxyzdxi(), and libMesh::FEAbstract::get_fe_map().

◆ init_map_phi() [2/2]

void libMesh::HDivFETransformation< Real >::init_map_phi ( const FEGenericBase< Real > &  ) const

Definition at line 457 of file hdiv_fe_transformation.C.

458{
459 libmesh_error_msg("HDiv transformations only make sense for vector-valued elements.");
460}

◆ map_curl()

template<typename OutputShape >
virtual void libMesh::HDivFETransformation< OutputShape >::map_curl ( const unsigned int  ,
const Elem * const  ,
const std::vector< Point > &  ,
const FEGenericBase< OutputShape > &  ,
std::vector< std::vector< OutputShape > > &   
) const
inlineoverridevirtual

Evaluates the shape function curl in physical coordinates based on \( H(div) \) conforming finite element transformation.

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 117 of file hdiv_fe_transformation.h.

122 {
123 libmesh_warning("WARNING: Shape function curls for HDiv elements are not currently being computed!");
124 }

◆ map_d2phi()

template<typename OutputShape >
virtual void libMesh::HDivFETransformation< OutputShape >::map_d2phi ( const unsigned int  ,
const std::vector< Point > &  ,
const FEGenericBase< OutputShape > &  ,
std::vector< std::vector< typename FEGenericBase< OutputShape >::OutputTensor > > &  ,
std::vector< std::vector< OutputShape > > &  ,
std::vector< std::vector< OutputShape > > &  ,
std::vector< std::vector< OutputShape > > &  ,
std::vector< std::vector< OutputShape > > &  ,
std::vector< std::vector< OutputShape > > &  ,
std::vector< std::vector< OutputShape > > &   
) const
inlineoverridevirtual

Evaluates shape function Hessians in physical coordinates based on \( H(div) \) conforming finite element transformation.

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 98 of file hdiv_fe_transformation.h.

108 {
109 libmesh_warning("WARNING: Shape function Hessians for HDiv elements are not currently being computed!");
110 }

◆ map_div() [1/2]

template<typename OutputShape >
void libMesh::HDivFETransformation< OutputShape >::map_div ( const unsigned int  dim,
const Elem *const  elem,
const std::vector< Point > &  qp,
const FEGenericBase< OutputShape > &  fe,
std::vector< std::vector< typename FEGenericBase< OutputShape >::OutputDivergence > > &  div_phi 
) const
overridevirtual

Evaluates the shape function divergence in physical coordinates based on \( H(div) \) conforming finite element transformation.

The transformation is \( \nabla \cdot \phi = J^{-1} \nabla \cdot \hat{\phi} \) where \( J = \det( dx/d\xi ) \)

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 403 of file hdiv_fe_transformation.C.

408{
409 switch (dim)
410 {
411 case 0:
412 case 1:
413 libmesh_error_msg("These element transformations only make sense in 2D and 3D.");
414
415 case 2:
416 {
417 const std::vector<std::vector<OutputShape>> & dphi_dxi = fe.get_dphidxi();
418 const std::vector<std::vector<OutputShape>> & dphi_deta = fe.get_dphideta();
419
420 const std::vector<Real> & J = fe.get_fe_map().get_jacobian();
421
422 // div(phi) = J^{-1} * div(\hat{phi})
423 for (auto i : index_range(div_phi))
424 for (auto p : index_range(div_phi[i]))
425 {
426 div_phi[i][p] = (dphi_dxi[i][p](0) + dphi_deta[i][p](1))/J[p];
427 }
428
429 break;
430 }
431 case 3:
432 {
433 const std::vector<std::vector<OutputShape>> & dphi_dxi = fe.get_dphidxi();
434 const std::vector<std::vector<OutputShape>> & dphi_deta = fe.get_dphideta();
435 const std::vector<std::vector<OutputShape>> & dphi_dzeta = fe.get_dphidzeta();
436
437 const std::vector<Real> & J = fe.get_fe_map().get_jacobian();
438
439 // div(phi) = J^{-1} * div(\hat{phi})
440 for (auto i : index_range(div_phi))
441 for (auto p : index_range(div_phi[i]))
442 {
443 div_phi[i][p] = (dphi_dxi[i][p](0) + dphi_deta[i][p](1) + dphi_dzeta[i][p](2))/J[p];
444 }
445
446 break;
447 }
448
449 default:
450 libmesh_error_msg("Invalid dim = " << dim);
451 } // switch(dim)
452}
unsigned int dim
const std::vector< std::vector< OutputShape > > & get_dphidxi() const
Definition fe_base.h:325
const std::vector< std::vector< OutputShape > > & get_dphidzeta() const
Definition fe_base.h:341
const std::vector< std::vector< OutputShape > > & get_dphideta() const
Definition fe_base.h:333
const std::vector< Real > & get_jacobian() const
Definition fe_map.h:223
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153

References dim, libMesh::FEGenericBase< OutputType >::get_dphideta(), libMesh::FEGenericBase< OutputType >::get_dphidxi(), libMesh::FEGenericBase< OutputType >::get_dphidzeta(), libMesh::FEAbstract::get_fe_map(), libMesh::FEMap::get_jacobian(), and libMesh::index_range().

◆ map_div() [2/2]

void libMesh::HDivFETransformation< Real >::map_div ( const unsigned int  ,
const Elem * const  ,
const std::vector< Point > &  ,
const FEGenericBase< Real > &  ,
std::vector< std::vector< Real > > &   
) const

Definition at line 499 of file hdiv_fe_transformation.C.

504{
505 libmesh_error_msg("HDiv transformations only make sense for vector-valued elements.");
506}

◆ map_dphi() [1/2]

template<typename OutputShape >
void libMesh::HDivFETransformation< OutputShape >::map_dphi ( const unsigned int  dim,
const Elem *const  elem,
const std::vector< Point > &  qp,
const FEGenericBase< OutputShape > &  fe,
std::vector< std::vector< typename FEGenericBase< OutputShape >::OutputGradient > > &  dphi,
std::vector< std::vector< OutputShape > > &  dphidx,
std::vector< std::vector< OutputShape > > &  dphidy,
std::vector< std::vector< OutputShape > > &  dphidz 
) const
overridevirtual

Evaluates shape function gradients in physical coordinates for \( H(div) \) conforming elements, via the contravariant Piola map's derivative (the gradient of \( \phi = J^{-1} (dx/d\xi) \hat{\phi} \) with respect to physical coordinates).

Requires LIBMESH_ENABLE_SECOND_DERIVATIVES, since the map's own second derivatives are needed to differentiate \( J^{-1} \) and \( (dx/d\xi) \).

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 161 of file hdiv_fe_transformation.C.

169{
170 switch (dim)
171 {
172 case 0:
173 case 1:
174 libmesh_error_msg("These element transformations only make sense in 2D and 3D.");
175
176 case 2:
177 {
178 const std::vector<RealGradient> & dxyz_dxi = fe.get_fe_map().get_dxyzdxi();
179 const std::vector<RealGradient> & dxyz_deta = fe.get_fe_map().get_dxyzdeta();
180
181#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
182 const std::vector<RealGradient> & d2xyz_dxi2 = fe.get_fe_map().get_d2xyzdxi2();
183 const std::vector<RealGradient> & d2xyz_deta2 = fe.get_fe_map().get_d2xyzdeta2();
184 const std::vector<RealGradient> & d2xyz_dxideta = fe.get_fe_map().get_d2xyzdxideta();
185#else
186 // Anything but a triangle mesh or simple grid may need --enable-second
187 libmesh_error_msg_if
188 (!elem->has_affine_map(),
189 "HDiv FE gradients on non-affine-mapped elements require second-derivative support");
190 auto n_qp = dxyz_dxi.size();
191
192 const std::vector<RealGradient> d2xyz_dxi2(n_qp, RealGradient());
193 const std::vector<RealGradient> d2xyz_deta2(n_qp, RealGradient());
194 const std::vector<RealGradient> d2xyz_dxideta(n_qp, RealGradient());
195#endif
196
197 const std::vector<Real> & J = fe.get_fe_map().get_jacobian();
198
199 const std::vector<Real> & dxi_dx = fe.get_fe_map().get_dxidx();
200 const std::vector<Real> & dxi_dy = fe.get_fe_map().get_dxidy();
201 const std::vector<Real> & deta_dx = fe.get_fe_map().get_detadx();
202 const std::vector<Real> & deta_dy = fe.get_fe_map().get_detady();
203#if LIBMESH_DIM > 2
204 const std::vector<Real> & dxi_dz = fe.get_fe_map().get_dxidz();
205 const std::vector<Real> & deta_dz = fe.get_fe_map().get_detadz();
206#endif
207
208 const std::vector<std::vector<OutputShape>> & dphi_dxi = fe.get_dphidxi();
209 const std::vector<std::vector<OutputShape>> & dphi_deta = fe.get_dphideta();
210
211 for (auto i : index_range(dphi))
212 for (auto p : index_range(dphi[i]))
213 {
214 // Need to temporarily cache reference shape functions
215 // We are computing mapping basis functions, so we explicitly ignore
216 // any non-zero p_level() the Elem might have.
217 OutputShape phi_ref;
218 FEInterface::shape(fe.get_fe_type(), /*extra_order=*/0, elem, i, qp[p], phi_ref);
219
220 const OutputShape phi_val =
221 hdiv_piola_map(dxyz_dxi[p], dxyz_deta[p], J[p], phi_ref);
222
223 // Jacobi's formula: dJ/dxi_n = J * tr(F^{-1} * dF/dxi_n)
224 Real dJ_dxi =
225 J[p] * (dxi_dx[p]*d2xyz_dxi2[p](0) + deta_dx[p]*d2xyz_dxideta[p](0) +
226 dxi_dy[p]*d2xyz_dxi2[p](1) + deta_dy[p]*d2xyz_dxideta[p](1));
227 Real dJ_deta =
228 J[p] * (dxi_dx[p]*d2xyz_dxideta[p](0) + deta_dx[p]*d2xyz_deta2[p](0) +
229 dxi_dy[p]*d2xyz_dxideta[p](1) + deta_dy[p]*d2xyz_deta2[p](1));
230#if LIBMESH_DIM > 2
231 dJ_dxi += J[p] * (dxi_dz[p]*d2xyz_dxi2[p](2) + deta_dz[p]*d2xyz_dxideta[p](2));
232 dJ_deta += J[p] * (dxi_dz[p]*d2xyz_dxideta[p](2) + deta_dz[p]*d2xyz_deta2[p](2));
233#endif
234
235 for (unsigned int k = 0; k < LIBMESH_DIM; ++k)
236 {
237 // dphi_k/dx_l = A + B + C, where (n, m summed over reference directions):
238 // A = -phi_k(x) * SUM_n (dxi_n/dx_l) * (1/J) * (dJ/dxi_n)
239 // B = (1/J) * SUM_n (dxi_n/dx_l) * SUM_m (d^2 x_k/dxi_m dxi_n) * phihat_m
240 // C = (1/J) * SUM_n (dxi_n/dx_l) * SUM_m F_{km} * dphihat_m/dxi_n
241
242 // Term A: -phi_k(x) * SUM_n (dxi_n/dx_l)*(1/J)*(dJ/dxi_n)
243 const Real phik = phi_val(k);
244
245 // Term B: (1/J) * SUM_n (dxi_n/dx_l) * SUM_m (d^2 x_k/dxi_m dxi_n) * phihat_m
246 const Real d2xk_dxi2 = d2xyz_dxi2[p](k);
247 const Real d2xk_deta2 = d2xyz_deta2[p](k);
248 const Real d2xk_dxideta = d2xyz_dxideta[p](k);
249
250 const Real dphik_dxi_B = (d2xk_dxi2*phi_ref(0) + d2xk_dxideta*phi_ref(1))/J[p];
251 const Real dphik_deta_B = (d2xk_dxideta*phi_ref(0) + d2xk_deta2*phi_ref(1))/J[p];
252
253 // Term C: (1/J) * SUM_n (dxi_n/dx_l) * SUM_m F_{km} * dphihat_m/dxi_n
254 const Real Fk_xi = dxyz_dxi[p](k);
255 const Real Fk_eta = dxyz_deta[p](k);
256
257 const Real dphik_dxi_C = (Fk_xi*dphi_dxi[i][p](0) + Fk_eta*dphi_dxi[i][p](1))/J[p];
258 const Real dphik_deta_C = (Fk_xi*dphi_deta[i][p](0) + Fk_eta*dphi_deta[i][p](1))/J[p];
259
260 const Real dphik_dxi_total = -phik*dJ_dxi/J[p] + dphik_dxi_B + dphik_dxi_C;
261 const Real dphik_deta_total = -phik*dJ_deta/J[p] + dphik_deta_B + dphik_deta_C;
262
263 dphidx[i][p](k) = dxi_dx[p]*dphik_dxi_total + deta_dx[p]*dphik_deta_total;
264 dphidy[i][p](k) = dxi_dy[p]*dphik_dxi_total + deta_dy[p]*dphik_deta_total;
265#if LIBMESH_DIM > 2
266 dphidz[i][p](k) = dxi_dz[p]*dphik_dxi_total + deta_dz[p]*dphik_deta_total;
267#endif
268 }
269
270 dphi[i][p].slice(0) = dphidx[i][p];
271 dphi[i][p].slice(1) = dphidy[i][p];
272#if LIBMESH_DIM > 2
273 dphi[i][p].slice(2) = dphidz[i][p];
274#endif
275 }
276
277 break;
278 }
279 case 3:
280 {
281 const std::vector<RealGradient> & dxyz_dxi = fe.get_fe_map().get_dxyzdxi();
282 const std::vector<RealGradient> & dxyz_deta = fe.get_fe_map().get_dxyzdeta();
283 const std::vector<RealGradient> & dxyz_dzeta = fe.get_fe_map().get_dxyzdzeta();
284
285#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
286 const std::vector<RealGradient> & d2xyz_dxi2 = fe.get_fe_map().get_d2xyzdxi2();
287 const std::vector<RealGradient> & d2xyz_deta2 = fe.get_fe_map().get_d2xyzdeta2();
288 const std::vector<RealGradient> & d2xyz_dzeta2 = fe.get_fe_map().get_d2xyzdzeta2();
289 const std::vector<RealGradient> & d2xyz_dxideta = fe.get_fe_map().get_d2xyzdxideta();
290 const std::vector<RealGradient> & d2xyz_dxidzeta = fe.get_fe_map().get_d2xyzdxidzeta();
291 const std::vector<RealGradient> & d2xyz_detadzeta = fe.get_fe_map().get_d2xyzdetadzeta();
292#else
293 // Anything but a tet mesh or simple grid may need --enable-second
294 libmesh_error_msg_if
295 (!elem->has_affine_map(),
296 "HDiv FE gradients on non-affine-mapped elements require second-derivative support");
297 auto n_qp = dxyz_dxi.size();
298
299 const std::vector<RealGradient> d2xyz_dxi2(n_qp, RealGradient());
300 const std::vector<RealGradient> d2xyz_deta2(n_qp, RealGradient());
301 const std::vector<RealGradient> d2xyz_dzeta2(n_qp, RealGradient());
302 const std::vector<RealGradient> d2xyz_dxideta(n_qp, RealGradient());
303 const std::vector<RealGradient> d2xyz_dxidzeta(n_qp, RealGradient());
304 const std::vector<RealGradient> d2xyz_detadzeta(n_qp, RealGradient());
305#endif
306
307 const std::vector<Real> & J = fe.get_fe_map().get_jacobian();
308
309 const std::vector<Real> & dxi_dx = fe.get_fe_map().get_dxidx();
310 const std::vector<Real> & dxi_dy = fe.get_fe_map().get_dxidy();
311 const std::vector<Real> & dxi_dz = fe.get_fe_map().get_dxidz();
312 const std::vector<Real> & deta_dx = fe.get_fe_map().get_detadx();
313 const std::vector<Real> & deta_dy = fe.get_fe_map().get_detady();
314 const std::vector<Real> & deta_dz = fe.get_fe_map().get_detadz();
315 const std::vector<Real> & dzeta_dx = fe.get_fe_map().get_dzetadx();
316 const std::vector<Real> & dzeta_dy = fe.get_fe_map().get_dzetady();
317 const std::vector<Real> & dzeta_dz = fe.get_fe_map().get_dzetadz();
318
319 const std::vector<std::vector<OutputShape>> & dphi_dxi = fe.get_dphidxi();
320 const std::vector<std::vector<OutputShape>> & dphi_deta = fe.get_dphideta();
321 const std::vector<std::vector<OutputShape>> & dphi_dzeta = fe.get_dphidzeta();
322
323 for (auto i : index_range(dphi))
324 for (auto p : index_range(dphi[i]))
325 {
326 // Need to temporarily cache reference shape functions
327 // We are computing mapping basis functions, so we explicitly ignore
328 // any non-zero p_level() the Elem might have.
329 OutputShape phi_ref;
330 FEInterface::shape(fe.get_fe_type(), /*extra_order=*/0, elem, i, qp[p], phi_ref);
331
332 const OutputShape phi_val =
333 hdiv_piola_map(dxyz_dxi[p], dxyz_deta[p], dxyz_dzeta[p], J[p], phi_ref);
334
335 // Jacobi's formula: dJ/dxi_n = J * tr(F^{-1} * dF/dxi_n)
336 const Real dJ_dxi =
337 J[p] * (dxi_dx[p]*d2xyz_dxi2[p](0) + deta_dx[p]*d2xyz_dxideta[p](0) + dzeta_dx[p]*d2xyz_dxidzeta[p](0) +
338 dxi_dy[p]*d2xyz_dxi2[p](1) + deta_dy[p]*d2xyz_dxideta[p](1) + dzeta_dy[p]*d2xyz_dxidzeta[p](1) +
339 dxi_dz[p]*d2xyz_dxi2[p](2) + deta_dz[p]*d2xyz_dxideta[p](2) + dzeta_dz[p]*d2xyz_dxidzeta[p](2));
340 const Real dJ_deta =
341 J[p] * (dxi_dx[p]*d2xyz_dxideta[p](0) + deta_dx[p]*d2xyz_deta2[p](0) + dzeta_dx[p]*d2xyz_detadzeta[p](0) +
342 dxi_dy[p]*d2xyz_dxideta[p](1) + deta_dy[p]*d2xyz_deta2[p](1) + dzeta_dy[p]*d2xyz_detadzeta[p](1) +
343 dxi_dz[p]*d2xyz_dxideta[p](2) + deta_dz[p]*d2xyz_deta2[p](2) + dzeta_dz[p]*d2xyz_detadzeta[p](2));
344 const Real dJ_dzeta =
345 J[p] * (dxi_dx[p]*d2xyz_dxidzeta[p](0) + deta_dx[p]*d2xyz_detadzeta[p](0) + dzeta_dx[p]*d2xyz_dzeta2[p](0) +
346 dxi_dy[p]*d2xyz_dxidzeta[p](1) + deta_dy[p]*d2xyz_detadzeta[p](1) + dzeta_dy[p]*d2xyz_dzeta2[p](1) +
347 dxi_dz[p]*d2xyz_dxidzeta[p](2) + deta_dz[p]*d2xyz_detadzeta[p](2) + dzeta_dz[p]*d2xyz_dzeta2[p](2));
348
349 for (unsigned int k = 0; k < 3; ++k)
350 {
351 // dphi_k/dx_l = A + B + C, where (n, m summed over reference directions):
352 // A = -phi_k(x) * SUM_n (dxi_n/dx_l) * (1/J) * (dJ/dxi_n)
353 // B = (1/J) * SUM_n (dxi_n/dx_l) * SUM_m (d^2 x_k/dxi_m dxi_n) * phihat_m
354 // C = (1/J) * SUM_n (dxi_n/dx_l) * SUM_m F_{km} * dphihat_m/dxi_n
355
356 // Term A: -phi_k(x) * SUM_n (dxi_n/dx_l)*(1/J)*(dJ/dxi_n)
357 const Real phik = phi_val(k);
358
359 // Term B: (1/J) * SUM_n (dxi_n/dx_l) * SUM_m (d^2 x_k/dxi_m dxi_n) * phihat_m
360 const Real d2xk_dxi2 = d2xyz_dxi2[p](k);
361 const Real d2xk_deta2 = d2xyz_deta2[p](k);
362 const Real d2xk_dzeta2 = d2xyz_dzeta2[p](k);
363 const Real d2xk_dxideta = d2xyz_dxideta[p](k);
364 const Real d2xk_dxidzeta = d2xyz_dxidzeta[p](k);
365 const Real d2xk_detadzeta = d2xyz_detadzeta[p](k);
366
367 const Real dphik_dxi_B = (d2xk_dxi2*phi_ref(0) + d2xk_dxideta*phi_ref(1) + d2xk_dxidzeta*phi_ref(2))/J[p];
368 const Real dphik_deta_B = (d2xk_dxideta*phi_ref(0) + d2xk_deta2*phi_ref(1) + d2xk_detadzeta*phi_ref(2))/J[p];
369 const Real dphik_dzeta_B = (d2xk_dxidzeta*phi_ref(0) + d2xk_detadzeta*phi_ref(1) + d2xk_dzeta2*phi_ref(2))/J[p];
370
371 // Term C: (1/J) * SUM_n (dxi_n/dx_l) * SUM_m F_{km} * dphihat_m/dxi_n
372 const Real Fk_xi = dxyz_dxi[p](k);
373 const Real Fk_eta = dxyz_deta[p](k);
374 const Real Fk_zeta = dxyz_dzeta[p](k);
375
376 const Real dphik_dxi_C = (Fk_xi*dphi_dxi[i][p](0) + Fk_eta*dphi_dxi[i][p](1) + Fk_zeta*dphi_dxi[i][p](2))/J[p];
377 const Real dphik_deta_C = (Fk_xi*dphi_deta[i][p](0) + Fk_eta*dphi_deta[i][p](1) + Fk_zeta*dphi_deta[i][p](2))/J[p];
378 const Real dphik_dzeta_C = (Fk_xi*dphi_dzeta[i][p](0) + Fk_eta*dphi_dzeta[i][p](1) + Fk_zeta*dphi_dzeta[i][p](2))/J[p];
379
380 const Real dphik_dxi_total = -phik*dJ_dxi/J[p] + dphik_dxi_B + dphik_dxi_C;
381 const Real dphik_deta_total = -phik*dJ_deta/J[p] + dphik_deta_B + dphik_deta_C;
382 const Real dphik_dzeta_total = -phik*dJ_dzeta/J[p] + dphik_dzeta_B + dphik_dzeta_C;
383
384 dphidx[i][p](k) = dxi_dx[p]*dphik_dxi_total + deta_dx[p]*dphik_deta_total + dzeta_dx[p]*dphik_dzeta_total;
385 dphidy[i][p](k) = dxi_dy[p]*dphik_dxi_total + deta_dy[p]*dphik_deta_total + dzeta_dy[p]*dphik_dzeta_total;
386 dphidz[i][p](k) = dxi_dz[p]*dphik_dxi_total + deta_dz[p]*dphik_deta_total + dzeta_dz[p]*dphik_dzeta_total;
387 }
388
389 dphi[i][p].slice(0) = dphidx[i][p];
390 dphi[i][p].slice(1) = dphidy[i][p];
391 dphi[i][p].slice(2) = dphidz[i][p];
392 }
393
394 break;
395 }
396
397 default:
398 libmesh_error_msg("Invalid dim = " << dim);
399 } // switch(dim)
400}
virtual bool has_affine_map() const
Definition elem.h:1312
FEType get_fe_type() const
static Real shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
const std::vector< Real > & get_dxidz() const
Definition fe_map.h:325
const std::vector< RealGradient > & get_dxyzdeta() const
Definition fe_map.h:247
const std::vector< Real > & get_detadx() const
Definition fe_map.h:333
const std::vector< Real > & get_dzetady() const
Definition fe_map.h:365
const std::vector< Real > & get_detady() const
Definition fe_map.h:341
const std::vector< RealGradient > & get_d2xyzdxidzeta() const
Definition fe_map.h:292
const std::vector< RealGradient > & get_d2xyzdetadzeta() const
Definition fe_map.h:299
const std::vector< Real > & get_dxidx() const
Definition fe_map.h:309
const std::vector< RealGradient > & get_d2xyzdeta2() const
Definition fe_map.h:271
const std::vector< Real > & get_dzetadx() const
Definition fe_map.h:357
const std::vector< RealGradient > & get_dxyzdzeta() const
Definition fe_map.h:255
const std::vector< Real > & get_dxidy() const
Definition fe_map.h:317
const std::vector< RealGradient > & get_d2xyzdzeta2() const
Definition fe_map.h:278
const std::vector< Real > & get_dzetadz() const
Definition fe_map.h:373
const std::vector< Real > & get_detadz() const
Definition fe_map.h:349
const std::vector< RealGradient > & get_d2xyzdxideta() const
Definition fe_map.h:285
RealVectorValue RealGradient
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References dim, libMesh::FEMap::get_d2xyzdeta2(), libMesh::FEMap::get_d2xyzdetadzeta(), libMesh::FEMap::get_d2xyzdxi2(), libMesh::FEMap::get_d2xyzdxideta(), libMesh::FEMap::get_d2xyzdxidzeta(), libMesh::FEMap::get_d2xyzdzeta2(), libMesh::FEMap::get_detadx(), libMesh::FEMap::get_detady(), libMesh::FEMap::get_detadz(), libMesh::FEGenericBase< OutputType >::get_dphideta(), libMesh::FEGenericBase< OutputType >::get_dphidxi(), libMesh::FEGenericBase< OutputType >::get_dphidzeta(), libMesh::FEMap::get_dxidx(), libMesh::FEMap::get_dxidy(), libMesh::FEMap::get_dxidz(), libMesh::FEMap::get_dxyzdeta(), libMesh::FEMap::get_dxyzdxi(), libMesh::FEMap::get_dxyzdzeta(), libMesh::FEMap::get_dzetadx(), libMesh::FEMap::get_dzetady(), libMesh::FEMap::get_dzetadz(), libMesh::FEAbstract::get_fe_map(), libMesh::FEAbstract::get_fe_type(), libMesh::FEMap::get_jacobian(), libMesh::Elem::has_affine_map(), libMesh::index_range(), libMesh::Real, and libMesh::FEInterface::shape().

◆ map_dphi() [2/2]

void libMesh::HDivFETransformation< Real >::map_dphi ( const unsigned int  ,
const Elem * const  ,
const std::vector< Point > &  ,
const FEGenericBase< Real > &  ,
std::vector< std::vector< FEGenericBase< Real >::OutputGradient > > &  ,
std::vector< std::vector< Real > > &  ,
std::vector< std::vector< Real > > &  ,
std::vector< std::vector< Real > > &   
) const

Definition at line 486 of file hdiv_fe_transformation.C.

494{
495 libmesh_error_msg("HDiv transformations only make sense for vector-valued elements.");
496}

◆ map_phi() [1/2]

template<typename OutputShape >
void libMesh::HDivFETransformation< OutputShape >::map_phi ( const unsigned int  dim,
const Elem *const  elem,
const std::vector< Point > &  qp,
const FEGenericBase< OutputShape > &  fe,
std::vector< std::vector< OutputShape > > &  phi,
bool  add_p_level = true 
) const
overridevirtual

Evaluates shape functions in physical coordinates for \( H(div) \) conforming elements.

In this case \( \phi = J^{-1} (dx/d\xi) \hat{\phi} \), where \( (dx/d\xi) \) is the Jacobian matrix of the element map and J = \det( dx/d\xi ).

Note
Here \( x, \xi \) are vectors.

Implements libMesh::FETransformationBase< OutputShape >.

Definition at line 96 of file hdiv_fe_transformation.C.

102{
103 switch (dim)
104 {
105 case 0:
106 case 1:
107 libmesh_error_msg("These element transformations only make sense in 2D and 3D.");
108
109 case 2:
110 {
111 const std::vector<RealGradient> & dxyz_dxi = fe.get_fe_map().get_dxyzdxi();
112 const std::vector<RealGradient> & dxyz_deta = fe.get_fe_map().get_dxyzdeta();
113
114 const std::vector<Real> & J = fe.get_fe_map().get_jacobian();
115
116 // phi = J^{-1} * (dx/dxi) * \hat{phi}
117 for (auto i : index_range(phi))
118 for (auto p : index_range(phi[i]))
119 {
120 // Need to temporarily cache reference shape functions
121 // We are computing mapping basis functions, so we explicitly ignore
122 // any non-zero p_level() the Elem might have.
123 OutputShape phi_ref;
124 FEInterface::shape(fe.get_fe_type(), /*extra_order=*/0, elem, i, qp[p], phi_ref);
125
126 phi[i][p] = hdiv_piola_map(dxyz_dxi[p], dxyz_deta[p], J[p], phi_ref);
127 }
128
129 break;
130 }
131 case 3:
132 {
133 const std::vector<RealGradient> & dxyz_dxi = fe.get_fe_map().get_dxyzdxi();
134 const std::vector<RealGradient> & dxyz_deta = fe.get_fe_map().get_dxyzdeta();
135 const std::vector<RealGradient> & dxyz_dzeta = fe.get_fe_map().get_dxyzdzeta();
136
137 const std::vector<Real> & J = fe.get_fe_map().get_jacobian();
138
139 // phi = J^{-1} * (dx/dxi) * \hat{phi}
140 for (auto i : index_range(phi))
141 for (auto p : index_range(phi[i]))
142 {
143 // Need to temporarily cache reference shape functions
144 // We are computing mapping basis functions, so we explicitly ignore
145 // any non-zero p_level() the Elem might have.
146 OutputShape phi_ref;
147 FEInterface::shape(fe.get_fe_type(), /*extra_order=*/0, elem, i, qp[p], phi_ref);
148
149 phi[i][p] = hdiv_piola_map(dxyz_dxi[p], dxyz_deta[p], dxyz_dzeta[p], J[p], phi_ref);
150 }
151
152 break;
153 }
154
155 default:
156 libmesh_error_msg("Invalid dim = " << dim);
157 } // switch(dim)
158}

References dim, libMesh::FEMap::get_dxyzdeta(), libMesh::FEMap::get_dxyzdxi(), libMesh::FEMap::get_dxyzdzeta(), libMesh::FEAbstract::get_fe_map(), libMesh::FEAbstract::get_fe_type(), libMesh::FEMap::get_jacobian(), libMesh::index_range(), and libMesh::FEInterface::shape().

◆ map_phi() [2/2]

void libMesh::HDivFETransformation< Real >::map_phi ( const unsigned int  ,
const Elem * const  ,
const std::vector< Point > &  ,
const FEGenericBase< Real > &  ,
std::vector< std::vector< Real > > &  ,
bool   
) const

Definition at line 475 of file hdiv_fe_transformation.C.

481{
482 libmesh_error_msg("HDiv transformations only make sense for vector-valued elements.");
483}

The documentation for this class was generated from the following files: