thermalBaffleFvPatchScalarField.C 6.32 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
Henry's avatar
Henry committed
5
    \\  /    A nd           | Copyright (C) 2011-2013 OpenFOAM Foundation
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

Henry's avatar
Henry committed
26
#include "thermalBaffleFvPatchScalarField.H"
27
28
29
30
31
32
33
34
35
36
37
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace compressible
{

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Henry's avatar
Henry committed
38
39
thermalBaffleFvPatchScalarField::
thermalBaffleFvPatchScalarField
40
41
42
43
44
45
46
47
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF
)
:
    turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(p, iF),
    owner_(false),
    baffle_(),
48
    dict_(dictionary::null)
49
50
51
{}


Henry's avatar
Henry committed
52
53
thermalBaffleFvPatchScalarField::
thermalBaffleFvPatchScalarField
54
(
Henry's avatar
Henry committed
55
    const thermalBaffleFvPatchScalarField& ptf,
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
    (
        ptf,
        p,
        iF,
        mapper
    ),
    owner_(ptf.owner_),
    baffle_(ptf.baffle_),
70
    dict_(ptf.dict_)
71
72
73
{}


Henry's avatar
Henry committed
74
75
thermalBaffleFvPatchScalarField::
thermalBaffleFvPatchScalarField
76
77
78
79
80
81
82
83
84
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(p, iF, dict),
    owner_(false),
    baffle_(),
85
    dict_(dict)
86
{
87
    if (!isA<mappedPatchBase>(patch().patch()))
88
89
90
    {
        FatalErrorIn
        (
Henry's avatar
Henry committed
91
92
            "thermalBaffleFvPatchScalarField::"
            "thermalBaffleFvPatchScalarField\n"
93
94
95
96
97
98
            "(\n"
            "    const fvPatch& p,\n"
            "    const DimensionedField<scalar, volMesh>& iF,\n"
            "    const dictionary& dict\n"
            ")\n"
        )   << "\n    patch type '" << patch().type()
99
            << "' not type '" << mappedPatchBase::typeName << "'"
100
101
102
103
104
105
            << "\n    for patch " << patch().name()
            << " of field " << dimensionedInternalField().name()
            << " in file " << dimensionedInternalField().objectPath()
            << exit(FatalError);
    }

106
107
    const mappedPatchBase& mpp =
        refCast<const mappedPatchBase>(patch().patch());
108
109
110

    const word nbrMesh = mpp.sampleRegion();

111
112
    const fvMesh& thisMesh = patch().boundaryMesh().mesh();

Henry's avatar
Henry committed
113
    typedef regionModels::thermalBaffleModels::thermalBaffleModel baffle;
114
115
116
117

    if
    (
        thisMesh.name() == polyMesh::defaultRegion
118
     && !thisMesh.foundObject<baffle>(nbrMesh)
119
120
121
     && !owner_
    )
    {
andy's avatar
andy committed
122
        Info << "Creating thermal baffle" <<  nbrMesh << endl;
123
124
        baffle_.reset(baffle::New(thisMesh, dict).ptr());
        owner_ = true;
125
        baffle_->rename(nbrMesh);
126
127
128
129
    }
}


Henry's avatar
Henry committed
130
131
thermalBaffleFvPatchScalarField::
thermalBaffleFvPatchScalarField
132
(
Henry's avatar
Henry committed
133
    const thermalBaffleFvPatchScalarField& ptf,
134
135
136
137
138
139
    const DimensionedField<scalar, volMesh>& iF
)
:
    turbulentTemperatureCoupledBaffleMixedFvPatchScalarField(ptf, iF),
    owner_(ptf.owner_),
    baffle_(ptf.baffle_),
140
    dict_(ptf.dict_)
141
142
{}

143

144
145
146
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //


Henry's avatar
Henry committed
147
void thermalBaffleFvPatchScalarField::autoMap
148
149
150
151
152
153
154
155
(
    const fvPatchFieldMapper& m
)
{
    mixedFvPatchScalarField::autoMap(m);
}


Henry's avatar
Henry committed
156
void thermalBaffleFvPatchScalarField::rmap
157
158
159
160
161
162
163
164
165
(
    const fvPatchScalarField& ptf,
    const labelList& addr
)
{
    mixedFvPatchScalarField::rmap(ptf, addr);
}


Henry's avatar
Henry committed
166
void thermalBaffleFvPatchScalarField::updateCoeffs()
167
168
169
170
171
172
173
174
{
    if (this->updated())
    {
        return;
    }

    const fvMesh& thisMesh = patch().boundaryMesh().mesh();

175
    if (owner_ && thisMesh.name() == polyMesh::defaultRegion)
176
177
178
179
180
181
182
183
    {
        baffle_->evolve();
    }

    turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs();
}


Henry's avatar
Henry committed
184
void thermalBaffleFvPatchScalarField::write(Ostream& os) const
185
186
187
188
189
190
191
{
    turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write(os);

    const fvMesh& thisMesh = patch().boundaryMesh().mesh();

    if (thisMesh.name() == polyMesh::defaultRegion && owner_)
    {
Henry's avatar
Henry committed
192
        word thermoModel = dict_.lookup("thermalBaffleModel");
193

Henry's avatar
Henry committed
194
        os.writeKeyword("thermalBaffleModel")
195
            << thermoModel
196
197
            << token::END_STATEMENT << nl;

198
199
        word regionName = dict_.lookup("regionName");
        os.writeKeyword("regionName") << regionName
200
201
            << token::END_STATEMENT << nl;

202
203
        bool infoOutput = readBool(dict_.lookup("infoOutput"));
        os.writeKeyword("infoOutput") << infoOutput
204
205
            << token::END_STATEMENT << nl;

206
207
208
        bool active = readBool(dict_.lookup("active"));
        os.writeKeyword("active") <<  active
            << token::END_STATEMENT << nl;
209

210
211
        os.writeKeyword(word(thermoModel + "Coeffs"));
        os << dict_.subDict(thermoModel + "Coeffs") << nl;
212

213
214
        os.writeKeyword("thermoType");
        os << dict_.subDict("thermoType") << nl;
215

216
217
        os.writeKeyword("mixture");
        os << dict_.subDict("mixture") << nl;
218

219
220
221
        os.writeKeyword("radiation");
        os << dict_.subDict("radiation") << nl;
   }
222
223
}

224

225
226
227
228
229
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

makePatchTypeField
(
    fvPatchScalarField,
Henry's avatar
Henry committed
230
    thermalBaffleFvPatchScalarField
231
232
233
234
235
236
237
238
239
240
);


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace compressible
} // End namespace Foam


// ************************************************************************* //