OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "anisotropicFilter.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "zeroGradientFvPatchFields.H"
00030 #include "wallFvPatch.H"
00031 #include "fvc.H"
00032 
00033 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037     defineTypeNameAndDebug(anisotropicFilter, 0);
00038     addToRunTimeSelectionTable(LESfilter, anisotropicFilter, dictionary);
00039 }
00040 
00041 
00042 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00043 
00044 Foam::anisotropicFilter::anisotropicFilter
00045 (
00046     const fvMesh& mesh,
00047     scalar widthCoeff
00048 )
00049 :
00050     LESfilter(mesh),
00051     widthCoeff_(widthCoeff),
00052     coeff_
00053     (
00054         IOobject
00055         (
00056             "anisotropicFilterCoeff",
00057             mesh.time().timeName(),
00058             mesh
00059         ),
00060         mesh,
00061         dimensionedVector("zero", dimLength*dimLength, vector::zero),
00062         calculatedFvPatchVectorField::typeName
00063     )
00064 {
00065     for (direction d=0; d<vector::nComponents; d++)
00066     {
00067         coeff_.internalField().replace
00068         (
00069             d,
00070             (2.0/widthCoeff_)*mesh.V()
00071            /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
00072         );
00073     }
00074 }
00075 
00076 
00077 Foam::anisotropicFilter::anisotropicFilter
00078 (
00079     const fvMesh& mesh,
00080     const dictionary& bd
00081 )
00082 :
00083     LESfilter(mesh),
00084     widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))),
00085     coeff_
00086     (
00087         IOobject
00088         (
00089             "anisotropicFilterCoeff",
00090             mesh.time().timeName(),
00091             mesh
00092         ),
00093         mesh,
00094         dimensionedVector("zero", dimLength*dimLength, vector::zero),
00095         calculatedFvPatchScalarField::typeName
00096     )
00097 {
00098     for (direction d=0; d<vector::nComponents; d++)
00099     {
00100         coeff_.internalField().replace
00101         (
00102             d,
00103             (2.0/widthCoeff_)*mesh.V()
00104             /fvc::surfaceSum(mag(mesh.Sf().component(d)))().internalField()
00105         );
00106     }
00107 }
00108 
00109 
00110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00111 
00112 void Foam::anisotropicFilter::read(const dictionary& bd)
00113 {
00114     bd.subDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_;
00115 }
00116 
00117 
00118 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00119 
00120 Foam::tmp<Foam::volScalarField> Foam::anisotropicFilter::operator()
00121 (
00122     const tmp<volScalarField>& unFilteredField
00123 ) const
00124 {
00125     tmp<volScalarField> tmpFilteredField =
00126         unFilteredField
00127       + (
00128            coeff_
00129          & fvc::surfaceIntegrate
00130            (
00131                mesh().Sf()
00132               *fvc::snGrad(unFilteredField())
00133            )
00134         );
00135 
00136     unFilteredField.clear();
00137 
00138     return tmpFilteredField;
00139 }
00140 
00141 
00142 Foam::tmp<Foam::volVectorField> Foam::anisotropicFilter::operator()
00143 (
00144     const tmp<volVectorField>& unFilteredField
00145 ) const
00146 {
00147     tmp<volVectorField> tmpFilteredField =
00148         unFilteredField
00149       + (
00150            coeff_
00151          & fvc::surfaceIntegrate
00152            (
00153                mesh().Sf()
00154               *fvc::snGrad(unFilteredField())
00155            )
00156         );
00157 
00158     unFilteredField.clear();
00159 
00160     return tmpFilteredField;
00161 }
00162 
00163 
00164 Foam::tmp<Foam::volSymmTensorField> Foam::anisotropicFilter::operator()
00165 (
00166     const tmp<volSymmTensorField>& unFilteredField
00167 ) const
00168 {
00169     tmp<volSymmTensorField> tmpFilteredField
00170     (
00171         new volSymmTensorField
00172         (
00173             IOobject
00174             (
00175                 "anisotropicFilteredSymmTensorField",
00176                 mesh().time().timeName(),
00177                 mesh(),
00178                 IOobject::MUST_READ,
00179                 IOobject::AUTO_WRITE
00180             ),
00181             mesh(),
00182             unFilteredField().dimensions()
00183         )
00184     );
00185 
00186     for (direction d=0; d<symmTensor::nComponents; d++)
00187     {
00188         tmpFilteredField().replace
00189         (
00190             d, anisotropicFilter::operator()(unFilteredField().component(d))
00191         );
00192     }
00193 
00194     unFilteredField.clear();
00195 
00196     return tmpFilteredField;
00197 }
00198 
00199 
00200 Foam::tmp<Foam::volTensorField> Foam::anisotropicFilter::operator()
00201 (
00202     const tmp<volTensorField>& unFilteredField
00203 ) const
00204 {
00205     tmp<volTensorField> tmpFilteredField
00206     (
00207         new volTensorField
00208         (
00209             IOobject
00210             (
00211                 "anisotropicFilteredTensorField",
00212                 mesh().time().timeName(),
00213                 mesh(),
00214                 IOobject::MUST_READ,
00215                 IOobject::AUTO_WRITE
00216             ),
00217             mesh(),
00218             unFilteredField().dimensions()
00219         )
00220     );
00221 
00222     for (direction d=0; d<tensor::nComponents; d++)
00223     {
00224         tmpFilteredField().replace
00225         (
00226             d, anisotropicFilter::operator()(unFilteredField().component(d))
00227         );
00228     }
00229 
00230     unFilteredField.clear();
00231 
00232     return tmpFilteredField;
00233 }
00234 
00235 
00236 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd