MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
ordering.hpp
Go to the documentation of this file.
1#ifndef MFEM_ORDERING
2#define MFEM_ORDERING
3
5#include "vector.hpp"
6
7namespace mfem
8{
9
10/** @brief The ordering method used when the number of unknowns per mesh node
11 (vector dimension) is bigger than 1. */
13{
14public:
15 /// %Ordering methods:
16 enum Type
17 {
18 byNODES, /**< loop first over the nodes (inner loop) then over the vector
19 dimension (outer loop); symbolically it can be represented
20 as: XXX...,YYY...,ZZZ... */
21 byVDIM /**< loop first over the vector dimension (inner loop) then over
22 the nodes (outer loop); symbolically it can be represented
23 as: XYZ,XYZ,XYZ,... */
24 };
25
26 template <Type Ord>
27 static inline int Map(int ndofs, int vdim, int dof, int vd);
28
29 template <Type Ord>
30 static void DofsToVDofs(int ndofs, int vdim, Array<int> &dofs);
31
32 /// Reorder Vector \p v from its current ordering \p in_ord to \p out_ord
33 static void Reorder(Vector &v, int vdim, Type in_ord, Type out_ord);
34
35};
36
37template <> inline int
38Ordering::Map<Ordering::byNODES>(int ndofs, int vdim, int dof, int vd)
39{
40 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim, "");
41 return (dof >= 0) ? dof+ndofs*vd : dof-ndofs*vd;
42}
43
44template <> inline int
45Ordering::Map<Ordering::byVDIM>(int ndofs, int vdim, int dof, int vd)
46{
47 MFEM_ASSERT(dof < ndofs && -1-dof < ndofs && 0 <= vd && vd < vdim, "");
48 return (dof >= 0) ? vd+vdim*dof : -1-(vd+vdim*(-1-dof));
49}
50
51} // namespace mfem
52
53#endif // MFEM_ORDERING
The ordering method used when the number of unknowns per mesh node (vector dimension) is bigger than ...
Definition ordering.hpp:13
static int Map(int ndofs, int vdim, int dof, int vd)
static void DofsToVDofs(int ndofs, int vdim, Array< int > &dofs)
Type
Ordering methods:
Definition ordering.hpp:17
static void Reorder(Vector &v, int vdim, Type in_ord, Type out_ord)
Reorder Vector v from its current ordering in_ord to out_ord.
Definition ordering.cpp:38
Vector data type.
Definition vector.hpp:82