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/>.
28 Engine mesh with topological changes to simulate four-stroke engines with
29 vertical valves. The mesh is split into several regions
32 - intake/exhaust ports
35 which are connected by sliding interfaces and attach/detach boundaries.
37 Layer/addition removal is performed by piston, top and bottom of the valves.
39 TetDecompositionMotionSolver is used for mesh deformation mode.
41 Works also with Fluent (*.msh) or Gambit (*.neu) meshes since the facesZones
42 are added in a different way.
45 addVerticalValvesGambitMeshModifiers.C
46 verticalValvesGambit.C
47 verticalValvesGambitCalculate.C
48 verticalValvesGambitInitialize.C
49 verticalValvesGambitMove.C
54 \*---------------------------------------------------------------------------*/
56 #ifndef thoboisSliding_H
57 #define thoboisSliding_H
59 #include "engineTopoChangerMesh.H"
60 #include "enginePiston.H"
61 #include "motionSolver.H"
62 #include "polyPatchID.H"
63 #include "thoboisSlidingValveBank.H"
64 #include "twoDPointCorrector.H"
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 // Class forward declarations
76 /*---------------------------------------------------------------------------*\
77 Class verticalValves Declaration
78 \*---------------------------------------------------------------------------*/
82 public engineTopoChangerMesh
90 thoboisSlidingValveBank valves_;
92 //- Markup field for moving points on the top of the valve. Moving points marked with 1
93 mutable scalarField* movingPointsMaskTopPtr_;
95 //- Markup field for moving points on the bottom of the valve. Moving points marked with 1
96 mutable scalarField* movingPointsMaskBottomPtr_;
98 //- Markup field for moving points on the remainder of the cylinder mesh. Moving points marked with 1
99 mutable scalarField* movingPointsMaskPistonPtr_;
101 //- Markup field for points.
102 mutable scalarField* movingPointsMaskPistonValvesPtr_;
104 //- Layering-to-deformation switch in crank-angle degrees
105 scalar deformSwitch_;
107 //- Tolerance used when the piston faceZone is created
110 //- Distance from the piston patch
113 //- Top valve tolerance, when valve lift < tol, valve top layering is disabled
117 scalar pistonPosition_;
119 //- Virtual piston position (pistonPosition + offSet)
120 scalar virtualPistonPosition_;
122 //- Virtual position of the top of the valves
123 scalarField valveTopPosition_;
125 //- Virtual position of the bottom of the valves
126 scalarField valveBottomPosition_;
128 //- Virtual position of the bottom of the valves
129 scalarField valvePistonPosition_;
135 scalarField minValveZ_;
137 //- tolerance for valve poppet faces (used to create a faceZone)
138 scalar poppetValveTol_;
140 //- tolerance for valve poppet faces (used to create a faceZone)
141 scalar bottomValveTol_;
144 autoPtr<motionSolver> msPtr_;
146 //- Is the valve really closed
147 boolList isReallyClosed_;
149 //- correct points motion after attach
150 Switch correctPointsMotion_;
152 // Private Member Functions
154 //- Disallow default bitwise copy construct
155 thoboisSliding(const thoboisSliding&);
157 //- Disallow default bitwise assignment
158 void operator=(const thoboisSliding&);
160 //- Make layering modifiers live
161 void makeLayersLive();
163 //- Make Sliding interface modifiers live
164 void makeSlidersLive();
166 //- Is the sliding interface attached?
167 bool attached() const;
169 //- Prepare valve attach/detach
172 //- Prepare valve attach/detach
175 //- Prepare valve attach/detach
176 void prepareValveDetach();
178 //- Check if all patches exist, then calculate virtualPistonPosition,
179 //- pistonPosition and deckHeight for the first time
180 void checkAndCalculate();
182 //- Calculate the virtualPistonPosition,
183 void setVirtualPositions();
185 //- Correct the vertical motion for the points below the "virtual piston",
186 void correctVerticalMotion();
188 //- Calculate moving masks
189 void calcMovingMasks() const;
191 //- Calculate moving masks for the top of the valves
192 void calcMovingMaskTop(const label i) const;
194 //- Calculate moving masks for the bottom of the valves
195 void calcMovingMaskBottom(const label i) const;
197 //- Calculate moving masks for the piston points
198 void calcMovingMaskPiston() const;
200 //- Calculate moving masks for the piston/valve points
201 void calcMovingMaskPistonValves(const label i) const;
203 //- Return moving points mask for the top of the valves
204 const scalarField& movingPointsMaskTop(const label i) const;
206 //- Return moving points mask for the bottom of the valves
207 const scalarField& movingPointsMaskBottom(const label i) const;
209 //- Return moving points mask for the top of the valves
210 const scalarField& movingPointsMaskPiston() const;
212 //- Return moving points mask for the bottom of the valves
213 const scalarField& movingPointsMaskPistonValves(const label i) const;
215 bool realDeformation() const;
217 bool inValve(const point& p, const label& i) const;
218 bool inPiston(const point& p) const;
220 bool isACylinderHeadFace(const labelList& cylHeadFaces, const label face);
224 //- Runtime type information
225 TypeName("thoboisSliding");
230 //- Construct from database
231 explicit thoboisSliding(const IOobject& io);
234 // Destructor - default
239 inline const enginePiston& piston() const;
240 inline const thoboisSlidingValveBank& valves() const;
241 inline const scalar& deformSwitch() const;
242 inline const scalar& delta() const;
243 inline const scalar& offSet() const;
244 inline const scalar& valveTopTol() const;
245 inline const scalar& pistonPosition() const;
246 inline scalar& pistonPosition();
247 inline const scalar& virtualPistonPosition() const;
248 inline scalar& virtualPistonPosition();
249 inline const scalarField& valveTopPosition() const;
250 inline scalarField& valveTopPosition();
251 inline const scalarField& valveBottomPosition() const;
252 inline scalarField& valveBottomPosition();
253 inline const scalarField& valvePistonPosition() const;
254 inline scalarField& valvePistonPosition();
255 inline const scalar& deckHeight() const;
256 inline scalar& deckHeight();
257 inline const scalarField& minValveZ() const;
258 inline scalarField& maxValveZ();
259 inline const scalar& poppetValveTol() const;
260 inline boolList& isReallyClosed();
261 inline const boolList& isReallyClosed() const;
264 //- Return true for mesh deformation mode
265 bool deformation() const
268 engTime().thetaRevolution() > -deformSwitch_
269 && engTime().thetaRevolution() < deformSwitch_;
272 //- Return number of valves
273 label nValves() const
275 return valves_.size();
278 //- Add valve and piston zones and modifiers
279 void addZonesAndModifiers();
282 virtual bool update();
284 //- Set boundary velocities
285 void setBoundaryVelocity(volVectorField& U);
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 } // End namespace Foam
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 #include "thoboisSlidingI.H"
299 // ************************************************************************* //