Forward compatibility: flex
[foam-extend-3.2.git] / src / dbns / limiter / BarthJespersenLimiter.H
blob334d59f1b4c7393a5af69753fe8a1932da85981d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     BarthJespersenLimiter
27 Description
28     Barth-Jespersen limiter
30 Author
31     Aleksandar Jemcov, Hrvoje Jasak
33 \*---------------------------------------------------------------------------*/
35 #ifndef BarthJespersenLimiter_H
36 #define BarthJespersenLimiter_H
38 #include "vector.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 /*---------------------------------------------------------------------------*\
46                     Class BarthJespersenLimiter Declaration
47 \*---------------------------------------------------------------------------*/
49 class BarthJespersenLimiter
51 public:
53     // Constructors
55         //- Construct null
56         BarthJespersenLimiter()
57         {}
60     // Desctructor - default
63     // Member functions
65         //- Return limiter value
66         inline scalar limiter
67         (
68             const scalar& cellVolume,
69             const scalar& deltaOneMax,
70             const scalar& deltaOneMin,
71             const scalar& deltaTwo
72         )
73         {
74             if (mag(deltaTwo) < SMALL)
75             {
76                 return 1;
77             }
78             else
79             {
80                 scalar deltaTwoStab = stabilise(deltaTwo, VSMALL);
82                 return min
83                 (
84                     max
85                     (
86                         max(deltaOneMax/deltaTwoStab, 0),
87                         max(deltaOneMin/deltaTwoStab, 0)
88                     ),
89                     1
90                 );
91             }
92         }
94         //- Return scalar limiter
95         inline scalar limiter
96         (
97             const scalar& cellVolume,
98             const scalar& faceFlux,
99             const scalar& deltaOneMax,
100             const scalar& deltaOneMin,
101             const vector& gradPhiP,
102             const vector& gradPhiN,
103             const vector& d
104         )
105         {
106             return limiter
107             (
108                 cellVolume,
109                 deltaOneMax,
110                 deltaOneMin,
111                 (d & gradPhiP)
112             );
113         }
115         //- Return vector limiter
116         inline vector limiter
117         (
118             const scalar& cellVolume,
119             const scalar& faceFlux,
120             const vector& deltaOneMax,
121             const vector& deltaOneMin,
122             const tensor& gradPhiP,
123             const tensor& gradPhiN,
124             const vector& d
125         )
126         {
127             vector deltaTwo = d & gradPhiP;
129             return vector
130             (
131                 limiter
132                 (
133                     cellVolume,
134                     deltaOneMax[vector::X],
135                     deltaOneMin[vector::X],
136                     deltaTwo[vector::X]
137                 ),
138                 limiter
139                 (
140                     cellVolume,
141                     deltaOneMax[vector::Y],
142                     deltaOneMin[vector::Y],
143                     deltaTwo[vector::Y]
144                 ),
145                 limiter
146                 (
147                     cellVolume,
148                     deltaOneMax[vector::Z],
149                     deltaOneMin[vector::Z],
150                     deltaTwo[vector::Z]
151                 )
152             );
153         }
155         //- Return limiter for a symmTensor
156         inline symmTensor limiter
157         (
158             const scalar& cellVolume,
159             const scalar& faceFlux,
160             const symmTensor& deltaOneMax,
161             const symmTensor& deltaOneMin,
162             const vector& gradPhiPXX,
163             const vector& gradPhiNXX,
164             const vector& gradPhiPXY,
165             const vector& gradPhiNXY,
166             const vector& gradPhiPXZ,
167             const vector& gradPhiNXZ,
168             const vector& gradPhiPYY,
169             const vector& gradPhiNYY,
170             const vector& gradPhiPYZ,
171             const vector& gradPhiNYZ,
172             const vector& gradPhiPZZ,
173             const vector& gradPhiNZZ,
174             const vector& d
175         )
176         {
177             return symmTensor
178             (
179                 limiter
180                 (
181                     cellVolume,
182                     deltaOneMax[0],
183                     deltaOneMin[0],
184                     d & gradPhiPXX
185                 ),
186                 limiter
187                 (
188                     cellVolume,
189                     deltaOneMax[1],
190                     deltaOneMin[1],
191                     d & gradPhiPXY
192                 ),
193                 limiter
194                 (
195                     cellVolume,
196                     deltaOneMax[2],
197                     deltaOneMin[2],
198                     d & gradPhiPXZ
199                 ),
200                 limiter
201                 (
202                     cellVolume,
203                     deltaOneMax[3],
204                     deltaOneMin[3],
205                     d & gradPhiPYY
206                 ),
207                 limiter
208                 (
209                     cellVolume,
210                     deltaOneMax[4],
211                     deltaOneMin[4],
212                     d & gradPhiPYZ
213                 ),
214                 limiter
215                 (
216                     cellVolume,
217                     deltaOneMax[5],
218                     deltaOneMin[5],
219                     d & gradPhiPZZ
220                 )
221             );
222         }
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 } // End namespace Foam
230 #endif
232 // ************************************************************************* //