IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
NedelecSpace.h
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
10#include "FEM/FEMQuadratureData.h"
11#include "FEM/FEMVector.h"
12#include "FEM/FiniteElementSpace.h"
13
14constexpr unsigned getNedelecNumElementDOFs(unsigned Dim, [[maybe_unused]] unsigned Order) {
15 // needs to be constexpr pow function to work at compile time. Kokkos::pow
16 // doesn't work.
17 return static_cast<unsigned>(static_cast<int>(Dim) * power(2, static_cast<int>(Dim - 1)));
18}
19
20namespace ippl {
21
32 template <typename T, unsigned Dim, unsigned Order, typename ElementType,
33 typename QuadratureType, typename FieldType>
34 // requires IsQuadrature<QuadratureType>
36 : public FiniteElementSpace<T, Dim, getNedelecNumElementDOFs(Dim, Order), ElementType,
37 QuadratureType, FEMVector<T>, FEMVector<T>> {
38 public:
39 // The number of degrees of freedom per element
40 static constexpr unsigned numElementDOFs = getNedelecNumElementDOFs(Dim, Order);
41
42 // The dimension of the mesh
43 static constexpr unsigned dim =
45 FEMVector<T>>::dim;
46
47 // The order of the Nedelec space
48 static constexpr unsigned order = Order;
49
50 // The number of mesh vertices per element
51 static constexpr unsigned numElementVertices =
53 FEMVector<T>>::numElementVertices;
54
55 // A vector with the position of the element in the mesh in each dimension
56 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
58
59 // A point in the global coordinate system
60 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
62
63 typedef typename FiniteElementSpace<T, Dim, numElementDOFs, ElementType, QuadratureType,
64 FEMVector<T>, FEMVector<T>>::vertex_points_t
66
67 // Field layout type for domain decomposition info
69
70 // View types
71 typedef typename detail::ViewType<T, 1>::view_type ViewType;
73 AtomicViewType;
74
76 // Constructors ///////////////////////////////////////////////////////
78
87 NedelecSpace(UniformCartesian<T, Dim>& mesh, ElementType& ref_element,
88 const QuadratureType& quadrature, const Layout_t& layout);
89
99 NedelecSpace(UniformCartesian<T, Dim>& mesh, ElementType& ref_element,
100 const QuadratureType& quadrature);
101
109 void initialize(UniformCartesian<T, Dim>& mesh, const Layout_t& layout);
110
112
115 void initializeElementIndices(const Layout_t& layout);
116
124 NDIndex<Dim> getLocalNDIndex() const { return layout_m.getLocalNDIndex(); }
125
128
134 KOKKOS_FUNCTION size_t numGlobalDOFs() const override;
135
145 KOKKOS_FUNCTION size_t getLocalDOFIndex(const size_t& elementIndex,
146 const size_t& globalDOFIndex) const override;
147
156 KOKKOS_FUNCTION size_t getGlobalDOFIndex(const size_t& elementIndex,
157 const size_t& localDOFIndex) const override;
158
166 KOKKOS_FUNCTION Vector<size_t, numElementDOFs> getLocalDOFIndices() const override;
167
177 const size_t& elementIndex) const override;
178
188 const indices_t& elementIndex) const;
189
200 const size_t& elementIndex, NDIndex<Dim> ldom) const;
201
212 indices_t elementIndex, NDIndex<Dim> ldom) const;
213
222 KOKKOS_FUNCTION point_t getLocalDOFPosition(size_t localDOFIndex) const;
223
227
238 KOKKOS_FUNCTION point_t evaluateRefElementShapeFunction(const size_t& localDOF,
239 const point_t& localPoint) const;
240
253 const size_t& localDOF, const point_t& localPoint) const;
254
258
267 template <typename F>
268 FEMVector<T> evaluateAx(FEMVector<T>& x, F& evalFunction) const;
269
281
294 template <typename F>
295 FEMVector<T> evaluateLoadVectorFunctor(const F& f) const;
296
300
312
339 Kokkos::View<point_t*> reconstructToPoints(const Kokkos::View<point_t*>& positions,
340 const FEMVector<T>& coef) const;
341
345
355 template <typename F>
356 T computeError(const FEMVector<T>& u_h, const F& u_sol) const;
357
371 KOKKOS_FUNCTION bool isDOFOnBoundary(const size_t& dofIdx) const;
372
393 KOKKOS_FUNCTION int getBoundarySide(const size_t& dofIdx) const;
394
395 private:
400 FEMVector<T> createFEMVector2d() const;
401
406 FEMVector<T> createFEMVector3d() const;
407
412 Kokkos::View<size_t*> elementIndices;
413
421 Vector<point_t, 12> localDofPositions_m;
422
430 Layout_t layout_m;
431 };
432
433} // namespace ippl
434
435#include "FEM/NedelecSpace.hpp"
436
437#endif
1D vector used in the context of FEM.
Definition FEMVector.h:34
Definition FieldLayout.h:166
The FiniteElementSpace class handles the mesh index mapping to vertices and elements and is the base ...
Definition FiniteElementSpace.h:41
Definition NDIndex.h:21
A class representing a Nedelec space for finite element methods on a structured, rectilinear grid.
Definition NedelecSpace.h:37
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...
Definition NedelecSpace.hpp:610
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 NedelecSpace.hpp:188
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...
Definition NedelecSpace.hpp:343
NDIndex< Dim > getLocalNDIndex() const
Return the local NDIndex of this rank's subdomain.
Definition NedelecSpace.h:124
FEMVector< T > evaluateAx(FEMVector< T > &x, F &evalFunction) const
Assembly operations ///////////////////////////////////////////////.
Definition NedelecSpace.hpp:372
T computeError(const FEMVector< T > &u_h, const F &u_sol) const
Error norm computations ///////////////////////////////////////////.
Definition NedelecSpace.hpp:912
void initialize(UniformCartesian< T, Dim > &mesh, const Layout_t &layout)
Initialize a NedelecSpace object created with the default constructor.
Definition NedelecSpace.hpp:43
void initializeElementIndices(const Layout_t &layout)
Initialize a Kokkos view containing the element indices.
Definition NedelecSpace.hpp:73
KOKKOS_FUNCTION int getBoundarySide(const size_t &dofIdx) const
Returns which side the boundary is on.
Definition NedelecSpace.hpp:1091
KOKKOS_FUNCTION point_t getLocalDOFPosition(size_t localDOFIndex) const
Get the cartesion position of a local DOF in the reference element.
Definition NedelecSpace.hpp:355
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...
Definition NedelecSpace.hpp:761
KOKKOS_FUNCTION size_t numGlobalDOFs() const override
Degree of Freedom operations //////////////////////////////////////.
Definition NedelecSpace.hpp:138
FEMVector< T > createFEMVector() const
FEMVector conversion and creation//////////////////////////////////.
Definition NedelecSpace.hpp:815
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.
Definition NedelecSpace.hpp:1003
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 ...
Definition NedelecSpace.hpp:494
KOKKOS_FUNCTION point_t evaluateRefElementShapeFunction(const size_t &localDOF, const point_t &localPoint) const
Basis functions and gradients /////////////////////////////////////.
Definition NedelecSpace.hpp:706
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.
Definition NedelecSpace.hpp:267
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 NedelecSpace.hpp:157
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 ...
Definition NedelecSpace.hpp:201
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.
Definition NedelecSpace.hpp:830
Definition UniformCartesian.h:14
Definition Archive.h:20
Definition ViewTypes.h:44