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

atmBoundaryLayerInletEpsilonFvPatchScalarField.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) 2010-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 the
00013     Free Software Foundation; either version 3 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 "atmBoundaryLayerInletEpsilonFvPatchScalarField.H"
00028 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00029 #include <finiteVolume/fvPatchFieldMapper.H>
00030 #include <finiteVolume/volFields.H>
00031 #include <finiteVolume/surfaceFields.H>
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 namespace incompressible
00038 {
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 atmBoundaryLayerInletEpsilonFvPatchScalarField::
00043 atmBoundaryLayerInletEpsilonFvPatchScalarField
00044 (
00045     const fvPatch& p,
00046     const DimensionedField<scalar, volMesh>& iF
00047 )
00048 :
00049     fixedValueFvPatchScalarField(p, iF),
00050     Ustar_(0),
00051     z_(pTraits<vector>::zero),
00052     z0_(0),
00053     kappa_(0.41),
00054     zGround_(0)
00055 {}
00056 
00057 
00058 atmBoundaryLayerInletEpsilonFvPatchScalarField::
00059 atmBoundaryLayerInletEpsilonFvPatchScalarField
00060 (
00061     const atmBoundaryLayerInletEpsilonFvPatchScalarField& ptf,
00062     const fvPatch& p,
00063     const DimensionedField<scalar, volMesh>& iF,
00064     const fvPatchFieldMapper& mapper
00065 )
00066 :
00067     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00068     Ustar_(ptf.Ustar_),
00069     z_(ptf.z_),
00070     z0_(ptf.z0_),
00071     kappa_(ptf.kappa_),
00072     zGround_(ptf.zGround_)
00073 {}
00074 
00075 
00076 atmBoundaryLayerInletEpsilonFvPatchScalarField::
00077 atmBoundaryLayerInletEpsilonFvPatchScalarField
00078 (
00079     const fvPatch& p,
00080     const DimensionedField<scalar, volMesh>& iF,
00081     const dictionary& dict
00082 )
00083 :
00084     fixedValueFvPatchScalarField(p, iF),
00085     Ustar_(readScalar(dict.lookup("Ustar"))),
00086     z_(dict.lookup("z")),
00087     z0_(readScalar(dict.lookup("z0"))),
00088     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00089     zGround_(readScalar(dict.lookup("zGround")))
00090 {
00091     if (mag(z_) < SMALL)
00092     {
00093         FatalErrorIn
00094         (
00095             "atmBoundaryLayerInletEpsilonFvPatchScalarField"
00096             "("
00097                 "const fvPatch&, "
00098                 "const DimensionedField<scalar, volMesh>&, "
00099                 "const dictionary&"
00100             ")"
00101         )
00102             << "magnitude of z vector must be greater than zero"
00103             << abort(FatalError);
00104     }
00105 
00106     z_ /= mag(z_);
00107 
00108     evaluate();
00109 }
00110 
00111 
00112 atmBoundaryLayerInletEpsilonFvPatchScalarField::
00113 atmBoundaryLayerInletEpsilonFvPatchScalarField
00114 (
00115     const atmBoundaryLayerInletEpsilonFvPatchScalarField& blpsf,
00116     const DimensionedField<scalar, volMesh>& iF
00117 )
00118 :
00119     fixedValueFvPatchScalarField(blpsf, iF),
00120     Ustar_(blpsf.Ustar_),
00121     z_(blpsf.z_),
00122     z0_(blpsf.z0_),
00123     kappa_(blpsf.kappa_),
00124     zGround_(blpsf.zGround_)
00125 {}
00126 
00127 
00128 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00129 
00130 void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
00131 {
00132     const vectorField& c = patch().Cf();
00133     scalarField coord = (c & z_);
00134     scalarField::operator=(pow3(Ustar_)/(kappa_*(coord - zGround_ + z0_)));
00135 }
00136 
00137 
00138 void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
00139 {
00140     fvPatchScalarField::write(os);
00141     os.writeKeyword("Ustar")
00142         << Ustar_ << token::END_STATEMENT << nl;
00143     os.writeKeyword("z")
00144         << z_ << token::END_STATEMENT << nl;
00145     os.writeKeyword("z0")
00146         << z0_ << token::END_STATEMENT << nl;
00147     os.writeKeyword("kappa")
00148         << kappa_ << token::END_STATEMENT << nl;
00149     os.writeKeyword("zGround")
00150         << zGround_ << token::END_STATEMENT << nl;
00151     writeEntry("value", os);
00152 }
00153 
00154 
00155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00156 
00157 makePatchTypeField
00158 (
00159     fvPatchScalarField,
00160     atmBoundaryLayerInletEpsilonFvPatchScalarField
00161 );
00162 
00163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00164 
00165 } // End namespace incompressible
00166 } // End namespace Foam
00167 
00168 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines