BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / derived / pressureInletVelocity / pressureInletVelocityFvPatchVectorField.C
blob3482deefbff98206a2478cf622ea4ee7bd6b09ff
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "pressureInletVelocityFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 Foam::pressureInletVelocityFvPatchVectorField::
34 pressureInletVelocityFvPatchVectorField
36     const fvPatch& p,
37     const DimensionedField<vector, volMesh>& iF
40     fixedValueFvPatchVectorField(p, iF),
41     phiName_("phi"),
42     rhoName_("rho")
46 Foam::pressureInletVelocityFvPatchVectorField::
47 pressureInletVelocityFvPatchVectorField
49     const pressureInletVelocityFvPatchVectorField& ptf,
50     const fvPatch& p,
51     const DimensionedField<vector, volMesh>& iF,
52     const fvPatchFieldMapper& mapper
55     fixedValueFvPatchVectorField(ptf, p, iF, mapper),
56     phiName_(ptf.phiName_),
57     rhoName_(ptf.rhoName_)
61 Foam::pressureInletVelocityFvPatchVectorField::
62 pressureInletVelocityFvPatchVectorField
64     const fvPatch& p,
65     const DimensionedField<vector, volMesh>& iF,
66     const dictionary& dict
69     fixedValueFvPatchVectorField(p, iF),
70     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
71     rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
73     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
77 Foam::pressureInletVelocityFvPatchVectorField::
78 pressureInletVelocityFvPatchVectorField
80     const pressureInletVelocityFvPatchVectorField& pivpvf
83     fixedValueFvPatchVectorField(pivpvf),
84     phiName_(pivpvf.phiName_),
85     rhoName_(pivpvf.rhoName_)
89 Foam::pressureInletVelocityFvPatchVectorField::
90 pressureInletVelocityFvPatchVectorField
92     const pressureInletVelocityFvPatchVectorField& pivpvf,
93     const DimensionedField<vector, volMesh>& iF
96     fixedValueFvPatchVectorField(pivpvf, iF),
97     phiName_(pivpvf.phiName_),
98     rhoName_(pivpvf.rhoName_)
102 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
104 void Foam::pressureInletVelocityFvPatchVectorField::updateCoeffs()
106     if (updated())
107     {
108         return;
109     }
111     const surfaceScalarField& phi =
112         db().lookupObject<surfaceScalarField>(phiName_);
114     const fvsPatchField<scalar>& phip =
115         patch().patchField<surfaceScalarField, scalar>(phi);
117     tmp<vectorField> n = patch().nf();
118     const Field<scalar>& magS = patch().magSf();
120     if (phi.dimensions() == dimVelocity*dimArea)
121     {
122         operator==(n*phip/magS);
123     }
124     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
125     {
126         const fvPatchField<scalar>& rhop =
127             patch().lookupPatchField<volScalarField, scalar>(rhoName_);
129         operator==(n*phip/(rhop*magS));
130     }
131     else
132     {
133         FatalErrorIn("pressureInletVelocityFvPatchVectorField::updateCoeffs()")
134             << "dimensions of phi are not correct"
135             << "\n    on patch " << this->patch().name()
136             << " of field " << this->dimensionedInternalField().name()
137             << " in file " << this->dimensionedInternalField().objectPath()
138             << exit(FatalError);
139     }
141     fixedValueFvPatchVectorField::updateCoeffs();
145 void Foam::pressureInletVelocityFvPatchVectorField::write(Ostream& os) const
147     fvPatchVectorField::write(os);
148     writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
149     writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
150     writeEntry("value", os);
154 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
156 void Foam::pressureInletVelocityFvPatchVectorField::operator=
158     const fvPatchField<vector>& pvf
161     fvPatchField<vector>::operator=(patch().nf()*(patch().nf() & pvf));
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 namespace Foam
169     makePatchTypeField
170     (
171         fvPatchVectorField,
172         pressureInletVelocityFvPatchVectorField
173     );
176 // ************************************************************************* //