COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Functions.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 #include <iostream>
8 #include "cf3/math/Defs.hpp"
9 
10 namespace cf3 {
11 namespace physics {
12 namespace lineuler {
13 namespace lineuler2d {
14 
16 
18  RowVector_NEQS& flux, Real& wave_speed )
19 {
20  static Real u0n;
21  static Real un;
22  u0n = p.U0.dot(normal);
23  un = p.U.dot(normal);
24 
25  flux[0] = u0n*p.cons[0] + p.rho0*un;
26  flux[1] = u0n*p.cons[1] + p.p*normal[XX];
27  flux[2] = u0n*p.cons[2] + p.p*normal[YY];
28  flux[3] = u0n*p.cons[3] + p.rho0*un*p.c0*p.c0;
29 
30  wave_speed=std::abs(u0n)+p.c0;
31 }
32 
34  RowVector_NEQS& flux )
35 {
36  static Real u0n;
37  static Real un;
38  u0n = p.U0.dot(normal);
39  un = p.U.dot(normal);
40 
41  flux[0] = u0n*p.cons[0] + p.rho0*un;
42  flux[1] = u0n*p.cons[1] + p.p*normal[XX];
43  flux[2] = u0n*p.cons[2] + p.p*normal[YY];
44  flux[3] = u0n*p.cons[3] + p.rho0*un*p.c0*p.c0;
45 }
46 
48  Real& wave_speed )
49 {
50  wave_speed=std::abs(p.U0.dot(normal))+p.c0;
51 }
52 
54  RowVector_NEQS& eigen_values )
55 {
56  static Real u0n;
57  u0n = p.U0.dot(normal);
58  eigen_values <<
59  u0n,
60  u0n,
61  u0n+p.c0,
62  u0n-p.c0;
63 }
64 
66  Matrix_NEQSxNEQS& right_eigenvectors )
67 {
68  const Real inv_c0 = 1./p.c0;
69  const Real& nx = normal[XX];
70  const Real& ny = normal[YY];
71 
72  right_eigenvectors <<
73  1., 0., 0.5*inv_c0, 0.5*inv_c0,
74  0., ny, 0.5*nx, -0.5*nx,
75  0., -nx, 0.5*ny, -0.5*ny,
76  0., 0., 0.5*p.c0, 0.5*p.c0;
77 }
78 
80  Matrix_NEQSxNEQS& left_eigenvectors )
81 {
82  const Real inv_c0 = 1./p.c0;
83  const Real& nx = normal[XX];
84  const Real& ny = normal[YY];
85 
86  // matrix of left eigenvectors (rows) = Rv.inverse()
87  left_eigenvectors <<
88  1., 0., 0., -inv_c0*inv_c0,
89  0., ny, -nx, 0,
90  0., nx, ny, inv_c0,
91  0., -nx, -ny, inv_c0;
92 }
93 
94 
95 void compute_rusanov_flux( const Data& left, const Data& right, const ColVector_NDIM& normal,
96  RowVector_NEQS& flux, Real& wave_speed )
97 {
98  static RowVector_NEQS left_flux, right_flux;
99  static Real left_wave_speed, right_wave_speed;
100  compute_convective_flux( left, normal, left_flux );
101  compute_convective_flux( right, normal, right_flux);
102  compute_convective_wave_speed( left, normal, wave_speed );
103  flux = 0.5*(left_flux+right_flux);
104  flux -= 0.5*wave_speed*(right.cons - left.cons);
105 }
106 
108  Matrix_NEQSxNEQS& absolute_flux_jacobian)
109 {
110  cf3_assert(p.c0 > 1e-12);
111  const Real u0n = p.U0.dot(normal);
112  const Real inv_2c = 0.5/p.c0;
113  const Real inv_2c2 = 0.5/(p.c0*p.c0);
114 
115  const Real& nx = normal[XX];
116  const Real& ny = normal[YY];
117  const Real nx2 = nx*nx;
118  const Real ny2 = ny*ny;
119  const Real absu0n = std::abs(u0n);
120  const Real cpu = std::abs(p.c0+u0n);
121  const Real cmu = std::abs(p.c0-u0n);
122  const Real plus = cmu + cpu;
123  const Real minus = cpu - cmu;
124  const Real pm2u = plus - 2*absu0n;
125 
126  absolute_flux_jacobian <<
127  absu0n, (nx*minus)*inv_2c, (ny*minus)*inv_2c, pm2u*inv_2c2,
128  0, (2*ny2*absu0n + nx2*plus)*0.5, (nx*ny*pm2u)*0.5, (nx*minus)*inv_2c,
129  0, (nx*ny*pm2u)*0.5, (2*nx2*absu0n + ny2*plus)*0.5, (ny*minus)*inv_2c,
130  0, (p.c0*nx*minus)*0.5, (p.c0*ny*minus)*0.5, plus*0.5;
131 }
132 
133 void compute_cir_flux( const Data& left, const Data& right, const ColVector_NDIM& normal,
134  RowVector_NEQS& flux, Real& wave_speed )
135 {
136  RowVector_NEQS flux_left, flux_right;
137  compute_convective_flux(left, normal,flux_left);
138  compute_convective_flux(right,normal,flux_right);
139 
140  // No Roe-average is needed as the eigen-system is only dependant of the mean flow
142  compute_absolute_flux_jacobian(left,normal,A);
143 
144  flux.noalias() = 0.5*(flux_left+flux_right);
145  flux.noalias() -= 0.5*A*(right.cons-left.cons).transpose();
146 
147  compute_convective_wave_speed(left,normal,wave_speed);
148 }
149 
151 
152 void cons_to_char(const RowVector_NEQS& conservative,
153  const ColVector_NDIM& characteristic_normal,
154  const Real& c0,
155  RowVector_NEQS& characteristic)
156 {
157  const Real& rho = conservative[0];
158  const Real& rho0u = conservative[1];
159  const Real& rho0v = conservative[2];
160  const Real& press = conservative[3];
161  const Real& nx = characteristic_normal[XX];
162  const Real& ny = characteristic_normal[YY];
163  Real& S = characteristic[0];
164  Real& Omega = characteristic[1];
165  Real& Aplus = characteristic[2];
166  Real& Amin = characteristic[3];
167 
168  S = rho - press/(c0*c0);
169  Omega = ny*rho0u - nx*rho0v;
170  Aplus = nx*rho0u + ny*rho0v + press/c0;
171  Amin = -nx*rho0u - ny*rho0v + press/c0;
172 }
173 
175 
176 void char_to_cons(const RowVector_NEQS& characteristic, const ColVector_NDIM& characteristic_normal, const Real& c0, RowVector_NEQS& conservative)
177 {
178  const Real& S = characteristic[0];
179  const Real& Omega = characteristic[1];
180  const Real& Aplus = characteristic[2];
181  const Real& Amin = characteristic[3];
182  const Real& nx = characteristic_normal[XX];
183  const Real& ny = characteristic_normal[YY];
184  Real& rho = conservative[0];
185  Real& rho0u = conservative[1];
186  Real& rho0v = conservative[2];
187  Real& press = conservative[3];
188 
189  const Real A = Aplus+Amin;
190  const Real omega = Aplus-Amin;
191 
192  rho = S + 0.5*A/c0;
193  rho0u = ny*Omega + 0.5*nx*omega;
194  rho0v = -nx*Omega + 0.5*ny*omega;
195  press = 0.5*c0*A;
196 }
197 
199 
200 } // lineuler2d
201 } // lineuler
202 } // physics
203 } // cf3
void cons_to_char(const RowVector_NEQS &conservative, const ColVector_NDIM &characteristic_normal, const Real &c0, RowVector_NEQS &characteristic)
Definition: Functions.cpp:152
MatrixTypes< NDIM, NEQS >::RowVector_NEQS RowVector_NEQS
Definition: Types.hpp:22
boost::proto::terminal< SFOp< NormalOp > >::type const normal
void compute_convective_wave_speed(const Data &p, const ColVector_NDIM &normal, Real &wave_speed)
Maximum absolute wave speed.
Definition: Functions.cpp:47
void compute_rusanov_flux(const Data &left, const Data &right, const ColVector_NDIM &normal, RowVector_NEQS &flux, Real &wave_speed)
Rusanov Approximate Riemann solver.
Definition: Functions.cpp:95
void compute_convective_right_eigenvectors(const Data &p, const ColVector_NDIM &normal, Matrix_NEQSxNEQS &right_eigenvectors)
Right eigenvectors projected on a given normal.
Definition: Functions.cpp:65
MatrixTypes< NDIM, NEQS >::Matrix_NEQSxNEQS Matrix_NEQSxNEQS
Definition: Types.hpp:24
#define cf3_assert(a)
Definition: Assertions.hpp:93
MatrixTypes< NDIM, NEQS >::ColVector_NDIM ColVector_NDIM
Definition: Types.hpp:23
#define S(x, n)
void compute_cir_flux(const Data &left, const Data &right, const ColVector_NDIM &normal, RowVector_NEQS &flux, Real &wave_speed)
CIR (Courant Isaacson Rees) Flux Splitting Upwind scheme for linear hyperbolic system Riemann solver ...
Definition: Functions.cpp:133
Real e()
Definition of the Unit charge [C].
Definition: Consts.hpp:30
Definition: Defs.hpp:17
boost::proto::terminal< TransposeFunction >::type const transpose
void compute_convective_left_eigenvectors(const Data &p, const ColVector_NDIM &normal, Matrix_NEQSxNEQS &left_eigenvectors)
Left eigenvectors projected on a given normal.
Definition: Functions.cpp:79
void char_to_cons(const RowVector_NEQS &characteristic, const ColVector_NDIM &characteristic_normal, const Real &c0, RowVector_NEQS &conservative)
Definition: Functions.cpp:176
Top-level namespace for coolfluid.
Definition: Action.cpp:18
ColVector_NDIM U
velocity
Definition: Data.hpp:45
void compute_convective_eigenvalues(const Data &p, const ColVector_NDIM &normal, RowVector_NEQS &eigen_values)
Eigenvalues or wave speeds projected on a given normal.
Definition: Functions.cpp:53
void compute_convective_flux(const Data &p, const ColVector_NDIM &normal, RowVector_NEQS &flux, Real &wave_speed)
Convective flux in conservative form, and maximum absolute wave speed.
Definition: Functions.cpp:17
Definition: Defs.hpp:17
void compute_absolute_flux_jacobian(const Data &p, const ColVector_NDIM &normal, Matrix_NEQSxNEQS &absolute_flux_jacobian)
Absolute flux jacobian projected on a given normal.
Definition: Functions.cpp:107
Send comments to:
COOLFluiD Web Admin