FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

anisotropicFilter.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "anisotropicFilter.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/zeroGradientFvPatchFields.H>
00029 #include <finiteVolume/wallFvPatch.H>
00030 #include <finiteVolume/fvc.H>
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036     defineTypeNameAndDebug(anisotropicFilter, 0);
00037     addToRunTimeSelectionTable(LESfilter, anisotropicFilter, dictionary);
00038 }
00039 
00040 
00041 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00042 
00043 Foam::anisotropicFilter::anisotropicFilter
00044 (
00045     const fvMesh& mesh,
00046     scalar widthCoeff
00047 )
00048 :
00049     LESfilter(mesh),
00050     widthCoeff_(widthCoeff),
00051     coeff_
00052     (
00053         IOobject
00054         (
00055             "anisotropicFilterCoeff",
00056             mesh.time().timeName(),
00057             mesh
00058         ),
00059         mesh,
00060         dimensionedVector("zero", dimLength*dimLength, vector::zero),
00061         calculatedFvPatchVectorField::typeName
00062     )
00063 {
00064     for (direction d=0; d<vector::nComponents; d++)
00065     {
00066         coeff_.internalField().replace
00067         (
00068             d,
00069             (2.0/widthCoeff_)*mesh.V()
00070            /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
00071         );
00072     }
00073 }
00074 
00075 
00076 Foam::anisotropicFilter::anisotropicFilter
00077 (
00078     const fvMesh& mesh,
00079     const dictionary& bd
00080 )
00081 :
00082     LESfilter(mesh),
00083     widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))),
00084     coeff_
00085     (
00086         IOobject
00087         (
00088             "anisotropicFilterCoeff",
00089             mesh.time().timeName(),
00090             mesh
00091         ),
00092         mesh,
00093         dimensionedVector("zero", dimLength*dimLength, vector::zero),
00094         calculatedFvPatchScalarField::typeName
00095     )
00096 {
00097     for (direction d=0; d<vector::nComponents; d++)
00098     {
00099         coeff_.internalField().replace
00100         (
00101             d,
00102             (2.0/widthCoeff_)*mesh.V()
00103             /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
00104         );
00105     }
00106 }
00107 
00108 
00109 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00110 
00111 void Foam::anisotropicFilter::read(const dictionary& bd)
00112 {
00113     bd.subDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_;
00114 }
00115 
00116 
00117 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00118 
00119 Foam::tmp<Foam::volScalarField> Foam::anisotropicFilter::operator()
00120 (
00121     const tmp<volScalarField>& unFilteredField
00122 ) const
00123 {
00124     tmp<volScalarField> tmpFilteredField =
00125         unFilteredField
00126       + (
00127            coeff_
00128          & fvc::surfaceIntegrate
00129            (
00130                mesh().Sf()
00131               *fvc::snGrad(unFilteredField())
00132            )
00133         );
00134 
00135     unFilteredField.clear();
00136 
00137     return tmpFilteredField;
00138 }
00139 
00140 
00141 Foam::tmp<Foam::volVectorField> Foam::anisotropicFilter::operator()
00142 (
00143     const tmp<volVectorField>& unFilteredField
00144 ) const
00145 {
00146     tmp<volVectorField> tmpFilteredField =
00147         unFilteredField
00148       + (
00149            coeff_
00150          & fvc::surfaceIntegrate
00151            (
00152                mesh().Sf()
00153               *fvc::snGrad(unFilteredField())
00154            )
00155         );
00156 
00157     unFilteredField.clear();
00158 
00159     return tmpFilteredField;
00160 }
00161 
00162 
00163 Foam::tmp<Foam::volSymmTensorField> Foam::anisotropicFilter::operator()
00164 (
00165     const tmp<volSymmTensorField>& unFilteredField
00166 ) const
00167 {
00168     tmp<volSymmTensorField> tmpFilteredField
00169     (
00170         new volSymmTensorField
00171         (
00172             IOobject
00173             (
00174                 "anisotropicFilteredSymmTensorField",
00175                 mesh().time().timeName(),
00176                 mesh(),
00177                 IOobject::MUST_READ,
00178                 IOobject::AUTO_WRITE
00179             ),
00180             mesh(),
00181             unFilteredField().dimensions()
00182         )
00183     );
00184 
00185     for (direction d=0; d<symmTensor::nComponents; d++)
00186     {
00187         tmpFilteredField().replace
00188         (
00189             d, anisotropicFilter::operator()(unFilteredField().component(d))
00190         );
00191     }
00192 
00193     unFilteredField.clear();
00194 
00195     return tmpFilteredField;
00196 }
00197 
00198 
00199 Foam::tmp<Foam::volTensorField> Foam::anisotropicFilter::operator()
00200 (
00201     const tmp<volTensorField>& unFilteredField
00202 ) const
00203 {
00204     tmp<volTensorField> tmpFilteredField
00205     (
00206         new volTensorField
00207         (
00208             IOobject
00209             (
00210                 "anisotropicFilteredTensorField",
00211                 mesh().time().timeName(),
00212                 mesh(),
00213                 IOobject::MUST_READ,
00214                 IOobject::AUTO_WRITE
00215             ),
00216             mesh(),
00217             unFilteredField().dimensions()
00218         )
00219     );
00220 
00221     for (direction d=0; d<tensor::nComponents; d++)
00222     {
00223         tmpFilteredField().replace
00224         (
00225             d, anisotropicFilter::operator()(unFilteredField().component(d))
00226         );
00227     }
00228 
00229     unFilteredField.clear();
00230 
00231     return tmpFilteredField;
00232 }
00233 
00234 
00235 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines