1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 "regionModel1D.H"
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace regionModels
34 defineTypeNameAndDebug(regionModel1D, 0);
38 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
40 void Foam::regionModels::regionModel1D::constructMeshObjects()
42 const fvMesh& regionMesh = regionMeshPtr_();
46 new surfaceScalarField
57 dimensionedScalar("zero", dimArea, 0.0)
63 void Foam::regionModels::regionModel1D::initialise()
67 Pout<< "regionModel1D::initialise()" << endl;
70 // Calculate boundaryFaceFaces and boundaryFaceCells
72 DynamicList<label> faceIDs;
73 DynamicList<label> cellIDs;
75 label localPyrolysisFaceI = 0;
77 const polyBoundaryMesh& rbm = regionMesh().boundaryMesh();
79 forAll(intCoupledPatchIDs_, i)
81 const label patchI = intCoupledPatchIDs_[i];
82 const polyPatch& ppCoupled = rbm[patchI];
83 forAll(ppCoupled, localFaceI)
85 label faceI = ppCoupled.start() + localFaceI;
91 label ownCellI = regionMesh().faceOwner()[faceI];
92 if (ownCellI != cellI)
98 cellI = regionMesh().faceNeighbour()[faceI];
101 cellIDs.append(cellI);
102 const cell& cFaces = regionMesh().cells()[cellI];
103 faceI = cFaces.opposingFaceLabel(faceI, regionMesh().faces());
104 faceIDs.append(faceI);
106 } while (regionMesh().isInternalFace(faceI));
108 boundaryFaceOppositeFace_[localPyrolysisFaceI] = faceI;
109 faceIDs.remove(); //remove boundary face.
112 boundaryFaceFaces_[localPyrolysisFaceI].transfer(faceIDs);
113 boundaryFaceCells_[localPyrolysisFaceI].transfer(cellIDs);
115 localPyrolysisFaceI++;
120 boundaryFaceOppositeFace_.setSize(localPyrolysisFaceI);
122 surfaceScalarField& nMagSf = nMagSfPtr_();
124 forAll(intCoupledPatchIDs_, i)
126 const label patchI = intCoupledPatchIDs_[i];
127 const polyPatch& ppCoupled = rbm[patchI];
128 const vectorField& pNormals = ppCoupled.faceNormals();
129 nMagSf.boundaryField()[patchI] =
130 regionMesh().Sf().boundaryField()[patchI] & pNormals;
131 forAll(pNormals, localFaceI)
133 const vector& n = pNormals[localFaceI];
134 const labelList& faces = boundaryFaceFaces_[localFaceI];
135 forAll (faces, faceI)
137 const label faceID = faces[faceI];
138 nMagSf[faceID] = regionMesh().Sf()[faceID] & n;
145 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
147 bool Foam::regionModels::regionModel1D::read()
149 if (regionModel::read())
151 moveMesh_.readIfPresent("moveMesh", coeffs_);
162 Foam::tmp<Foam::labelField> Foam::regionModels::regionModel1D::moveMesh
164 const scalarList& deltaV,
165 const scalar minDelta
168 tmp<labelField> tcellMoveMap(new labelField(regionMesh().nCells(), 0));
169 labelField& cellMoveMap = tcellMoveMap();
176 pointField oldPoints = regionMesh().points();
177 pointField newPoints = oldPoints;
179 const polyBoundaryMesh& bm = regionMesh().boundaryMesh();
181 forAll(intCoupledPatchIDs_, localPatchI)
183 label patchI = intCoupledPatchIDs_[localPatchI];
184 const polyPatch pp = bm[patchI];
185 const vectorField& cf = regionMesh().Cf().boundaryField()[patchI];
187 forAll(pp, patchFaceI)
189 const labelList& faces = boundaryFaceFaces_[patchFaceI];
190 const labelList& cells = boundaryFaceCells_[patchFaceI];
191 const vector n = pp.faceNormals()[patchFaceI];
192 const vector sf = pp.faceAreas()[patchFaceI];
194 List<point> oldCf(faces.size() + 1);
195 oldCf[0] = cf[patchFaceI];
198 oldCf[i + 1] = regionMesh().faceCentres()[faces[i]];
201 vector newDelta = vector::zero;
202 point nbrCf = oldCf[0];
206 const label faceI = faces[i];
207 const label cellI = cells[i];
209 const face f = regionMesh().faces()[faceI];
211 newDelta += (deltaV[cellI]/mag(sf))*n;
213 vector localDelta = vector::zero;
216 const label pointI = f[pti];
220 ((nbrCf - (oldPoints[pointI] + newDelta)) & n)
224 newPoints[pointI] = oldPoints[pointI] + newDelta;
225 localDelta = newDelta;
226 cellMoveMap[cellI] = 1;
229 nbrCf = oldCf[i + 1] + localDelta;
233 const label bFaceI = boundaryFaceOppositeFace_[patchFaceI];
234 const face f = regionMesh().faces()[bFaceI];
235 const label cellI = cells[cells.size() - 1];
236 newDelta += (deltaV[cellI]/mag(sf))*n;
239 const label pointI = f[pti];
243 ((nbrCf - (oldPoints[pointI] + newDelta)) & n)
247 newPoints[pointI] = oldPoints[pointI] + newDelta;
248 cellMoveMap[cellI] = 1;
255 regionMesh().movePoints(newPoints);
261 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
263 Foam::regionModels::regionModel1D::regionModel1D(const fvMesh& mesh)
266 boundaryFaceFaces_(),
267 boundaryFaceCells_(),
268 boundaryFaceOppositeFace_(),
275 Foam::regionModels::regionModel1D::regionModel1D
278 const word& regionType,
279 const word& modelName,
283 regionModel(mesh, regionType, modelName, false),
284 boundaryFaceFaces_(regionMesh().nCells()),
285 boundaryFaceCells_(regionMesh().nCells()),
286 boundaryFaceOppositeFace_(regionMesh().nCells()),
293 constructMeshObjects();
304 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
306 Foam::regionModels::regionModel1D::~regionModel1D()
310 // ************************************************************************* //