IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
NedelecSpace.h
Go to the documentation of this file.
1// Class NedelecSpace
2// This is the NedelecSpace class. It is a class representing a Nedelec space
3// for finite element methods on a structured grid.
4
5#ifndef IPPL_NEDELECSPACE_H
6#define IPPL_NEDELECSPACE_H
7
8#include <cmath>
9
11#include "FEM/FEMVector.h"
12
13constexpr unsigned getNedelecNumElementDOFs(unsigned Dim, [[maybe_unused]] unsigned Order) {
14 // needs to be constexpr pow function to work at compile time. Kokkos::pow
15 // doesn't work.
16 return static_cast<unsigned>(static_cast<int>(Dim)*power(2, static_cast<int>(Dim-1)));
17}
18
19namespace ippl {
20
31 template <typename T, unsigned Dim, unsigned Order, typename ElementType,
32 typename QuadratureType, typename FieldType>
33 // requires IsQuadrature<QuadratureType>
34 class NedelecSpace : public FiniteElementSpace<T, Dim, getNedelecNumElementDOFs(Dim, Order),
35 ElementType, QuadratureType, FEMVector<T>, FEMVector<T>> {
36 public:
37 // The number of degrees of freedom per element
38 static constexpr unsigned numElementDOFs = getNedelecNumElementDOFs(Dim, Order);
39
40 // The dimension of the mesh
41 static constexpr unsigned dim = FiniteElementSpace<T, Dim, numElementDOFs, ElementType,
42 QuadratureType, FEMVector<T>, FEMVector<T>>::dim;
43
44 // The order of the Nedelec space
45 static constexpr unsigned order = Order;
46
47 // The number of mesh vertices per element
49 ElementType, QuadratureType, FEMVector<T>, FEMVector<T>>::numElementVertices;
50
51 // A vector with the position of the element in the mesh in each dimension
52 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
54
55 // A point in the global coordinate system
56 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
58
59 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
61
62 // Field layout type for domain decomposition info
64
65 // View types
67 typedef typename detail::ViewType<T, 1,
68 Kokkos::MemoryTraits<Kokkos::Atomic>>::view_type AtomicViewType;
69
70
71
73 // Constructors ///////////////////////////////////////////////////////
75
84 NedelecSpace(UniformCartesian<T, Dim>& mesh, ElementType& ref_element,
85 const QuadratureType& quadrature, const Layout_t& layout);
86
96 NedelecSpace(UniformCartesian<T, Dim>& mesh, ElementType& ref_element,
97 const QuadratureType& quadrature);
98
106 void initialize(UniformCartesian<T, Dim>& mesh, const Layout_t& layout);
107
109
113
116
122 KOKKOS_FUNCTION size_t numGlobalDOFs() const override;
123
133 KOKKOS_FUNCTION size_t getLocalDOFIndex(const size_t& elementIndex,
134 const size_t& globalDOFIndex) const override;
135
144 KOKKOS_FUNCTION size_t getGlobalDOFIndex(const size_t& elementIndex,
145 const size_t& localDOFIndex) const override;
146
154 KOKKOS_FUNCTION Vector<size_t, numElementDOFs> getLocalDOFIndices() const override;
155
165 const size_t& elementIndex) const override;
166
176 const indices_t& elementIndex) const;
177
187 const size_t& elementIndex, NDIndex<Dim> ldom) const;
188
198 indices_t elementIndex, NDIndex<Dim> ldom) const;
199
200
209 KOKKOS_FUNCTION point_t getLocalDOFPosition(size_t localDOFIndex) const;
210
214
215
226 KOKKOS_FUNCTION point_t evaluateRefElementShapeFunction(const size_t& localDOF,
227 const point_t& localPoint) const;
228
229
241 KOKKOS_FUNCTION point_t evaluateRefElementShapeFunctionCurl(const size_t& localDOF,
242 const point_t& localPoint) const;
243
247
255 template <typename F>
256 FEMVector<T> evaluateAx(FEMVector<T>& x, F& evalFunction) const;
257
269
270
283 template <typename F>
285
286
287
291
303
304
331 Kokkos::View<point_t*> reconstructToPoints(const Kokkos::View<point_t*>& positions,
332 const FEMVector<T>& coef) const;
333
337
338
348 template <typename F> T computeError(const FEMVector<T>& u_h, const F& u_sol) const;
349
350
364 KOKKOS_FUNCTION bool isDOFOnBoundary(const size_t& dofIdx) const;
365
386 KOKKOS_FUNCTION int getBoundarySide(const size_t& dofIdx) const;
387
388
389
390 private:
396
402
407 Kokkos::View<size_t*> elementIndices;
408
417
426
427 };
428
429} // namespace ippl
430
431#include "FEM/NedelecSpace.hpp"
432
433#endif
typename ippl::detail::ViewType< ippl::Vector< double, Dim >, 1 >::view_type view_type
constexpr unsigned Dim
constexpr T power(T base, unsigned exponent)
Definition Quadrature.h:17
constexpr unsigned getNedelecNumElementDOFs(unsigned Dim, unsigned Order)
Definition Archive.h:20
1D vector used in the context of FEM.
Definition FEMVector.h:32
FiniteElementSpace(UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature)
FEMVector< T > evaluateLoadVectorFunctor(const F &f) const
Assemble the load vector b of the system Ax = b, given a functional of the rhs. If a field instead of...
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.
detail::ViewType< T, 1 >::view_type ViewType
KOKKOS_FUNCTION Vector< size_t, numElementDOFs > getFEMVectorDOFIndices(const size_t &elementIndex, NDIndex< Dim > ldom) const
Get the DOF indices (vector of indices) corresponding to the position inside the FEMVector of an elem...
FEMVector< T > evaluateAx(FEMVector< T > &x, F &evalFunction) const
Assembly operations ///////////////////////////////////////////////.
FiniteElementSpace< T, Dim, numElementDOFs, ElementType, QuadratureType, FEMVector< T >, FEMVector< T > >::vertex_points_t vertex_points_t
T computeError(const FEMVector< T > &u_h, const F &u_sol) const
Error norm computations ///////////////////////////////////////////.
void initialize(UniformCartesian< T, Dim > &mesh, const Layout_t &layout)
Initialize a NedelecSpace object created with the default constructor.
NedelecSpace(UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature)
Construct a new NedelecSpace object (without layout) This constructor is made to work with the defaul...
void initializeElementIndices(const Layout_t &layout)
Initialize a Kokkos view containing the element indices.
FieldLayout< Dim > Layout_t
KOKKOS_FUNCTION int getBoundarySide(const size_t &dofIdx) const
Returns which side the boundary is on.
FiniteElementSpace< T, Dim, numElementDOFs, ElementType, QuadratureType, FEMVector< T >, FEMVector< T > >::point_t point_t
KOKKOS_FUNCTION point_t getLocalDOFPosition(size_t localDOFIndex) const
Get the cartesion position of a local DOF in the reference element.
KOKKOS_FUNCTION point_t evaluateRefElementShapeFunctionCurl(const size_t &localDOF, const point_t &localPoint) const
Evaluate the curl of the shape function of a local degree of of freedom at ta given point in the refe...
FEMVector< T > createFEMVector3d() const
Implementation of the NedelecSpace::createFEMVector function for 3d.
KOKKOS_FUNCTION size_t numGlobalDOFs() const override
Degree of Freedom operations //////////////////////////////////////.
FEMVector< T > createFEMVector() const
FEMVector conversion and creation//////////////////////////////////.
FiniteElementSpace< T, Dim, numElementDOFs, ElementType, QuadratureType, FEMVector< T >, FEMVector< T > >::indices_t indices_t
KOKKOS_FUNCTION Vector< size_t, numElementDOFs > getGlobalDOFIndices(const indices_t &elementIndex) const
Get the global DOF indices (vector of global DOF indices) of an element.
KOKKOS_FUNCTION bool isDOFOnBoundary(const size_t &dofIdx) const
Check if a DOF is on the boundary of the mesh.
FEMVector< T > evaluateLoadVector(const FEMVector< point_t > &f) const
Assemble the load vector b of the system Ax = b, given a field of the right hand side defined at the ...
KOKKOS_FUNCTION point_t evaluateRefElementShapeFunction(const size_t &localDOF, const point_t &localPoint) const
Basis functions and gradients /////////////////////////////////////.
KOKKOS_FUNCTION Vector< size_t, numElementDOFs > getGlobalDOFIndices(const size_t &elementIndex) const override
Get the global DOF indices (vector of global DOF indices) of an element.
NedelecSpace(UniformCartesian< T, Dim > &mesh, ElementType &ref_element, const QuadratureType &quadrature, const Layout_t &layout)
Construct a new NedelecSpace object.
detail::ViewType< T, 1, Kokkos::MemoryTraits< Kokkos::Atomic > >::view_type AtomicViewType
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 Vector< size_t, numElementDOFs > getFEMVectorDOFIndices(indices_t elementIndex, NDIndex< Dim > ldom) const
Get the DOF indices (vector of indices) corresponding to the position inside the FEMVector of an elem...
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 ...
Kokkos::View< point_t * > reconstructToPoints(const Kokkos::View< point_t * > &positions, const FEMVector< T > &coef) const
Reconstructs function values at arbitrary points in the mesh given the Nedelec DOF coefficients.
FEMVector< T > createFEMVector2d() const
Implementation of the NedelecSpace::createFEMVector function for 2d.
Kokkos::View< typename NPtr< T, Dim >::type, Properties... > view_type
Definition ViewTypes.h:45