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.
43 addVerticalValvesMeshModifiers.C
45 verticalValvesCalculate.C
46 verticalValvesInitialize.C
52 \*---------------------------------------------------------------------------*/
54 #ifndef verticalValves_H
55 #define verticalValves_H
57 #include "engineTopoChangerMesh.H"
58 #include "simpleEnginePiston.H"
59 #include "motionSolver.H"
60 #include "polyPatchID.H"
61 #include "verticalValveBank.H"
62 #include "twoDPointCorrector.H"
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 // Class forward declarations
71 /*---------------------------------------------------------------------------*\
72 Class verticalValves Declaration
73 \*---------------------------------------------------------------------------*/
74 class twoDPointCorrector;
78 public engineTopoChangerMesh
83 simpleEnginePiston piston_;
86 verticalValveBank valves_;
88 //- Markup field for moving points on the top of the valve. Moving points marked with 1
89 mutable scalarField* movingPointsMaskTopPtr_;
91 //- Markup field for moving points on the bottom of the valve. Moving points marked with 1
92 mutable scalarField* movingPointsMaskBottomPtr_;
94 //- Markup field for moving points on the remainder of the cylinder mesh. Moving points marked with 1
95 mutable scalarField* movingPointsMaskPistonPtr_;
97 //- Markup field for points.
98 mutable scalarField* movingPointsMaskPistonValvesPtr_;
100 //- Layering-to-deformation switch in crank-angle degrees
101 scalar deformSwitch_;
103 //- Tolerance used when the piston faceZone is created
106 //- Distance from the piston patch
109 //- Top valve tolerance, when valve lift < tol, valve top layering is disabled
113 scalar pistonPosition_;
115 //- Virtual piston position (pistonPosition + offSet)
116 scalar virtualPistonPosition_;
118 //- Virtual position of the top of the valves
119 scalarField valveTopPosition_;
121 //- Virtual position of the bottom of the valves
122 scalarField valveBottomPosition_;
124 //- Virtual position of the bottom of the valves
125 scalarField valvePistonPosition_;
131 scalarField minValveZ_;
133 //- tolerance for valve poppet faces (used to create a faceZone)
134 scalar poppetValveTol_;
136 //- tolerance for valve poppet faces (used to create a faceZone)
137 scalar bottomValveTol_;
140 autoPtr<motionSolver> msPtr_;
142 //- Is the valve really closed
143 boolList isReallyClosed_;
145 //- correct points motion after attach
146 Switch correctPointsMotion_;
150 // Private Member Functions
152 //- Disallow default bitwise copy construct
153 verticalValves(const verticalValves&);
155 //- Disallow default bitwise assignment
156 void operator=(const verticalValves&);
158 //- Make layering modifiers live
159 void makeLayersLive();
161 //- Make Sliding interface modifiers live
162 void makeSlidersLive();
164 //- Is the sliding interface attached?
165 bool attached() const;
167 //- Prepare valve attach/detach
170 //- Prepare valve attach/detach
173 //- Prepare valve attach/detach
174 void prepareValveDetach();
176 //- Check if all patches exist, then calculate virtualPistonPosition,
177 //- pistonPosition and deckHeight for the first time
178 void checkAndCalculate();
180 //- Calculate the virtualPistonPosition,
181 void setVirtualPositions();
183 //- Correct the vertical motion for the points below the "virtual piston",
184 void correctVerticalMotion();
186 //- Calculate moving masks
187 void calcMovingMasks() const;
189 //- Calculate moving masks for the top of the valves
190 void calcMovingMaskTop(const label i) const;
192 //- Calculate moving masks for the bottom of the valves
193 void calcMovingMaskBottom(const label i) const;
195 //- Calculate moving masks for the piston points
196 void calcMovingMaskPiston() const;
198 //- Calculate moving masks for the piston/valve points
199 void calcMovingMaskPistonValves(const label i) const;
201 //- Return moving points mask for the top of the valves
202 const scalarField& movingPointsMaskTop(const label i) const;
204 //- Return moving points mask for the bottom of the valves
205 const scalarField& movingPointsMaskBottom(const label i) const;
207 //- Return moving points mask for the top of the valves
208 const scalarField& movingPointsMaskPiston() const;
210 //- Return moving points mask for the bottom of the valves
211 const scalarField& movingPointsMaskPistonValves(const label i) const;
213 bool realDeformation() const;
215 bool inValve(const point& p, const label& i) const;
216 bool inPiston(const point& p) const;
218 bool isACylinderHeadFace(const labelList& cylHeadFaces, const label face);
222 //- Runtime type information
223 TypeName("verticalValves");
228 //- Construct from database
229 explicit verticalValves(const IOobject& io);
232 // Destructor - default
237 inline const simpleEnginePiston& piston() const;
238 inline const verticalValveBank& valves() const;
239 inline const scalar& deformSwitch() const;
240 inline const scalar& delta() const;
241 inline const scalar& offSet() const;
242 inline const scalar& valveTopTol() const;
243 inline const scalar& pistonPosition() const;
244 inline scalar& pistonPosition();
245 inline const scalar& virtualPistonPosition() const;
246 inline scalar& virtualPistonPosition();
247 inline const scalarField& valveTopPosition() const;
248 inline scalarField& valveTopPosition();
249 inline const scalarField& valveBottomPosition() const;
250 inline scalarField& valveBottomPosition();
251 inline const scalarField& valvePistonPosition() const;
252 inline scalarField& valvePistonPosition();
253 inline const scalar& deckHeight() const;
254 inline scalar& deckHeight();
255 inline const scalarField& minValveZ() const;
256 inline scalarField& maxValveZ();
257 inline const scalar& poppetValveTol() const;
258 inline boolList& isReallyClosed();
259 inline const boolList& isReallyClosed() const;
262 //- Return true for mesh deformation mode
263 bool deformation() const
266 engTime().thetaRevolution() > -deformSwitch_
267 && engTime().thetaRevolution() < deformSwitch_;
270 //- Return number of valves
271 label nValves() const
273 return valves_.size();
276 //- Add valve and piston zones and modifiers
277 void addZonesAndModifiers();
280 virtual bool update();
282 //- Set boundary velocities
283 void setBoundaryVelocity(volVectorField& U);
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 } // End namespace Foam
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 #include "verticalValvesI.H"
297 // ************************************************************************* //