timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField: new BC.
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / timeVaryingMappedPressureDirectedInletVelocity / timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField.C
blob3fb91ab91646de85ba5b056c4e82c42d8262f2f6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
38     const fvPatch& p,
39     const DimensionedField<vector, volMesh>& iF
42     timeVaryingMappedFixedValueFvPatchVectorField(p, iF),
43     phiName_("phi"),
44     rhoName_("rho")
48 Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
49 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
51     const fvPatch& p,
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,
68     const fvPatch& p,
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&
83     pivpvf
86     timeVaryingMappedFixedValueFvPatchVectorField(pivpvf),
87     phiName_(pivpvf.phiName_),
88     rhoName_(pivpvf.rhoName_)
92 Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
93 timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
95     const timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField&
96     pivpvf,
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::
109 autoMap
111     const fvPatchFieldMapper& m
114     timeVaryingMappedFixedValueFvPatchVectorField::autoMap(m);
118 void Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
119 rmap
121     const fvPatchVectorField& ptf,
122     const labelList& addr
125     timeVaryingMappedFixedValueFvPatchVectorField::rmap(ptf, addr);
129 void Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
130 updateCoeffs()
132     if (updated())
133     {
134         return;
135     }
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)
154     {
155         operator==(inletDir*phip/ndmagS);
156     }
157     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
158     {
159         const fvPatchField<scalar>& rhop =
160             patch().lookupPatchField<volScalarField, scalar>(rhoName_);
162         operator==(inletDir*phip/(rhop*ndmagS));
163     }
164     else
165     {
166         FatalErrorIn
167         (
168             "timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField"
169             "::updateCoeffs()"
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()
174             << exit(FatalError);
175     }
179 void Foam::timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField::
180 write
182     Ostream& os
183 ) const
185     if (phiName_ != "phi")
186     {
187         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
188     }
189     if (rhoName_ != "rho")
190     {
191         os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
192     }
193     timeVaryingMappedFixedValueFvPatchVectorField::write(os);
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 namespace Foam
201     makePatchTypeField
202     (
203         fvPatchVectorField,
204         timeVaryingMappedPressureDirectedInletVelocityFvPatchVectorField
205     );
209 // ************************************************************************* //