IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS > Class Template Reference

A class representing a Lagrange space for finite element methods on a structured, rectilinear grid. More...

#include <LagrangeSpace.h>

+ Inheritance diagram for ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >:
+ Collaboration diagram for ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >:

Classes

struct  DeviceStruct
 Device struct for copies //////////////////////////////////////////. More...
 

Public Types

typedef FiniteElementSpace< T, Dim, numElementDOFs, ElementType, QuadratureType, FieldLHS, FieldRHS >::indices_t indices_t
 
typedef FiniteElementSpace< T, Dim, numElementDOFs, ElementType, QuadratureType, FieldLHS, FieldRHS >::point_t point_t
 
typedef FiniteElementSpace< T, Dim, numElementDOFs, ElementType, QuadratureType, FieldLHS, FieldRHS >::vertex_points_t vertex_points_t
 
typedef FieldLayout< Dim > Layout_t
 
typedef detail::ViewType< T, Dim >::view_type ViewType
 
typedef detail::ViewType< T, Dim, Kokkos::MemoryTraits< Kokkos::Atomic > >::view_type AtomicViewType
 
- Public Types inherited from ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >
typedef Vector< size_t, Dim > indices_t
 
typedef Vector< T, Dim > point_t
 
typedef Vector< size_t, numElementVertices > vertex_indices_t
 
typedef Vector< indices_t, numElementVertices > indices_list_t
 
typedef Vector< point_t, numElementVertices > vertex_points_t
 

Public Member Functions

 LagrangeSpace (UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature, Layout_t &layout)
 Construct a new LagrangeSpace object.
 
 LagrangeSpace (UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature)
 Construct a new LagrangeSpace object (without layout) This constructor is made to work with the default constructor in FEMPoissonSolver.h such that it is compatible with alpine.
 
void initialize (UniformCartesian< T, Dim > &mesh, Layout_t &layout)
 Initialize a LagrangeSpace object created with the default constructor.
 
void initializeElementIndices (Layout_t &layout)
 Initialize a Kokkos view containing the element indices. This distributes the elements among MPI ranks.
 
void updateLayout (Layout_t &layout)
 Function to update the element partition and the layout of fields in the LagrangeSpace if the layout has been changed during the simulation (for example by the load balancer).
 
KOKKOS_FUNCTION size_t numGlobalDOFs () const override
 Degree of Freedom operations //////////////////////////////////////.
 
KOKKOS_FUNCTION size_t getLocalDOFIndex (const size_t &elementIndex, const size_t &globalDOFIndex) const override
 Get the elements local DOF from the element index and global DOF index.
 
KOKKOS_FUNCTION size_t getGlobalDOFIndex (const size_t &elementIndex, const size_t &localDOFIndex) const override
 Get the global DOF index from the element index and local DOF.
 
KOKKOS_FUNCTION Vector< size_t, numElementDOFs > getLocalDOFIndices () const override
 Get the local DOF indices (vector of local DOF indices) They are independent of the specific element because it only depends on the reference element type.
 
KOKKOS_FUNCTION Vector< size_t, numElementDOFs > getGlobalDOFIndices (const size_t &element_index) const override
 Get the global DOF indices (vector of global DOF indices) of an element.
 
KOKKOS_FUNCTION T evaluateRefElementShapeFunction (const size_t &localDOF, const point_t &localPoint) const
 Basis functions and gradients /////////////////////////////////////.
 
KOKKOS_FUNCTION point_t evaluateRefElementShapeFunctionGradient (const size_t &localDOF, const point_t &localPoint) const
 Evaluate the gradient of the shape function of a local degree of freedom at a given point in the reference element.
 
KOKKOS_FUNCTION point_t getInverseTransposeTransformationJacobian (vertex_points_t pt) const
 Functions to access element info from outside /////////////////////.
 
template<typename F >
FieldLHS evaluateAx (FieldLHS &field, F &evalFunction)
 Assembly operations ///////////////////////////////////////////////.
 
template<typename F >
FieldLHS evaluateAx_lower (FieldLHS &field, F &evalFunction)
 
template<typename F >
FieldLHS evaluateAx_upper (FieldLHS &field, F &evalFunction)
 
template<typename F >
FieldLHS evaluateAx_upperlower (FieldLHS &field, F &evalFunction)
 
template<typename F >
FieldLHS evaluateAx_inversediag (FieldLHS &field, F &evalFunction)
 
template<typename F >
FieldLHS evaluateAx_diag (FieldLHS &field, F &evalFunction)
 
template<typename F >
FieldLHS evaluateAx_lift (FieldLHS &field, F &evalFunction)
 Assemble the left stiffness matrix A of the system but only for the boundary values, so that they can be subtracted from the RHS for treatment of Dirichlet BCs.
 
void evaluateLoadVector (FieldRHS &field) const
 Assemble the load vector b of the system Ax = b.
 
void evaluateLumpedMass (FieldRHS &field) const
 Functions for error computations, etc. ////////////////////////////.
 
