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
29 Engine mesh with topological changes to simulate four-stroke engines with
30 vertical valves. The mesh is split into several regions
33 - intake/exhaust ports
36 which are connected by sliding interfaces and attach/detach boundaries.
38 Layer/addition removal is performed by piston, top and bottom of the valves.
40 TetDecompositionMotionSolver is used for mesh deformation mode.
42 Works also with Fluent (*.msh) or Gambit (*.neu) meshes since the facesZones
43 are added in a different way.
46 addVerticalValvesGambitMeshModifiers.C
47 verticalValvesGambit.C
48 verticalValvesGambitCalculate.C
49 verticalValvesGambitInitialize.C
50 verticalValvesGambitMove.C
55 \*---------------------------------------------------------------------------*/
57 #ifndef pistonSliding_H
58 #define pistonSliding_H
60 #include "engineTopoChangerMesh.H"
61 #include "enginePiston.H"
62 #include "motionSolver.H"
63 #include "polyPatchID.H"
64 #include "thoboisSlidingValveBank.H"
65 #include "twoDPointCorrector.H"
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 // Class forward declarations
77 /*---------------------------------------------------------------------------*\
78 Class verticalValves Declaration
79 \*---------------------------------------------------------------------------*/
83 public engineTopoChangerMesh
91 thoboisSlidingValveBank valves_;
93 //- Markup field for moving points on the top of the valve. Moving points marked with 1
94 mutable scalarField* movingPointsMaskTopPtr_;
96 //- Markup field for moving points on the bottom of the valve. Moving points marked with 1
97 mutable scalarField* movingPointsMaskBottomPtr_;
99 //- Markup field for moving points on the remainder of the cylinder mesh. Moving points marked with 1
100 mutable scalarField* movingPointsMaskPistonPtr_;
102 //- Markup field for points.
103 mutable scalarField* movingPointsMaskPistonValvesPtr_;
105 //- Layering-to-deformation switch in crank-angle degrees
106 scalar deformSwitch_;
108 //- Tolerance used when the piston faceZone is created
111 //- Distance from the piston patch
114 //- Top valve tolerance, when valve lift < tol, valve top layering is disabled
118 scalar pistonPosition_;
120 //- Virtual piston position (pistonPosition + offSet)
121 scalar virtualPistonPosition_;
123 //- Virtual position of the top of the valves
124 scalarField valveTopPosition_;
126 //- Virtual position of the bottom of the valves
127 scalarField valveBottomPosition_;
129 //- Virtual position of the bottom of the valves
130 scalarField valvePistonPosition_;
136 scalarField minValveZ_;
138 //- tolerance for valve poppet faces (used to create a faceZone)
139 scalar poppetValveTol_;
141 //- tolerance for valve poppet faces (used to create a faceZone)
142 scalar bottomValveTol_;
145 autoPtr<motionSolver> msPtr_;
147 //- Is the valve really closed
148 boolList isReallyClosed_;
150 //- correct points motion after attach
151 Switch correctPointsMotion_;
153 // Private Member Functions
155 //- Disallow default bitwise copy construct
156 pistonSliding(const pistonSliding&);
158 //- Disallow default bitwise assignment
159 void operator=(const pistonSliding&);
161 //- Make layering modifiers live
162 void makeLayersLive();
164 //- Make Sliding interface modifiers live
165 void makeSlidersLive();
167 //- Is the sliding interface attached?
168 bool attached() const;
170 //- Prepare valve attach/detach
173 //- Prepare valve attach/detach
176 //- Prepare valve attach/detach
177 void prepareValveDetach();
179 //- Check if all patches exist, then calculate virtualPistonPosition,
180 //- pistonPosition and deckHeight for the first time
181 void checkAndCalculate();
183 //- Calculate the virtualPistonPosition,
184 void setVirtualPositions();
186 //- Correct the vertical motion for the points below the "virtual piston",
187 void correctVerticalMotion();
189 //- Calculate moving masks
190 void calcMovingMasks() const;
192 //- Calculate moving masks for the top of the valves
193 void calcMovingMaskTop(const label i) const;
195 //- Calculate moving masks for the bottom of the valves
196 void calcMovingMaskBottom(const label i) const;
198 //- Calculate moving masks for the piston points
199 void calcMovingMaskPiston() const;
201 //- Calculate moving masks for the piston/valve points
202 void calcMovingMaskPistonValves(const label i) const;
204 //- Return moving points mask for the top of the valves
205 const scalarField& movingPointsMaskTop(const label i) const;
207 //- Return moving points mask for the bottom of the valves
208 const scalarField& movingPointsMaskBottom(const label i) const;
210 //- Return moving points mask for the top of the valves
211 const scalarField& movingPointsMaskPiston() const;
213 //- Return moving points mask for the bottom of the valves
214 const scalarField& movingPointsMaskPistonValves(const label i) const;
216 bool realDeformation() const;
218 bool inValve(const point& p, const label& i) const;
219 bool inPiston(const point& p) const;
221 bool isACylinderHeadFace(const labelList& cylHeadFaces, const label face);
225 //- Runtime type information
226 TypeName("pistonSliding");
231 //- Construct from database
232 explicit pistonSliding(const IOobject& io);
235 // Destructor - default
240 inline const enginePiston& piston() const;
241 inline const thoboisSlidingValveBank& valves() const;
242 inline const scalar& deformSwitch() const;
243 inline const scalar& delta() const;
244 inline const scalar& offSet() const;
245 inline const scalar& valveTopTol() const;
246 inline const scalar& pistonPosition() const;
247 inline scalar& pistonPosition();
248 inline const scalar& virtualPistonPosition() const;
249 inline scalar& virtualPistonPosition();
250 inline const scalarField& valveTopPosition() const;
251 inline scalarField& valveTopPosition();
252 inline const scalarField& valveBottomPosition() const;
253 inline scalarField& valveBottomPosition();
254 inline const scalarField& valvePistonPosition() const;
255 inline scalarField& valvePistonPosition();
256 inline const scalar& deckHeight() const;
257 inline scalar& deckHeight();
258 inline const scalarField& minValveZ() const;
259 inline scalarField& maxValveZ();
260 inline const scalar& poppetValveTol() const;
261 inline boolList& isReallyClosed();
262 inline const boolList& isReallyClosed() const;
265 //- Return true for mesh deformation mode
266 bool deformation() const
269 engTime().thetaRevolution() > -deformSwitch_
270 && engTime().thetaRevolution() < deformSwitch_;
273 //- Return number of valves
274 label nValves() const
276 return valves_.size();
279 //- Add valve and piston zones and modifiers
280 void addZonesAndModifiers();
283 virtual bool update();
285 //- Set boundary velocities
286 void setBoundaryVelocity(volVectorField& U);
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 } // End namespace Foam
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 #include "pistonSlidingI.H"
299 // ************************************************************************* //