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

laplaceFilter.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 "laplaceFilter.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "calculatedFvPatchFields.H"
00030 #include "fvm.H"
00031 #include "fvc.H"
00032 
00033 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037     defineTypeNameAndDebug(laplaceFilter, 0);
00038     addToRunTimeSelectionTable(LESfilter, laplaceFilter, dictionary);
00039 }
00040 
00041 
00042 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00043 
00044 Foam::laplaceFilter::laplaceFilter(const fvMesh& mesh, scalar widthCoeff)
00045 :
00046     LESfilter(mesh),
00047     widthCoeff_(widthCoeff),
00048     coeff_
00049     (
00050         IOobject
00051         (
00052             "laplaceFilterCoeff",
00053             mesh.time().timeName(),
00054             mesh
00055         ),
00056         mesh,
00057         dimensionedScalar("zero", dimLength*dimLength, 0),
00058         calculatedFvPatchScalarField::typeName
00059     )
00060 {
00061     coeff_.internalField() = pow(mesh.V(), 2.0/3.0)/widthCoeff_;
00062 }
00063 
00064 
00065 Foam::laplaceFilter::laplaceFilter(const fvMesh& mesh, const dictionary& bd)
00066 :
00067     LESfilter(mesh),
00068     widthCoeff_(readScalar(bd.subDict(type() + "Coeffs").lookup("widthCoeff"))),
00069     coeff_
00070     (
00071         IOobject
00072         (
00073             "laplaceFilterCoeff",
00074             mesh.time().timeName(),
00075             mesh
00076         ),
00077         mesh,
00078         dimensionedScalar("zero", dimLength*dimLength, 0),
00079         calculatedFvPatchScalarField::typeName
00080     )
00081 {
00082     coeff_.internalField() = pow(mesh.V(), 2.0/3.0)/widthCoeff_;
00083 }
00084 
00085 
00086 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00087 
00088 void Foam::laplaceFilter::read(const dictionary& bd)
00089 {
00090     bd.subDict(type() + "Coeffs").lookup("widthCoeff") >> widthCoeff_;
00091 }
00092 
00093 
00094 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00095 
00096 Foam::tmp<Foam::volScalarField> Foam::laplaceFilter::operator()
00097 (
00098     const tmp<volScalarField>& unFilteredField
00099 ) const
00100 {
00101     tmp<volScalarField> filteredField =
00102         unFilteredField() + fvc::laplacian(coeff_, unFilteredField());
00103 
00104     unFilteredField.clear();
00105 
00106     return filteredField;
00107 }
00108 
00109 
00110 Foam::tmp<Foam::volVectorField> Foam::laplaceFilter::operator()
00111 (
00112     const tmp<volVectorField>& unFilteredField
00113 ) const
00114 {
00115     tmp<volVectorField> filteredField =
00116         unFilteredField() + fvc::laplacian(coeff_, unFilteredField());
00117 
00118     unFilteredField.clear();
00119 
00120     return filteredField;
00121 }
00122 
00123 
00124 Foam::tmp<Foam::volSymmTensorField> Foam::laplaceFilter::operator()
00125 (
00126     const tmp<volSymmTensorField>& unFilteredField
00127 ) const
00128 {
00129     tmp<volSymmTensorField> filteredField =
00130         unFilteredField() + fvc::laplacian(coeff_, unFilteredField());
00131 
00132     unFilteredField.clear();
00133 
00134     return filteredField;
00135 }
00136 
00137 
00138 Foam::tmp<Foam::volTensorField> Foam::laplaceFilter::operator()
00139 (
00140     const tmp<volTensorField>& unFilteredField
00141 ) const
00142 {
00143     tmp<volTensorField> filteredField =
00144         unFilteredField() + fvc::laplacian(coeff_, unFilteredField());
00145 
00146     unFilteredField.clear();
00147 
00148     return filteredField;
00149 }
00150 
00151 
00152 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd