COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-physics-lineuler.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 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for cf3::Euler"
9 
10 #include <iostream>
11 #include <boost/test/unit_test.hpp>
12 
13 #include "cf3/common/Log.hpp"
14 #include "cf3/common/Core.hpp"
17 
18 using namespace std;
19 using namespace cf3;
20 using namespace cf3::common;
22 
24 
25 BOOST_AUTO_TEST_SUITE( Euler_Suite )
26 
27 
29 BOOST_AUTO_TEST_CASE( Test_LinEuler2d_convection )
30 {
31  Data p;
32  p.gamma=4.;
33  p.U0 << 0.5, 0.;
34  p.rho0 = 1.;
35  p.p0 = 1.;
36  p.c0 = std::sqrt(p.gamma*p.p0/p.rho0);
37 
38  RowVector_NEQS prim;
39  prim << 0.1, 0.2, 0.3, 0.4;
40  p.compute_from_primitive(prim);
41 
42  ColVector_NDIM normal; normal << 1., 1.;
43  RowVector_NEQS flux;
44  Real wave_speed;
45  compute_convective_flux( p, normal, flux , wave_speed );
46 
47  BOOST_CHECK_EQUAL( flux[0] , 0.55 );
48  BOOST_CHECK_EQUAL( flux[1] , 0.5 );
49  BOOST_CHECK_EQUAL( flux[2] , 0.55 );
50  BOOST_CHECK_EQUAL( flux[3] , 2.2 );
51  BOOST_CHECK_EQUAL( wave_speed, 2.5 );
52 }
53 
55 
56 BOOST_AUTO_TEST_CASE( Test_LinEuler2d_riemann )
57 {
58  Data pL, pR;
59 
60  pL.gamma=4.; pR.gamma = pL.gamma;
61  pL.U0 << 0.5, 0.; pR.U0 = pL.U0;
62  pL.rho0 = 1.; pR.rho0 = pL.rho0;
63  pL.p0 = 1.; pR.p0 = pL.p0;
64  pL.c0 = std::sqrt(pL.gamma*pL.p0/pL.rho0); pR.c0 = pL.c0;
65  pL.cons << 0.1, 0.2, 0.3, 0.4; pR.cons = pL.cons*2.;
66 
67  RowVector_NEQS flux_pos, flux_neg;
68  ColVector_NDIM normal; normal << 1.,1.;
69  Real wave_speed;
70 
71  compute_rusanov_flux( pL, pR, normal, flux_pos , wave_speed );
72  std::cout << wave_speed << "\t" << flux_pos << std::endl;
73 
74  compute_rusanov_flux( pR, pL, -normal, flux_neg , wave_speed );
75  std::cout << wave_speed << "\t" << flux_neg << std::endl;
76 
77  BOOST_CHECK_EQUAL ( flux_pos, -flux_neg );
78 
79  compute_cir_flux( pL, pR, normal, flux_pos , wave_speed );
80  std::cout << wave_speed << "\t" << flux_pos << std::endl;
81 
82  compute_cir_flux( pR, pL, -normal, flux_neg , wave_speed );
83  std::cout << wave_speed << "\t" << flux_neg << std::endl;
84 
85  BOOST_CHECK_EQUAL ( flux_pos, -flux_neg );
86 
87 
88  Matrix_NEQSxNEQS A, R, L;
90  compute_absolute_flux_jacobian(pL, normal, A);
93  compute_convective_eigenvalues(pL, normal, D);
94 
95  Matrix_NEQSxNEQS Acheck;
96  Acheck <<
97  0.5, 0.25, 0.25, 0.375,
98  0, 2.5, 1.5, 0.25,
99  0, 1.5, 2.5, 0.25,
100  0, 1, 1, 2;
101  BOOST_CHECK( A == Acheck );
102  BOOST_CHECK( R*D.cwiseAbs().asDiagonal()*L == Acheck );
103 
104 }
105 
107 
108 BOOST_AUTO_TEST_SUITE_END()
109 
110 
MatrixTypes< NDIM, NEQS >::RowVector_NEQS RowVector_NEQS
Definition: Types.hpp:22
boost::proto::terminal< SFOp< NormalOp > >::type const normal
Real R()
Definition of the ideal gas constant [J/mol K].
Definition: Consts.hpp:36
MatrixTypes< NDIM, NEQS >::Matrix_NEQSxNEQS Matrix_NEQSxNEQS
Definition: Types.hpp:24
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:18
STL namespace.
MatrixTypes< NDIM, NEQS >::ColVector_NDIM ColVector_NDIM
Definition: Types.hpp:23
void compute_from_primitive(const RowVector_NEQS &prim)
Compute the data given primitive state.
Definition: Data.cpp:28
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
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:45
BOOST_AUTO_TEST_CASE(Test_LinEuler2d_convection)
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:55
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Real gamma
specific heat ratio
Definition: Data.hpp:28
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:82
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:64
Most basic kernel library.
Definition: Action.cpp:19
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