ThirdParty: initial commit of the packages selection mechanism using environment...
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / simpleTwoStroke / simpleTwoStrokeCalculate.C
blob4a856893e774cc927c57a6d726771b70b92c748f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     |
5     \\  /    A nd           | For copyright notice see file Copyright
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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/>.
24 \*---------------------------------------------------------------------------*/
27 #include "simpleTwoStroke.H"
28 #include "slidingInterface.H"
29 #include "layerAdditionRemoval.H"
30 #include "surfaceFields.H"
31 #include "regionSplit.H"
32 #include "componentMixedTetPolyPatchVectorField.H"
34 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
36 void Foam::simpleTwoStroke::correctVerticalMotion()
41 void Foam::simpleTwoStroke::calcMovingMasks() const
43     if (debug)
44     {
45         Info<< "void movingSquaresTM::calcMovingMasks() const : "
46             << "Calculating point and cell masks"
47             << endl;
48     }
50     if (movingPointsMaskPtr_)
51     {
52         FatalErrorIn("void movingSquaresTM::calcMovingMasks() const")
53             << "point mask already calculated"
54             << abort(FatalError);
55     }
57     // Set the point mask
58     movingPointsMaskPtr_ = new scalarField(allPoints().size(), 0);
59     scalarField& movingPointsMask = *movingPointsMaskPtr_;
61     const cellList& c = cells();
62     const faceList& f = allFaces();
64     const labelList& cellAddr =
65         cellZones()[cellZones().findZoneID("movingCells")];
67     forAll (cellAddr, cellI)
68     {
69         const cell& curCell = c[cellAddr[cellI]];
71         forAll (curCell, faceI)
72         {
73             // Mark all the points as moving
74             const face& curFace = f[curCell[faceI]];
76             forAll (curFace, pointI)
77             {
78                 movingPointsMask[curFace[pointI]] = 1;
79             }
80         }
81     }
84     if(foundScavPorts())
85     {
87         const word innerScavZoneName
88         (
89             scavInCylPatchName_  + "Zone"
90         );
92         const labelList& innerScavAddr =
93             faceZones()[faceZones().findZoneID(innerScavZoneName)];
95         forAll (innerScavAddr, faceI)
96         {
97             const face& curFace = f[innerScavAddr[faceI]];
99             forAll (curFace, pointI)
100             {
101                 movingPointsMask[curFace[pointI]] = 1;
102             }
103         }
105         const word outerScavZoneName
106         (
107             scavInPortPatchName_ + "Zone"
108         );
110         const labelList& outerScavAddr =
111             faceZones()[faceZones().findZoneID(outerScavZoneName)];
113         forAll (outerScavAddr, faceI)
114         {
115             const face& curFace = f[outerScavAddr[faceI]];
117             forAll (curFace, pointI)
118             {
119                 movingPointsMask[curFace[pointI]] = 0;
120             }
121         }
123     }
127 // Return moving points mask.  Moving points marked with 1
128 const Foam::scalarField& Foam::simpleTwoStroke::movingPointsMask() const
130     if(movingPointsMaskPtr_)
131     {
132         movingPointsMaskPtr_ = NULL;
133     }
135     if (!movingPointsMaskPtr_)
136     {
137         calcMovingMasks();
138     }
140     return *movingPointsMaskPtr_;
143 void Foam::simpleTwoStroke::applyMovingMask()