initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / finiteVolume / snGradSchemes / limitedSnGrad / limitedSnGrad.C
blobeb1144c1d3d88af5bbdb89ea3bc2b62f29db93e3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM 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 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
26     snGrad scheme with limited non-orthogonal correction.
28     The limiter is controlled by a coefficient with a value between 0 and 1
29     which when 0 switches the correction off and the scheme behaves as
30     uncorrectedSnGrad, when set to 1 the full correction is applied and the
31     scheme behaves as correctedSnGrad and when set to 0.5 the limiter is
32     calculated such that the non-orthogonal contribution does not exceed the
33     orthogonal part.
35 \*---------------------------------------------------------------------------*/
37 #include "fv.H"
38 #include "limitedSnGrad.H"
39 #include "volFields.H"
40 #include "surfaceFields.H"
41 #include "correctedSnGrad.H"
42 #include "localMax.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace fv
54 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
56 template<class Type>
57 limitedSnGrad<Type>::~limitedSnGrad()
61 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
63 template<class Type>
64 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
65 limitedSnGrad<Type>::correction
67     const GeometricField<Type, fvPatchField, volMesh>& vf
68 ) const
70     GeometricField<Type, fvsPatchField, surfaceMesh> corr = 
71         correctedSnGrad<Type>(this->mesh()).correction(vf);
73     surfaceScalarField limiter
74     (
75         min
76         (
77             limitCoeff_
78            *mag(snGradScheme<Type>::snGrad(vf, deltaCoeffs(vf), "orthSnGrad"))
79            /(
80                 (1 - limitCoeff_)*mag(corr)
81               + dimensionedScalar("small", corr.dimensions(), SMALL)
82             ),
83             dimensionedScalar("one", dimless, 1.0)
84         )
85     );
87     if (fv::debug)
88     {
89         Info<< "limitedSnGrad :: limiter min: " << min(limiter.internalField())
90             << " max: "<< max(limiter.internalField())
91             << " avg: " << average(limiter.internalField()) << endl;
92     }
94     return limiter*corr;
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 } // End namespace fv
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 } // End namespace Foam
106 // ************************************************************************* //