thermalBaffleFvPatchScalarField.C 8.07 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2016 OpenFOAM Foundation
9
    Copyright (C) 2020 OpenCFD Ltd
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
-------------------------------------------------------------------------------
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
29
#include "thermalBaffleFvPatchScalarField.H"
30
#include "addToRunTimeSelectionTable.H"
31 32
#include "emptyPolyPatch.H"
#include "mappedWallPolyPatch.H"
33 34 35 36 37 38 39 40 41 42

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

namespace Foam
{
namespace compressible
{

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

43
thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField
44 45 46 47 48
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF
)
:
49
    turbulentTemperatureRadCoupledMixedFvPatchScalarField(p, iF),
50
    owner_(false),
51
    internal_(true),
52
    baffle_(),
53 54
    dict_(dictionary::null),
    extrudeMeshPtr_()
55 56 57
{}


58
thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField
59
(
Henry's avatar
Henry committed
60
    const thermalBaffleFvPatchScalarField& ptf,
61 62 63 64 65
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
66
    turbulentTemperatureRadCoupledMixedFvPatchScalarField
67 68 69 70 71 72 73
    (
        ptf,
        p,
        iF,
        mapper
    ),
    owner_(ptf.owner_),
74
    internal_(ptf.internal_),
75 76 77
    baffle_(),
    dict_(ptf.dict_),
    extrudeMeshPtr_()
78 79 80
{}


81
thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField
82 83 84 85 86 87
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
88
    turbulentTemperatureRadCoupledMixedFvPatchScalarField(p, iF, dict),
89
    owner_(false),
90
    internal_(true),
91
    baffle_(),
92 93
    dict_(dict),
    extrudeMeshPtr_()
94
{
95

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

Henry's avatar
Henry committed
98
    typedef regionModels::thermalBaffleModels::thermalBaffleModel baffle;
99

100 101
    word regionName("none");
    dict_.readIfPresent("region", regionName);
102

103
    dict_.readIfPresent("internal", internal_);
104

105 106 107 108 109 110 111 112
    const word baffleName("3DBaffle" + regionName);

    if
    (
        !thisMesh.time().foundObject<fvMesh>(regionName)
        && regionName != "none"
    )
    {
113
        if (!extrudeMeshPtr_)
114
        {
115
            createPatchMesh();
116
        }
117 118 119 120

        baffle_.reset(baffle::New(thisMesh, dict).ptr());
        owner_ = true;
        baffle_->rename(baffleName);
121 122 123 124
    }
}


125
thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField
126
(
Henry's avatar
Henry committed
127
    const thermalBaffleFvPatchScalarField& ptf,
128 129 130
    const DimensionedField<scalar, volMesh>& iF
)
:
131
    turbulentTemperatureRadCoupledMixedFvPatchScalarField(ptf, iF),
132
    owner_(ptf.owner_),
133
    internal_(ptf.internal_),
134 135 136
    baffle_(),
    dict_(ptf.dict_),
    extrudeMeshPtr_()
137 138
{}

139

140 141 142
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //


Henry's avatar
Henry committed
143
void thermalBaffleFvPatchScalarField::autoMap
144 145 146 147 148 149 150 151
(
    const fvPatchFieldMapper& m
)
{
    mixedFvPatchScalarField::autoMap(m);
}


Henry's avatar
Henry committed
152
void thermalBaffleFvPatchScalarField::rmap
153 154 155 156 157 158 159 160 161
(
    const fvPatchScalarField& ptf,
    const labelList& addr
)
{
    mixedFvPatchScalarField::rmap(ptf, addr);
}


162 163
void thermalBaffleFvPatchScalarField::createPatchMesh()
{
164
    const fvMesh& thisMesh = patch().boundaryMesh().mesh();
165

166
    const word regionName(dict_.get<word>("region"));
167

168 169 170 171 172 173 174 175 176 177
    List<polyPatch*> regionPatches(3);
    List<word> patchNames(regionPatches.size());
    List<word> patchTypes(regionPatches.size());
    List<dictionary> dicts(regionPatches.size());

    patchNames[bottomPatchID] = word("bottom");
    patchNames[sidePatchID] = word("side");
    patchNames[topPatchID] = word("top");

    patchTypes[bottomPatchID] = mappedWallPolyPatch::typeName;
178 179 180 181 182 183 184 185 186

    if (internal_)
    {
        patchTypes[topPatchID] = mappedWallPolyPatch::typeName;
    }
    else
    {
        patchTypes[topPatchID] = polyPatch::typeName;
    }
187

188
    if (dict_.get<bool>("columnCells"))
189 190 191 192 193 194 195 196 197
    {
        patchTypes[sidePatchID] = emptyPolyPatch::typeName;
    }
    else
    {
        patchTypes[sidePatchID] = polyPatch::typeName;
    }

    const mappedPatchBase& mpp =
198
        refCast<const mappedPatchBase>(patch().patch(), dict_);
199 200 201 202 203 204

    const word coupleGroup(mpp.coupleGroup());

    wordList inGroups(1);
    inGroups[0] = coupleGroup;

205
    // The bottomPatchID is coupled with this patch
206 207 208
    dicts[bottomPatchID].add("coupleGroup", coupleGroup);
    dicts[bottomPatchID].add("inGroups", inGroups);
    dicts[bottomPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
209 210
    dicts[bottomPatchID].add("samplePatch", patch().name());
    dicts[bottomPatchID].add("sampleRegion", thisMesh.name());
211

212 213 214 215 216
    // Internal baffle needs a coupled on the topPatchID
    if (internal_)
    {
        const word coupleGroupSlave =
            coupleGroup.substr(0, coupleGroup.find('_')) + "_slave";
217

218 219 220 221 222
        inGroups[0] = coupleGroupSlave;
        dicts[topPatchID].add("coupleGroup", coupleGroupSlave);
        dicts[topPatchID].add("inGroups", inGroups);
        dicts[topPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
    }
223 224


225
    forAll(regionPatches, patchi)
226
    {
227
        dictionary&  patchDict = dicts[patchi];
228 229 230
        patchDict.set("nFaces", 0);
        patchDict.set("startFace", 0);

231
        regionPatches[patchi] = polyPatch::New
232
        (
233 234 235 236
            patchTypes[patchi],
            patchNames[patchi],
            dicts[patchi],
            patchi,
237 238 239 240
            thisMesh.boundaryMesh()
        ).ptr();
    }

241 242 243 244
    extrudeMeshPtr_.reset
    (
        new extrudePatchMesh
        (
245
            thisMesh,
246 247
            patch(),
            dict_,
248 249
            regionName,
            regionPatches
250 251 252 253 254
        )
    );
}


Henry's avatar
Henry committed
255
void thermalBaffleFvPatchScalarField::updateCoeffs()
256 257 258 259 260 261
{
    if (this->updated())
    {
        return;
    }

262
    if (owner_)
263 264 265 266
    {
        baffle_->evolve();
    }

267
    turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs();
268 269 270
}


Henry's avatar
Henry committed
271
void thermalBaffleFvPatchScalarField::write(Ostream& os) const
272
{
273
    turbulentTemperatureRadCoupledMixedFvPatchScalarField::write(os);
274

275
    if (owner_)
276
    {
277
        os.writeEntry("extrudeModel", dict_.get<word>("extrudeModel"));
278

279
        os.writeEntry("nLayers", dict_.get<label>("nLayers"));
280

281
        os.writeEntry("expansionRatio", dict_.get<scalar>("expansionRatio"));
282

283 284 285
        os.writeEntry("columnCells", dict_.get<Switch>("columnCells"));

        const word extrudeModel(dict_.get<word>("extrudeModel") + "Coeffs");
286

287
        dict_.subDict(extrudeModel).writeEntry(extrudeModel, os);
288

289
        os.writeEntry("region", dict_.get<word>("region"));
290

291 292
        os.writeEntryIfDifferent<bool>("internal", true, internal_);

293
        os.writeEntry("active", dict_.get<Switch>("active"));
294

295 296 297
        dict_.subDict("thermoType").writeEntry("thermoType", os);
        dict_.subDict("mixture").writeEntry("mixture", os);
        dict_.subDict("radiation").writeEntry("radiation", os);
298
   }
299 300
}

301

302 303 304 305 306
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

makePatchTypeField
(
    fvPatchScalarField,
Henry's avatar
Henry committed
307
    thermalBaffleFvPatchScalarField
308 309 310 311 312 313 314 315 316 317
);


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

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


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