https://mooseframework.inl.gov
FluidPropertiesTestUtils.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "metaphysicl/raw_type.h"
13 
14 // Relative tolerance to be used when comparing to a value from external fluid
15 // property packages, which might be using different underlying models
16 #define REL_TOL_EXTERNAL_VALUE 1e-3
17 
18 // Relative tolerance to be used when comparing to a value computed directly
19 // from the code at an earlier date, to ensure that implementations are not
20 // inadvertently changed
21 #define REL_TOL_SAVED_VALUE 1e-12
22 
23 // Relative tolerance to be used for consistency checks - computing properties
24 // in different ways at the same state
25 #define REL_TOL_CONSISTENCY 1e-10
26 
27 // Relative tolerance to be used when comparing a derivative value to a finite
28 // difference approximation
29 #define REL_TOL_DERIVATIVE 1e-6
30 
31 // Macro for performing relative error test
32 #define REL_TEST(value, ref_value, tol) \
33  if (std::abs(ref_value) < 1e-15) \
34  ABS_TEST(value, ref_value, tol); \
35  else \
36  EXPECT_LE(std::abs(((MetaPhysicL::raw_value(value)) - (MetaPhysicL::raw_value(ref_value))) / \
37  (MetaPhysicL::raw_value(ref_value))), \
38  tol);
39 
40 // Macro for performing relative or absolute error test
41 #define REL_ABS_TEST(value, ref_value, rel_tol, abs_tol) \
42  if (std::abs(ref_value - value) < abs_tol) \
43  EXPECT_TRUE(true); \
44  else \
45  EXPECT_LE(std::abs(((MetaPhysicL::raw_value(value)) - (MetaPhysicL::raw_value(ref_value))) / \
46  (MetaPhysicL::raw_value(ref_value))), \
47  rel_tol);
48 
49 // Macro for computing absolute error
50 #define ABS_TEST(value, ref_value, tol) \
51  EXPECT_LE(std::abs(((MetaPhysicL::raw_value(value)) - (MetaPhysicL::raw_value(ref_value)))), \
52  (tol))