OpenLB 1.7
Loading...
Searching...
No Matches
integrationTestUtils.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Nicolas Hafen
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#ifndef INTEGRATION_TEST_UTILS_H
25#define INTEGRATION_TEST_UTILS_H
26
27namespace olb {
28
29namespace util {
30
31//Test function for final values
32//TODO: Adapt to parallel runs
33template<typename T>
34int evaluateIntegration( std::vector<T>& testValues, bool print=false ){
35 OstreamManager clout( std::cout,"Integrationtest" );
36 bool allPassed = true;
37 for (int i=0; i<testValues.size(); i+=3){
38 T val = testValues[i];
39 T ref = testValues[i+1];
40 T maxErr = testValues[i+2];
41 T err = std::abs(ref-val)/ref;
42 bool passed = err <= maxErr;
43 if (print || !passed ){
44 clout << std::setprecision(16);
45 clout << "i:|" << "Value: |"
46 << "Reference: |"
47 << "Error: |"
48 << "MaxError: |"
49 << "Passed:" << std::endl;
50 clout << i << " |" << std::setw(22) << val
51 << " |" << std::setw(22) << ref
52 << " |" << std::setw(22) << err
53 << " |" << std::setw(22) << maxErr
54 << " |" << passed << std::endl;
55 clout << std::setprecision(6);
56 }
57 if (!passed){ allPassed=false; };
58 }
59 if (allPassed){
60 return 0;
61 } else {
62 return 1;
63 }
64}
65
66}//namespace util
67
68}//namespace olb
69
70#endif
class for marking output with some text
int evaluateIntegration(std::vector< T > &testValues, bool print=false)
void print(U data, const std::string &name="", OstreamManager clout=OstreamManager(std::cout,"print"), const char delimiter=',')
Top level namespace for all of OpenLB.