DUNE PDELab (2.7)

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
13
14#include "bvector.hh"
15#include "solvercategory.hh"
16
17
18namespace Dune {
47 template<class X>
49 public:
51 typedef X domain_type;
52 typedef typename X::field_type field_type;
53 typedef typename FieldTraits<field_type>::real_type real_type;
54
59 virtual field_type dot (const X& x, const X& y) const
60 {
61 return x.dot(y);
62 }
63
67 virtual real_type norm (const X& x) const
68 {
69 return x.two_norm();
70 }
71
74 {
76 }
77
79 virtual ~ScalarProduct () {}
80 };
81
93 template<class X, class C>
95 {
96 public:
101 typedef X domain_type;
103 typedef typename X::field_type field_type;
104 typedef typename FieldTraits<field_type>::real_type real_type;
110
117 : _communication(com), _category(cat)
118 {}
119
124 virtual field_type dot (const X& x, const X& y) const override
125 {
126 field_type result(0);
127 _communication.dot(x,y,result); // explicitly loop and apply masking
128 return result;
129 }
130
134 virtual real_type norm (const X& x) const override
135 {
136 return _communication.norm(x);
137 }
138
140 virtual SolverCategory::Category category() const override
141 {
142 return _category;
143 }
144
145 private:
146 const communication_type& _communication;
147 SolverCategory::Category _category;
148 };
149
151 template<class X>
153 {
154 using ScalarProduct<X>::ScalarProduct;
155 };
156
162 template<class X, class C>
164 {
165 public:
166 NonoverlappingSchwarzScalarProduct (const C& comm) :
168 };
169
181 template<class X, class C>
183 {
184 public:
185 OverlappingSchwarzScalarProduct (const C& comm) :
187 };
188
202 template<class X, class Comm>
203 std::shared_ptr<ScalarProduct<X>> createScalarProduct(const Comm& comm, SolverCategory::Category category)
204 {
205 switch(category)
206 {
208 return
209 std::make_shared<ScalarProduct<X>>();
210 default:
211 return
212 std::make_shared<ParallelScalarProduct<X,Comm>>(comm,category);
213 }
214 }
215
216} // end namespace Dune
217
218#endif
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Nonoverlapping Scalar Product with communication object.
Definition: scalarproducts.hh:164
Scalar product for overlapping Schwarz methods.
Definition: scalarproducts.hh:183
Scalar product for overlapping Schwarz methods.
Definition: scalarproducts.hh:95
virtual field_type dot(const X &x, const X &y) const override
Dot product of two vectors. It is assumed that the vectors are consistent on the interior+border part...
Definition: scalarproducts.hh:124
virtual SolverCategory::Category category() const override
Category of the scalar product (see SolverCategory::Category)
Definition: scalarproducts.hh:140
C communication_type
The type of the communication object.
Definition: scalarproducts.hh:109
ParallelScalarProduct(const communication_type &com, SolverCategory::Category cat)
Definition: scalarproducts.hh:116
X domain_type
The type of the vector to compute the scalar product on.
Definition: scalarproducts.hh:101
X::field_type field_type
The field type used by the vector type domain_type.
Definition: scalarproducts.hh:103
virtual real_type norm(const X &x) const override
Norm of a right-hand side vector. The vector must be consistent on the interior+border partition.
Definition: scalarproducts.hh:134
Base class for scalar product and norm computation.
Definition: scalarproducts.hh:48
virtual field_type dot(const X &x, const X &y) const
Dot product of two vectors. It is assumed that the vectors are consistent on the interior+border part...
Definition: scalarproducts.hh:59
virtual SolverCategory::Category category() const
Category of the scalar product (see SolverCategory::Category)
Definition: scalarproducts.hh:73
X domain_type
export types, they come from the derived class
Definition: scalarproducts.hh:51
virtual ~ScalarProduct()
every abstract base class has a virtual destructor
Definition: scalarproducts.hh:79
virtual real_type norm(const X &x) const
Norm of a right-hand side vector. The vector must be consistent on the interior+border partition.
Definition: scalarproducts.hh:67
Default implementation for the scalar case.
Definition: scalarproducts.hh:153
A few common exception classes.
Dune namespace.
Definition: alignedallocator.hh:14
std::shared_ptr< ScalarProduct< X > > createScalarProduct(const Comm &comm, SolverCategory::Category category)
Choose the approriate scalar product for a solver category.
Definition: scalarproducts.hh:203
Category
Definition: solvercategory.hh:21
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:23
@ nonoverlapping
Category for non-overlapping solvers.
Definition: solvercategory.hh:25
@ overlapping
Category for overlapping solvers.
Definition: solvercategory.hh:27
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)