BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / solvers / compressible / rhoCentralFoam / BCs / U / maxwellSlipUFvPatchVectorField.C
blob2f40670abdcb7690b2e5522df3aec0651a4eb990
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 "maxwellSlipUFvPatchVectorField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "fvcGrad.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
42     const fvPatch& p,
43     const DimensionedField<vector, volMesh>& iF
46     mixedFixedValueSlipFvPatchVectorField(p, iF),
47     accommodationCoeff_(1.0),
48     Uwall_(p.size(), vector(0.0, 0.0, 0.0)),
49     thermalCreep_(true),
50     curvature_(true)
54 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
56     const maxwellSlipUFvPatchVectorField& tdpvf,
57     const fvPatch& p,
58     const DimensionedField<vector, volMesh>& iF,
59     const fvPatchFieldMapper& mapper
62     mixedFixedValueSlipFvPatchVectorField(tdpvf, p, iF, mapper),
63     accommodationCoeff_(tdpvf.accommodationCoeff_),
64     Uwall_(tdpvf.Uwall_),
65     thermalCreep_(tdpvf.thermalCreep_),
66     curvature_(tdpvf.curvature_)
70 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
72     const fvPatch& p,
73     const DimensionedField<vector, volMesh>& iF,
74     const dictionary& dict
77     mixedFixedValueSlipFvPatchVectorField(p, iF),
78     accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
79     Uwall_("Uwall", dict, p.size()),
80     thermalCreep_(dict.lookupOrDefault("thermalCreep", true)),
81     curvature_(dict.lookupOrDefault("curvature", true))
83     if
84     (
85         mag(accommodationCoeff_) < SMALL
86      || mag(accommodationCoeff_) > 2.0
87     )
88     {
89         FatalIOErrorIn
90         (
91             "maxwellSlipUFvPatchScalarField::"
92             "maxwellSlipUFvPatchScalarField"
93             "(const fvPatch&, const scalarField&, const dictionary&)",
94             dict
95         )   << "unphysical accommodationCoeff_ specified"
96             << "(0 < accommodationCoeff_ <= 1)" << endl
97             << exit(FatalError);
98     }
100     if (dict.found("value"))
101     {
102         fvPatchField<vector>::operator=
103         (
104             vectorField("value", dict, p.size())
105         );
107         if (dict.found("refValue") && dict.found("valueFraction"))
108         {
109             this->refValue() = vectorField("refValue", dict, p.size());
110             this->valueFraction() = 
111                 scalarField("valueFraction", dict, p.size());
112         }
113         else
114         {
115             this->refValue() = *this;
116             this->valueFraction() = scalar(1.0);
117         }
118     }
122 maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
124     const maxwellSlipUFvPatchVectorField& tdpvf,
125     const DimensionedField<vector, volMesh>& iF
128     mixedFixedValueSlipFvPatchVectorField(tdpvf, iF),
129     accommodationCoeff_(tdpvf.accommodationCoeff_),
130     Uwall_(tdpvf.Uwall_),
131     thermalCreep_(tdpvf.thermalCreep_),
132     curvature_(tdpvf.curvature_)
136 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
138 void maxwellSlipUFvPatchVectorField::updateCoeffs()
140     if (updated())
141     {
142         return;
143     }
145     const fvPatchScalarField& pmu =
146         patch().lookupPatchField<volScalarField, scalar>("mu");
147     const fvPatchScalarField& prho =
148         patch().lookupPatchField<volScalarField, scalar>("rho");
149     const fvPatchField<scalar>& ppsi =
150         patch().lookupPatchField<volScalarField, scalar>("psi");
152     Field<scalar> C1
153     (
154         sqrt(ppsi*constant::mathematical::piByTwo)
155       * (2.0 - accommodationCoeff_)/accommodationCoeff_
156     );
158     Field<scalar> pnu(pmu/prho);
159     valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C1*pnu));
161     refValue() = Uwall_;
163     if (thermalCreep_)
164     {
165         const volScalarField& vsfT =
166             this->db().objectRegistry::lookupObject<volScalarField>("T");
167         label patchi = this->patch().index();
168         const fvPatchScalarField& pT = vsfT.boundaryField()[patchi];
169         Field<vector> gradpT(fvc::grad(vsfT)().boundaryField()[patchi]);
170         vectorField n(patch().nf());
172         refValue() -= 3.0*pnu/(4.0*pT)*transform(I - n*n, gradpT);
173     }
175     if (curvature_)
176     {
177         const fvPatchTensorField& ptauMC =
178             patch().lookupPatchField<volTensorField, tensor>("tauMC");
179         vectorField n(patch().nf());
181         refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
182     }
184     mixedFixedValueSlipFvPatchVectorField::updateCoeffs();
188 void maxwellSlipUFvPatchVectorField::write(Ostream& os) const
190     fvPatchVectorField::write(os);
191     os.writeKeyword("accommodationCoeff")
192         << accommodationCoeff_ << token::END_STATEMENT << nl;
193     Uwall_.writeEntry("Uwall", os);
194     os.writeKeyword("thermalCreep")
195         << thermalCreep_ << token::END_STATEMENT << nl;
196     os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl;
198     os.writeKeyword("refValue")
199         << refValue() << token::END_STATEMENT << nl;
200     os.writeKeyword("valueFraction")
201         << valueFraction() << token::END_STATEMENT << nl;
203     writeEntry("value", os);
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 makePatchTypeField
211     fvPatchVectorField,
212     maxwellSlipUFvPatchVectorField
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 } // End namespace Foam
219 // ************************************************************************* //