DGBasis.hpp
1 /*
2  Copyright 2013 SINTEF ICT, Applied Mathematics.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_DGBASIS_HEADER_INCLUDED
21 #define OPM_DGBASIS_HEADER_INCLUDED
22 
23 #include <vector>
24 
25 struct UnstructuredGrid;
26 
27 namespace Opm
28 {
29 
32  {
33  public:
35  virtual ~DGBasisInterface();
36 
38  virtual int numBasisFunc() const = 0;
39 
41  virtual int dimensions() const = 0;
42 
44  virtual int degree() const = 0;
45 
49  virtual void eval(const int cell,
50  const double* x,
51  double* f_x) const = 0;
52 
58  virtual void evalGrad(const int cell,
59  const double* x,
60  double* grad_f_x) const = 0;
61 
68  virtual void addConstant(const double increment,
69  double* coefficients) const = 0;
70 
78  virtual void multiplyGradient(const double factor,
79  double* coefficients) const = 0;
80 
87  double evalFunc(const int cell,
88  const double* coefficients,
89  const double* x) const;
90 
93  virtual double functionAverage(const double* coefficients) const = 0;
94 
95  private:
96  mutable std::vector<double> bvals_; // For evalFunc().
97  };
98 
99 
100 
101 
102 
112  {
113  public:
117  DGBasisBoundedTotalDegree(const UnstructuredGrid& grid, const int degree);
118 
120  virtual ~DGBasisBoundedTotalDegree();
121 
123  virtual int numBasisFunc() const;
124 
126  virtual int dimensions() const;
127 
129  virtual int degree() const;
130 
134  virtual void eval(const int cell,
135  const double* x,
136  double* f_x) const;
137 
143  virtual void evalGrad(const int cell,
144  const double* x,
145  double* grad_f_x) const;
146 
153  virtual void addConstant(const double increment,
154  double* coefficients) const;
155 
163  virtual void multiplyGradient(const double factor,
164  double* coefficients) const;
165 
168  virtual double functionAverage(const double* coefficients) const;
169 
170  private:
171  const UnstructuredGrid& grid_;
172  const int degree_;
173  };
174 
175 
176 
177 
189  {
190  public:
194  DGBasisMultilin(const UnstructuredGrid& grid, const int degree);
195 
197  virtual ~DGBasisMultilin();
198 
200  virtual int numBasisFunc() const;
201 
203  virtual int dimensions() const;
204 
206  virtual int degree() const;
207 
211  virtual void eval(const int cell,
212  const double* x,
213  double* f_x) const;
214 
220  virtual void evalGrad(const int cell,
221  const double* x,
222  double* grad_f_x) const;
223 
230  virtual void addConstant(const double increment,
231  double* coefficients) const;
232 
240  virtual void multiplyGradient(const double factor,
241  double* coefficients) const;
242 
245  virtual double functionAverage(const double* coefficients) const;
246 
247  private:
248  const UnstructuredGrid& grid_;
249  const int degree_;
250 
251  };
252 
253 
254 
255 
256 } // namespace Opm
257 
258 
259 #endif // OPM_DGBASIS_HEADER_INCLUDED
virtual double functionAverage(const double *coefficients) const
Compute the average of the function f = sum_i c_i b_i.
Definition: DGBasis.cpp:336
virtual int dimensions() const
The number of space dimensions.
Definition: DGBasis.cpp:94
virtual ~DGBasisMultilin()
Destructor.
Definition: DGBasis.cpp:205
A class providing discontinuous Galerkin basis functions of multi-degree 1 (bilinear or trilinear fun...
Definition: DGBasis.hpp:188
virtual void addConstant(const double increment, double *coefficients) const
Modify basis coefficients to add to the function value.
Definition: DGBasis.cpp:307
virtual void evalGrad(const int cell, const double *x, double *grad_f_x) const
Evaluate gradients of all basis functions associated with cell at x, writing to grad_f_x.
Definition: DGBasis.cpp:271
virtual int numBasisFunc() const =0
The number of basis functions per cell.
virtual void multiplyGradient(const double factor, double *coefficients) const
Modify basis coefficients to change the function&#39;s slope.
Definition: DGBasis.cpp:167
virtual double functionAverage(const double *coefficients) const
Compute the average of the function f = sum_i c_i b_i.
Definition: DGBasis.cpp:178
virtual double functionAverage(const double *coefficients) const =0
Compute the average of the function f = sum_i c_i b_i.
virtual int degree() const
The polynomial degree of the basis functions.
Definition: DGBasis.cpp:231
Definition: AnisotropicEikonal.cpp:446
virtual void addConstant(const double increment, double *coefficients) const =0
Modify basis coefficients to add to the function value.
virtual void multiplyGradient(const double factor, double *coefficients) const
Modify basis coefficients to change the function&#39;s slope.
Definition: DGBasis.cpp:324
virtual int numBasisFunc() const
The number of basis functions per cell.
Definition: DGBasis.cpp:210
virtual int numBasisFunc() const
The number of basis functions per cell.
Definition: DGBasis.cpp:79
virtual void evalGrad(const int cell, const double *x, double *grad_f_x) const
Evaluate gradients of all basis functions associated with cell at x, writing to grad_f_x.
Definition: DGBasis.cpp:134
Base class for Discontinuous Galerkin bases, intended for time-of-flight computations.
Definition: DGBasis.hpp:31
virtual void multiplyGradient(const double factor, double *coefficients) const =0
Modify basis coefficients to change the function&#39;s slope.
virtual int dimensions() const
The number of space dimensions.
Definition: DGBasis.cpp:225
virtual ~DGBasisInterface()
Virtual destructor.
Definition: DGBasis.cpp:33
virtual void eval(const int cell, const double *x, double *f_x) const
Evaluate all basis functions associated with cell at x, writing to f_x.
Definition: DGBasis.cpp:239
virtual int degree() const =0
The polynomial degree of the basis functions.
DGBasisBoundedTotalDegree(const UnstructuredGrid &grid, const int degree)
Constructor.
Definition: DGBasis.cpp:60
virtual void eval(const int cell, const double *x, double *f_x) const
Evaluate all basis functions associated with cell at x, writing to f_x.
Definition: DGBasis.cpp:108
double evalFunc(const int cell, const double *coefficients, const double *x) const
Evaluate function f = sum_i c_i b_i at the point x.
Definition: DGBasis.cpp:43
virtual void eval(const int cell, const double *x, double *f_x) const =0
Evaluate all basis functions associated with cell at x, writing to f_x.
virtual int dimensions() const =0
The number of space dimensions.
virtual ~DGBasisBoundedTotalDegree()
Destructor.
Definition: DGBasis.cpp:74
virtual int degree() const
The polynomial degree of the basis functions.
Definition: DGBasis.cpp:100
A class providing discontinuous Galerkin basis functions of bounded total degree. ...
Definition: DGBasis.hpp:111
DGBasisMultilin(const UnstructuredGrid &grid, const int degree)
Constructor.
Definition: DGBasis.cpp:191
virtual void evalGrad(const int cell, const double *x, double *grad_f_x) const =0
Evaluate gradients of all basis functions associated with cell at x, writing to grad_f_x.
virtual void addConstant(const double increment, double *coefficients) const
Modify basis coefficients to add to the function value.
Definition: DGBasis.cpp:154