5#ifndef IPPL_LAGRANGESPACE_H
6#define IPPL_LAGRANGESPACE_H
10#include "FEM/FEMQuadratureData.h"
11#include "FEM/FiniteElementSpace.h"
13constexpr unsigned getLagrangeNumElementDOFs(
unsigned Dim,
unsigned Order) {
15 return static_cast<unsigned>(power(
static_cast<int>(Order + 1),
static_cast<int>(Dim)));
31 template <
typename T,
unsigned Dim,
unsigned Order,
typename ElementType,
32 typename QuadratureType,
typename FieldLHS,
typename FieldRHS>
35 :
public FiniteElementSpace<T, Dim, getLagrangeNumElementDOFs(Dim, Order), ElementType,
36 QuadratureType, FieldLHS, FieldRHS> {
39 static constexpr unsigned numElementDOFs = getLagrangeNumElementDOFs(Dim, Order);
42 static constexpr unsigned dim =
FiniteElementSpace<T, Dim, numElementDOFs, ElementType,
43 QuadratureType, FieldLHS, FieldRHS>::dim;
46 static constexpr unsigned order = Order;
49 static constexpr unsigned numElementVertices =
51 FieldRHS>::numElementVertices;
54 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
58 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
59 FieldLHS, FieldRHS>::point_t
point_t;
61 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
68 typedef typename detail::ViewType<T, Dim>::view_type ViewType;
85 const QuadratureType& quadrature,
Layout_t& layout);
97 const QuadratureType& quadrature);
142 const size_t& globalDOFIndex)
const override;
153 const size_t& localDOFIndex)
const override;
172 const size_t& element_index)
const override;
188 const point_t& localPoint)
const;
201 const size_t& localDOF,
const point_t& localPoint)
const;
209 return this->ref_element_m.getInverseTransposeTransformationJacobian(pt);
224 template <
typename F>
225 FieldLHS
evaluateAx(FieldLHS& field, F& evalFunction);
227 template <
typename F>
228 FieldLHS evaluateAx_lower(FieldLHS& field, F& evalFunction);
230 template <
typename F>
231 FieldLHS evaluateAx_upper(FieldLHS& field, F& evalFunction);
233 template <
typename F>
234 FieldLHS evaluateAx_upperlower(FieldLHS& field, F& evalFunction);
236 template <
typename F>
237 FieldLHS evaluateAx_inversediag(FieldLHS& field, F& evalFunction);
239 template <
typename F>
240 FieldLHS evaluateAx_diag(FieldLHS& field, F& evalFunction);
252 template <
typename F>
275 template <
typename F>
293 static constexpr unsigned numElementDOFs = LagrangeSpace::numElementDOFs;
295 ElementType ref_element_m;
298 KOKKOS_FUNCTION
indices_t getMeshVertexNDIndex(
const size_t& vertex_index)
const;
300 KOKKOS_FUNCTION
size_t getLocalDOFIndex(
const indices_t& elementNDIndex,
301 const size_t& globalDOFIndex)
const;
305 KOKKOS_FUNCTION T evaluateRefElementShapeFunction(
const size_t& localDOF,
306 const point_t& localPoint)
const;
307 KOKKOS_FUNCTION
point_t evaluateRefElementShapeFunctionGradient(
308 const size_t& localDOF,
const point_t& localPoint)
const;
322 KOKKOS_FUNCTION
bool isDOFOnBoundary(
const indices_t& ndindex)
const {
323 for (
size_t d = 0; d < Dim; ++d) {
324 if (ndindex[d] <= 0 || ndindex[d] >= this->nr_m[d] - 1) {
335 Kokkos::View<size_t*> elementIndices;
338 FieldLHS resultField;
343#include "FEM/LagrangeSpace.hpp"
Definition FieldLayout.h:166
The FiniteElementSpace class handles the mesh index mapping to vertices and elements and is the base ...
Definition FiniteElementSpace.h:41
A class representing a Lagrange space for finite element methods on a structured, rectilinear grid.
Definition LagrangeSpace.h:36
void initializeElementIndices(Layout_t &layout)
Initialize a Kokkos view containing the element indices. This distributes the elements among MPI rank...
Definition LagrangeSpace.hpp:58
T computeAvg(const FieldLHS &u_h) const
Given a field, compute the average.
Definition LagrangeSpace.hpp:1609
void initialize(UniformCartesian< T, Dim > &mesh, Layout_t &layout)
Initialize a LagrangeSpace object created with the default constructor.
Definition LagrangeSpace.hpp:41
KOKKOS_FUNCTION size_t numGlobalDOFs() const override
Degree of Freedom operations //////////////////////////////////////.
Definition LagrangeSpace.hpp:132
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.
Definition LagrangeSpace.hpp:200
void evaluateLoadVector(FieldRHS &field) const
Assemble the load vector b of the system Ax = b.
Definition LagrangeSpace.hpp:1330
DeviceStruct getDeviceMirror() const
Device struct definitions /////////////////////////////////////////.
Definition LagrangeSpace.hpp:1697
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.
Definition LagrangeSpace.hpp:145
FieldLHS evaluateAx(FieldLHS &field, F &evalFunction)
Assembly operations ///////////////////////////////////////////////.
Definition LagrangeSpace.hpp:372
KOKKOS_FUNCTION T evaluateRefElementShapeFunction(const size_t &localDOF, const point_t &localPoint) const
Basis functions and gradients /////////////////////////////////////.
Definition LagrangeSpace.hpp:279
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 ...
Definition LagrangeSpace.hpp:185
KOKKOS_FUNCTION point_t getInverseTransposeTransformationJacobian(vertex_points_t pt) const
Functions to access element info from outside /////////////////////.
Definition LagrangeSpace.h:208
T computeErrorL2(const FieldLHS &u_h, const F &u_sol) const
Error norm computations ///////////////////////////////////////////.
Definition LagrangeSpace.hpp:1525
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 refe...
Definition LagrangeSpace.hpp:314
FieldLHS evaluateAx_lift(FieldLHS &field, F &evalFunction)
Assemble the left stiffness matrix A of the system but only for the boundary values,...
Definition LagrangeSpace.hpp:1212
void evaluateLumpedMass(FieldRHS &field) const
Functions for error computations, etc. ////////////////////////////.
Definition LagrangeSpace.hpp:1452
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.
Definition LagrangeSpace.hpp:173
void updateLayout(Layout_t &layout)
Function to update the element partition and the layout of fields in the LagrangeSpace if the layout ...
Definition LagrangeSpace.hpp:118
Device struct for copies //////////////////////////////////////////.
Definition LagrangeSpace.h:290
Definition ViewTypes.h:44