1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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 "filmPyrolysisTemperatureCoupledFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "surfaceFields.H"
29 #include "pyrolysisModel.H"
30 #include "surfaceFilmModel.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::
35 filmPyrolysisTemperatureCoupledFvPatchScalarField
38 const DimensionedField<scalar, volMesh>& iF
41 fixedValueFvPatchScalarField(p, iF),
48 Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::
49 filmPyrolysisTemperatureCoupledFvPatchScalarField
51 const filmPyrolysisTemperatureCoupledFvPatchScalarField& ptf,
53 const DimensionedField<scalar, volMesh>& iF,
54 const fvPatchFieldMapper& mapper
57 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
58 phiName_(ptf.phiName_),
59 rhoName_(ptf.rhoName_),
60 deltaWet_(ptf.deltaWet_)
64 Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::
65 filmPyrolysisTemperatureCoupledFvPatchScalarField
68 const DimensionedField<scalar, volMesh>& iF,
69 const dictionary& dict
72 fixedValueFvPatchScalarField(p, iF),
73 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
74 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
75 deltaWet_(dict.lookupOrDefault<scalar>("deltaWet", 1e-6))
77 fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
81 Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::
82 filmPyrolysisTemperatureCoupledFvPatchScalarField
84 const filmPyrolysisTemperatureCoupledFvPatchScalarField& fptpsf
87 fixedValueFvPatchScalarField(fptpsf),
88 phiName_(fptpsf.phiName_),
89 rhoName_(fptpsf.rhoName_),
90 deltaWet_(fptpsf.deltaWet_)
94 Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::
95 filmPyrolysisTemperatureCoupledFvPatchScalarField
97 const filmPyrolysisTemperatureCoupledFvPatchScalarField& fptpsf,
98 const DimensionedField<scalar, volMesh>& iF
101 fixedValueFvPatchScalarField(fptpsf, iF),
102 phiName_(fptpsf.phiName_),
103 rhoName_(fptpsf.rhoName_),
104 deltaWet_(fptpsf.deltaWet_)
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs()
117 typedef regionModels::surfaceFilmModels::surfaceFilmModel filmModelType;
118 typedef regionModels::pyrolysisModels::pyrolysisModel pyrModelType;
120 // Since we're inside initEvaluate/evaluate there might be processor
121 // comms underway. Change the tag we use.
122 int oldTag = UPstream::msgType();
123 UPstream::msgType() = oldTag+1;
126 db().objectRegistry::foundObject<filmModelType>
128 "surfaceFilmProperties"
133 db().objectRegistry::foundObject<pyrModelType>
135 "pyrolysisProperties"
138 if (!filmOk || !pyrOk)
140 // do nothing on construction - film model doesn't exist yet
144 scalarField& Tp = *this;
146 const label patchI = patch().index();
148 // Retrieve film model
149 const filmModelType& filmModel =
150 db().lookupObject<filmModelType>("surfaceFilmProperties");
152 const label filmPatchI = filmModel.regionPatchID(patchI);
154 const mapDistribute& filmMap = filmModel.mappedPatches()[filmPatchI].map();
156 scalarField deltaFilm = filmModel.delta().boundaryField()[filmPatchI];
157 filmMap.distribute(deltaFilm);
159 scalarField TFilm = filmModel.Ts().boundaryField()[filmPatchI];
160 filmMap.distribute(TFilm);
163 // Retrieve pyrolysis model
164 const pyrModelType& pyrModel =
165 db().lookupObject<pyrModelType>("pyrolysisProperties");
167 const label pyrPatchI = pyrModel.regionPatchID(patchI);
169 const mapDistribute& pyrMap = pyrModel.mappedPatches()[pyrPatchI].map();
171 scalarField TPyr = pyrModel.T().boundaryField()[pyrPatchI];
172 pyrMap.distribute(TPyr);
177 if (deltaFilm[i] > deltaWet_)
179 // temperature set by film
184 // temperature set by pyrolysis model
190 UPstream::msgType() = oldTag;
192 fixedValueFvPatchScalarField::updateCoeffs();
196 void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::write
201 fvPatchScalarField::write(os);
202 writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
203 writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
204 os.writeKeyword("deltaWet") << deltaWet_ << token::END_STATEMENT << nl;
205 writeEntry("value", os);
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 filmPyrolysisTemperatureCoupledFvPatchScalarField
221 // ************************************************************************* //