Forward compatibility: flex
[foam-extend-3.2.git] / src / dbns / limiter / VenkatakrishnanLimiter.H
blob8f8c6fe1fba1faf0e021eab2973cbca30c02d526
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     VenkatakrishnanLimiter
27 Description
28     Venkatakrishnan differentiable limiter
30 Author
31     Aleksandar Jemcov
32     Updated by Hrvoje Jasak
34 \*---------------------------------------------------------------------------*/
36 #ifndef VenkatakrishnanLimiter_H
37 #define VenkatakrishnanLimiter_H
39 #include "vector.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 /*---------------------------------------------------------------------------*\
47                   Class VenkatakrishnanLimiter Declaration
48 \*---------------------------------------------------------------------------*/
50 class VenkatakrishnanLimiter
52     // Private data
54         //- Limiter value
55         scalar k_;
57 public:
59     // Constructor
61         //- Construct null
62         VenkatakrishnanLimiter()
63         :
64             k_(5)
65         {}
67         //- Return limiter
68         inline scalar limiter
69         (
70             const scalar& cellVolume,
71             const scalar& deltaOneMax,
72             const scalar& deltaOneMin,
73             const scalar& deltaTwo
74         )
75         {
76             scalar epsilonSquare = pow3(k_)*cellVolume;
78             if (deltaTwo > 0)
79             {
80                 return max
81                 (
82                     min
83                     (
84                         (
85                             (sqr(deltaOneMax) + epsilonSquare)*deltaTwo
86                           + 2*sqr(deltaTwo)*deltaOneMax
87                         )/
88                         stabilise
89                         (
90                             deltaTwo*
91                             (
92                                 sqr(deltaOneMax)
93                               + 2.0*sqr(deltaTwo)
94                               + deltaOneMax*deltaTwo
95                               + epsilonSquare
96                             ),
97                             SMALL
98                         ),
99                         1
100                     ),
101                     0
102                 );
103             }
104             else if (deltaTwo < 0)
105             {
106                 return max
107                 (
108                     min
109                     (
110                         (
111                             (sqr(deltaOneMin) + epsilonSquare)*deltaTwo
112                           + 2*sqr(deltaTwo)*deltaOneMin
113                         )/
114                         stabilise
115                         (
116                             deltaTwo*
117                             (
118                                 sqr(deltaOneMin)
119                               + 2.0*sqr(deltaTwo) + deltaOneMin*deltaTwo
120                               + epsilonSquare
121                             ),
122                             SMALL
123                         ),
124                         1
125                     ),
126                     0
127                 );
128             }
129             else
130             {
131                 return 1;
132             }
133         }
135         //- Return limiter for a scalar
136         inline scalar limiter
137         (
138             const scalar& cellVolume,
139             const scalar& faceFlux,
140             const scalar& deltaOneMax,
141             const scalar& deltaOneMin,
142             const vector& gradPhiP,
143             const vector& gradPhiN,
144             const vector& d
145         )
146         {
147             return limiter
148             (
149                 cellVolume,
150                 deltaOneMax,
151                 deltaOneMin,
152                 d & gradPhiP
153             );
154         }
156         //- Return limiter for a vector
157         inline vector limiter
158         (
159             const scalar& cellVolume,
160             const scalar& faceFlux,
161             const vector& deltaOneMax,
162             const vector& deltaOneMin,
163             const tensor& gradPhiP,
164             const tensor& gradPhiN,
165             const vector& d
166         )
167         {
168             vector deltaTwo = d & gradPhiP;
170             return vector
171             (
172                 limiter
173                 (
174                     cellVolume,
175                     deltaOneMax[vector::X],
176                     deltaOneMin[vector::X],
177                     deltaTwo[vector::X]
178                 ),
179                 limiter
180                 (
181                     cellVolume,
182                     deltaOneMax[vector::Y],
183                     deltaOneMin[vector::Y],
184                     deltaTwo[vector::Y]
185                 ),
186                 limiter
187                 (
188                     cellVolume,
189                     deltaOneMax[vector::Z],
190                     deltaOneMin[vector::Z],
191                     deltaTwo[vector::Z]
192                 )
193             );
194         }
196         //- Return limiter for a symmTensor
197         inline symmTensor limiter
198         (
199             const scalar& cellVolume,
200             const scalar& faceFlux,
201             const symmTensor& deltaOneMax,
202             const symmTensor& deltaOneMin,
203             const vector& gradPhiPXX,
204             const vector& gradPhiNXX,
205             const vector& gradPhiPXY,
206             const vector& gradPhiNXY,
207             const vector& gradPhiPXZ,
208             const vector& gradPhiNXZ,
209             const vector& gradPhiPYY,
210             const vector& gradPhiNYY,
211             const vector& gradPhiPYZ,
212             const vector& gradPhiNYZ,
213             const vector& gradPhiPZZ,
214             const vector& gradPhiNZZ,
215             const vector& d
216         )
217         {
218             return symmTensor
219             (
220                 limiter
221                 (
222                     cellVolume,
223                     deltaOneMax[0],
224                     deltaOneMin[0],
225                     d & gradPhiPXX
226                 ),
227                 limiter
228                 (
229                     cellVolume,
230                     deltaOneMax[1],
231                     deltaOneMin[1],
232                     d & gradPhiPXY
233                 ),
234                 limiter
235                 (
236                     cellVolume,
237                     deltaOneMax[2],
238                     deltaOneMin[2],
239                     d & gradPhiPXZ
240                 ),
241                 limiter
242                 (
243                     cellVolume,
244                     deltaOneMax[3],
245                     deltaOneMin[3],
246                     d & gradPhiPYY
247                 ),
248                 limiter
249                 (
250                     cellVolume,
251                     deltaOneMax[4],
252                     deltaOneMin[4],
253                     d & gradPhiPYZ
254                 ),
255                 limiter
256                 (
257                     cellVolume,
258                     deltaOneMax[5],
259                     deltaOneMin[5],
260                     d & gradPhiPZZ
261                 )
262             );
263         }
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 } // End namespace Foam
271 #endif
273 // ************************************************************************* //