ThirdParty: initial commit of the packages selection mechanism using environment...
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / pistonLayer / addPistonLayerMeshModifiers.C
blobc5be6139b1d434fe883d2923426b0b68662c3b5f
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/>.
25 // ------------------------------------------------------------------------- //
27 #include "pistonLayer.H"
28 #include "slidingInterface.H"
29 #include "layerAdditionRemoval.H"
30 #include "surfaceFields.H"
31 #include "pointSet.H"
32 #include "faceSet.H"
33 #include "SortableList.H"
36 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
38 void Foam::pistonLayer::addZonesAndModifiers()
40     // Add the zones and mesh modifiers to operate piston motion
42     if
43     (
44         pointZones().size() > 0
45      || faceZones().size() > 0
46      || cellZones().size() > 0
47     )
48     {
49         Info<< "void pistonLayer::addZonesAndModifiers() : "
50             << "Zones and modifiers already present.  Skipping."
51             << endl;
53         if (topoChanger_.size() == 0)
54         {
55             FatalErrorIn
56             (
57                 "void pistonLayer::addZonesAndModifiers()"
58             )   << "Mesh modifiers not read properly"
59                 << abort(FatalError);
60         }
62         Info << "topoChanger.size() = " << topoChanger_.size() << endl;
64         checkAndCalculate();
66         setVirtualPistonPosition();
67         topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
68         topoChanger_.write();
70         return;
71     }
73     checkAndCalculate();
75     Info<< "Time = " << engTime().theta() << endl
76         << "Adding zones to the engine mesh" << endl;
78     //fz = 1: faces where layer are added/removed
79     //pz = 2: points below the virtual piston faces and head points
81     DynamicList<pointZone*> pz(2);
82     DynamicList<faceZone*> fz(1);
83     DynamicList<cellZone*> cz(0);
85     label nPointZones = 0;
86     label nFaceZones = 0;
88 #   include "addPistonLayerFaces.H"
90     {
92         pointSet headPointSet(*this, headPointsSetName_);
94         Info << "Number of head points = " << headPointSet.size() << endl;
95         pz[nPointZones] =
96             new pointZone
97             (
98                 "headPoints",
99                 headPointSet.toc(),
100                 nPointZones,
101                 pointZones()
102             );
104         nPointZones++;
106     }
108     Info<< "Adding " << nPointZones << " point and "
109         << nFaceZones << " face zones" << endl;
111     pz.setSize(nPointZones);
112     fz.setSize(nFaceZones);
113     addZones(pz, fz, cz);
115     List<polyMeshModifier*> tm(1);
116     label nMods = 0;
118     // Add piston layer addition
119     Info << "Adding Layer Addition/Removal Mesh Modifier" << endl;
121 #   include "addPistonLayerAdditionRemovalMeshModifier.H"
123     topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
124     topoChanger_.write();
126     write();
128     // Calculating the virtual piston position
129     setVirtualPistonPosition();
131     Info << "virtualPistonPosition = " << virtualPistonPosition() << endl;
132     Info << "piston position = " << pistonPosition() << endl;
137 // ************************************************************************* //