LifeV
VerifySolutions.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2014 EPFL, Politecnico di Milano, Emory University
6 
7  This file is part of LifeV.
8 
9  LifeV is free software; you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  LifeV is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
21 
22 *******************************************************************************
23 */
24 //@HEADER
25 
26 /*!
27  @file VerifySolutions.hpp
28  @brief This files contains the description of the VerifySolutions class, which is a helper class for checking results by
29  Computing the mean norm and correlation matrix of vectors
30 
31  @author Simone Deparis <simone.deparis@epfl.ch>
32  @date 12-05-2014
33  @mantainer Simone Deparis <simone.deparis@epfl.ch>
34 
35  */
36 
37 #ifndef VERIFYSOLUTIONS_HPP_
38 #define VERIFYSOLUTIONS_HPP_
39 
40 #include <Epetra_SerialDenseMatrix.h>
41 #include <lifev/core/LifeV.hpp>
42 #include <list>
43 
44 #include <lifev/core/array/VectorEpetra.hpp>
45 
46 namespace LifeV
47 {
48 
49 /** This class helps the testsuites in verifying that the solutions
50  * do not change from one execution to the other.
51  * We want to check if the solutions are correct between versions.
52  * we want to produce a small number of scalars and check they are always the same.
53  *
54  * Given: u_0, ustd::placeholders::_1, ...
55  *
56  * mean: u = mean u_j
57  *
58  * correlation matrix: (u_i-u , u_j-u) i,j=0,1,...
59  *
60  * Store the correlation matrix and (u,u)
61  * each entry of the matrix shall be equal to the stored one up to a tolerance.
62  *
63  * Example of use taken from \ref testsuite/verify_solution/main.cpp
64  *
65  * \snippet testsuite/verify_solution/main.cpp Example of use of VerifySolutions
66  */
68 {
69 public:
70 
71  /*! @name Constructors and destructor
72  */
73  //@{
74 
76  virtual ~VerifySolutions();
77 
78  //@}
79 
80  /*! @name Methods
81  */
82  //@{
83 
84  //! Add a vector to the list of stored vectors.
85  /*!
86  * The vector is copied in a list container.
87  * \param newVector vector to be copied and stored
88  */
89  void PushBack (VectorEpetra const& newVector);
90 
91  //! Compute the correlation matrix and norm of the mean.
92  /*!
93  * This has to be called after all vectors have been PushBack and befor the Checks
94  */
95  void ComputeCorrelation();
96 
97  //! Checks that the current Correlation matrix is the same as the one provided by the user.
98  /*!
99  * Usually the reference matrix is computed with a solution set which is known to be correct.
100  * \param refM precomputed correlation matrix
101  * \param tol Tolerance for checking same results
102  */
103  bool Check ( Epetra_SerialDenseMatrix const& refM, Real tol) const;
104 
105  //! Checks that the current norm of the mean of the vectors is the same as the one provided by the user.
106  /*!
107  * Usually the norm of the mean is computed with a solution set which is known to be correct.
108  * \param referenceMean precomputed norm of the mean of the vectors
109  * \param tol Tolerance for checking same results
110  */
111  bool Check ( Real referenceMean, Real tol) const;
112 
113  //! Print Mean and Correlation matrix as c++ lines ready to be inserted into the test.
114  void Print () const;
115 
116 private:
119 
121 
122 };
123 
124 } /* namespace LifeV */
125 #endif /* VERIFYSOLUTIONS_HPP_ */
VectorEpetra - The Epetra Vector format Wrapper.
std::list< VectorEpetra > M_VectorList
bool Check(Epetra_SerialDenseMatrix const &refM, Real tol) const
Checks that the current Correlation matrix is the same as the one provided by the user...
void updateInverseJacobian(const UInt &iQuadPt)
Epetra_SerialDenseMatrix M_CorrelationMatrix
void Print() const
Print Mean and Correlation matrix as c++ lines ready to be inserted into the test.
void ComputeCorrelation()
Compute the correlation matrix and norm of the mean.
void PushBack(VectorEpetra const &newVector)
Add a vector to the list of stored vectors.
double Real
Generic real data.
Definition: LifeV.hpp:175
This class helps the testsuites in verifying that the solutions do not change from one execution to t...
bool Check(Real referenceMean, Real tol) const
Checks that the current norm of the mean of the vectors is the same as the one provided by the user...