GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/material/solidsystems/checksolidsystem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 20 22 90.9%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup MaterialTests
10 * \brief This file provides the actual code for the solid systems test.
11 *
12 * It is not directly in test_solidsystems.cc so that external modules
13 * like dumux-devel can use it easily
14 */
15
16 #ifndef DUMUX_CHECK_SOLIDSYSTEM_HH
17 #define DUMUX_CHECK_SOLIDSYSTEM_HH
18
19 #include <type_traits>
20 #include <iostream>
21
22 #include <dune/common/classname.hh>
23 #include <dune/common/exceptions.hh>
24
25 // include all solid states
26 #include <dumux/material/solidstates/inertsolidstate.hh>
27 #include <dumux/material/solidstates/compositionalsolidstate.hh>
28
29 namespace Dumux {
30
31 template<class Scalar, class SolidSystem>
32 11 int checkSolidSystem()
33 {
34 static_assert((SolidSystem::isInert() && SolidSystem::numInertComponents == SolidSystem::numComponents)
35 || !SolidSystem::isInert(), "numInertComponents == numComponents has to be equal to SolidSystem::isInert()");
36
37 // inert solid state
38 using Solidstate = std::conditional_t<SolidSystem::isInert(),
39 InertSolidState<Scalar, SolidSystem>,
40 CompositionalSolidState<Scalar, SolidSystem>>;
41 Solidstate sst;
42
43 11 int success = 0;
44 22 std::cout << "Testing solid system '" << Dune::className<SolidSystem>() << "'\n";
45
46 // output strings
47 22 std::string collectedErrors;
48 22 std::string collectedWarnings;
49
50 // make sure the solid system provides the number of phases and
51 // the number of components
52 enum
53 {
54 numComponents = SolidSystem::numComponents
55 };
56
57 // some value to make sure the return values of the solid system
58 // are convertible to scalars
59 [[maybe_unused]] Scalar val;
60
61 // test for componentName and isCompressible
62 25 for (int phaseIdx = 0; phaseIdx < numComponents; ++phaseIdx)
63 {
64 28 [[maybe_unused]] std::string name = SolidSystem::componentName(phaseIdx);
65 14 [[maybe_unused]] bool bVal = SolidSystem::isCompressible(phaseIdx);
66 14 val = SolidSystem::molarMass(phaseIdx);
67 }
68
69 // test for componentName
70 25 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
71 {
72 14 [[maybe_unused]] std::string name = SolidSystem::componentName(compIdx);
73 }
74
75 // test for name
76 22 [[maybe_unused]] std::string name = SolidSystem::name();
77
78 try
79 {
80 11 val = SolidSystem::heatCapacity(sst);
81 } catch (Dune::NotImplemented&)
82 {
83 collectedWarnings += "warning: SolidSystem::heatCapacity() is not implemented\n";
84 } catch (...)
85 {
86 collectedErrors += "error: SolidSystem::heatCapacity() throws exception!\n";
87 }
88
89 try
90 {
91 11 val = SolidSystem::thermalConductivity(sst);
92 } catch (Dune::NotImplemented&)
93 {
94 collectedWarnings += "warning: SolidSystem::thermalConductivity() is not implemented\n";
95 } catch (...)
96 {
97 collectedErrors += "error: SolidSystem::thermalConductivity() throws exception!\n";
98 }
99
100 try
101 {
102 11 val = SolidSystem::density(sst);
103 } catch (Dune::Exception &e)
104 {
105 collectedErrors += "error: SolidSystem::density() throws exception!\n";
106 }
107
108 11 std::cout << collectedErrors;
109 11 std::cout << collectedWarnings;
110 22 if (collectedErrors.empty()) // success
111 {
112 22 std::cout << "... successful" << std::endl;
113 33 std::cout << "----------------------------------" << std::endl;
114 return 0;
115 }
116 else
117 {
118 std::cout << "... failed" << std::endl;
119 std::cout << "----------------------------------" << std::endl;
120 return 1;
121 }
122 std::cout << "----------------------------------\n";
123 return success;
124 }
125
126 } // end namespace Dumux
127
128 #endif
129