NormSupport.hpp
Go to the documentation of this file.
1/*===========================================================================
2//
3// File: NormSupport.hpp
4//
5// Created: 2011-10-04 19:37:35+0200
6//
7// Authors: Ingeborg S. Ligaarden <Ingeborg.Ligaarden@sintef.no>
8// Jostein R. Natvig <Jostein.R.Natvig@sintef.no>
9// Halvor M. Nilsen <HalvorMoll.Nilsen@sintef.no>
10// Atgeirr F. Rasmussen <atgeirr@sintef.no>
11// Bård Skaflestad <Bard.Skaflestad@sintef.no>
12//
13//==========================================================================*/
14
15
16/*
17 Copyright 2011 SINTEF ICT, Applied Mathematics.
18 Copyright 2011 Statoil ASA.
19
20 This file is part of the Open Porous Media Project (OPM).
21
22 OPM is free software: you can redistribute it and/or modify
23 it under the terms of the GNU General Public License as published by
24 the Free Software Foundation, either version 3 of the License, or
25 (at your option) any later version.
26
27 OPM is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public License
33 along with OPM. If not, see <http://www.gnu.org/licenses/>.
34*/
35
36#ifndef OPM_NORMSUPPORT_HPP_HEADER
37#define OPM_NORMSUPPORT_HPP_HEADER
38
39#include <algorithm>
40#include <cmath>
41#include <functional>
42#include <numeric>
43
44namespace Opm {
45 namespace ImplicitTransportDefault {
46 template <typename T>
47 class MaxAbs {
48 public:
49 double
50 operator()(double x, const T& y) {
51 return std::max(std::abs(x), std::abs(y));
52 }
53
54 static double
55 postprocess(double nrm_inf) { return nrm_inf; }
56 };
57
58 template <typename T>
59 class SumAbs {
60 public:
61 double
62 operator()(double x, const T& y) {
63 return std::abs(x) + std::abs(y);
64 }
65
66 static double
67 postprocess(double nrm_1) { return nrm_1; }
68 };
69
70 template <typename T>
71 class Euclid {
72 public:
73 double
74 operator()(double x, const T& y) {
75 const double ay = ::std::abs(y);
76
77 return std::abs(x) + ay*ay;
78 }
79
80 static double
81 postprocess(double nrm2) { return ::std::sqrt(nrm2); }
82 };
83
84 template <class Vector, template <typename> class NormImpl>
86 public:
87 static double
88 norm(const Vector& v) {
89 typedef typename Vector::value_type VT;
90
91 double nrm = ::std::accumulate(v.begin(), v.end(), VT(0.0),
92 NormImpl<VT>());
93
94 return NormImpl<VT>::postprocess(nrm);
95 }
96 };
97 }
98}
99
100#endif /* OPM_NORMSUPPORT_HPP_HEADER */
static double norm(const Vector &v)
Definition: NormSupport.hpp:88
Definition: NormSupport.hpp:71
double operator()(double x, const T &y)
Definition: NormSupport.hpp:74
static double postprocess(double nrm2)
Definition: NormSupport.hpp:81
Definition: NormSupport.hpp:47
double operator()(double x, const T &y)
Definition: NormSupport.hpp:50
static double postprocess(double nrm_inf)
Definition: NormSupport.hpp:55
Definition: NormSupport.hpp:59
static double postprocess(double nrm_1)
Definition: NormSupport.hpp:67
double operator()(double x, const T &y)
Definition: NormSupport.hpp:62
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition: matrixops.hpp:33
Definition: ImplicitAssembly.hpp:43