IODA Bundle
test/assimilation/FullGMRES.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 Met Office UK
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #ifndef TEST_ASSIMILATION_FULLGMRES_H_
9 #define TEST_ASSIMILATION_FULLGMRES_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "eckit/testing/Test.h"
15 
19 #include "oops/runs/Test.h"
20 #include "oops/util/Expect.h"
21 #include "oops/util/FloatCompare.h"
22 
24 
25 namespace test {
26 
28 
30  {
31  // Solve Ax = b using the FullGMRES algorithm
32 
33  // Starting guess
34  Vector3D x(1, 2, 3);
35  const Vector3D b(30, 15, -20);
36  // A is a diagonal matrix
37  const Vector3D diagA(10, 5, -5);
38  const Matrix3D A(diagA);
39  // Deliberately incorrect preconditioning in order to trigger
40  // multiple iterations of the minimisation
41  const Vector3D diagprecond(1, 1, 1);
42  const Matrix3D precond(diagprecond);
43  const int maxiter = 10;
44  const double tolerance = 1e-9;
45  // pq and xy are diagnostics for this minimizer
46  std::vector<Vector3D> pq;
47  std::vector<Vector3D> xy;
48 
49  const double normReduction = FullGMRES(x, b, A, precond, maxiter, tolerance, pq, xy);
50  EXPECT(oops::is_close_absolute(x.x(), 3.0, 1.0e-9));
51  EXPECT(oops::is_close_absolute(x.y(), 3.0, 1.0e-9));
52  EXPECT(oops::is_close_absolute(x.z(), 4.0, 1.0e-9));
53  EXPECT(oops::is_close_absolute(normReduction, 0.0, 1.0e-9));
54  }
55 
56  CASE("assimilation/FullGMRES/FullGMRES") {
58  }
59 
60  class FullGMRES : public oops::Test {
61  private:
62  std::string testid() const override {return "test::FullGMRES";}
63  void register_tests() const override {}
64  void clear() const override {}
65  };
66 
67 } // namespace test
68 
69 #endif // TEST_ASSIMILATION_FULLGMRES_H_
Diagonal matrix.
std::string testid() const override
void clear() const override
void register_tests() const override
double x() const
Definition: Vector3D.h:30
double y() const
Definition: Vector3D.h:31
double z() const
Definition: Vector3D.h:32
double FullGMRES(VECTOR &xx, const VECTOR &bb, const AMATRIX &A, const PMATRIX &precond, const int maxiter, const double tolerance, std::vector< VECTOR > &pqVEC, std::vector< VECTOR > &xyVEC)
oops::DiagonalMatrix< Vector3D > Matrix3D
CASE("assimilation/FullGMRES/FullGMRES")
void test_FullGMRES_FullGMRES()
FullGMRES solver for Ax=b.