homTempFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v4
5 
6  OpenFOAM: The Open Source CFD Toolbox
7 
8  Copyright (C): 2011-2016 OpenFOAM Foundation
9 
10  OpenFOAM License:
11 
12  OpenFOAM is free software: you can redistribute it and/or modify it
13  under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20  for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 
25 \*---------------------------------------------------------------------------*/
26 
28 #include "addToRunTimeSelectionTable.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 #include "pressureInletOutletVelocityFvPatchVectorField.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36  const fvPatch& p,
37  const DimensionedField<scalar, volMesh>& iF)
38  : fixedValueFvPatchScalarField(p, iF),
39  kS_(0.0),
40  kF_(0.0),
41  solidThickness_(0.0),
42  baseTemperature_(p.size(), 0.0)
43 {
44 }
45 
47  const fvPatch& p,
48  const DimensionedField<scalar, volMesh>& iF,
49  const dictionary& dict)
50  : fixedValueFvPatchScalarField(p, iF, dict),
51  kS_(readScalar(dict.lookup("kS"))),
52  kF_(readScalar(dict.lookup("kF"))),
53  solidThickness_(readScalar(dict.lookup("solidThickness"))),
54  baseTemperature_("baseTemperature", dict, p.size())
55 {
56 }
57 
59  const homTempFvPatchScalarField& ptf,
60  const fvPatch& p,
61  const DimensionedField<scalar, volMesh>& iF,
62  const fvPatchFieldMapper& mapper)
63  : fixedValueFvPatchScalarField(ptf, p, iF, mapper),
64  kS_(ptf.kS_),
65  kF_(ptf.kF_),
66  solidThickness_(ptf.solidThickness_),
67  baseTemperature_(ptf.baseTemperature_)
68 {
69 }
70 
72  const homTempFvPatchScalarField& tppsf,
73  const DimensionedField<scalar, volMesh>& iF)
74  : fixedValueFvPatchScalarField(tppsf, iF),
75  kS_(tppsf.kS_),
76  kF_(tppsf.kF_),
77  solidThickness_(tppsf.solidThickness_),
78  baseTemperature_(tppsf.baseTemperature_)
79 {
80 }
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
85 {
86 
87  // store in "Tp" the field of scalar temperature on the patch
88  const scalarField& Tp(patch().lookupPatchField<volScalarField, scalar>("T"));
89 
90  // store in "Tc" the field of scalar temperature in the computational domain
91  const scalarField& Tc(patch().lookupPatchField<volScalarField, scalar>("T").internalField());
92  //Info << "Size of Tc: " << Tc.size() << endl;
93 
94  // initialize cell's temperature variable
95  scalarField Tcell(Tp.size(), 0); //Zero
96 
97  // distance from the face center to the cell center on patch's cells
98  const scalarField& deltaInv(patch().deltaCoeffs());
99 
100  // separately calculate the homogenization coefficient "lambda_theta"
101  const scalarField Coeff(kF_ / kS_ * solidThickness_ * deltaInv);
102 
103  // store in "cells" the labels of the cells adjacent to the face
104  const labelList cells(patch().faceCells());
105 
106  // initialize the counter
107  label cellN(0);
108  forAll(cells, patchCell)
109  {
110  cellN = cells[patchCell];
111  Tcell[patchCell] = Tc[cellN];
112  }
113 
114  // face temperature
115  const scalarField faceTemp((baseTemperature_ + Tcell * Coeff) / (1 + Coeff));
116 
117  // value assigned to the patch
118  operator==(
119  faceTemp);
120 
121  fixedValueFvPatchScalarField::updateCoeffs();
122 }
123 
125 {
126  fixedValueFvPatchScalarField::write(os);
127 
128  os.writeEntry("kS", kS_);
129  os.writeEntry("kF", kF_);
130  os.writeEntry("solidThickness", solidThickness_);
131  baseTemperature_.writeEntry("baseTemperature", os);
132  this->writeEntry("value", os);
133 }
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 namespace Foam
138 {
140  fvPatchScalarField,
142 }
143 
144 // ************************************************************************* //
Foam::homTempFvPatchScalarField
Definition: homTempFvPatchScalarField.H:46
homTempFvPatchScalarField.H
Foam::homTempFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Definition: homTempFvPatchScalarField.C:84
Foam::homTempFvPatchScalarField::write
virtual void write(Ostream &) const
Definition: homTempFvPatchScalarField.C:124
p
volScalarField & p
Definition: createRefsPimpleDyM.H:6
Foam
Definition: checkGeometry.C:32
forAll
forAll(nuTilda1, cellI)
Definition: nuTilda1EqnIrkPimple.H:19
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, fixedWallHeatFluxFvPatchScalarField)
Foam::homTempFvPatchScalarField::homTempFvPatchScalarField
homTempFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Definition: homTempFvPatchScalarField.C:35