contactHeatFluxSource.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "contactHeatFluxSource.H"
29 #include "faMatrices.H"
31 #include "volFields.H"
32 #include "famSup.H"
34 
35 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace fa
40 {
41  defineTypeNameAndDebug(contactHeatFluxSource, 0);
42  addToRunTimeSelectionTable(option, contactHeatFluxSource, dictionary);
43 }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const word& sourceName,
52  const word& modelType,
53  const dictionary& dict,
54  const fvPatch& patch
55 )
56 :
57  fa::faceSetOption(sourceName, modelType, dict, patch),
59  TName_(dict.getOrDefault<word>("T", "T")),
60  TprimaryName_(dict.get<word>("Tprimary")),
61  Tp_(mesh().lookupObject<volScalarField>(TprimaryName_)),
62  Tw1_
63  (
64  IOobject
65  (
66  "Tw1_" + sourceName,
67  mesh().time().timeName(),
68  mesh(),
69  IOobject::READ_IF_PRESENT,
70  IOobject::NO_WRITE
71  ),
72  regionMesh(),
74  zeroGradientFaPatchScalarField::typeName
75  ),
76  thicknessLayers_(Zero),
77  kappaLayers_(Zero),
78  contactRes_(0),
79  curTimeIndex_(-1)
80 {
81  fieldNames_.resize(1, TName_);
82 
83  fa::option::resetApplied();
84 
85  read(dict);
86 }
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
91 Foam::tmp<Foam::areaScalarField> Foam::fa::contactHeatFluxSource::htc() const
92 {
93  IOobject io
94  (
95  "thtc",
96  mesh().time().timeName(),
97  mesh(),
100  );
101 
103  (
104  new areaScalarField
105  (
106  io,
107  regionMesh(),
109  )
110  );
111 
112  areaScalarField& htc = thtc.ref();
113 
114  const volScalarField::Boundary& vfb = Tp_.boundaryField();
115 
116  htc.primitiveFieldRef() =
118  (
119  vsm().mapInternalToSurface<scalar>(vfb)()
120  )*patch().deltaCoeffs();
121 
122  if (contactRes_ != 0)
123  {
124  tmp<areaScalarField> tcontact
125  (
126  new areaScalarField
127  (
128  io,
129  regionMesh(),
131  (
132  "contact",
134  contactRes_
135  )
136  )
137  );
138  areaScalarField& contact = tcontact.ref();
139  htc.primitiveFieldRef() += contact.primitiveField();
140  }
141 
142  return thtc;
143 }
144 
145 
147 (
148  const areaScalarField& h,
149  const areaScalarField& rhoCph,
150  faMatrix<scalar>& eqn,
151  const label fieldi
152 )
153 {
154  if (isActive())
155  {
156  DebugInfo<< name() << ": applying source to " << eqn.psi().name()
157  << endl;
158 
159  if (curTimeIndex_ != mesh().time().timeIndex())
160  {
161  const volScalarField::Boundary& vfb = Tp_.boundaryField();
162 
163  Tw1_.primitiveFieldRef() =
164  this->vsm().mapInternalToSurface<scalar>(vfb);
165 
166  tmp<areaScalarField> htcw = htc();
167 
168  eqn += -fam::Sp(htcw(), eqn.psi()) + htcw()*Tw1_;
169 
170  curTimeIndex_ = mesh().time().timeIndex();
171  }
172  }
173 }
174 
175 
177 {
178  if (fa::option::read(dict))
179  {
180  coeffs_.readIfPresent("T", TName_);
181 
182  if (dict.readIfPresent("thicknessLayers", thicknessLayers_))
183  {
184  dict.readEntry("kappaLayers", kappaLayers_);
185 
186  if (thicknessLayers_.size() > 0)
187  {
188  // Calculate effective thermal resistance by harmonic averaging
189  forAll(thicknessLayers_, iLayer)
190  {
191  contactRes_ += thicknessLayers_[iLayer]/kappaLayers_[iLayer];
192  }
193  contactRes_ = scalar(1)/contactRes_;
194  }
195  }
196 
197  return true;
198  }
199 
200  return false;
201 }
202 
203 
204 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatricesFwd.H:43
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::fa::option::patch
const fvPatch & patch() const noexcept
Return const access to fvPatch.
Definition: faOptionI.H:42
Foam::GeometricField::primitiveField
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Definition: GeometricFieldI.H:53
Foam::fa::faceSetOption
Intermediate abstract class for handling face-set options for the derived faOptions.
Definition: faceSetOption.H:134
faMatrices.H
Foam::temperatureCoupledBase
Common functions used in temperature coupled boundaries.
Definition: temperatureCoupledBase.H:135
contactHeatFluxSource.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
famSup.H
Calculate the matrix for implicit and explicit sources.
Foam::fa::defineTypeNameAndDebug
defineTypeNameAndDebug(limitVelocity, 0)
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
vsm
volSurfaceMapping vsm(aMesh)
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
Foam::fam::Sp
tmp< faMatrix< Type > > Sp(const areaScalarField &sp, const GeometricField< Type, faPatchField, areaMesh > &vf)
Definition: famSup.C:86
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::fa::option::regionMesh
const faMesh & regionMesh() const
Return the region mesh database (demand-driven)
Definition: faOptionI.H:80
Foam::dimPower
const dimensionSet dimPower
timeName
word timeName
Definition: getTimeIndex.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fa::option::vsm
const volSurfaceMapping & vsm() const
Return volSurfaceMapping (demand-driven)
Definition: faOptionI.H:90
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fa::option::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: faOptionIO.C:54
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
zeroGradientFaPatchFields.H
Foam::fa::option::mesh
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: faOptionI.H:36
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::GeometricField::ref
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Definition: GeometricField.C:749
Foam::faMatrix::psi
const GeometricField< Type, faPatchField, areaMesh > & psi() const
Definition: faMatrix.H:255
Foam::fvPatch::deltaCoeffs
const scalarField & deltaCoeffs() const
Definition: fvPatch.C:196
Foam::temperatureCoupledBase::kappa
virtual tmp< scalarField > kappa(const scalarField &Tp) const
Given patch temperature calculate corresponding K field.
Definition: temperatureCoupledBase.C:210
Foam::fa::contactHeatFluxSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: contactHeatFluxSource.C:176
Foam::fa::contactHeatFluxSource::addSup
virtual void addSup(const areaScalarField &h, const areaScalarField &rho, faMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
Definition: contactHeatFluxSource.C:147
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fa::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, limitVelocity, dictionary)
timeIndex
label timeIndex
Definition: getTimeIndex.H:30
Foam::fa::contactHeatFluxSource::contactHeatFluxSource
contactHeatFluxSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvPatch &patch)
Construct from explicit source name and mesh.
Definition: contactHeatFluxSource.C:50
Foam::GeometricField< scalar, faPatchField, areaMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62