1 #ifndef MESHFIELD_SHAPE_H
2 #define MESHFIELD_SHAPE_H
3 #include <MeshField_Defines.hpp>
26 KOKKOS_INLINE_FUNCTION
bool greaterThanOrEqual(MeshField::Real xi,
const MeshField::Real val,
const MeshField::Real tol) {
27 if ( xi > val )
return true;
28 return (Kokkos::fabs(xi - val) <= tol);
38 template <
typename Array>
39 KOKKOS_INLINE_FUNCTION
bool eachGreaterThanOrEqual(Array &xi,
const MeshField::Real val,
const MeshField::Real tol) {
41 for (
size_t i = 0; i < xi.size(); i++) {
42 gt = gt && greaterThanOrEqual(xi[i],val,tol);
53 KOKKOS_INLINE_FUNCTION
bool lessThanOrEqual(MeshField::Real xi,
const MeshField::Real val,
const MeshField::Real tol) {
54 if ( xi < val )
return true;
55 return (Kokkos::fabs(xi - val) <= tol);
65 template <
typename Array>
66 KOKKOS_INLINE_FUNCTION
bool eachLessThanOrEqual(Array &xi,
const MeshField::Real val,
const MeshField::Real tol) {
68 for (
size_t i = 0; i < xi.size(); i++) {
69 lt = lt && lessThanOrEqual(xi[i],val,tol);
109 KOKKOS_INLINE_FUNCTION
122 KOKKOS_INLINE_FUNCTION
124 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
125 assert(eachGreaterThanOrEqual(xi,-1.0,ParametricCoordTol));
127 return {(1.0 - xi[0]) / 2.0,
128 (1.0 + xi[0]) / 2.0};
137 KOKKOS_INLINE_FUNCTION
174 KOKKOS_INLINE_FUNCTION
189 KOKKOS_INLINE_FUNCTION
191 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
192 assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
193 const Real L0 = 1 - xi[0] - xi[1];
194 assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
195 assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
209 KOKKOS_INLINE_FUNCTION
240 KOKKOS_INLINE_FUNCTION
254 KOKKOS_INLINE_FUNCTION
256 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
257 assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
258 const Real L0 = 1 - xi[0] - xi[1];
259 assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
260 assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
288 constexpr
static Mesh_Topology
DofHolders[2] = {Vertex, Edge};
297 KOKKOS_INLINE_FUNCTION
321 KOKKOS_INLINE_FUNCTION
323 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
324 assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
325 const Real L0 = 1 - xi[0] - xi[1];
326 assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
327 assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
328 const Real L1 = xi[0];
329 const Real L2 = xi[1];
331 return {L0 * (2 * L0 - 1),
345 KOKKOS_INLINE_FUNCTION
346 Kokkos::Array<Real, meshEntDim * numNodes>
348 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
349 assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
350 const Real L0 = 1 - xi[0] - xi[1];
351 assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
352 assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
353 const Real L1 = xi[0];
354 const Real L2 = xi[1];
398 KOKKOS_INLINE_FUNCTION
414 KOKKOS_INLINE_FUNCTION
416 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
417 assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
418 const Real L0 = 1 - xi[0] - xi[1] - xi[2];
419 assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
420 assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
435 KOKKOS_INLINE_FUNCTION
464 constexpr
static Mesh_Topology
DofHolders[2] = {Vertex, Edge};
473 KOKKOS_INLINE_FUNCTION
501 KOKKOS_INLINE_FUNCTION
503 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
504 assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
505 const Real L0 = 1 - xi[0] - xi[1] - xi[2];
506 assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
507 assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
508 const Real L1 = xi[0];
509 const Real L2 = xi[1];
510 const Real L3 = xi[2];
530 KOKKOS_INLINE_FUNCTION
531 Kokkos::Array<Real, meshEntDim * numNodes>
533 assert(eachLessThanOrEqual(xi,1.0,ParametricCoordTol));
534 assert(eachGreaterThanOrEqual(xi,0.0,ParametricCoordTol));
535 const Real L0 = 1 - xi[0] - xi[1] - xi[2];
536 assert(greaterThanOrEqual(L0,0.0,ParametricCoordTol));
537 assert(lessThanOrEqual(L0,1.0,ParametricCoordTol));
538 const Real L1 = xi[0];
539 const Real L2 = xi[1];
540 const Real L3 = xi[2];
542 const Real d3 = 1 - 4 * L0;
549 4*L0-4*L1 , -4*L1 , -4*L1 ,
550 -4*L2 , 4*L0-4*L2 , -4*L2 ,
551 -4*L3 , -4*L3 , 4*L0-4*L3 ,
Kokkos::Array< Real, 2 > Vector2
2D parametric coordinate vector
Kokkos::Array< Real, 3 > Vector3
3D parametric coordinate vector
Kokkos::Array< Real, 1 > Vector1
1D parametric coordinate vector
Linear (P1) shape functions for 1D edge elements.
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes *meshEntDim > getNodeParametricCoords() const
Get parametric coordinates of element nodes.
static const size_t meshEntDim
Mesh entity dimension (1D)
constexpr static Mesh_Topology DofHolders[1]
DOFs located at vertices.
constexpr static size_t Order
Polynomial order (linear)
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes > getValues(Vector1 const &xi) const
Evaluate shape functions at parametric coordinate.
static const size_t numNodes
Number of nodes (2 for linear edge)
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes > getLocalGradients(Vector1 const &) const
Get gradients of shape functions in parametric coordinates @detail gradients are constant - ignoring ...
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes > getValues(Vector3 const &xi) const
Evaluate shape functions at parametric coordinate.
static const size_t numNodes
Number of nodes (4 for linear tetrahedron)
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes *meshEntDim > getNodeParametricCoords() const
Get parametric coordinates of element nodes.
constexpr static Mesh_Topology DofHolders[1]
DOFs located at vertices.
static const size_t meshEntDim
Mesh entity dimension (3D)
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, meshEntDim *numNodes > getLocalGradients(Vector3 const &) const
Get gradients of shape functions in parametric coordinates @detail gradients are constant - ignoring ...
constexpr static size_t Order
Polynomial order (linear)
Linear triangle shape functions for coordinate fields.
constexpr static Mesh_Topology DofHolders[1]
DOFs located at vertices.
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes > getValues(Vector2 const &xi) const
Evaluate shape functions at parametric coordinate.
static const size_t numNodes
Number of nodes.
constexpr static size_t Order
Polynomial order (linear)
static const size_t meshEntDim
Mesh entity dimension (2D)
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes *meshEntDim > getNodeParametricCoords() const
Get parametric coordinates of element nodes.
Linear (P1) shape functions for 2D triangular elements.
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, meshEntDim *numNodes > getLocalGradients(Vector2 const &) const
Get gradients of shape functions @detail gradients are constant - ignoring parametric coord input.
static const size_t numComponentsPerDof
Components per DOF (scalar field)
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes *meshEntDim > getNodeParametricCoords() const
Get parametric coordinates of element nodes.
constexpr static size_t Order
Polynomial order (linear)
static const size_t meshEntDim
Mesh entity dimension (2D)
static const size_t numNodes
Number of nodes (3 for linear triangle)
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes > getValues(Vector2 const &xi) const
Evaluate shape functions at parametric coordinate.
constexpr static Mesh_Topology DofHolders[1]
DOFs located at vertices.
Quadratic (P2) shape functions for 3D tetrahedral elements.
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes *meshEntDim > getNodeParametricCoords() const
Get parametric coordinates of element nodes.
constexpr static size_t NumDofHolders[2]
4 vertices, 6 edges
constexpr static size_t Order
Polynomial order (quadratic)
static const size_t numNodes
Number of nodes (10 for quadratic tetrahedron)
constexpr static Mesh_Topology DofHolders[2]
DOFs at vertices and edges.
constexpr static size_t DofsPerHolder[2]
1 DOF per vertex/edge
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes > getValues(Vector3 const &xi) const
Evaluate quadratic shape functions at parametric coordinate.
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, meshEntDim *numNodes > getLocalGradients(Vector3 const &xi) const
Get gradients of quadratic shape functions in parametric coordinates.
static const size_t meshEntDim
Mesh entity dimension (3D)
Quadratic (P2) shape functions for 2D triangular elements.
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes > getValues(Vector2 const &xi) const
Evaluate quadratic shape functions at parametric coordinate.
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, meshEntDim *numNodes > getLocalGradients(Vector2 const &xi) const
Get gradients of quadratic shape functions at parametric coordinate.
constexpr static size_t NumDofHolders[2]
3 vertices, 3 edges
KOKKOS_INLINE_FUNCTION Kokkos::Array< Real, numNodes *meshEntDim > getNodeParametricCoords() const
Get parametric coordinates of element nodes.
constexpr static Mesh_Topology DofHolders[2]
DOFs at vertices and edges.
constexpr static size_t DofsPerHolder[2]
1 DOF per vertex/edge
static const size_t numNodes
Number of nodes (6 for quadratic triangle)
constexpr static size_t Order
Polynomial order (quadratic)
static const size_t meshEntDim
Mesh entity dimension (2D)