Alamo
Riemann.H
Go to the documentation of this file.
1#ifndef SOLVER_LOCAL_RIEMANN_H
2#define SOLVER_LOCAL_RIEMANN_H
3
4
5namespace Solver
6{
7namespace Local
8{
9namespace Riemann
10{
11struct State {
16 // Construtor for convenience
17 State() { rho = 0.0; M_normal = 0.0, M_tangent = 0.0; E = 0.0;}
18 State(Set::Scalar a_rho, Set::Scalar a_M_normal, Set::Scalar a_M_tangent, Set::Scalar a_E)
19 : rho(a_rho), M_normal(a_M_normal), M_tangent(a_M_tangent), E(a_E) {}
20 State(Set::Patch<const Set::Scalar> density_mf, Set::Patch<const Set::Scalar> momentum_mf, Set::Patch<const Set::Scalar> energy_mf, int i, int j, int k, int direction)
21 {
22 rho = density_mf(i,j,k);
23 if (direction == 0)
24 {
25 M_normal = momentum_mf(i,j,k,0);
26 M_tangent = momentum_mf(i,j,k,1);
27 }
28 else if (direction == 1)
29 {
30 M_normal = momentum_mf(i,j,k,1);
31 M_tangent = momentum_mf(i,j,k,0);
32 }
33 else
34 {
35 Util::Abort(INFO, "Not supported yet");
36 }
37 E = energy_mf(i,j,k);
38 }
39
40
41 friend std::ostream &operator<<(std::ostream &os, const State &state)
42 {
43 os << "rho=" << state.rho << ", ";
44 os << "Mn=" << state.M_normal << ", ";
45 os << "Mt=" << state.M_tangent << ", ";
46 os << "E=" << state.E << ", ";
47 // do stuf
48 return os;
49 }
50 void operator += (const State &a)
51 {
52 rho += a.rho; M_normal += a.M_normal; M_tangent += a.M_tangent; E += a.E;
53 };
54 void operator -= (const State &a)
55 {
56 rho -= a.rho; M_normal -= a.M_normal; M_tangent -= a.M_tangent; E -= a.E;
57 };
58 void operator *= (const Set::Scalar alpha)
59 {
60 rho *= alpha; M_normal *= alpha; M_tangent *= alpha; E *= alpha;
61 };
62 void operator /= (const Set::Scalar alpha)
63 {
64 rho /= alpha; M_normal /= alpha; M_tangent /= alpha; E /= alpha;
65 };
66 friend State operator + (const State &a, const State &b)
67 {
68 return State(a.rho+b.rho, a.M_normal+b.M_normal, a.M_tangent+b.M_tangent, a.E+b.E);
69 }
70 friend State operator - (const State &a, const State &b)
71 {
72 return State(a.rho-b.rho, a.M_normal-b.M_normal, a.M_tangent-b.M_tangent, a.E-b.E);
73 }
74 friend State operator * (const Set::Scalar alpha, const State &b)
75 {
76 return State(b.rho*alpha, b.M_normal*alpha, b.M_tangent*alpha, b.E*alpha);
77 }
78 friend State operator * (const State &b, const Set::Scalar alpha)
79 {
80 return State(b.rho*alpha, b.M_normal*alpha, b.M_tangent*alpha, b.E*alpha);
81 }
82 friend State operator / (const State &b, const Set::Scalar alpha)
83 {
84 return State(b.rho/alpha, b.M_normal/alpha, b.M_tangent/alpha, b.E/alpha);
85 }
86};
87
88struct Flux {
93 Flux() : mass(0.0), momentum_normal(0.0), momentum_tangent(0.0), energy(0.0) {}
94 Flux(Set::Scalar a_mass, Set::Scalar a_momentum_normal, Set::Scalar a_momentum_tangent, Set::Scalar a_energy) :
95 mass(a_mass), momentum_normal(a_momentum_normal),
96 momentum_tangent(a_momentum_tangent), energy(a_energy) {}
97 friend std::ostream &operator<<(std::ostream &os, const Flux &flux)
98 {
99 os << "mass=" << flux.mass << ", ";
100 os << "Mn=" << flux.momentum_normal << ", ";
101 os << "Mt=" << flux.momentum_tangent << ", ";
102 os << "E=" << flux.energy << ", ";
103 // do stuff
104 return os;
105 }
106 void operator += (const Flux &a)
107 {
108 mass += a.mass;
110 energy += a.energy;
111 }
112 void operator -= (const Flux &a)
113 {
114 mass -= a.mass;
116 energy -= a.energy;
117 }
118 void operator *= (const Set::Scalar alpha)
119 {
120 mass *= alpha;
121 momentum_normal *= alpha;
122 momentum_tangent *= alpha;
123 energy *= alpha;
124 }
125 void operator /= (const Set::Scalar alpha)
126 {
127 mass /= alpha;
128 momentum_normal /= alpha;
129 momentum_tangent /= alpha;
130 energy /= alpha;
131 }
132 friend Flux operator + (const Flux &a, const Flux &b)
133 {
136 }
137 friend Flux operator - (const Flux &a, const Flux &b)
138 {
141 }
142 friend Flux operator * (const Flux &a, const Set::Scalar beta)
143 {
144 return Flux(a.mass*beta, a.momentum_normal*beta,
145 a.momentum_tangent*beta, a.energy*beta);
146 }
147 friend Flux operator * (const Set::Scalar beta,const Flux &a)
148 {
149 return Flux(a.mass*beta, a.momentum_normal*beta,
150 a.momentum_tangent*beta, a.energy*beta);
151 }
152 friend Flux operator / (const Flux &a, const Set::Scalar beta)
153 {
154 return Flux(a.mass/beta, a.momentum_normal/beta,
155 a.momentum_tangent/beta, a.energy/beta);
156 }
157
158};
159
160
161
162}
163}
164}
165
166
167
168
169#endif
#define INFO
Definition Util.H:20
amrex::Real Scalar
Definition Base.H:19
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:20
A bunch of solvers.
Definition CG.H:6
void Abort(const char *msg)
Definition Util.cpp:170
friend Flux operator*(const Flux &a, const Set::Scalar beta)
Definition Riemann.H:142
void operator*=(const Set::Scalar alpha)
Definition Riemann.H:118
Set::Scalar momentum_normal
Definition Riemann.H:90
friend Flux operator-(const Flux &a, const Flux &b)
Definition Riemann.H:137
Set::Scalar momentum_tangent
Definition Riemann.H:91
friend Flux operator/(const Flux &a, const Set::Scalar beta)
Definition Riemann.H:152
Flux(Set::Scalar a_mass, Set::Scalar a_momentum_normal, Set::Scalar a_momentum_tangent, Set::Scalar a_energy)
Definition Riemann.H:94
friend Flux operator+(const Flux &a, const Flux &b)
Definition Riemann.H:132
void operator+=(const Flux &a)
Definition Riemann.H:106
void operator/=(const Set::Scalar alpha)
Definition Riemann.H:125
void operator-=(const Flux &a)
Definition Riemann.H:112
friend std::ostream & operator<<(std::ostream &os, const Flux &flux)
Definition Riemann.H:97
friend State operator*(const Set::Scalar alpha, const State &b)
Definition Riemann.H:74
void operator+=(const State &a)
Definition Riemann.H:50
friend State operator/(const State &b, const Set::Scalar alpha)
Definition Riemann.H:82
void operator*=(const Set::Scalar alpha)
Definition Riemann.H:58
friend State operator+(const State &a, const State &b)
Definition Riemann.H:66
friend std::ostream & operator<<(std::ostream &os, const State &state)
Definition Riemann.H:41
void operator-=(const State &a)
Definition Riemann.H:54
void operator/=(const Set::Scalar alpha)
Definition Riemann.H:62
State(Set::Patch< const Set::Scalar > density_mf, Set::Patch< const Set::Scalar > momentum_mf, Set::Patch< const Set::Scalar > energy_mf, int i, int j, int k, int direction)
Definition Riemann.H:20
friend State operator-(const State &a, const State &b)
Definition Riemann.H:70
State(Set::Scalar a_rho, Set::Scalar a_M_normal, Set::Scalar a_M_tangent, Set::Scalar a_E)
Definition Riemann.H:18