template<typename F >
computeErrorL2 (const FieldLHS &u_h, const F &u_sol) const
 Error norm computations ///////////////////////////////////////////.
 
computeAvg (const FieldLHS &u_h) const
 Given a field, compute the average.
 
DeviceStruct getDeviceMirror () const
 Device struct definitions /////////////////////////////////////////.
 
- Public Member Functions inherited from ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >
 FiniteElementSpace (UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature)
 Construct a new FiniteElementSpace object.
 
void setMesh (UniformCartesian< T, Dim > &mesh)
 
KOKKOS_FUNCTION size_t numElements () const
 Mesh and Element operations ///////////////////////////////////////.
 
KOKKOS_FUNCTION size_t numElementsInDim (const size_t &dim) const
 Get the number of elements in a given dimension.
 
KOKKOS_FUNCTION indices_t getMeshVertexNDIndex (const size_t &vertex_index) const
 Get the NDIndex of a mesh vertex.
 
KOKKOS_FUNCTION size_t getMeshVertexIndex (const indices_t &vertex_nd_index) const
 Get the global index of a mesh vertex given its NDIndex.
 
KOKKOS_FUNCTION indices_t getElementNDIndex (const size_t &elementIndex) const
 Get the NDIndex (vector of indices for each dimension) of a mesh element.
 
KOKKOS_FUNCTION size_t getElementIndex (const indices_t &ndindex) const
 Get the global index of a mesh element given the NDIndex.
 
KOKKOS_FUNCTION vertex_indices_t getElementMeshVertexIndices (const indices_t &elementNDIndex) const
 Get all the global vertex indices of an element (given by its NDIndex).
 
KOKKOS_FUNCTION indices_list_t getElementMeshVertexNDIndices (const indices_t &elementNDIndex) const
 Get all the NDIndices of the vertices of an element (given by its NDIndex).
 
KOKKOS_FUNCTION vertex_points_t getElementMeshVertexPoints (const indices_t &elementNDIndex) const
 Get all the global vertex points of an element (given by its NDIndex).
 

Static Public Attributes

static constexpr unsigned numElementDOFs = getLagrangeNumElementDOFs(Dim, Order)
 
static constexpr unsigned dim
 
static constexpr unsigned order = Order
 
static constexpr unsigned numElementVertices
 
- Static Public Attributes inherited from ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >
static constexpr unsigned dim
 
static constexpr unsigned numElementVertices
 
static constexpr unsigned numElementDOFs
 

Additional Inherited Members

- Public Attributes inherited from ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >
UniformCartesian< T, Dim > & mesh_m
 Member variables //////////////////////////////////////////////////.
 
ElementType ref_element_m
 
const QuadratureType & quadrature_m
 
Vector< size_t, Dim > nr_m
 
Vector< double, Dim > hr_m
 
Vector< double, Dim > origin_m
 

Detailed Description

template<typename T, unsigned Dim, unsigned Order, typename ElementType, typename QuadratureType, typename FieldLHS, typename FieldRHS>
class ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >

A class representing a Lagrange space for finite element methods on a structured, rectilinear grid.

Template Parameters
TThe floating point number type of the field values
DimThe dimension of the mesh
OrderThe order of the Lagrange space
QuadratureTypeThe type of the quadrature rule
FieldLHSThe type of the left hand side field
FieldRHSThe type of the right hand side field

Constructor & Destructor Documentation

◆ LagrangeSpace() [1/2]

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::LagrangeSpace ( UniformCartesian< T, Dim > &  mesh,
ElementType &  ref_element,
const QuadratureType &  quadrature,
Layout_t layout 
)

Construct a new LagrangeSpace object.

Parameters
meshReference to the mesh
ref_elementReference to the reference element
quadratureReference to the quadrature rule
layoutReference to the field layout

◆ LagrangeSpace() [2/2]

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::LagrangeSpace ( UniformCartesian< T, Dim > &  mesh,
ElementType &  ref_element,
const QuadratureType &  quadrature 
)

Construct a new LagrangeSpace object (without layout) This constructor is made to work with the default constructor in FEMPoissonSolver.h such that it is compatible with alpine.

Parameters
meshReference to the mesh
ref_elementReference to the reference element
quadratureReference to the quadrature rule

Member Function Documentation

◆ computeAvg()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
T ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::computeAvg ( const FieldLHS &  u_h) const

Given a field, compute the average.

Parameters
u_hThe numerical solution found using FEM
Returns
avg The average of the field on the domain

◆ computeErrorL2()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
template<typename F >
T ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::computeErrorL2 ( const FieldLHS &  u_h,
const F &  u_sol 
) const

Error norm computations ///////////////////////////////////////////.

Given two fields, compute the L2 norm error

Parameters
u_hThe numerical solution found using FEM
u_solThe analytical solution (functor)
Returns
error - The error ||u_h - u_sol||_L2

◆ evaluateAx()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
template<typename F >
FieldLHS ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::evaluateAx ( FieldLHS &  field,
F &  evalFunction 
)

Assembly operations ///////////////////////////////////////////////.

