10#include "gtest/gtest.h"
14TEST(NumericsTest, test_absoluteFuzzyEqualVectors_True)
16 const RealVectorValue
a(1.0, 2.0, 3.0);
17 const RealVectorValue
b(1.0 + 1.0e-15, 2.0, 3.0);
21TEST(NumericsTest, test_absoluteFuzzyEqualVectors_False)
23 const RealVectorValue
a(1.0, 2.0, 3.0);
24 const RealVectorValue
b(1.1, 2.0, 3.0);
28TEST(NumericsTest, test_areParallelVectors_True)
30 const RealVectorValue
a(1.0, 2.0, 3.0);
31 const RealVectorValue
b(-2.0, -4.0, -6.0);
35TEST(NumericsTest, test_areParallelVectors_False)
37 const RealVectorValue
a(1.0, 2.0, 3.0);
38 const RealVectorValue
b(2.0, 3.0, 1.0);
42TEST(NumericsTest, test_haveSameDirection_True)
44 const RealVectorValue
a(1.0, 2.0, 3.0);
45 const RealVectorValue
b(2.0, 4.0, 6.0);
49TEST(NumericsTest, test_haveSameDirection_False)
51 const RealVectorValue
a(1.0, 2.0, 3.0);
52 const RealVectorValue
b(-1.0, 2.0, 3.0);
56TEST(NumericsTest, Reynolds)
58 ABS_TEST(
THM::Reynolds(0.1, 999., 0.5, 2.0e-2, 0.9), 1.11, 1e-13);
59 ABS_TEST(
THM::Reynolds(0.1, 999., -0.5, 2.0e-2, 0.9), 1.11, 1e-13);
66 ABS_TEST(
THM::Peclet(0.1, 999., 999., 0.5, 2.0e-2, 0.9), 1108.89, 1e-13);
71 ABS_TEST(
THM::Grashof(0.1, 1., 2.0e-2, 999., 0.05, 9.81), 3.1329247392e3, 1e-13);
74TEST(NumericsTest, Laplace) { ABS_TEST(
THM::Laplace(0.001, 1., 9.81), 0.010096375546923, 1e-13); }
76TEST(NumericsTest, viscosityNumber)
81TEST(NumericsTest, wallHeatTransferCoefficient)
83 ABS_TEST(THM::wallHeatTransferCoefficient(2., 6., 3.), 4, 1e-13);
91 const Real arhouA = 2;
93 Real vel, dvel_darhoA, dvel_darhouA;
95 ABS_TEST(vel, 2., 1e-15);
96 ABS_TEST(dvel_darhoA, -2, 1e-15);
97 ABS_TEST(dvel_darhouA, 1., 1e-15);
105 const Real arhoA = 2;
106 const Real alpha = 0.1;
109 Real
rho, drho_darhoA, drho_dalpha;
111 ABS_TEST(
rho, 20., 1e-15);
112 ABS_TEST(drho_darhoA, 10., 1e-15);
113 ABS_TEST(drho_dalpha, -200., 1e-13);
116TEST(NumericsTest, specific_volume)
118 const Real arhoA = 2;
123 ABS_TEST(
v, 0.5, 1e-15);
124 ABS_TEST(dv_drhoA, -0.25, 1e-15);
126 const Real alpha = 0.1;
127 Real dv_darhoA, dv_dalpha;
129 ABS_TEST(
v, 0.05, 1e-15);
130 ABS_TEST(dv_darhoA, -0.025, 1e-15);
131 ABS_TEST(dv_dalpha, 0.5, 1e-13);
136 ABS_TEST(
v, 0.05, 1e-15);
137 ABS_TEST(dv_darhoA, -0.025, 1e-15);
145TEST(NumericsTest, internal_energy)
147 const Real arhoA = 2;
148 const Real arhouA = 4;
149 const Real arhoEA = 8;
151 Real e, de_darhoA, de_darhouA, de_darhoEA;
153 ABS_TEST(e, 2., 1e-15);
154 ABS_TEST(de_darhoA, 0., 1e-15);
155 ABS_TEST(de_darhouA, -1., 1e-15);
156 ABS_TEST(de_darhoEA, 0.5, 1e-15);
162 ABS_TEST(e, 8., 1e-15);
163 ABS_TEST(de_dE, 1., 1e-15);
164 ABS_TEST(de_dvel, -2., 1e-15);
171TEST(NumericsTest, total_energy)
173 const Real arhoA = 2.;
174 const Real arhoEA = 8.;
176 Real E, dE_darhoA, dE_darhoEA;
178 ABS_TEST(E, 4., 1e-15);
179 ABS_TEST(dE_darhoA, -2., 1e-15);
180 ABS_TEST(dE_darhoEA, 0.5, 1e-15);
188 ABS_TEST(E, 6., 1e-15);
189 ABS_TEST(dE_de, 1., 1e-15);
190 ABS_TEST(dE_dvel, 2., 1e-15);
193TEST(NumericsTest, specific_enthalpy)
199 Real h, dh_de, dh_dp, dh_drho;
201 ABS_TEST(h, 8., 1e-15);
202 ABS_TEST(dh_de, 1., 1e-15);
203 ABS_TEST(dh_dp, 0.5, 1e-15);
204 ABS_TEST(dh_drho, -1., 1e-15);
TEST(NumericsTest, test_absoluteFuzzyEqualVectors_True)
void v_from_rhoA_A(Real rhoA, Real A, Real &v, Real &dv_drhoA)
Computes specific volume and its derivatives from rho*A, and area.
Real dv_dalpha_liquid(Real area, Real arhoA, bool is_liquid)
Derivative of specific volume wrt alpha_liquid.
auto viscosityNumber(const T1 &viscosity, const T2 &surf_tension, const T3 &rho_k, const T4 &delta_rho, const Real &gravity_magnitude)
Compute viscosity number (or coefficient)
bool haveSameDirection(const RealVectorValue &a, const RealVectorValue &b, const Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Tests if two real-valued vectors are in the same direction.
bool isOutlet(Real vel, Real normal)
Determine if outlet boundary condition should be applied.
auto Prandtl(const T1 &cp, const T2 &mu, const T3 &k)
Compute Prandtl number.
bool absoluteFuzzyEqualVectors(const RealVectorValue &a, const RealVectorValue &b, const Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Tests if two real-valued vectors are equal within some absolute tolerance.
void v_from_rho(Real rho, Real &v, Real &dv_drho)
Computes specific volume and its derivative with respect to density.
Real dv_darhoA(Real area, Real arhoA)
Derivative of specific volume wrt density equation solution variable.
void h_from_e_p_rho(Real e, Real p, Real rho, Real &h, Real &dh_de, Real &dh_dp, Real &dh_drho)
Computes specific enthalpy and its derivatives from specific internal energy, pressure,...
auto Laplace(const T1 &surf_tension, const T2 &delta_rho, const Real &gravity_magnitude)
Compute Laplace number (or coefficient)
auto Reynolds(const T1 &volume_fraction, const T2 &rho, const T3 &vel, const T4 &D_h, const T5 &mu)
Compute Reynolds number.
Real dvel_darhoA(Real arhoA, Real arhouA)
Derivative of velocity w.r.t.
bool isInlet(Real vel, Real normal)
Determine if inlet boundary condition should be applied.
Real de_darhouA(Real arhoA, Real arhouA)
Derivative of specific internal energy wrt momentum of the phase (rhouA or arhouA)
Real dvel_darhouA(Real arhoA)
Derivative of velocity w.r.t.
void v_from_arhoA_alpha_A(Real arhoA, Real alpha, Real A, Real &v, Real &dv_darhoA, Real &dv_dalpha)
Computes specific volume and its derivatives from alpha*rho*A, volume fraction, and area.
void rho_from_arhoA_alpha_A(Real arhoA, Real alpha, Real A, Real &rho, Real &drho_darhoA, Real &drho_dalpha)
Computes density and its derivatives from alpha*rho*A, alpha, and area.
void E_from_arhoA_arhoEA(Real arhoA, Real arhoEA, Real &E, Real &dE_darhoA, Real &dE_darhoEA)
Computes specific total energy and its derivatives from alpha*rho*A and alpha*rho*E*A.
Real de_darhoEA(Real arhoA)
Derivative of specific internal energy wrt total energy of the phase (rhoEA or arhoEA)
void e_from_arhoA_arhouA_arhoEA(Real arhoA, Real arhouA, Real arhoEA, Real &e, Real &de_darhoA, Real &de_darhouA, Real &de_darhoEA)
Computes specific internal energy and its derivatives from alpha*rho*A, alpha*rho*u*A,...
void E_from_e_vel(Real e, Real vel, Real &E, Real &dE_de, Real &dE_dvel)
Computes specific total energy and its derivatives from specific internal energy and velocity.
auto Grashof(const T1 &beta, const T2 &dT, const T3 &D_h, const T4 &rho_liquid, const T5 &mu_liquid, const Real &gravity_magnitude)
Compute Grashof number.
void vel_from_arhoA_arhouA(Real arhoA, Real arhouA, Real &vel, Real &dvel_darhoA, Real &dvel_darhouA)
Computes velocity and its derivatives from alpha*rho*A and alpha*rho*u*A.
Real de_darhoA(Real arhoA, Real arhouA, Real arhoEA)
Derivative of specific internal energy wrt density of the phase (rhoA or arhoA)
bool areParallelVectors(const RealVectorValue &a, const RealVectorValue &b, const Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Tests if two real-valued vectors are parallel within some absolute tolerance.
auto Peclet(const T1 &volume_fraction, const T2 &cp, const T3 &rho, const T4 &vel, const T5 &D_h, const T6 &k)
Compute Peclet number.
auto Dean(const T1 &Re, const T2 &doD)
Compute Dean number.
void e_from_E_vel(Real E, Real vel, Real &e, Real &de_dE, Real &de_dvel)
Computes specific internal energy and its derivatives from specific total energy and velocity.