DUNE PDELab (git)

solver.hh
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=8 sw=2 sts=2:
3#ifndef DUNE_PDELAB_BACKEND_SOLVER_HH
4#define DUNE_PDELAB_BACKEND_SOLVER_HH
5
7#include <dune/pdelab/backend/interface.hh>
8
9namespace Dune {
10 namespace PDELab {
11
15
16 struct SequentialNorm
17 {
21 template<class V>
22 typename Dune::template FieldTraits<typename V::ElementType >::real_type norm(const V& v) const
23 {
24 return v.two_norm();
25 }
26 };
27
28 // Status information of a linear solver
29 template<class RFType>
30 struct LinearSolverResult
31 {
32 bool converged; // Solver converged
33 unsigned int iterations; // number of iterations
34 double elapsed; // total user time in seconds
35 RFType reduction; // defect reduction
36 RFType conv_rate; // convergence rate (average reduction per step)
37
38 LinearSolverResult()
39 {
40 clear();
41 }
42
43 void clear()
44 {
45 converged = false;
46 iterations = 0;
47 elapsed = 0.0;
48 reduction = 0.0;
49 conv_rate = 0.0;
50 }
51 };
52
53 class LinearResultStorage
54 {
55 public:
57 const Dune::PDELab::LinearSolverResult<double>& result() const
58 {
59 return res;
60 }
61
62 protected:
63 Dune::PDELab::LinearSolverResult<double> res;
64 };
65
67
68
69 template <typename LS, typename = void>
70 struct LinearSolverHasIsMatrixFree : std::false_type {};
71
73 template <typename LS>
74 struct LinearSolverHasIsMatrixFree<LS, std::void_t<decltype(std::declval<LS>().isMatrixFree)>> : std::true_type {};
75
80 template <typename LS>
81 constexpr bool linearSolverIsMatrixFree(){
82 if constexpr (LinearSolverHasIsMatrixFree<LS>::value){
83 if constexpr (LS::isMatrixFree){
84 return true;
85 }
86 }
87 else{
88 return false;
89 }
90 }
91
92 } // end namespace PDELab
93} // end namespace Dune
94
95
96#endif // DUNE_PDELAB_BACKEND_SOLVER_HH
Implements a vector constructed from a given type representing a field and a compile-time given size.
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)