initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / uniformDensityHydrostaticPressure / uniformDensityHydrostaticPressureFvPatchScalarField.C
blobf47606f86e4fd9cc178ca58d7ceeaa55bbfff4e3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "uniformDensityHydrostaticPressureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
32 #include "uniformDimensionedFields.H"
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
37 uniformDensityHydrostaticPressureFvPatchScalarField
39     const fvPatch& p,
40     const DimensionedField<scalar, volMesh>& iF
43     fixedValueFvPatchScalarField(p, iF),
44     rho_(0.0),
45     pRefValue_(0.0),
46     pRefPoint_(vector::zero)
50 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
51 uniformDensityHydrostaticPressureFvPatchScalarField
53     const fvPatch& p,
54     const DimensionedField<scalar, volMesh>& iF,
55     const dictionary& dict
58     fixedValueFvPatchScalarField(p, iF),
59     rho_(readScalar(dict.lookup("rho"))),
60     pRefValue_(readScalar(dict.lookup("pRefValue"))),
61     pRefPoint_(dict.lookup("pRefPoint"))
63     if (dict.found("value"))
64     {
65         fvPatchField<scalar>::operator=
66         (
67             scalarField("value", dict, p.size())
68         );
69     }
70     else
71     {
72         evaluate();
73     }
77 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
78 uniformDensityHydrostaticPressureFvPatchScalarField
80     const uniformDensityHydrostaticPressureFvPatchScalarField& ptf,
81     const fvPatch& p,
82     const DimensionedField<scalar, volMesh>& iF,
83     const fvPatchFieldMapper& mapper
86     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
87     rho_(ptf.rho_),
88     pRefValue_(ptf.pRefValue_),
89     pRefPoint_(ptf.pRefPoint_)
93 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
94 uniformDensityHydrostaticPressureFvPatchScalarField
96     const uniformDensityHydrostaticPressureFvPatchScalarField& ptf
99     fixedValueFvPatchScalarField(ptf),
100     rho_(ptf.rho_),
101     pRefValue_(ptf.pRefValue_),
102     pRefPoint_(ptf.pRefPoint_)
106 Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
107 uniformDensityHydrostaticPressureFvPatchScalarField
109     const uniformDensityHydrostaticPressureFvPatchScalarField& ptf,
110     const DimensionedField<scalar, volMesh>& iF
113     fixedValueFvPatchScalarField(ptf, iF),
114     rho_(ptf.rho_),
115     pRefValue_(ptf.pRefValue_),
116     pRefPoint_(ptf.pRefPoint_)
120 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
122 void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs()
124     if (updated())
125     {
126         return;
127     }
129     const uniformDimensionedVectorField& g =
130         db().lookupObject<uniformDimensionedVectorField>("g");
132     operator==
133     (
134         pRefValue_
135       + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_))
136     );
138     fixedValueFvPatchScalarField::updateCoeffs();
142 void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::write
144     Ostream& os
145 ) const
147     fvPatchScalarField::write(os);
148     os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl;
149     os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl;
150     os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl;
151     writeEntry("value", os);
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 namespace Foam
159     makePatchTypeField
160     (
161         fvPatchScalarField,
162         uniformDensityHydrostaticPressureFvPatchScalarField
163     );
166 // ************************************************************************* //