Memosa-FVM  0.2
FluxLimiters.h
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #ifndef _FLUXLIMITERS_H_
6 #define _FLUXLIMITERS_H_
7 
8 #include <math.h>
9 
10 struct minModLim
11 {
12 
13  template<class T>
14  T operator()(const T r)
15  {return max(0., min(1., r));}
16 
17 };
18 
19 struct vanLeer
20 {
21  template<class T>
22  T operator()(const T a, const T b) const
23  {
24  if (b!=0.)
25  return (a/b+fabs(a/b))/(1+fabs(a/b));
26  else
27  return 0.;
28  }
29 
30  template<class T>
31  T operator()(const T r) const
32  {
33  if (r!=0.)
34  return (r+fabs(r))/(1+fabs(r));
35  else
36  return 0.;
37  }
38 
39 };
40 
41 struct superbee
42 {
43  template<class T>
44  T operator()(const T a, const T b) const
45  {
46  if(b!=0.)
47  return max(0., max(min(1., 2.*a/b), min(2., a/b)));
48  }
49 };
50 
51 struct vanAlbada1
52 {
53  template<class T>
54  T operator()(const T r)
55  {return (pow(r,2)+r)/(pow(r,2)+1.);}
56 };
57 
58 struct ospre
59 {
60 
61  template<class T>
62  T operator()(const T a, const T b) const
63  {
64  if(a>0 && b!=0.)
65  return 1.5*(pow(a/b,2)+a/b)/(pow(a/b,2)+a/b+1.);
66  return 0.;
67  }
68 
69 };
70 
71 template<class T, class LimitFunc>
72  void computeLimitCoeff(T& lc, const T x, const T& dx,
73  const T& min, const T& max, const LimitFunc& f)
74 {
75  T thislc = NumTypeTraits<T>::getUnity();
76  if (dx>0)
77  thislc = f(dx,max-x);
78  else
79  thislc = f(-dx,x-min);
80  if (thislc < lc)
81  lc = thislc;
82 };
83 
84 template<class T, class LimitFunc>
85  void computeLimitCoeff2(T& lc, const T x, const T& dx,
86  const T& min, const T& max, const LimitFunc& f)
87 {
88  T thislc = NumTypeTraits<T>::getUnity();
89  if (dx>0)
90  thislc = f(dx/(max-x));
91  else
92  thislc = f(-dx/(x-min));
93  if (thislc < lc)
94  lc = thislc;
95 };
96 
97 
98 #endif
T operator()(const T r) const
Definition: FluxLimiters.h:31
T operator()(const T r)
Definition: FluxLimiters.h:54
double max(double x, double y)
Definition: Octree.cpp:18
void computeLimitCoeff(T &lc, const T x, const T &dx, const T &min, const T &max, const LimitFunc &f)
Definition: FluxLimiters.h:72
T operator()(const T a, const T b) const
Definition: FluxLimiters.h:22
void computeLimitCoeff2(T &lc, const T x, const T &dx, const T &min, const T &max, const LimitFunc &f)
Definition: FluxLimiters.h:85
T operator()(const T r)
Definition: FluxLimiters.h:14
Tangent fabs(const Tangent &a)
Definition: Tangent.h:312
T operator()(const T a, const T b) const
Definition: FluxLimiters.h:62
double min(double x, double y)
Definition: Octree.cpp:23
T operator()(const T a, const T b) const
Definition: FluxLimiters.h:44