1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | 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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "twoStrokeEngine.H"
27 #include "slidingInterface.H"
28 #include "layerAdditionRemoval.H"
29 #include "surfaceFields.H"
30 #include "regionSplit.H"
34 #include "SortableList.H"
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 void Foam::twoStrokeEngine::addZonesAndModifiers()
41 // Add the zones and mesh modifiers to operate piston motion
42 if (faceZones().size() > 0)
44 Info<< "Time = " << engTime().theta() << endl;
45 Info<< "void twoStrokeEngine::addZonesAndModifiers() : "
46 << "Zones and modifiers already present. Skipping."
49 if (topoChanger_.size() == 0)
53 "void twoStrokeEngine::addZonesAndModifiers()"
54 ) << "Mesh modifiers not read properly"
58 setVirtualPistonPosition();
66 Info<< "Time = " << engTime().theta() << endl
67 << "Adding zones to the engine mesh" << endl;
70 // fz = 4: virtual piston, outSidePort, insidePort, cutFaceZone
71 // pz = 2: piston points, cutPointZone
72 // cz = 1: moving mask
74 label nPorts = scavInCylPatches_.size();
77 List<pointZone*> pz(nPorts + 2);
78 List<faceZone*> fz(3*nPorts + 1);
80 // Added piston cells and head cells
81 List<cellZone*> cz(3);
83 label nPointZones = 0;
87 Info << "Adding piston layer faces" << endl;
89 # include "addPistonLayer.H"
91 // Add head points that do not move
94 cellSet headCellSet(*this, headCellsSetName_);
108 // Sliding interface for scavenging ports
112 forAll(scavInCylPatches_, patchi)
115 const polyPatch& innerScav =
118 boundaryMesh().findPatchID(scavInCylPatches_[patchi])
122 const polyPatch& outerScav =
125 boundaryMesh().findPatchID(scavInPortPatches_[patchi])
128 // Add zone if both patches has got faces
129 if (!innerScav.empty() && !outerScav.empty())
132 labelList isf(innerScav.size());
136 isf[i] = innerScav.start() + i;
139 fz[nFaceZones] = new faceZone
141 scavInCylPatches_[patchi] + "Zone"
142 + Foam::name(patchi + 1),
144 boolList(innerScav.size(), false),
152 labelList osf(outerScav.size());
156 osf[i] = outerScav.start() + i;
159 fz[nFaceZones] = new faceZone
161 scavInPortPatches_[patchi] + "Zone"
162 + Foam::name(patchi + 1),
164 boolList(outerScav.size(), false),
172 fz[nFaceZones] = new faceZone
174 "cutFaceZone" + Foam::name(patchi + 1),
184 pz[nPointZones] = new pointZone
186 "cutPointZone" + Foam::name(patchi + 1),
197 Info << "Adding moving cells zone" << endl;
200 cellSet movingCells(*this, movingCellSetName_);
202 cz[nCellZones] = new cellZone
213 Pout<< "Adding " << nPointZones << " point, "
214 << nFaceZones << " face zones and " << nCellZones
215 << " cell zones" << endl;
217 pz.setSize(nPointZones);
218 fz.setSize(nFaceZones);
219 cz.setSize(nCellZones);
220 addZones(pz, fz, cz);
222 List<polyMeshModifier*> tm(nPorts + 1);
225 // Add piston layer addition
227 # include "addPistonLayerAdditionRemovalMeshModifier.H"
231 forAll (scavInPortPatches_, i)
233 // Check if patches are present on local processor
235 boundaryMesh().findPatchID(scavInPortPatches_[i]);
238 boundaryMesh().findPatchID(scavInCylPatches_[i]);
240 if (sipID > -1 && sicID > -1)
244 boundaryMesh()[sipID].size() > 0
245 && boundaryMesh()[sicID].size() > 0
248 Pout<< "Adding slider for pair " << scavInPortPatches_[i]
249 << " and " << scavInCylPatches_[i]
251 << boundaryMesh()[sipID].size() << " "
252 << boundaryMesh()[sicID].size() << endl;
254 // Patches present. Add modifier
255 topoChanger_.setSize(topoChanger_.size() + 1);
262 "portCylinderInterface" + Foam::name(i + 1),
265 scavInPortPatches_[i] + "Zone" + Foam::name(i + 1),
266 scavInCylPatches_[i] + "Zone" + Foam::name(i + 1),
267 "cutPointZone" + Foam::name(i + 1),
268 "cutFaceZone" + Foam::name(i + 1),
269 scavInPortPatches_[i],
270 scavInCylPatches_[i],
271 slidingInterface::INTEGRAL,
272 true, // Attach-detach action
273 intersection::VISIBLE // Projection algorithm
283 Info << "Adding " << nMods << " topology modifiers" << endl;
285 // Calculating the virtual piston position
287 setVirtualPistonPosition();
290 topoChanger_.setSize(nMods);
292 // Write mesh modifiers
293 topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
294 topoChanger_.write();
297 Info << "virtualPistonPosition = " << virtualPistonPosition() << endl;
298 Info << "piston position = " << pistonPosition() << endl;
302 // ************************************************************************* //