Discontinuous Galerkin Library
#include "dg/algorithm.h"
enums.h
Go to the documentation of this file.
1#pragma once
2#include <string>
4
9namespace dg
10{
13
15enum bc{
16 PER = 0,
17 DIR = 1,
18 DIR_NEU = 2,
19 NEU_DIR = 3,
20 NEU = 4
21};
22
23
37static inline std::string bc2str( bc bcx)
38{
39 std::string s;
40 switch(bcx)
41 {
42 case(dg::PER): s = "PERIODIC"; break;
43 case(dg::DIR): s = "DIRICHLET"; break;
44 case(dg::NEU): s = "NEUMANN"; break;
45 case(dg::DIR_NEU): s = "DIR_NEU"; break;
46 case(dg::NEU_DIR): s = "NEU_DIR"; break;
47 default: s = "Not specified!!";
48 }
49 return s;
50}
51
66static inline bc str2bc( std::string s)
67{
68 if( s=="PER"||s=="per"||s=="periodic"||s=="Periodic" || s == "PERIODIC")
69 return PER;
70 if( s=="DIR"||s=="dir"||s=="dirichlet"||s=="Dirichlet" || s == "DIRICHLET")
71 return DIR;
72 if( s=="NEU"||s=="neu"||s=="neumann"||s=="Neumann" || s=="NEUMANN")
73 return NEU;
74 if( s=="NEU_DIR"||s=="neu_dir" )
75 return NEU_DIR;
76 if( s=="DIR_NEU"||s=="dir_neu" )
77 return DIR_NEU;
78 throw std::runtime_error( "Boundary condition '"+s+"' not recognized!");
79}
80
87static inline bc inverse( bc bound)
88{
89 if( bound == DIR) return NEU;
90 if( bound == NEU) return DIR;
91 if( bound == DIR_NEU) return NEU_DIR;
92 if( bound == NEU_DIR) return DIR_NEU;
93 return PER;
94}
95
100 centered
102
103
116static inline direction str2direction( std::string s)
117{
118 if( "forward" == s)
119 return forward;
120 if( "backward" == s)
121 return backward;
122 if( "centered" == s)
123 return centered;
124 throw std::runtime_error( "Direction '"+s+"' not recognized!");
125}
137static inline std::string direction2str( enum direction dir)
138{
139 std::string s;
140 switch(dir)
141 {
142 case(dg::forward): s = "forward"; break;
143 case(dg::backward): s = "backward"; break;
144 case(dg::centered): s = "centered"; break;
145 default: s = "Not specified!!";
146 }
147 return s;
148}
149
156static inline direction inverse( direction dir)
157{
158 if( dir == forward) return backward;
159 if( dir == backward) return forward;
160 return centered;
161}
162
164enum space{
166 xspace
168
170enum class coo2d : char
171{
172 x = 'x',
173 y = 'y',
174};
176enum class coo3d : char
177{
178 x = 'x',
179 y = 'y',
180 z = 'z',
181 xy = 'a',
182 yz = 'b',
183 xz = 'c',
184};
185
187}//namespace dg
Error classes or the dg library.
static bc inverse(bc bound)
invert boundary condition
Definition: enums.h:87
coo3d
3d contra- and covariant coordinates
Definition: enums.h:177
bc
Switch between boundary conditions.
Definition: enums.h:15
space
Space of DG coefficients.
Definition: enums.h:164
static bc str2bc(std::string s)
convert a string to a bc
Definition: enums.h:66
static std::string bc2str(bc bcx)
write a string describing boundary condition to an output stream
Definition: enums.h:37
static direction str2direction(std::string s)
convert a string to a direction
Definition: enums.h:116
direction
Direction of a discrete derivative.
Definition: enums.h:97
coo2d
2d coordinates
Definition: enums.h:171
static std::string direction2str(enum direction dir)
convert a direciton to string
Definition: enums.h:137
@ yz
yz plane
@ xy
xy plane
@ xz
xz plane
@ z
z direction
@ NEU_DIR
Neumann on left, Dirichlet on right boundary.
Definition: enums.h:19
@ PER
periodic boundaries
Definition: enums.h:16
@ NEU
Neumann on both boundaries.
Definition: enums.h:20
@ DIR
homogeneous dirichlet boundaries
Definition: enums.h:17
@ DIR_NEU
Dirichlet on left, Neumann on right boundary.
Definition: enums.h:18
@ xspace
Configuration space "nodal values".
Definition: enums.h:166
@ lspace
DG Polynomial space "modal values".
Definition: enums.h:165
@ backward
backward derivative (cell to the left and current cell)
Definition: enums.h:99
@ forward
forward derivative (cell to the right and current cell)
Definition: enums.h:98
@ centered
centered derivative (cell to the left and right and current cell)
Definition: enums.h:100
@ y
y direction
@ x
x direction
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...