BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / derived / pressureNormalInletOutletVelocity / pressureNormalInletOutletVelocityFvPatchVectorField.C
blob52b7d65295f09f0acca6f0890042ad91b68da78a
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 "pressureNormalInletOutletVelocityFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
35 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
36 pressureNormalInletOutletVelocityFvPatchVectorField
38     const fvPatch& p,
39     const DimensionedField<vector, volMesh>& iF
42     mixedFvPatchVectorField(p, iF),
43     phiName_("phi"),
44     rhoName_("rho")
46     refValue() = *this;
47     refGrad() = vector::zero;
48     valueFraction() = 0.0;
52 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
53 pressureNormalInletOutletVelocityFvPatchVectorField
55     const pressureNormalInletOutletVelocityFvPatchVectorField& ptf,
56     const fvPatch& p,
57     const DimensionedField<vector, volMesh>& iF,
58     const fvPatchFieldMapper& mapper
61     mixedFvPatchVectorField(ptf, p, iF, mapper),
62     phiName_(ptf.phiName_),
63     rhoName_(ptf.rhoName_)
67 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
68 pressureNormalInletOutletVelocityFvPatchVectorField
70     const fvPatch& p,
71     const DimensionedField<vector, volMesh>& iF,
72     const dictionary& dict
75     mixedFvPatchVectorField(p, iF),
76     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
77     rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
79     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
80     refValue() = *this;
81     refGrad() = vector::zero;
82     valueFraction() = 0.0;
86 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
87 pressureNormalInletOutletVelocityFvPatchVectorField
89     const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf
92     mixedFvPatchVectorField(pivpvf),
93     phiName_(pivpvf.phiName_),
94     rhoName_(pivpvf.rhoName_)
98 Foam::pressureNormalInletOutletVelocityFvPatchVectorField::
99 pressureNormalInletOutletVelocityFvPatchVectorField
101     const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf,
102     const DimensionedField<vector, volMesh>& iF
105     mixedFvPatchVectorField(pivpvf, iF),
106     phiName_(pivpvf.phiName_),
107     rhoName_(pivpvf.rhoName_)
111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
113 void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs()
115     if (updated())
116     {
117         return;
118     }
120     const surfaceScalarField& phi =
121         db().lookupObject<surfaceScalarField>(phiName_);
123     const fvsPatchField<scalar>& phip =
124         patch().patchField<surfaceScalarField, scalar>(phi);
126     tmp<vectorField> n = patch().nf();
127     const Field<scalar>& magS = patch().magSf();
129     if (phi.dimensions() == dimVelocity*dimArea)
130     {
131         refValue() = n*phip/magS;
132     }
133     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
134     {
135         const fvPatchField<scalar>& rhop =
136             patch().lookupPatchField<volScalarField, scalar>(rhoName_);
138         refValue() = n*phip/(rhop*magS);
139     }
140     else
141     {
142         FatalErrorIn
143         (
144             "pressureNormalInletOutletVelocityFvPatchVectorField::"
145             "updateCoeffs()"
146         )   << "dimensions of phi are not correct"
147             << "\n    on patch " << this->patch().name()
148             << " of field " << this->dimensionedInternalField().name()
149             << " in file " << this->dimensionedInternalField().objectPath()
150             << exit(FatalError);
151     }
153     valueFraction() = 1.0 - pos(phip);
155     mixedFvPatchVectorField::updateCoeffs();
159 void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::write
161     Ostream& os
162 ) const
164     fvPatchVectorField::write(os);
165     os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
166     os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
167     writeEntry("value", os);
171 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
173 void Foam::pressureNormalInletOutletVelocityFvPatchVectorField::operator=
175     const fvPatchField<vector>& pvf
178     fvPatchField<vector>::operator=
179     (
180         valueFraction()*(patch().nf()*(patch().nf() & pvf))
181       + (1 - valueFraction())*pvf
182     );
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 namespace Foam
190     makePatchTypeField
191     (
192         fvPatchVectorField,
193         pressureNormalInletOutletVelocityFvPatchVectorField
194     );
197 // ************************************************************************* //