Debian Codegraph @

dune/istl/test/registermacrosbackwardcompatibilitytest.cc

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 #include <config.h>
4
5 #include <dune/common/parametertree.hh>
6 #include <dune/istl/solvers.hh>
7 #include <dune/istl/solverfactory.hh>
8
9 #include <dune/istl/umfpack.hh>
10
11 namespace Dune {
12 DUNE_REGISTER_SOLVER("dummy_direct", [](auto opInfo, auto op, const ParameterTree& config){
13 using OpInfo = std::decay_t<decltype(opInfo)>;
14 using M = typename OpInfo::matrix_type;
15 using U = typename OpInfo::domain_type;
16 using V = typename OpInfo::range_type;
17 return std::make_shared<UMFPack<M>>();
18 });
19 DUNE_REGISTER_SOLVER("dummy_iterative", [](auto opInfo, auto op, const ParameterTree& config){
20 using OpInfo = std::decay_t<decltype(opInfo)>;
21 using U = typename OpInfo::domain_type;
22 using V = typename OpInfo::range_type;
23 std::shared_ptr<Preconditioner<V,U>> preconditioner = getPreconditionerFromFactory(op, config.sub("preconditioner"));
24 return std::make_shared<CGSolver<V>>(op, preconditioner, config);
25 });
26 DUNE_REGISTER_PRECONDITIONER("dummy_prec", [](auto opInfo, auto op, const ParameterTree& config){
27 using OpInfo = std::decay_t<decltype(opInfo)>;
28 using M = typename OpInfo::matrix_type;
29 using U = typename OpInfo::domain_type;
30 using V = typename OpInfo::range_type;
31 return std::make_shared<Richardson<U,V>>();
32 });
33 }
34
35 using namespace Dune;
36
37 int main(){
38 using Mat = BCRSMatrix<double>;
39 using V = BlockVector<double>;
40 using Op = MatrixAdapter<Mat, V, V>;
41 Mat A;
42 std::shared_ptr<Op> op = std::make_shared<Op>(A);
43
44 initSolverFactories<Op>();
45 ParameterTree config_direct;
46 config_direct["type"] = "dummy_direct";
47 auto direct_solver = getSolverFromFactory(op, config_direct);
48
49 ParameterTree config_iterative;
50 config_iterative["type"] = "dummy_iterative";
51 config_iterative["verbose"] = "1";
52 config_iterative["maxit"] = "100";
53 config_iterative["reduction"] = "1e-6";
54 config_iterative.sub("preconditioner")["type"] = "dummy_prec";
55 auto iterative_solver = getSolverFromFactory(op, config_iterative);
56 return 0;
57 }