Assemble the left stiffness matrix A of the system Ax = b

Parameters
fieldThe field to assemble the matrix for
evalFunctionThe lambda telling us the form which A takes
Returns
FieldLHS - The LHS field containing A*x

◆ evaluateAx_lift()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
template<typename F >
FieldLHS ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::evaluateAx_lift ( FieldLHS &  field,
F &  evalFunction 
)

Assemble the left stiffness matrix A of the system but only for the boundary values, so that they can be subtracted from the RHS for treatment of Dirichlet BCs.

Parameters
fieldThe field to assemble the matrix for
evalFunctionThe lambda telling us the form which A takes
Returns
FieldLHS - The LHS field containing A*x

◆ evaluateLoadVector()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
void ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::evaluateLoadVector ( FieldRHS &  field) const

Assemble the load vector b of the system Ax = b.

Parameters
fieldThe field to set with the load vector

◆ evaluateRefElementShapeFunction()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
KOKKOS_FUNCTION T ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::evaluateRefElementShapeFunction ( const size_t &  localDOF,
const point_t localPoint 
) const

Basis functions and gradients /////////////////////////////////////.

Evaluate the shape function of a local degree of freedom at a given point in the reference element

Parameters
localDOFsize_t - The local degree of freedom index
localPointpoint_t (Vector<T, Dim>) - The point in the reference element
Returns
T - The value of the shape function at the given point

◆ evaluateRefElementShapeFunctionGradient()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
KOKKOS_FUNCTION LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::point_t ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::evaluateRefElementShapeFunctionGradient ( const size_t &  localDOF,
const point_t localPoint 
) const

Evaluate the gradient of the shape function of a local degree of freedom at a given point in the reference element.

Parameters
localDOFsize_t - The local degree of freedom index
localPointpoint_t (Vector<T, Dim>) - The point in the reference element
Returns
point_t (Vector<T, Dim>) - The gradient of the shape function at the given point

◆ getGlobalDOFIndex()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
KOKKOS_FUNCTION size_t ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::getGlobalDOFIndex ( const size_t &  elementIndex,
const size_t &  localDOFIndex 
) const
overridevirtual

Get the global DOF index from the element index and local DOF.

Parameters
elementIndexsize_t - The index of the element
localDOFIndexsize_t - The local DOF index
Returns
size_t - The global DOF index

Implements ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >.

◆ getGlobalDOFIndices()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
KOKKOS_FUNCTION Vector< size_t, LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::numElementDOFs > ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::getGlobalDOFIndices ( const size_t &  element_index) const
overridevirtual

Get the global DOF indices (vector of global DOF indices) of an element.

Parameters
element_indexsize_t - The index of the element
Returns
Vector<size_t, NumElementDOFs> - The global DOF indices

Implements ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >.

◆ getLocalDOFIndex()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
KOKKOS_FUNCTION size_t ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::getLocalDOFIndex ( const size_t &  elementIndex,
const size_t &  globalDOFIndex 
) const
overridevirtual

Get the elements local DOF from the element index and global DOF index.

Parameters
elementIndexsize_t - The index of the element
globalDOFIndexsize_t - The global DOF index
Returns
size_t - The local DOF index

Implements ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >.

◆ getLocalDOFIndices()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
KOKKOS_FUNCTION Vector< size_t, LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::numElementDOFs > ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::getLocalDOFIndices ( ) const
overridevirtual

Get the local DOF indices (vector of local DOF indices) They are independent of the specific element because it only depends on the reference element type.

Returns
Vector<size_t, NumElementDOFs> - The local DOF indices

Implements ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >.

◆ initialize()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
void ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::initialize ( UniformCartesian< T, Dim > &  mesh,
Layout_t layout 
)

Initialize a LagrangeSpace object created with the default constructor.

Parameters
meshReference to the mesh
layoutReference to the field layout

◆ numGlobalDOFs()

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
KOKKOS_FUNCTION size_t ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::numGlobalDOFs ( ) const
overridevirtual

Degree of Freedom operations //////////////////////////////////////.

Get the number of global degrees of freedom in the space

Returns
size_t - unsigned integer number of global degrees of freedom

Implements ippl::FiniteElementSpace< T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType, QuadratureType, FieldLHS, FieldRHS >.

Member Data Documentation

◆ dim

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
constexpr unsigned ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::dim
staticconstexpr
Initial value:
= FiniteElementSpace<T, Dim, numElementDOFs, ElementType,
QuadratureType, FieldLHS, FieldRHS>::dim
FiniteElementSpace(UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature)
Construct a new FiniteElementSpace object.
Definition FiniteElementSpace.hpp:6

◆ numElementVertices

template<typename T , unsigned Dim, unsigned Order, typename ElementType , typename QuadratureType , typename FieldLHS , typename FieldRHS >
constexpr unsigned ippl::LagrangeSpace< T, Dim, Order, ElementType, QuadratureType, FieldLHS, FieldRHS >::numElementVertices
staticconstexpr
Initial value:
=
FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType, FieldLHS,
FieldRHS>::numElementVertices

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