00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "atmBoundaryLayerInletVelocityFvPatchVectorField.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
00041
00042 atmBoundaryLayerInletVelocityFvPatchVectorField::
00043 atmBoundaryLayerInletVelocityFvPatchVectorField
00044 (
00045 const fvPatch& p,
00046 const DimensionedField<vector, volMesh>& iF
00047 )
00048 :
00049 fixedValueFvPatchVectorField(p, iF),
00050 Ustar_(0),
00051 n_(pTraits<vector>::zero),
00052 z_(pTraits<vector>::zero),
00053 z0_(0),
00054 kappa_(0.41),
00055 Uref_(0),
00056 Href_(0),
00057 zGround_(0)
00058 {}
00059
00060
00061 atmBoundaryLayerInletVelocityFvPatchVectorField::
00062 atmBoundaryLayerInletVelocityFvPatchVectorField
00063 (
00064 const atmBoundaryLayerInletVelocityFvPatchVectorField& ptf,
00065 const fvPatch& p,
00066 const DimensionedField<vector, volMesh>& iF,
00067 const fvPatchFieldMapper& mapper
00068 )
00069 :
00070 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
00071 Ustar_(ptf.Ustar_),
00072 n_(ptf.n_),
00073 z_(ptf.z_),
00074 z0_(ptf.z0_),
00075 kappa_(ptf.kappa_),
00076 Uref_(ptf.Uref_),
00077 Href_(ptf.Href_),
00078 zGround_(ptf.zGround_)
00079 {}
00080
00081
00082 atmBoundaryLayerInletVelocityFvPatchVectorField::
00083 atmBoundaryLayerInletVelocityFvPatchVectorField
00084 (
00085 const fvPatch& p,
00086 const DimensionedField<vector, volMesh>& iF,
00087 const dictionary& dict
00088 )
00089 :
00090 fixedValueFvPatchVectorField(p, iF),
00091 Ustar_(0),
00092 n_(dict.lookup("n")),
00093 z_(dict.lookup("z")),
00094 z0_(readScalar(dict.lookup("z0"))),
00095 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00096 Uref_(readScalar(dict.lookup("Uref"))),
00097 Href_(readScalar(dict.lookup("Href"))),
00098 zGround_(readScalar(dict.lookup("zGround")))
00099 {
00100 if (mag(n_) < SMALL || mag(z_) < SMALL || mag(z0_) < SMALL)
00101 {
00102 FatalErrorIn
00103 (
00104 "atmBoundaryLayerInletVelocityFvPatchVectorField"
00105 "("
00106 "const fvPatch&, "
00107 "const DimensionedField<vector, volMesh>&, "
00108 "onst dictionary&"
00109 ")"
00110 )
00111 << "magnitude of n, z and z0 vectors must be greater than zero"
00112 << abort(FatalError);
00113 }
00114
00115 n_ /= mag(n_);
00116 z_ /= mag(z_);
00117
00118 Ustar_ = kappa_*Uref_/(log((Href_ + z0_)/max(z0_ , 0.001)));
00119
00120 evaluate();
00121 }
00122
00123
00124 atmBoundaryLayerInletVelocityFvPatchVectorField::
00125 atmBoundaryLayerInletVelocityFvPatchVectorField
00126 (
00127 const atmBoundaryLayerInletVelocityFvPatchVectorField& blpvf,
00128 const DimensionedField<vector, volMesh>& iF
00129 )
00130 :
00131 fixedValueFvPatchVectorField(blpvf, iF),
00132 Ustar_(blpvf.Ustar_),
00133 n_(blpvf.n_),
00134 z_(blpvf.z_),
00135 z0_(blpvf.z0_),
00136 kappa_(blpvf.kappa_),
00137 Uref_(blpvf.Uref_),
00138 Href_(blpvf.Href_),
00139 zGround_(blpvf.zGround_)
00140 {}
00141
00142
00143
00144
00145 void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs()
00146 {
00147 const vectorField& c = patch().Cf();
00148 scalarField coord = (c & z_);
00149 scalarField Un(coord.size());
00150
00151 forAll(coord, i)
00152 {
00153 if((coord[i] - zGround_) < Href_)
00154 {
00155 Un[i] = (Ustar_/kappa_)*log((coord[i] - zGround_ + z0_)/max(z0_ , 0.001));
00156 }
00157 else
00158 {
00159 Un[i] = (Uref_);
00160 }
00161 }
00162
00163 vectorField::operator=(n_*Un);
00164
00165 fixedValueFvPatchVectorField::updateCoeffs();
00166 }
00167
00168
00169 void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const
00170 {
00171 fvPatchVectorField::write(os);
00172 os.writeKeyword("z0")
00173 << z0_ << token::END_STATEMENT << nl;
00174 os.writeKeyword("n")
00175 << n_ << token::END_STATEMENT << nl;
00176 os.writeKeyword("z")
00177 << z_ << token::END_STATEMENT << nl;
00178 os.writeKeyword("kappa")
00179 << kappa_ << token::END_STATEMENT << nl;
00180 os.writeKeyword("Uref")
00181 << Uref_ << token::END_STATEMENT << nl;
00182 os.writeKeyword("Href")
00183 << Href_ << token::END_STATEMENT << nl;
00184 os.writeKeyword("zGround")
00185 << zGround_ << token::END_STATEMENT << nl;
00186 writeEntry("value", os);
00187 }
00188
00189
00190
00191
00192 makePatchTypeField
00193 (
00194 fvPatchVectorField,
00195 atmBoundaryLayerInletVelocityFvPatchVectorField
00196 );
00197
00198
00199
00200 }
00201 }
00202
00203