1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
27 \*---------------------------------------------------------------------------*/
29 #include "thoboisSliding.H"
30 #include "slidingInterface.H"
31 #include "layerAdditionRemoval.H"
32 #include "surfaceFields.H"
33 #include "regionSplit.H"
34 #include "componentMixedTetPolyPatchVectorField.H"
36 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 void Foam::thoboisSliding::calcMovingMaskTop(const label i) const
43 Info<< "void movingSquaresTM::calcMovingMasks() const : "
44 << "Calculating point and cell masks"
48 if (movingPointsMaskTopPtr_)
50 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
51 << "point mask already calculated"
56 movingPointsMaskTopPtr_ = new scalarField(allPoints().size(), 0);
57 scalarField& movingPointsMaskTop = *movingPointsMaskTopPtr_;
59 const cellList& c = cells();
60 const faceList& f = allFaces();
62 const labelList& cellTopVAddr =
63 cellZones()[cellZones().findZoneID("movingCellsTopZoneV"+ Foam::name(i+1))];
65 forAll (cellTopVAddr, cellI)
67 const cell& curCell = c[cellTopVAddr[cellI]];
69 forAll (curCell, faceI)
71 // Mark all the points as moving
72 const face& curFace = f[curCell[faceI]];
74 forAll (curFace, pointI)
76 movingPointsMaskTop[curFace[pointI]] = 1;
81 const labelList& cellTopAddr =
82 cellZones()[cellZones().findZoneID("movingCellsZoneV"+ Foam::name(i+1))];
84 forAll (cellTopAddr, cellI)
86 const cell& curCell = c[cellTopAddr[cellI]];
88 forAll (curCell, faceI)
90 // Mark all the points as moving
91 const face& curFace = f[curCell[faceI]];
93 forAll (curFace, pointI)
95 movingPointsMaskTop[curFace[pointI]] = 1;
103 if(valves_[i].poppetPatchID().active())
106 const word curtainCylZoneName
108 "curtainCylZoneV" + Foam::name(i + 1)
111 const labelList& curtainCylAddr =
112 faceZones()[faceZones().findZoneID(curtainCylZoneName)];
114 forAll (curtainCylAddr, faceI)
116 const face& curFace = f[curtainCylAddr[faceI]];
118 forAll (curFace, pointI)
120 movingPointsMaskTop[curFace[pointI]] = 0;
128 // Return moving points mask. Moving points marked with 1
129 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskTop(const label i) const
131 if(movingPointsMaskTopPtr_)
133 movingPointsMaskTopPtr_ = NULL;
136 if (!movingPointsMaskTopPtr_)
138 calcMovingMaskTop(i);
141 return *movingPointsMaskTopPtr_;
145 void Foam::thoboisSliding::calcMovingMaskBottom(const label i) const
149 Info<< "void movingSquaresTM::calcMovingMasks() const : "
150 << "Calculating point and cell masks"
154 if (movingPointsMaskBottomPtr_)
156 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
157 << "point mask already calculated"
158 << abort(FatalError);
161 // Set the point mask
162 movingPointsMaskBottomPtr_ = new scalarField(allPoints().size(), 0);
163 scalarField& movingPointsMaskBottom = *movingPointsMaskBottomPtr_;
165 const cellList& c = cells();
166 const faceList& f = allFaces();
168 const labelList& cellAddr =
169 cellZones()[cellZones().findZoneID("movingCellsBottomZoneV"+ Foam::name(i+1))];
171 forAll (cellAddr, cellI)
173 const cell& curCell = c[cellAddr[cellI]];
175 forAll (curCell, faceI)
177 // Mark all the points as moving
178 const face& curFace = f[curCell[faceI]];
180 forAll (curFace, pointI)
183 movingPointsMaskBottom[curFace[pointI]] = 1;
190 if(valves_[i].bottomPatchID().active())
193 const word curtainCylZoneName
195 "curtainCylZoneV" + Foam::name(i + 1)
198 const labelList& curtainCylAddr =
199 faceZones()[faceZones().findZoneID(curtainCylZoneName)];
201 forAll (curtainCylAddr, faceI)
203 const face& curFace = f[curtainCylAddr[faceI]];
205 forAll (curFace, pointI)
207 movingPointsMaskBottom[curFace[pointI]] = 0;
215 // Return moving points mask. Moving points marked with 1
216 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskBottom(const label i) const
218 if(movingPointsMaskBottomPtr_)
220 movingPointsMaskBottomPtr_ = NULL;
223 if (!movingPointsMaskBottomPtr_)
225 calcMovingMaskBottom(i);
228 return *movingPointsMaskBottomPtr_;
232 void Foam::thoboisSliding::calcMovingMaskPiston() const
236 Info<< "void movingSquaresTM::calcMovingMasks() const : "
237 << "Calculating point and cell masks"
241 if (movingPointsMaskPistonPtr_)
243 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
244 << "point mask already calculated"
245 << abort(FatalError);
248 // Set the point mask
249 movingPointsMaskPistonPtr_ = new scalarField(allPoints().size(), 0);
250 scalarField& movingPointsMaskPiston = *movingPointsMaskPistonPtr_;
252 const cellList& c = cells();
253 const faceList& f = allFaces();
255 const labelList& cellAddr =
256 cellZones()[cellZones().findZoneID("movingCellsPiston")];
258 forAll (cellAddr, cellI)
260 const cell& curCell = c[cellAddr[cellI]];
262 forAll (curCell, faceI)
264 // Mark all the points as moving
265 const face& curFace = f[curCell[faceI]];
267 forAll (curFace, pointI)
269 movingPointsMaskPiston[curFace[pointI]] = 1;
275 // Return moving points mask. Moving points marked with 1
276 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskPiston() const
278 if(movingPointsMaskPistonPtr_)
280 movingPointsMaskPistonPtr_ = NULL;
283 if (!movingPointsMaskPistonPtr_)
285 calcMovingMaskPiston();
288 return *movingPointsMaskPistonPtr_;
293 void Foam::thoboisSliding::calcMovingMaskPistonValves(const label i) const
297 Info<< "void movingSquaresTM::calcMovingMasks() const : "
298 << "Calculating point and cell masks"
302 if (movingPointsMaskPistonValvesPtr_)
304 FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
305 << "point mask already calculated"
306 << abort(FatalError);
309 // Set the point mask
310 movingPointsMaskPistonValvesPtr_ = new scalarField(allPoints().size(), 0);
311 scalarField& movingPointsMaskPistonValves = *movingPointsMaskPistonValvesPtr_;
313 const cellList& c = cells();
314 const faceList& f = allFaces();
316 const labelList& cellAddr =
317 cellZones()[cellZones().findZoneID("movingCellsPistonV" + Foam::name(i+1))];
319 forAll (cellAddr, cellI)
321 const cell& curCell = c[cellAddr[cellI]];
323 forAll (curCell, faceI)
325 // Mark all the points as moving
326 const face& curFace = f[curCell[faceI]];
328 forAll (curFace, pointI)
330 movingPointsMaskPistonValves[curFace[pointI]] = 1;
336 // Return moving points mask. Moving points marked with 1
337 const Foam::scalarField& Foam::thoboisSliding::movingPointsMaskPistonValves(const label i) const
339 if(movingPointsMaskPistonValvesPtr_)
341 movingPointsMaskPistonValvesPtr_ = NULL;
344 if (!movingPointsMaskPistonValvesPtr_)
346 calcMovingMaskPistonValves(i);
349 return *movingPointsMaskPistonValvesPtr_;