BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / turbulenceModels / derivedFvPatchFields / porousBafflePressure / porousBafflePressureFvPatchFields.C
blob7207e3d7ac02ac7b3c1a812fce39925e5da72db5
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 "porousBafflePressureFvPatchFields.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
31 #include "compressible/turbulenceModel/turbulenceModel.H"
32 #include "incompressible/turbulenceModel/turbulenceModel.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace Foam
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 makeTemplatePatchTypeField
44     fvPatchScalarField,
45     porousBafflePressureFvPatchScalarField
48 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
50 //- Specialisation of the jump-condition for the pressure
51 template<>
52 void Foam::porousBafflePressureFvPatchField<Foam::scalar>::updateCoeffs()
54     if (updated())
55     {
56         return;
57     }
59     const label patchI = patch().index();
61     const surfaceScalarField& phi =
62             db().lookupObject<surfaceScalarField>("phi");
64     const fvsPatchField<scalar>& phip =
65         patch().patchField<surfaceScalarField, scalar>(phi);
67     scalarField Un(phip/patch().magSf());
69     scalarField magUn(mag(Un));
71     if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
72     {
73         const incompressible::turbulenceModel& model =
74             db().lookupObject<incompressible::turbulenceModel>
75             (
76                 "turbulenceModel"
77             );
79         const scalarField nuEffw = model.nuEff()().boundaryField()[patchI];
81         jump_ = -sign(Un)*(I_*nuEffw + D_*0.5*magUn*length_)*magUn;
82     }
83     else
84     {
85         const compressible::turbulenceModel& model =
86             db().lookupObject<compressible::turbulenceModel>
87             (
88                 "turbulenceModel"
89             );
91         const scalarField muEffw = model.muEff()().boundaryField()[patchI];
93         const scalarField rhow =
94             patch().lookupPatchField<volScalarField, scalar>("rho");
96         Un /= rhow;
98         jump_ = -sign(Un)*(I_*muEffw + D_*0.5*rhow*magUn*length_)*magUn;
99     }
101     if (debug)
102     {
103         scalar avePressureJump = gAverage(jump_);
104         scalar aveVelocity = gAverage(mag(Un));
106         Info<< patch().boundaryMesh().mesh().name() << ':'
107             << patch().name() << ':'
108             << " Average pressure drop :" << avePressureJump
109             << " Average velocity :" << aveVelocity
110             << endl;
111     }
113     fixedJumpFvPatchField<scalar>::updateCoeffs();
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 } // End namespace Foam
121 // ************************************************************************* //