1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(anisotropicFilter, 0);
38 addToRunTimeSelectionTable(LESfilter, anisotropicFilter, dictionary);
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 Foam::anisotropicFilter::anisotropicFilter
51 widthCoeff_(widthCoeff),
56 "anisotropicFilterCoeff",
57 mesh.time().timeName(),
61 dimensionedVector("zero", dimLength*dimLength, vector::zero),
62 calculatedFvPatchVectorField::typeName
65 for (direction d=0; d<vector::nComponents; d++)
67 coeff_.internalField().replace
70 (2.0/widthCoeff_)*mesh.V()
71 /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
77 Foam::anisotropicFilter::anisotropicFilter
84 widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))),
89 "anisotropicFilterCoeff",
90 mesh.time().timeName(),
94 dimensionedVector("zero", dimLength*dimLength, vector::zero),
95 calculatedFvPatchScalarField::typeName
98 for (direction d=0; d<vector::nComponents; d++)
100 coeff_.internalField().replace
103 (2.0/widthCoeff_)*mesh.V()
104 /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
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
125 tmp<volScalarField> tmpFilteredField =
129 & fvc::surfaceIntegrate
132 *fvc::snGrad(unFilteredField())
136 unFilteredField.clear();
138 return tmpFilteredField;
142 Foam::tmp<Foam::volVectorField> Foam::anisotropicFilter::operator()
144 const tmp<volVectorField>& unFilteredField
147 tmp<volVectorField> tmpFilteredField =
151 & fvc::surfaceIntegrate
154 *fvc::snGrad(unFilteredField())
158 unFilteredField.clear();
160 return tmpFilteredField;
164 Foam::tmp<Foam::volSymmTensorField> Foam::anisotropicFilter::operator()
166 const tmp<volSymmTensorField>& unFilteredField
169 tmp<volSymmTensorField> tmpFilteredField
171 new volSymmTensorField
175 "anisotropicFilteredSymmTensorField",
176 mesh().time().timeName(),
182 unFilteredField().dimensions()
186 for (direction d=0; d<symmTensor::nComponents; d++)
188 tmpFilteredField().replace
190 d, anisotropicFilter::operator()(unFilteredField().component(d))
194 unFilteredField.clear();
196 return tmpFilteredField;
200 Foam::tmp<Foam::volTensorField> Foam::anisotropicFilter::operator()
202 const tmp<volTensorField>& unFilteredField
205 tmp<volTensorField> tmpFilteredField
211 "anisotropicFilteredTensorField",
212 mesh().time().timeName(),
218 unFilteredField().dimensions()
222 for (direction d=0; d<tensor::nComponents; d++)
224 tmpFilteredField().replace
226 d, anisotropicFilter::operator()(unFilteredField().component(d))
230 unFilteredField.clear();
232 return tmpFilteredField;
236 // ************************************************************************* //