Alamo
Riemann.H
Go to the documentation of this file.
1#ifndef SOLVER_LOCAL_RIEMANN_H
2#define SOLVER_LOCAL_RIEMANN_H
3
4#include "Set/Base.H"
5#include "Set/Set.H"
6
7namespace Solver
8{
9namespace Local
10{
11namespace Riemann
12{
13struct State {
18 // Construtor for convenience
19 State() { rho = 0.0; M_normal = 0.0, M_tangent = 0.0; E = 0.0;}
20 State(Set::Scalar a_rho, Set::Scalar a_M_normal, Set::Scalar a_M_tangent, Set::Scalar a_E)
21 : rho(a_rho), M_normal(a_M_normal), M_tangent(a_M_tangent), E(a_E) {}
22 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)
23 {
24 rho = density_mf(i,j,k);
25 if (direction == 0)
26 {
27 M_normal = momentum_mf(i,j,k,0);
28 M_tangent = momentum_mf(i,j,k,1);
29 }
30 else if (direction == 1)
31 {
32 M_normal = momentum_mf(i,j,k,1);
33 M_tangent = momentum_mf(i,j,k,0);
34 }
35 else
36 {
37 Util::Abort(INFO, "Not supported yet");
38 }
39 E = energy_mf(i,j,k);
40 }
41
42
43 friend std::ostream &operator<<(std::ostream &os, const State &state)
44 {
45 os << "rho=" << state.rho << ", ";
46 os << "Mn=" << state.M_normal << ", ";
47 os << "Mt=" << state.M_tangent << ", ";
48 os << "E=" << state.E << ", ";
49 // do stuf
50 return os;
51 }
52 void operator += (const State &a)
53 {
54 rho += a.rho; M_normal += a.M_normal; M_tangent += a.M_tangent; E += a.E;
55 };
56 void operator -= (const State &a)
57 {
58 rho -= a.rho; M_normal -= a.M_normal; M_tangent -= a.M_tangent; E -= a.E;
59 };
60 void operator *= (const Set::Scalar alpha)
61 {
62 rho *= alpha; M_normal *= alpha; M_tangent *= alpha; E *= alpha;
63 };
64 void operator /= (const Set::Scalar alpha)
65 {
66 rho /= alpha; M_normal /= alpha; M_tangent /= alpha; E /= alpha;
67 };
68 friend State operator + (const State &a, const State &b)
69 {
70 return State(a.rho+b.rho, a.M_normal+b.M_normal, a.M_tangent+b.M_tangent, a.E+b.E);
71 }
72 friend State operator - (const State &a, const State &b)
73 {
74 return State(a.rho-b.rho, a.M_normal-b.M_normal, a.M_tangent-b.M_tangent, a.E-b.E);
75 }
76 friend State operator * (const Set::Scalar alpha, const State &b)
77 {
78 return State(b.rho*alpha, b.M_normal*alpha, b.M_tangent*alpha, b.E*alpha);
79 }
80 friend State operator * (const State &b, const Set::Scalar alpha)
81 {
82 return State(b.rho*alpha, b.M_normal*alpha, b.M_tangent*alpha, b.E*alpha);
83 }
84 friend State operator / (const State &b, const Set::Scalar alpha)
85 {
86 return State(b.rho/alpha, b.M_normal/alpha, b.M_tangent/alpha, b.E/alpha);
87 }
88};
89
90struct Flux {
95 Flux() : mass(0.0), momentum_normal(0.0), momentum_tangent(0.0), energy(0.0) {}
96 Flux(Set::Scalar a_mass, Set::Scalar a_momentum_normal, Set::Scalar a_momentum_tangent, Set::Scalar a_energy) :
97 mass(a_mass), momentum_normal(a_momentum_normal),
98 momentum_tangent(a_momentum_tangent), energy(a_energy) {}
99
100 Flux(State &in) :
101 mass(in.rho),
102 momentum_normal(in.M_normal),
103 momentum_tangent(in.M_tangent),
104 energy(in.E) {}
105
106 friend std::ostream &operator<<(std::ostream &os, const Flux &flux)
107 {
108 os << "mass=" << flux.mass << ", ";
109 os << "Mn=" << flux.momentum_normal << ", ";
110 os << "Mt=" << flux.momentum_tangent << ", ";
111 os << "E=" << flux.energy << ", ";
112 // do stuff
113 return os;
114 }
115 void operator += (const Flux &a)
116 {
117 mass += a.mass;
119 energy += a.energy;
120 }
121 void operator -= (const Flux &a)
122 {
123 mass -= a.mass;
125 energy -= a.energy;
126 }
127 void operator *= (const Set::Scalar alpha)
128 {
129 mass *= alpha;
130 momentum_normal *= alpha;
131 momentum_tangent *= alpha;
132 energy *= alpha;
133 }
134 void operator /= (const Set::Scalar alpha)
135 {
136 mass /= alpha;
137 momentum_normal /= alpha;
138 momentum_tangent /= alpha;
139 energy /= alpha;
140 }
141 friend Flux operator + (const Flux &a, const Flux &b)
142 {
145 }
146 friend Flux operator - (const Flux &a, const Flux &b)
147 {
150 }
151 friend Flux operator * (const Flux &a, const Set::Scalar beta)
152 {
153 return Flux(a.mass*beta, a.momentum_normal*beta,
154 a.momentum_tangent*beta, a.energy*beta);
155 }
156 friend Flux operator * (const Set::Scalar beta,const Flux &a)
157 {
158 return Flux(a.mass*beta, a.momentum_normal*beta,
159 a.momentum_tangent*beta, a.energy*beta);
160 }
161 friend Flux operator / (const Flux &a, const Set::Scalar beta)
162 {
163 return Flux(a.mass/beta, a.momentum_normal/beta,
164 a.momentum_tangent/beta, a.energy/beta);
165 }
166
167};
168
169
171{
172public:
173 virtual Flux Solve(State lo, State hi, Set::Scalar gamma, Set::Scalar p_ref, Set::Scalar small) = 0;
174 virtual ~Riemann() = default;
175};
176
177
178}
179}
180}
181
182
183
184
185#endif
#define INFO
Definition Util.H:20
virtual Flux Solve(State lo, State hi, Set::Scalar gamma, Set::Scalar p_ref, Set::Scalar small)=0
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:151
void operator*=(const Set::Scalar alpha)
Definition Riemann.H:127
Set::Scalar momentum_normal
Definition Riemann.H:92
friend Flux operator-(const Flux &a, const Flux &b)
Definition Riemann.H:146
Set::Scalar momentum_tangent
Definition Riemann.H:93
friend Flux operator/(const Flux &a, const Set::Scalar beta)
Definition Riemann.H:161
Flux(Set::Scalar a_mass, Set::Scalar a_momentum_normal, Set::Scalar a_momentum_tangent, Set::Scalar a_energy)
Definition Riemann.H:96
friend Flux operator+(const Flux &a, const Flux &b)
Definition Riemann.H:141
void operator+=(const Flux &a)
Definition Riemann.H:115
void operator/=(const Set::Scalar alpha)
Definition Riemann.H:134
void operator-=(const Flux &a)
Definition Riemann.H:121
friend std::ostream & operator<<(std::ostream &os, const Flux &flux)
Definition Riemann.H:106
friend State operator*(const Set::Scalar alpha, const State &b)
Definition Riemann.H:76
void operator+=(const State &a)
Definition Riemann.H:52
friend State operator/(const State &b, const Set::Scalar alpha)
Definition Riemann.H:84
void operator*=(const Set::Scalar alpha)
Definition Riemann.H:60
friend State operator+(const State &a, const State &b)
Definition Riemann.H:68
friend std::ostream & operator<<(std::ostream &os, const State &state)
Definition Riemann.H:43
void operator-=(const State &a)
Definition Riemann.H:56
void operator/=(const Set::Scalar alpha)
Definition Riemann.H:64
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:22
friend State operator-(const State &a, const State &b)
Definition Riemann.H:72
State(Set::Scalar a_rho, Set::Scalar a_M_normal, Set::Scalar a_M_tangent, Set::Scalar a_E)
Definition Riemann.H:20