MeshFields
GPU accelerated mesh-based fields
Public Types | Public Member Functions | Static Public Member Functions | List of all members
MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor > Struct Template Reference

Supports the evaluation of a field, and other per-element operations, given the definition of the element ((the topological type of mesh entity to operate over (i.e., edge, tri, quad, tet, etc.)) and shape functions used by the field. Operations are expected to be executed concurrently across all (or a subset of) elements in the on-process mesh (e.g., within a parallel for loop). More...

#include <MeshField_Element.hpp>

Public Types

using DofArray = Kokkos::Array< typename baseType< typename FieldAccessor::BaseType >::type, ShapeType::numNodes *NumComponents >
 every dof of one element, indexed [node * NumComponents + comp]
 
using LocalGradArray = Kokkos::Array< typename baseType< typename FieldAccessor::BaseType >::type, MeshEntDim *NumComponents >
 parametric gradients of every component at one point, indexed [direction * NumComponents + comp]
 
using JacobianArray = Kokkos::Array< Real, MeshEntDim *MeshEntDim >
 the Jacobian at one point, row-major with J[i][j] = dx_j/dxi_i
 

Public Member Functions

KOKKOS_INLINE_FUNCTION DofArray gatherDofs (int ent) const
 gather element's dofs into an array More...
 
KOKKOS_INLINE_FUNCTION DofArray coefficients (int ent) const
 the coefficients of one element on its reference basis More...
 
template<typename Coefficients >
KOKKOS_INLINE_FUNCTION ValArray valueFromCoefficients (Coefficients const &c, Kokkos::Array< Real, MeshEntDim > localCoord) const
 compute dot product between the basis functions and the coefficients I.e., $$\sum_{A=1}^{N} c_A N_A$$ More...
 
template<typename Coefficients >
KOKKOS_INLINE_FUNCTION LocalGradArray localGradientFromCoefficients (Coefficients const &c, Kokkos::Array< Real, MeshEntDim > localCoord) const
 compute dot product between the basis function gradients and the coefficients I.e., $$\sum_{A=1}^{N} c_A N_{A,x}$$ More...
 
template<typename Coefficients , typename ShapeGradients >
KOKKOS_INLINE_FUNCTION LocalGradArray localGradientFromShapeGradients (Coefficients const &c, ShapeGradients const &shapeGrads) const
 localGradientFromCoefficients with the shape function gradients already evaluated, so they can be shared with a geometry that uses the same shape More...
 
KOKKOS_INLINE_FUNCTION ValArray getValue (int ent, Kokkos::Array< Real, MeshEntDim > localCoord) const
 evaluate the field in the specified element at the specified parametric/local/area coordinate More...
 
KOKKOS_INLINE_FUNCTION JacobianArray jacobianFromNodeValues (NodeArray const &x, Kokkos::Array< Real, MeshEntDim > localCoord) const
 compute the Jacobian at a parametric coordinate from the node coordinates More...
 
template<typename ShapeGradients >
KOKKOS_INLINE_FUNCTION JacobianArray jacobianFromShapeGradients (NodeArray const &x, ShapeGradients const &grads) const
 jacobianFromNodeValues with the shape function gradients already evaluated, so they can be shared with a field that uses the same shape More...
 
KOKKOS_INLINE_FUNCTION Real getJacobian1d (int ent) const
 compute the Jacobian of an edge More...
 
template<typename Matrices >
Kokkos::View< Real * > getJacobianDeterminants (Matrices const &J) const
 
Kokkos::View< Real *** > getJacobians (Kokkos::View< Real ** > localCoords, Kokkos::View< LO * > offsets) const
 Given an array of parametric coordinates 'localCoords', one per mesh element, compute the jacobian within each element. More...
 

Static Public Member Functions

static constexpr KOKKOS_FUNCTION auto getTopology ()
 the topology of the element's reference element
 

Detailed Description

template<typename FieldAccessor, typename ShapeType, typename ElementDofHolderAccessor>
struct MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >

Supports the evaluation of a field, and other per-element operations, given the definition of the element ((the topological type of mesh entity to operate over (i.e., edge, tri, quad, tet, etc.)) and shape functions used by the field. Operations are expected to be executed concurrently across all (or a subset of) elements in the on-process mesh (e.g., within a parallel for loop).

Template Parameters
FieldAccessorprovides parenthesis operator to access the field (see CreateLagrangeField and CreateCoordinateField)
ShapeTypeDefines the shape function order and mesh topology (i.e., QuadraticTriangleShape, QuadraticTetrahedronShape, ...)
ElementDofHolderAccessorprovides the mapping from the element indices to the underlying field storage
Todo:
add static asserts for functions provided by the templated types
Parameters
in_numMeshEntsnumber of mesh entities that are associated with the ElementType
fieldInsee FieldAccessor
elmInsee ElementType

Definition at line 149 of file MeshField_Element.hpp.

Member Function Documentation

◆ coefficients()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
KOKKOS_INLINE_FUNCTION DofArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::coefficients ( int  ent) const
inline

the coefficients of one element on its reference basis

The coefficients depend only on the element, not on the evaluation point, so compute them once per element and pass them to valueFromCoefficients and localGradientFromCoefficients for each point. For a FieldElement the stored dofs are the coefficients; elements whose dofs must be transformed to the reference element (e.g., the Bell element) override this.

Parameters
entthe mesh entity index
Returns
coefficients, indexed [node * NumComponents + component]

Definition at line 232 of file MeshField_Element.hpp.

◆ gatherDofs()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
KOKKOS_INLINE_FUNCTION DofArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::gatherDofs ( int  ent) const
inline

gather element's dofs into an array

Parameters
entthe mesh entity index
Returns
the element's dofs, indexed [node * NumComponents + component]

Definition at line 202 of file MeshField_Element.hpp.

◆ getJacobian1d()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
KOKKOS_INLINE_FUNCTION Real MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::getJacobian1d ( int  ent) const
inline

compute the Jacobian of an edge

@TODO use the same approach taken for 2d

heavily based on SCOREC/core @ 7cd76473 apf/apfVectorElement.cc

Parameters
entthe mesh entity index
Returns
the result of evaluation

Definition at line 398 of file MeshField_Element.hpp.

◆ getJacobianDeterminants()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
template<typename Matrices >
Kokkos::View<Real *> MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::getJacobianDeterminants ( Matrices const &  J) const
inline

heavily based on SCOREC/core @ 7cd76473 apf/apfVectorElement.cc

Definition at line 416 of file MeshField_Element.hpp.

◆ getJacobians()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
Kokkos::View<Real ***> MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::getJacobians ( Kokkos::View< Real ** >  localCoords,
Kokkos::View< LO * >  offsets 
) const
inline

Given an array of parametric coordinates 'localCoords', one per mesh element, compute the jacobian within each element.

Todo:

add static asserts for values and functions provided by the templated types

consider making this a member function of FieldElement

Parameters
localCoords2D Kokkos::View containing the local/parametric/area coordinates for each element
offsets1D Kokkos::View containing the offsets into localCoords, size = localCoords.extent(0)+1
Returns
Kokkos::View containing the jacobian for all the mesh elements

Definition at line 574 of file MeshField_Element.hpp.

◆ getValue()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
KOKKOS_INLINE_FUNCTION ValArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::getValue ( int  ent,
Kokkos::Array< Real, MeshEntDim >  localCoord 
) const
inline

evaluate the field in the specified element at the specified parametric/local/area coordinate

Prefer coefficients and valueFromCoefficients when evaluating an element at more than one point.

Parameters
entthe mesh entity index
localCoordthe parametric coordinate
Returns
the result of evaluation

Definition at line 319 of file MeshField_Element.hpp.

◆ jacobianFromNodeValues()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
KOKKOS_INLINE_FUNCTION JacobianArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::jacobianFromNodeValues ( NodeArray const &  x,
Kokkos::Array< Real, MeshEntDim >  localCoord 
) const
inline

compute the Jacobian at a parametric coordinate from the node coordinates

The field must be a coordinate field.

heavily based on SCOREC/core @ 7cd76473 apf/apfVectorElement.cc

Parameters
xnode coordinates from getNodeValues
localCoordthe parametric coordinate
Returns
the Jacobian, row-major with J[i][j] = dx_j/dxi_i

Definition at line 358 of file MeshField_Element.hpp.

◆ jacobianFromShapeGradients()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
template<typename ShapeGradients >
KOKKOS_INLINE_FUNCTION JacobianArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::jacobianFromShapeGradients ( NodeArray const &  x,
ShapeGradients const &  grads 
) const
inline

jacobianFromNodeValues with the shape function gradients already evaluated, so they can be shared with a field that uses the same shape

Parameters
xnode coordinates from getNodeValues
gradsshapeFn.getLocalGradients at the parametric coordinate
Returns
the Jacobian, row-major with J[i][j] = dx_j/dxi_i

Definition at line 373 of file MeshField_Element.hpp.

◆ localGradientFromCoefficients()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
template<typename Coefficients >
KOKKOS_INLINE_FUNCTION LocalGradArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::localGradientFromCoefficients ( Coefficients const &  c,
Kokkos::Array< Real, MeshEntDim >  localCoord 
) const
inline

compute dot product between the basis function gradients and the coefficients I.e., $$\sum_{A=1}^{N} c_A N_{A,x}$$

The result is the gradient with respect to the parametric coordinates, not the physical coordinates; mapping it to the physical element requires the geometry's Jacobian.

Parameters
ccoefficients from coefficients(ent)
localCoordthe parametric coordinate
Returns
parametric gradients, indexed [direction * NumComponents + component]

Definition at line 276 of file MeshField_Element.hpp.

◆ localGradientFromShapeGradients()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
template<typename Coefficients , typename ShapeGradients >
KOKKOS_INLINE_FUNCTION LocalGradArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::localGradientFromShapeGradients ( Coefficients const &  c,
ShapeGradients const &  shapeGrads 
) const
inline

localGradientFromCoefficients with the shape function gradients already evaluated, so they can be shared with a geometry that uses the same shape

Parameters
ccoefficients from coefficients(ent)
shapeGradsshapeFn.getLocalGradients at the parametric coordinate
Returns
parametric gradients, indexed [direction * NumComponents + component]

Definition at line 292 of file MeshField_Element.hpp.

◆ valueFromCoefficients()

template<typename FieldAccessor , typename ShapeType , typename ElementDofHolderAccessor >
template<typename Coefficients >
KOKKOS_INLINE_FUNCTION ValArray MeshField::FieldElement< FieldAccessor, ShapeType, ElementDofHolderAccessor >::valueFromCoefficients ( Coefficients const &  c,
Kokkos::Array< Real, MeshEntDim >  localCoord 
) const
inline

compute dot product between the basis functions and the coefficients I.e., $$\sum_{A=1}^{N} c_A N_A$$

heavily based on SCOREC/core @ 7cd76473 apf/apfElement.cc

Parameters
ccoefficients from coefficients(ent)
localCoordthe parametric coordinate
Returns
the field value

Definition at line 249 of file MeshField_Element.hpp.


The documentation for this struct was generated from the following file: