1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2005-2010 Tommaso Lucchini
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 \*---------------------------------------------------------------------------*/
30 #include "thoboisSliding.H"
31 #include "slidingInterface.H"
32 #include "layerAdditionRemoval.H"
33 #include "surfaceFields.H"
34 #include "regionSplit.H"
35 #include "componentMixedTetPolyPatchVectorField.H"
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 void Foam::thoboisSliding::calcMovingMaskTop(const label i) const
44 Info<< "void movingSquaresTM::calcMovingMasks() const : "
45 << "Calculating point and cell masks"
49 if (movingPointsMaskTopPtr_)
51 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
52 << "point mask already calculated"
57 movingPointsMaskTopPtr_ = new scalarField(allPoints().size(), 0);
58 scalarField& movingPointsMaskTop = *movingPointsMaskTopPtr_;
60 const cellList& c = cells();
61 const faceList& f = allFaces();
63 const labelList& cellTopVAddr =
64 cellZones()[cellZones().findZoneID("movingCellsTopZoneV"+ Foam::name(i+1))];
68 forAll (cellTopVAddr, cellI)
70 const cell& curCell = c[cellTopVAddr[cellI]];
72 forAll (curCell, faceI)
74 // Mark all the points as moving
75 const face& curFace = f[curCell[faceI]];
77 forAll (curFace, pointI)
83 movingPointsMaskTop[curFace[pointI]] = 1;
93 const labelList& cellTopAddr =
94 cellZones()[cellZones().findZoneID("movingCellsZoneV"+ Foam::name(i+1))];
96 forAll (cellTopAddr, cellI)
98 const cell& curCell = c[cellTopAddr[cellI]];
100 forAll (curCell, faceI)
102 // Mark all the points as moving
103 const face& curFace = f[curCell[faceI]];
105 forAll (curFace, pointI)
111 movingPointsMaskTop[curFace[pointI]] = 1;
124 if(valves_[i].poppetPatchID().active())
127 const word curtainCylZoneName
129 "curtainCylZoneV" + Foam::name(i + 1)
132 const labelList& curtainCylAddr =
133 faceZones()[faceZones().findZoneID(curtainCylZoneName)];
135 forAll (curtainCylAddr, faceI)
137 const face& curFace = f[curtainCylAddr[faceI]];
139 forAll (curFace, pointI)
141 movingPointsMaskTop[curFace[pointI]] = 0;
149 // Return moving points mask. Moving points marked with 1
150 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskTop(const label i) const
152 if(movingPointsMaskTopPtr_)
154 movingPointsMaskTopPtr_ = NULL;
157 if (!movingPointsMaskTopPtr_)
159 calcMovingMaskTop(i);
162 return *movingPointsMaskTopPtr_;
166 void Foam::thoboisSliding::calcMovingMaskBottom(const label i) const
170 Info<< "void movingSquaresTM::calcMovingMasks() const : "
171 << "Calculating point and cell masks"
175 if (movingPointsMaskBottomPtr_)
177 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
178 << "point mask already calculated"
179 << abort(FatalError);
182 // Set the point mask
183 movingPointsMaskBottomPtr_ = new scalarField(allPoints().size(), 0);
184 scalarField& movingPointsMaskBottom = *movingPointsMaskBottomPtr_;
186 const cellList& c = cells();
187 const faceList& f = allFaces();
189 const labelList& cellAddr =
190 cellZones()[cellZones().findZoneID("movingCellsBottomZoneV"+ Foam::name(i+1))];
192 forAll (cellAddr, cellI)
194 const cell& curCell = c[cellAddr[cellI]];
196 forAll (curCell, faceI)
198 // Mark all the points as moving
199 const face& curFace = f[curCell[faceI]];
201 forAll (curFace, pointI)
204 movingPointsMaskBottom[curFace[pointI]] = 1;
211 if(valves_[i].bottomPatchID().active())
214 const word curtainCylZoneName
216 "curtainCylZoneV" + Foam::name(i + 1)
219 const labelList& curtainCylAddr =
220 faceZones()[faceZones().findZoneID(curtainCylZoneName)];
222 forAll (curtainCylAddr, faceI)
224 const face& curFace = f[curtainCylAddr[faceI]];
226 forAll (curFace, pointI)
228 movingPointsMaskBottom[curFace[pointI]] = 0;
236 // Return moving points mask. Moving points marked with 1
237 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskBottom(const label i) const
239 if(movingPointsMaskBottomPtr_)
241 movingPointsMaskBottomPtr_ = NULL;
244 if (!movingPointsMaskBottomPtr_)
246 calcMovingMaskBottom(i);
249 return *movingPointsMaskBottomPtr_;
253 void Foam::thoboisSliding::calcMovingMaskPiston() const
257 Info<< "void movingSquaresTM::calcMovingMasks() const : "
258 << "Calculating point and cell masks"
262 if (movingPointsMaskPistonPtr_)
264 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
265 << "point mask already calculated"
266 << abort(FatalError);
269 // Set the point mask
270 movingPointsMaskPistonPtr_ = new scalarField(allPoints().size(), 0);
271 scalarField& movingPointsMaskPiston = *movingPointsMaskPistonPtr_;
273 const cellList& c = cells();
274 const faceList& f = allFaces();
276 const labelList& cellAddr =
277 cellZones()[cellZones().findZoneID("movingCellsPiston")];
279 bool foundOne(false);
281 forAll (cellAddr, cellI)
283 const cell& curCell = c[cellAddr[cellI]];
285 forAll (curCell, faceI)
287 // Mark all the points as moving
288 const face& curFace = f[curCell[faceI]];
290 forAll (curFace, pointI)
296 movingPointsMaskPiston[curFace[pointI]] = 1;
309 // Return moving points mask. Moving points marked with 1
310 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskPiston() const
312 if(movingPointsMaskPistonPtr_)
314 movingPointsMaskPistonPtr_ = NULL;
317 if (!movingPointsMaskPistonPtr_)
319 calcMovingMaskPiston();
322 return *movingPointsMaskPistonPtr_;
327 void Foam::thoboisSliding::calcMovingMaskPistonValves(const label i) const
331 Info<< "void movingSquaresTM::calcMovingMasks() const : "
332 << "Calculating point and cell masks"
336 if (movingPointsMaskPistonValvesPtr_)
338 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
339 << "point mask already calculated"
340 << abort(FatalError);
343 // Set the point mask
344 movingPointsMaskPistonValvesPtr_ = new scalarField(allPoints().size(), 0);
345 scalarField& movingPointsMaskPistonValves = *movingPointsMaskPistonValvesPtr_;
347 const cellList& c = cells();
348 const faceList& f = allFaces();
350 const labelList& cellAddr =
351 cellZones()[cellZones().findZoneID("movingCellsPistonV" + Foam::name(i+1))];
353 bool foundOne(false);
355 forAll (cellAddr, cellI)
357 const cell& curCell = c[cellAddr[cellI]];
359 forAll (curCell, faceI)
361 // Mark all the points as moving
362 const face& curFace = f[curCell[faceI]];
364 forAll (curFace, pointI)
370 movingPointsMaskPistonValves[curFace[pointI]] = 1;
383 // Return moving points mask. Moving points marked with 1
384 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskPistonValves(const label i) const
386 if(movingPointsMaskPistonValvesPtr_)
388 movingPointsMaskPistonValvesPtr_ = NULL;
391 if (!movingPointsMaskPistonValvesPtr_)
393 calcMovingMaskPistonValves(i);
396 return *movingPointsMaskPistonValvesPtr_;