1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "parabolicVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
43 const DimensionedField<vector, volMesh>& iF
46 fixedValueFvPatchVectorField(p, iF),
53 parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
55 const parabolicVelocityFvPatchVectorField& ptf,
57 const DimensionedField<vector, volMesh>& iF,
58 const fvPatchFieldMapper& mapper
61 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
62 maxValue_(ptf.maxValue_),
68 parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
71 const DimensionedField<vector, volMesh>& iF,
72 const dictionary& dict
75 fixedValueFvPatchVectorField(p, iF),
76 maxValue_(readScalar(dict.lookup("maxValue"))),
80 if (mag(n_) < SMALL || mag(y_) < SMALL)
82 FatalErrorIn("parabolicVelocityFvPatchVectorField(dict)")
83 << "n or y given with zero size not correct"
94 parabolicVelocityFvPatchVectorField::parabolicVelocityFvPatchVectorField
96 const parabolicVelocityFvPatchVectorField& fcvpvf,
97 const DimensionedField<vector, volMesh>& iF
100 fixedValueFvPatchVectorField(fcvpvf, iF),
101 maxValue_(fcvpvf.maxValue_),
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 void parabolicVelocityFvPatchVectorField::updateCoeffs()
116 // Get range and orientation
117 boundBox bb(patch().patch().localPoints(), true);
119 vector ctr = 0.5*(bb.max() + bb.min());
121 const vectorField& c = patch().Cf();
123 // Calculate local 1-D coordinate for the parabolic profile
124 scalarField coord = 2*((c - ctr) & y_)/((bb.max() - bb.min()) & y_);
126 vectorField::operator=(n_*maxValue_*(1.0 - sqr(coord)));
131 void parabolicVelocityFvPatchVectorField::write(Ostream& os) const
133 fvPatchVectorField::write(os);
134 os.writeKeyword("maxValue")
135 << maxValue_ << token::END_STATEMENT << nl;
137 << n_ << token::END_STATEMENT << nl;
139 << y_ << token::END_STATEMENT << nl;
140 writeEntry("value", os);
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 makePatchTypeField(fvPatchVectorField, parabolicVelocityFvPatchVectorField);
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 } // End namespace Foam
152 // ************************************************************************* //