initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / LES / LESfilters / anisotropicFilter / anisotropicFilter.C
blob7b7d7155929d46f9c49f3d3af464c7aec48de670
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 \*---------------------------------------------------------------------------*/
27 #include "anisotropicFilter.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "zeroGradientFvPatchFields.H"
30 #include "wallFvPatch.H"
31 #include "fvc.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 namespace Foam
37     defineTypeNameAndDebug(anisotropicFilter, 0);
38     addToRunTimeSelectionTable(LESfilter, anisotropicFilter, dictionary);
42 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
44 Foam::anisotropicFilter::anisotropicFilter
46     const fvMesh& mesh,
47     scalar widthCoeff
50     LESfilter(mesh),
51     widthCoeff_(widthCoeff),
52     coeff_
53     (
54         IOobject
55         (
56             "anisotropicFilterCoeff",
57             mesh.time().timeName(),
58             mesh
59         ),
60         mesh,
61         dimensionedVector("zero", dimLength*dimLength, vector::zero),
62         calculatedFvPatchVectorField::typeName
63     )
65     for (direction d=0; d<vector::nComponents; d++)
66     {
67         coeff_.internalField().replace
68         (
69             d,
70             (2.0/widthCoeff_)*mesh.V()
71            /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
72         );
73     }
77 Foam::anisotropicFilter::anisotropicFilter
79     const fvMesh& mesh,
80     const dictionary& bd
83     LESfilter(mesh),
84     widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))),
85     coeff_
86     (
87         IOobject
88         (
89             "anisotropicFilterCoeff",
90             mesh.time().timeName(),
91             mesh
92         ),
93         mesh,
94         dimensionedVector("zero", dimLength*dimLength, vector::zero),
95         calculatedFvPatchScalarField::typeName
96     )
98     for (direction d=0; d<vector::nComponents; d++)
99     {
100         coeff_.internalField().replace
101         (
102             d,
103             (2.0/widthCoeff_)*mesh.V()
104             /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
105         );
106     }
110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
112 void Foam::anisotropicFilter::read(const dictionary& bd)
114     bd.subDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_;
118 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
120 Foam::tmp<Foam::volScalarField> Foam::anisotropicFilter::operator()
122     const tmp<volScalarField>& unFilteredField
123 ) const
125     tmp<volScalarField> tmpFilteredField =
126         unFilteredField
127       + (
128            coeff_
129          & fvc::surfaceIntegrate
130            (
131                mesh().Sf()
132               *fvc::snGrad(unFilteredField())
133            )
134         );
136     unFilteredField.clear();
138     return tmpFilteredField;
142 Foam::tmp<Foam::volVectorField> Foam::anisotropicFilter::operator()
144     const tmp<volVectorField>& unFilteredField
145 ) const
147     tmp<volVectorField> tmpFilteredField =
148         unFilteredField
149       + (
150            coeff_
151          & fvc::surfaceIntegrate
152            (
153                mesh().Sf()
154               *fvc::snGrad(unFilteredField())
155            )
156         );
158     unFilteredField.clear();
160     return tmpFilteredField;
164 Foam::tmp<Foam::volSymmTensorField> Foam::anisotropicFilter::operator()
166     const tmp<volSymmTensorField>& unFilteredField
167 ) const
169     tmp<volSymmTensorField> tmpFilteredField
170     (
171         new volSymmTensorField
172         (
173             IOobject
174             (
175                 "anisotropicFilteredSymmTensorField",
176                 mesh().time().timeName(),
177                 mesh(),
178                 IOobject::MUST_READ,
179                 IOobject::AUTO_WRITE
180             ),
181             mesh(),
182             unFilteredField().dimensions()
183         )
184     );
186     for (direction d=0; d<symmTensor::nComponents; d++)
187     {
188         tmpFilteredField().replace
189         (
190             d, anisotropicFilter::operator()(unFilteredField().component(d))
191         );
192     }
194     unFilteredField.clear();
196     return tmpFilteredField;
200 Foam::tmp<Foam::volTensorField> Foam::anisotropicFilter::operator()
202     const tmp<volTensorField>& unFilteredField
203 ) const
205     tmp<volTensorField> tmpFilteredField
206     (
207         new volTensorField
208         (
209             IOobject
210             (
211                 "anisotropicFilteredTensorField",
212                 mesh().time().timeName(),
213                 mesh(),
214                 IOobject::MUST_READ,
215                 IOobject::AUTO_WRITE
216             ),
217             mesh(),
218             unFilteredField().dimensions()
219         )
220     );
222     for (direction d=0; d<tensor::nComponents; d++)
223     {
224         tmpFilteredField().replace
225         (
226             d, anisotropicFilter::operator()(unFilteredField().component(d))
227         );
228     }
230     unFilteredField.clear();
232     return tmpFilteredField;
236 // ************************************************************************* //