DUNE-ACFEM (2.5.1)

solverselector.hh
1#ifndef __DUNE_ACFEM_SOLVER_SELECTOR_HH__
2#define __DUNE_ACFEM_SOLVER_SELECTOR_HH__
3
4// include linear operators
5#include <dune/fem/operator/linear/istloperator.hh>
6#include <dune/fem/solver/istlsolver.hh>
7#include <dune/fem/operator/linear/petscoperator.hh>
8#include <dune/fem/solver/petscsolver.hh>
9#include <dune/fem/operator/linear/spoperator.hh>
10#include <dune/fem/solver/cginverseoperator.hh>
11
12#include "../models/modelinterface.hh"
13
14#ifndef HAVE_PETSC
15# define HAVE_PETSC false
16#endif
17#ifndef WANT_PETSC
18# define WANT_PETSC false
19#endif
20#ifndef HAVE_DUNE_ISTL
21# define HAVE_DUNE_ISTL false
22#endif
23#ifndef WANT_ISTL
24# define WANT_ISTL false
25#endif
26
27namespace Dune {
28
29 namespace ACFem {
30
39 {
40 enum Family {
41 PETSC,
42 ISTL,
43 FEM
44 };
45 enum SolverType {
46 CG,
47 MINRES,
48 BICGSTAB,
49 GMRES
50 };
51 static const Family family =
52 ((HAVE_DUNE_ISTL && WANT_ISTL)
53 ? ISTL
54 : ((HAVE_PETSC && WANT_PETSC)
55 ? PETSC
56 : FEM));
57 };
58
88 template<class DiscreteFunctionType, class OperatorParts, SolverFamily::Family family = SolverFamily::family>
90 {
92
93 static_assert(family != SolverFamily::FEM ||
95 "No non-linear or indefinite problems with bare Dune::Fem CG solver");
96
97 template<SolverFamily::Family fam, bool dummy = false>
98 struct OperatorSelector;
99
100#if HAVE_DUNE_ISTL && WANT_ISTL
101 template<bool dummy>
102 struct OperatorSelector<SolverFamily::ISTL, dummy>
103 {
104 typedef
105 Fem::ISTLLinearOperator<DiscreteFunctionType, DiscreteFunctionType>
106 LinearOperatorType;
107
108 // Choose PCG if symmetric and semi-definite, otherwise MINRES
109 // if symmetric, otherwise BICGSTAB (should we use GMRES?)
110 typedef
111 typename std::conditional<
113 typename std::conditional<
115 Fem::ISTLCGOp<DiscreteFunctionType, LinearOperatorType>,
116 Fem::ISTLMINResOp<DiscreteFunctionType, LinearOperatorType> >::type,
117 Fem::ISTLGMResOp<DiscreteFunctionType, LinearOperatorType>
118 /*Fem::ISTLBICGSTABOp<DiscreteFunctionType, LinearOperatorType>*/ >::type
119 LinearInverseOperatorType;
120 };
121#endif
122
123#if HAVE_PETSC && WANT_PETSC
124 template<bool dummy>
125 struct OperatorSelector<SolverFamily::PETSC, dummy>
126 {
127 typedef
128 Fem::PetscLinearOperator<DiscreteFunctionType, DiscreteFunctionType>
129 LinearOperatorType;
130
131 // The PETSC inverse operator is configured at run-time.
132 typedef
133 Fem::PetscInverseOperator<DiscreteFunctionType, LinearOperatorType>
134 LinearInverseOperatorType;
135 };
136#endif
137
138 template<bool dummy>
139 struct OperatorSelector<SolverFamily::FEM, dummy>
140 {
141 typedef
142 Fem::SparseRowLinearOperator<DiscreteFunctionType, DiscreteFunctionType>
143 LinearOperatorType;
144 typedef
145 Fem::CGInverseOperator<DiscreteFunctionType>
146 LinearInverseOperatorType;
147 };
148
149 typedef typename OperatorSelector<family>::LinearOperatorType LinearOperatorType;
150 typedef typename OperatorSelector<family>::LinearInverseOperatorType LinearInverseOperatorType;
151 };
152
154
155 } // ACFEM::
156
157} // Dune::
158
159
160#endif // __DUNE_ACFEM_SOLVER_SELECTOR_HH__
Interface class for second order elliptic models.
Definition: operatorparts.hh:92
@ isSymmetric
Define to true for the symmetric case.
Definition: operatorparts.hh:120
@ isSemiDefinite
Define to true for the non-indefinite case (non trivial kernel is allowed).
Definition: operatorparts.hh:121
Define some symbolic constants for SolverSelector and "parse" some preprocessort defines.
Definition: solverselector.hh:39
Select one appropriate (linear) solver depending on whether the model is symmetric and/or semidefinit...
Definition: solverselector.hh:90
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)