Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / regionModels / thermoBaffleModels / thermoBaffleModel / thermoBaffleModel.C
blobb47ec3436f52d13b0036adbf604becbe516994b1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "thermoBaffleModel.H"
27 #include "fvMesh.H"
28 #include "directMappedVariableThicknessWallPolyPatch.H"
29 #include "wedgePolyPatch.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
35 namespace regionModels
37 namespace thermoBaffleModels
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(thermoBaffleModel, 0);
43 defineRunTimeSelectionTable(thermoBaffleModel, mesh);
44 defineRunTimeSelectionTable(thermoBaffleModel, dictionary);
47 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
49 bool thermoBaffleModel::read()
51     regionModel1D::read();
52     return true;
56 void thermoBaffleModel::init()
58     if (active_)
59     {
60         const polyBoundaryMesh& rbm = regionMesh().boundaryMesh();
62         // Check if region mesh in 1-D
63         label nTotalEdges = 0;
64         const label patchi = intCoupledPatchIDs_[0];
65         nTotalEdges = 2*nLayers_*rbm[patchi].nInternalEdges();
66         nTotalEdges +=
67             nLayers_*(rbm[patchi].nEdges() - rbm[patchi].nInternalEdges());
69         reduce(nTotalEdges, sumOp<label>());
71         label nFaces = 0;
72         forAll (rbm, patchi)
73         {
74             if (
75                    rbm[patchi].size()
76                 &&
77                    (
78                        isA<wedgePolyPatch>(rbm[patchi])
79                     || isA<emptyPolyPatch>(rbm[patchi])
80                    )
81                 )
82             {
83                 nFaces += rbm[patchi].size();
84             }
85         }
86         reduce(nFaces, sumOp<label>());
88         if (nTotalEdges == nFaces)
89         {
90             oneD_ = true;
91             Info << "\nThe thermal baffle is 1D \n" << endl;
92         }
93         else
94         {
95             Info << "\nThe thermal baffle is 3D \n" << endl;
96         }
98         forAll(intCoupledPatchIDs_, i)
99         {
100             const label patchI = intCoupledPatchIDs_[i];
101             const polyPatch& pp = rbm[patchI];
103             if  (
104                     !isA<directMappedVariableThicknessWallPolyPatch>(pp)
105                  && oneD_
106                  && !constantThickness_
107                 )
108             {
109                 FatalErrorIn
110                 (
111                     "thermoBaffleModel::thermoBaffleModel"
112                     "("
113                     "   const word&,"
114                     "   const fvMesh&"
115                     ")"
116                 )   << "\n    patch type '" << pp.type()
117                     << "' not type '"
118                     << directMappedVariableThicknessWallPolyPatch::typeName
119                     << "'. This is necessary for 1D solution "
120                     << " and variable thickness"
121                     << "\n    for patch. " << pp.name()
122                     << exit(FatalError);
123             }
124             else if (!isA<directMappedWallPolyPatch>(pp))
125             {
126                 FatalErrorIn
127                 (
128                     "thermoBaffleModel::thermoBaffleModel"
129                     "("
130                     "   const word&,"
131                     "   const fvMesh&"
132                     ")"
133                 )   << "\n    patch type '" << pp.type()
134                     << "' not type '"
135                     << directMappedWallPolyPatch::typeName
136                     << "'. This is necessary for 3D solution"
137                     << "\n    for patch. " << pp.name()
138                     << exit(FatalError);
139             }
140         }
142         if (oneD_ && !constantThickness_)
143         {
144             const label patchI = intCoupledPatchIDs_[0];
145             const polyPatch& pp = rbm[patchI];
146             const directMappedVariableThicknessWallPolyPatch& ppCoupled =
147                 refCast
148                 <
149                     const directMappedVariableThicknessWallPolyPatch
150                 >(pp);
152             thickness_ = ppCoupled.thickness();
154             // Check that thickness has the right size
155             if (thickness_.size() != pp.size())
156             {
157                 FatalErrorIn
158                 (
159                     "thermoBaffleModel::thermoBaffleModel"
160                     "("
161                     "   const word&,"
162                     "   const fvMesh&"
163                     ")"
164                 )   << " coupled patches in thermoBaffle are " << nl
165                     << " different sizes from list thickness" << nl
166                     << exit(FatalError);
167             }
169             // Calculate thickness of the baffle on the first face only.
170             if (delta_.value() == 0.0)
171             {
172                 forAll (ppCoupled, localFaceI)
173                 {
174                     label faceI = ppCoupled.start() + localFaceI;
176                     label faceO =
177                         boundaryFaceOppositeFace_[localFaceI];
179                     delta_.value() = mag
180                     (
181                         regionMesh().faceCentres()[faceI]
182                       - regionMesh().faceCentres()[faceO]
183                     );
184                     break;
185                 }
186             }
187         }
188     }
192 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
194 thermoBaffleModel::thermoBaffleModel(const fvMesh& mesh)
196     regionModel1D(mesh),
197     thickness_(),
198     delta_("delta", dimLength, 0.0),
199     oneD_(false),
200     constantThickness_(true)
204 thermoBaffleModel::thermoBaffleModel
206     const word& modelType,
207     const fvMesh& mesh,
208     const dictionary& dict
212     regionModel1D(mesh, "thermoBaffle", modelType, dict, true),
213     thickness_(),
214     delta_("delta", dimLength, 0.0),
215     oneD_(false),
216     constantThickness_(dict.lookupOrDefault<bool>("constantThickness", true))
218     init();
222 thermoBaffleModel::thermoBaffleModel(const word& modelType, const fvMesh& mesh)
224     regionModel1D(mesh, "thermoBaffle", modelType),
225     thickness_(),
226     delta_("delta", dimLength, 0.0),
227     oneD_(false),
228     constantThickness_(lookupOrDefault<bool>("constantThickness", true))
230     init();
234 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
236 thermoBaffleModel::~thermoBaffleModel()
240 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
242 void thermoBaffleModel::preEvolveRegion()
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 } // End namespace thermoBaffleModels
249 } // End namespace regionModels
250 } // End namespace Foam
252 // ************************************************************************* //