Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / pressureNormalInletOutletVelocity / pressureNormalInletOutletVelocityFvPatchVectorField.C
blob289a370bba95799287ff9364ba04360ee2878e9b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 "pressureNormalInletOutletVelocityFvPatchVectorField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 pressureNormalInletOutletVelocityFvPatchVectorField::
41 pressureNormalInletOutletVelocityFvPatchVectorField
43     const fvPatch& p,
44     const DimensionedField<vector, volMesh>& iF
47     mixedFvPatchVectorField(p, iF),
48     phiName_("phi"),
49     rhoName_("rho")
51     refValue() = *this;
52     refGrad() = vector::zero;
53     valueFraction() = 0.0;
57 pressureNormalInletOutletVelocityFvPatchVectorField::
58 pressureNormalInletOutletVelocityFvPatchVectorField
60     const pressureNormalInletOutletVelocityFvPatchVectorField& ptf,
61     const fvPatch& p,
62     const DimensionedField<vector, volMesh>& iF,
63     const fvPatchFieldMapper& mapper
66     mixedFvPatchVectorField(ptf, p, iF, mapper),
67     phiName_(ptf.phiName_),
68     rhoName_(ptf.rhoName_)
72 pressureNormalInletOutletVelocityFvPatchVectorField::
73 pressureNormalInletOutletVelocityFvPatchVectorField
75     const fvPatch& p,
76     const DimensionedField<vector, volMesh>& iF,
77     const dictionary& dict
80     mixedFvPatchVectorField(p, iF),
81     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
82     rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
84     fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
85     refValue() = *this;
86     refGrad() = vector::zero;
87     valueFraction() = 0.0;
91 pressureNormalInletOutletVelocityFvPatchVectorField::
92 pressureNormalInletOutletVelocityFvPatchVectorField
94     const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf
97     mixedFvPatchVectorField(pivpvf),
98     phiName_(pivpvf.phiName_),
99     rhoName_(pivpvf.rhoName_)
103 pressureNormalInletOutletVelocityFvPatchVectorField::
104 pressureNormalInletOutletVelocityFvPatchVectorField
106     const pressureNormalInletOutletVelocityFvPatchVectorField& pivpvf,
107     const DimensionedField<vector, volMesh>& iF
110     mixedFvPatchVectorField(pivpvf, iF),
111     phiName_(pivpvf.phiName_),
112     rhoName_(pivpvf.rhoName_)
116 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
118 void pressureNormalInletOutletVelocityFvPatchVectorField::updateCoeffs()
120     if (updated())
121     {
122         return;
123     }
125     const surfaceScalarField& phi =
126         db().lookupObject<surfaceScalarField>(phiName_);
128     const fvsPatchField<scalar>& phip =
129         patch().patchField<surfaceScalarField, scalar>(phi);
131     vectorField n = patch().nf();
132     const Field<scalar>& magS = patch().magSf();
134     if (phi.dimensions() == dimVelocity*dimArea)
135     {
136         refValue() = n*phip/magS;
137     }
138     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
139     {
140         const fvPatchField<scalar>& rhop =
141             patch().lookupPatchField<volScalarField, scalar>(rhoName_);
143         refValue() = n*phip/(rhop*magS);
144     }
145     else
146     {
147         FatalErrorIn
148         (
149             "pressureNormalInletOutletVelocityFvPatchVectorField::"
150             "updateCoeffs()"
151         )   << "dimensions of phi are not correct"
152             << "\n    on patch " << this->patch().name()
153             << " of field " << this->dimensionedInternalField().name()
154             << " in file " << this->dimensionedInternalField().objectPath()
155             << exit(FatalError);
156     }
158     valueFraction() = 1.0 - pos(phip);
160     mixedFvPatchVectorField::updateCoeffs();
164 void pressureNormalInletOutletVelocityFvPatchVectorField::
165 write(Ostream& os) const
167     fvPatchVectorField::write(os);
168     os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
169     os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
170     writeEntry("value", os);
174 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
176 void pressureNormalInletOutletVelocityFvPatchVectorField::operator=
178     const fvPatchField<vector>& pvf
181     fvPatchField<vector>::operator=
182     (
183         valueFraction()*(patch().nf()*(patch().nf() & pvf))
184       + (1 - valueFraction())*pvf
185     );
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 makePatchTypeField
193     fvPatchVectorField,
194     pressureNormalInletOutletVelocityFvPatchVectorField
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 } // End namespace Foam
201 // ************************************************************************* //