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#include "Model/Gas/Gas.H"
7#include <memory>
8
9namespace Solver
10{
11namespace Local
12{
13namespace Riemann
14{
15struct State {
20 // Construtor for convenience
21 State() { rho = 0.0; M_normal = 0.0, M_tangent = 0.0; E = 0.0;}
22 State(Set::Scalar a_rho, Set::Scalar a_M_normal, Set::Scalar a_M_tangent, Set::Scalar a_E)
23 : rho(a_rho), M_normal(a_M_normal), M_tangent(a_M_tangent), E(a_E) {}
24 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)
25 {
26 rho = density_mf(i,j,k);
27 if (direction == 0)
28 {
29 M_normal = momentum_mf(i,j,k,0);
30 M_tangent = momentum_mf(i,j,k,1);
31 }
32 else if (direction == 1)
33 {
34 M_normal = momentum_mf(i,j,k,1);
35 M_tangent = momentum_mf(i,j,k,0);
36 }
37 else
38 {
39 Util::Abort(INFO, "Not supported yet");
40 }
41 E = energy_mf(i,j,k);
42 }
43
44
45 friend std::ostream &operator<<(std::ostream &os, const State &state)
46 {
47 os << "rho=" << state.rho << ", ";
48 os << "Mn=" << state.M_normal << ", ";
49 os << "Mt=" << state.M_tangent << ", ";
50 os << "E=" << state.E << ", ";
51 // do stuf
52 return os;
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 State &a)
59 {
60 rho -= a.rho; M_normal -= a.M_normal; M_tangent -= a.M_tangent; E -= a.E;
61 };
62 void operator *= (const Set::Scalar alpha)
63 {
64 rho *= alpha; M_normal *= alpha; M_tangent *= alpha; E *= alpha;
65 };
66 void operator /= (const Set::Scalar alpha)
67 {
68 rho /= alpha; M_normal /= alpha; M_tangent /= alpha; E /= alpha;
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 State &a, const State &b)
75 {
76 return State(a.rho-b.rho, a.M_normal-b.M_normal, a.M_tangent-b.M_tangent, a.E-b.E);
77 }
78 friend State operator * (const Set::Scalar alpha, const State &b)
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 friend State operator / (const State &b, const Set::Scalar alpha)
87 {
88 return State(b.rho/alpha, b.M_normal/alpha, b.M_tangent/alpha, b.E/alpha);
89 }
90};
91
92struct Flux {
97 Flux() : mass(0.0), momentum_normal(0.0), momentum_tangent(0.0), energy(0.0) {}
98 Flux(Set::Scalar a_mass, Set::Scalar a_momentum_normal, Set::Scalar a_momentum_tangent, Set::Scalar a_energy) :
99 mass(a_mass), momentum_normal(a_momentum_normal),
100 momentum_tangent(a_momentum_tangent), energy(a_energy) {}
101
102 Flux(const State &in) :
103 mass(in.rho),
104 momentum_normal(in.M_normal),
105 momentum_tangent(in.M_tangent),
106 energy(in.E) {}
107
108 friend std::ostream &operator<<(std::ostream &os, const Flux &flux)
109 {
110 os << "mass=" << flux.mass << ", ";
111 os << "Mn=" << flux.momentum_normal << ", ";
112 os << "Mt=" << flux.momentum_tangent << ", ";
113 os << "E=" << flux.energy << ", ";
114 // do stuff
115 return os;
116 }
117 void operator += (const Flux &a)
118 {
119 mass += a.mass;
121 energy += a.energy;
122 }
123 void operator -= (const Flux &a)
124 {
125 mass -= a.mass;
127 energy -= a.energy;
128 }
129 void operator *= (const Set::Scalar alpha)
130 {
131 mass *= alpha;
132 momentum_normal *= alpha;
133 momentum_tangent *= alpha;
134 energy *= alpha;
135 }
136 void operator /= (const Set::Scalar alpha)
137 {
138 mass /= alpha;
139 momentum_normal /= alpha;
140 momentum_tangent /= alpha;
141 energy /= alpha;
142 }
143 friend Flux operator + (const Flux &a, const Flux &b)
144 {
147 }
148 friend Flux operator - (const Flux &a, const Flux &b)
149 {
152 }
153 friend Flux operator * (const Flux &a, const Set::Scalar beta)
154 {
155 return Flux(a.mass*beta, a.momentum_normal*beta,
156 a.momentum_tangent*beta, a.energy*beta);
157 }
158 friend Flux operator * (const Set::Scalar beta,const Flux &a)
159 {
160 return Flux(a.mass*beta, a.momentum_normal*beta,
161 a.momentum_tangent*beta, a.energy*beta);
162 }
163 friend Flux operator / (const Flux &a, const Set::Scalar beta)
164 {
165 return Flux(a.mass/beta, a.momentum_normal/beta,
166 a.momentum_tangent/beta, a.energy/beta);
167 }
168
169};
170
171
173{
174public:
175 virtual Flux Solve(State lo, State hi, Model::Gas::Gas& gas, Set::Patch<const Set::Scalar>& X, int i, int j, int k, int side, Set::Scalar small) = 0;
176 virtual ~Riemann() = default;
177};
178
179
180}
181}
182}
183
184
185
186
187#endif
#define X(name)
#define INFO
Definition Util.H:24
virtual Flux Solve(State lo, State hi, Model::Gas::Gas &gas, Set::Patch< const Set::Scalar > &X, int i, int j, int k, int side, Set::Scalar small)=0
amrex::Real Scalar
Definition Base.H:18
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:19
A bunch of solvers.
Definition CG.H:6
void Abort(const char *msg)
Definition Util.cpp:268
friend Flux operator*(const Flux &a, const Set::Scalar beta)
Definition Riemann.H:153
Flux(const State &in)
Definition Riemann.H:102
void operator*=(const Set::Scalar alpha)
Definition Riemann.H:129
Set::Scalar momentum_normal
Definition Riemann.H:94
friend Flux operator-(const Flux &a, const Flux &b)
Definition Riemann.H:148
Set::Scalar momentum_tangent
Definition Riemann.H:95
friend Flux operator/(const Flux &a, const Set::Scalar beta)
Definition Riemann.H:163
Flux(Set::Scalar a_mass, Set::Scalar a_momentum_normal, Set::Scalar a_momentum_tangent, Set::Scalar a_energy)
Definition Riemann.H:98
friend Flux operator+(const Flux &a, const Flux &b)
Definition Riemann.H:143
void operator+=(const Flux &a)
Definition Riemann.H:117
void operator/=(const Set::Scalar alpha)
Definition Riemann.H:136
void operator-=(const Flux &a)
Definition Riemann.H:123
friend std::ostream & operator<<(std::ostream &os, const Flux &flux)
Definition Riemann.H:108
friend State operator*(const Set::Scalar alpha, const State &b)
Definition Riemann.H:78
void operator+=(const State &a)
Definition Riemann.H:54
friend State operator/(const State &b, const Set::Scalar alpha)
Definition Riemann.H:86
void operator*=(const Set::Scalar alpha)
Definition Riemann.H:62
friend State operator+(const State &a, const State &b)
Definition Riemann.H:70
friend std::ostream & operator<<(std::ostream &os, const State &state)
Definition Riemann.H:45
void operator-=(const State &a)
Definition Riemann.H:58
void operator/=(const Set::Scalar alpha)
Definition Riemann.H:66
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:24
friend State operator-(const State &a, const State &b)
Definition Riemann.H:74
State(Set::Scalar a_rho, Set::Scalar a_M_normal, Set::Scalar a_M_tangent, Set::Scalar a_E)
Definition Riemann.H:22