Chi-Tech
devman_A3_UnknownMan.h
Go to the documentation of this file.
1
/**\page DevManUKMan The chi_math::UnknownManager
2
## Table of contents
3
- \ref devmanA3_sec0
4
- \ref devmanA3_sec1
5
- \ref devmanA3_sec2
6
- \ref devmanA3_sec3
7
- \ref devmanA3_sec4
8
9
10
\section devmanA3_sec0 Introduction
11
As a developer you might come across code such as
12
\code
13
imap[i] = sdm.MapDOF(cell, i);
14
\endcode
15
or its more elaborate cousin
16
\code
17
const int64_t imap = m_sdm.MapDOF(cell,i,m_uk_man,0,g);
18
\endcode
19
20
The two function calls, `MapDOF` with 2 arguments and `MapDOF` with 5 arguments,
21
are both methods of the base-class `chi_math::SpatialDiscretization`.
22
23
The two overloaded methods, `chi_math::SpatialDiscretization::MapDOF` return the
24
global index of a degree-of-freedom (DOF). The counterparts to `MapDOF` are the
25
`MapDOFLocal` methods that provide the local index of a DOF.
26
27
These functions are called with either 2 arguments
28
- A cell reference
29
- A cell-node local-index
30
31
or with 5 arguments
32
- A cell reference
33
- A cell-node local-index
34
- An unknown-manager (`chi_math::UnknownManager`)
35
- An unknown id
36
- A component id
37
38
\section devmanA3_sec1 1 Cells vs Vertices vs Nodes vs Degree-of-Freedom (DOF)
39
These comparisons are conceptually simple. The geometry of a cell is described
40
by its vertices (see Figure 1 below). The mesh cannot be completely defined
41
without the vertices, therefore, cells always go hand-in-hand with vertices.
42
43
A spatial discretization (e.g., Finite Volume, PWL, Lagrange Q1, Lagrange Q2)
44
places nodes on the mesh that may or may not coincide with some of the vertices.
45
For example, the Finite Volume spatial discretization places a single node for
46
each cell, at the cell's centroid (hence no coincidence with any vertex), whilst
47
a Lagrange Q2 spatial discretization has some of its nodes on the vertices while
48
other are not (see Figure 1 below).
49
50
\image html UkManVertsNodes.png "Figure 1: Cells, vertices and nodes." width=600px
51
52
Where degrees-of-freedom differ from nodes is that each node can be stacked with
53
a number of unknowns, e.g., one might have to solve a number of physical
54
variables in a multiphysics simulation involving 2D velocity, \f$ u_x \f$ and
55
\f$ u_y \f$, a three energy group flux, \f$ \phi_0, \ \phi_1, \ \phi_2 \f$, and
56
pressure, \f$ p \f$. One can stack these variables in any form, for example:
57
- Unknown 0, a 6 component vector containing
58
\f$ u_x, \ u_y, \ \phi_0, \ \phi_1, \ \phi_2 \f$, and \f$ p \f$
59
60
or more elegantly
61
- Unknown 0, a 2 component vector containing \f$ u_x \f$ and \f$ u_y \f$
62
- Unknown 1, a 3 component vector containing \f$ \phi_0, \ \phi_1, \ \phi_2 \f$
63
- Unknown 2, a single scalar (1 component) containing just \f$ p \f$
64
65
The latter essentially means that each node can have a number of unknowns stacked
66
onto it as shown in Figure 2 below.
67
68
\image html UkManNodeDOFs.png "Figure 2: Unknowns/DOFs stacked onto a node" width=300px
69
70
The individual components of the unknowns are unique for every node and are
71
called the degrees-of-freedom (DOFs).
72
73
\section devmanA3_sec2 2 One DOF per node
74
All the spatial discretizations have a default unknown-manager, defined during
75
initialization, called `UNITARY_UNKNOWN_MANAGER`. This allows the spatial
76
discretization to map indices as shown in Figure 3 below
77
78
\image html UkMan-OneDOFPN.png "Figure 3: Mapping One DOF per Node" width=800px
79
80
\section devmanA3_sec3 3 Multiple DOFs Nodal ordering
81
With multiple unknowns like the 2D velocity, multigroup flux, and pressure
82
example above we can create an unknown manager with this structure as follows
83
\code
84
chi_math::UnknownManager uk_man;
85
uk_man.AddUnknown(chi_math::UnknownType::VECTOR_2); //u_x, u_y
86
uk_man.AddUnknown(chi_math::UnknownType::VECTOR_N, 3); //phi_0 to phi_2
87
uk_man.AddUnknown(chi_math::UnknownType::SCALAR); //pressure
88
\endcode
89
90
Using this unknown manager to map DOFs is then done as shown below in Figure 4.
91
92
\image html UkMan-NODAL.png "Figure 4: Mapping with a nodal ordering" width=800px
93
94
Notice here that the ordering is per-node, i.e., for each node the DOFs all the
95
DOFs are stacked into a vector before moving to a new node. This is the default
96
ordering in ChiTech.
97
98
\section devmanA3_sec4 4 Multiple DOFs Block ordering
99
To create a Block-ordered vector mapping the only modification needed is in the
100
constructor of the unknown manager:
101
\code
102
chi_math::UnknownManager uk_man(chi_math::UnknownStorageType::BLOCK);
103
uk_man.AddUnknown(chi_math::UnknownType::VECTOR_2); //u_x, u_y
104
uk_man.AddUnknown(chi_math::UnknownType::VECTOR_N, 3); //phi_0 to phi_2
105
uk_man.AddUnknown(chi_math::UnknownType::SCALAR); //pressure
106
\endcode
107
108
Now that we specified that we should use `chi_math::UnknownStorageType::BLOCK`
109
the unknown manager maps as shown in Figure 5 below
110
111
\image html UkMan-Block.png "Figure 5: Mapping with a block ordering" width=800px
112
113
Block ordering is likely desireable if one wishes to apply block-solves.
114
*/
doc
PAGES
ProgrammersManual
ReferenceContent
devman_A3_UnknownMan.h
Generated by
1.9.3