1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 "timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
36 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
39 const DimensionedField<vector, volMesh>& iF
42 timeVaryingMappedFixedValueFvPatchVectorField(p, iF),
48 Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
49 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
52 const DimensionedField<vector, volMesh>& iF,
53 const dictionary& dict
56 timeVaryingMappedFixedValueFvPatchVectorField(p, iF),
57 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
58 rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
60 fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
64 Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
65 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
67 const timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField& ptf,
69 const DimensionedField<vector, volMesh>& iF,
70 const fvPatchFieldMapper& mapper
73 timeVaryingMappedFixedValueFvPatchVectorField(ptf, p, iF, mapper),
74 phiName_(ptf.phiName_),
75 rhoName_(ptf.rhoName_)
79 Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
80 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
82 const timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField&
86 timeVaryingMappedFixedValueFvPatchVectorField(pivpvf),
87 phiName_(pivpvf.phiName_),
88 rhoName_(pivpvf.rhoName_)
92 Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
93 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
95 const timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField&
97 const DimensionedField<vector, volMesh>& iF
100 timeVaryingMappedFixedValueFvPatchVectorField(pivpvf, iF),
101 phiName_(pivpvf.phiName_),
102 rhoName_(pivpvf.rhoName_)
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 void Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
111 const fvPatchFieldMapper& m
114 timeVaryingMappedFixedValueFvPatchVectorField::autoMap(m);
118 void Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
121 const fvPatchVectorField& ptf,
122 const labelList& addr
125 timeVaryingMappedFixedValueFvPatchVectorField::rmap(ptf, addr);
129 void Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
137 // Map the tabulated velocity field onto this field
138 timeVaryingMappedFixedValueFvPatchVectorField::updateCoeffs();
139 vectorField inletDir = *this;
141 // Normalise to obtain the flow direction
142 inletDir /= (mag(inletDir) + SMALL);
144 const surfaceScalarField& phi =
145 db().lookupObject<surfaceScalarField>(phiName_);
147 const fvsPatchField<scalar>& phip =
148 patch().patchField<surfaceScalarField, scalar>(phi);
150 vectorField n = patch().nf();
151 scalarField ndmagS = (n & inletDir)*patch().magSf();
153 if (phi.dimensions() == dimVelocity*dimArea)
155 operator==(inletDir*phip/ndmagS);
157 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
159 const fvPatchField<scalar>& rhop =
160 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
162 operator==(inletDir*phip/(rhop*ndmagS));
168 "timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField"
170 ) << "dimensions of phi are not correct"
171 << "\n on patch " << this->patch().name()
172 << " of field " << this->dimensionedInternalField().name()
173 << " in file " << this->dimensionedInternalField().objectPath()
179 void Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
185 if (phiName_ != "phi")
187 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
189 if (rhoName_ != "rho")
191 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
193 timeVaryingMappedFixedValueFvPatchVectorField::write(os);
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
209 // ************************************************************************* //