Dune Core Modules (2.5.2)

scalarproducts.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_ISTL_SCALARPRODUCTS_HH
4 #define DUNE_ISTL_SCALARPRODUCTS_HH
5 
6 #include <cmath>
7 #include <complex>
8 #include <iostream>
9 #include <iomanip>
10 #include <string>
11 
12 #include "bvector.hh"
13 #include "solvercategory.hh"
14 
15 
16 namespace Dune {
43  template<class X>
44  class ScalarProduct {
45  public:
47  typedef X domain_type;
48  typedef typename X::field_type field_type;
49  typedef typename FieldTraits<field_type>::real_type real_type;
50 
55  virtual field_type dot (const X& x, const X& y) = 0;
56 
60  virtual real_type norm (const X& x) = 0;
61 
63  virtual ~ScalarProduct () {}
64  };
65 
75  template<class X, class C, int c>
77  {
79  typedef C communication_type;
80 
81  enum {
84  };
85  };
86 
87 
88 
89  //=====================================================================
90  // Implementation for ISTL-matrix based operator
91  //=====================================================================
92 
94  template<class X>
95  class SeqScalarProduct : public ScalarProduct<X>
96  {
97  public:
99  typedef X domain_type;
100  typedef typename X::field_type field_type;
101  typedef typename FieldTraits<field_type>::real_type real_type;
102 
104  enum {category=SolverCategory::sequential};
105 
110  virtual field_type dot (const X& x, const X& y)
111  {
112  return x.dot(y);
113  }
114 
118  virtual real_type norm (const X& x)
119  {
120  return x.two_norm();
121  }
122  };
123 
124  template<class X, class C>
125  struct ScalarProductChooser<X,C,SolverCategory::sequential>
126  {
128  typedef SeqScalarProduct<X> ScalarProduct;
129 
130  enum {
133  };
134 
135  static ScalarProduct* construct(const C&)
136  {
137  return new ScalarProduct();
138  }
139  };
140 
141 
144 } // end namespace
145 
146 #endif
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Base class for scalar product and norm computation.
Definition: scalarproducts.hh:44
virtual field_type dot(const X &x, const X &y)=0
Dot product of two vectors. It is assumed that the vectors are consistent on the interior+border part...
X domain_type
export types, they come from the derived class
Definition: scalarproducts.hh:47
virtual ~ScalarProduct()
every abstract base class has a virtual destructor
Definition: scalarproducts.hh:63
virtual real_type norm(const X &x)=0
Norm of a right-hand side vector. The vector must be consistent on the interior+border partition.
Default implementation for the scalar case.
Definition: scalarproducts.hh:96
X domain_type
export types
Definition: scalarproducts.hh:99
virtual real_type norm(const X &x)
Norm of a right-hand side vector. The vector must be consistent on the interior+border partition.
Definition: scalarproducts.hh:118
virtual field_type dot(const X &x, const X &y)
Dot product of two vectors. In the complex case, the first argument is conjugated....
Definition: scalarproducts.hh:110
Dune namespace.
Definition: alignment.hh:11
Choose the approriate scalar product for a solver category.
Definition: scalarproducts.hh:77
C communication_type
The type of the communication object.
Definition: scalarproducts.hh:79
@ solverCategory
The solver category.
Definition: scalarproducts.hh:83
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:21
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 8, 22:30, 2024)