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-------------------------------------------------------------------------------
10License
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
29#include "faMatrices.H"
31#include "volFields.H"
32#include "famSup.H"
34
35// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
36
37namespace Foam
38{
39namespace fa
40{
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 (
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
84
85 read(dict);
86}
87
88
89// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90
91Foam::tmp<Foam::areaScalarField> Foam::fa::contactHeatFluxSource::htc() const
92{
94 (
95 "thtc",
96 mesh().time().timeName(),
97 mesh(),
100 );
101
103 (
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 (
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{
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
virtual bool read()
Re-read model coefficients if they have changed.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatrix.H:76
const GeometricField< Type, faPatchField, areaMesh > & psi() const
Definition: faMatrix.H:270
Applies contact heat flux between specified faMesh and fvMesh within a specified region for compressi...
virtual void addSup(const areaScalarField &h, const areaScalarField &rho, faMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to compressible momentum equation.
virtual bool read(const dictionary &dict)
Read source dictionary.
Intermediate abstract class for handling face-set options for the derived faOptions.
Base abstract class for handling finite area options (i.e. faOption).
Definition: faOption.H:134
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: faOption.H:164
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: faOption.C:45
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
Common functions used in temperature coupled boundaries.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
volSurfaceMapping vsm(aMesh)
Calculate the finiteArea matrix for implicit and explicit sources.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
word timeName
Definition: getTimeIndex.H:3
#define DebugInfo
Report an information message using Foam::Info.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
zeroField Sp(const Foam::zero, const GeometricField< Type, faPatchField, areaMesh > &)
A no-op source.
Namespace for OpenFOAM.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimPower
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:54
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
label timeIndex
Definition: getTimeIndex.H:30
dictionary dict
volScalarField & h
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333