Formatting
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / engineValveSliding / engineValveSliding.C
blobf1fc3d24fbf01ab1642ab396a7e7817b749abeb1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
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/>.
24 Class
25     verticalValvesGambit
27 \*---------------------------------------------------------------------------*/
29 #include "engineValveSliding.H"
30 #include "layerAdditionRemoval.H"
31 #include "attachDetach.H"
32 #include "componentMixedTetPolyPatchVectorField.H"
33 #include "mapPolyMesh.H"
34 #include "polyTopoChange.H"
35 #include "addToRunTimeSelectionTable.H"
36 #include "GeometricField.H"
37 #include "volMesh.H"
38 #include "engineTime.H"
39 #include "pointField.H"
40 #include "fvPatchField.H"
41 #include "Switch.H"
42 #include "symmetryFvPatch.H"
43 #include "tetMotionSolver.H"
45 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
47 namespace Foam
49     defineTypeNameAndDebug(Foam::engineValveSliding, 0);
51     addToRunTimeSelectionTable
52     (
53         engineTopoChangerMesh,
54         engineValveSliding,
55         IOobject
56     );
60 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
62 bool Foam::engineValveSliding::realDeformation() const
64     return deformation();
67 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
69 // Construct from components
70 Foam::engineValveSliding::engineValveSliding
72     const IOobject& io
75     engineTopoChangerMesh(io),
76     piston_(*this, engTime().engineDict().subDict("piston")),
77     valves_(*this, engTime().engineDict().lookup("engineValveSliding")),
78     deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
79     valveTopTol_(readScalar(engTime().engineDict().lookup("valveTopTol"))),
80     pistonPosition_(-GREAT),
81     deckHeight_(GREAT),
82     minValveZ_(nValves()),
83     poppetValveTol_
84     (
85         readScalar(engTime().engineDict().lookup("poppetValveTol"))
86     ),
87     bottomValveTol_
88     (
89         readScalar(engTime().engineDict().lookup("bottomValveTol"))
90     ),
91     msPtr_(motionSolver::New(*this)),
92     isReallyClosed_(valves().size(), false),
93     correctPointsMotion_(engTime().engineDict().lookup("correctPointsMotion"))
95     // Add zones and modifiers if not already there.
96     addZonesAndModifiers();
100 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
102 void Foam::engineValveSliding::setBoundaryVelocity(volVectorField& U)
104     // Set valve velociaty
105     forAll (valves(), valveI)
106     {
107         vector valveVel =
108             valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
110         // If valve is present in geometry, set the motion
111         if (valves()[valveI].curtainInPortPatchID().active())
112         {
113             // Bottom of the valve moves with given velocity
114             U.boundaryField()
115                 [valves()[valveI].curtainInPortPatchID().index()] ==
116 //                valveVel;
117                 vector::zero;
118         }
120         // If valve is present in geometry, set the motion
121         if (valves()[valveI].curtainInCylinderPatchID().active())
122         {
123             // Bottom of the valve moves with given velocity
124             U.boundaryField()
125                 [valves()[valveI].curtainInCylinderPatchID().index()] ==
126 //                valveVel;
127                 vector::zero;
128         }
130         // If valve is present in geometry, set the motion
131         if (valves()[valveI].poppetPatchID().active())
132         {
133             // Bottom of the valve moves with given velocity
134             U.boundaryField()[valves()[valveI].poppetPatchID().index()] ==
135                 valveVel;
136         }
138         if (valves()[valveI].bottomPatchID().active())
139         {
140             // Bottom of the valve moves with given velocity
141             U.boundaryField()[valves()[valveI].bottomPatchID().index()] ==
142                 valveVel;
143         }
145         // If valve is present in geometry, set the motion
146         if (valves()[valveI].stemPatchID().active())
147         {
148             // Bottom of the valve moves with given velocity
149             U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
150                 valveVel;
151         }
152     }
157 bool Foam::engineValveSliding::inValve(const point& p, const label& i) const
159     scalar valveX = valves_[i].cs().origin().x();
160     scalar valveY = valves_[i].cs().origin().y();
161     return
162     (
163         sqrt(sqr(p.x() - valveX) + sqr(p.y() - valveY))
164       < 0.5*valves_[i].diameter()
165     );
168 bool Foam::engineValveSliding::inPiston(const point& p) const
170     scalar pistonX = piston_.cs().origin().x();
171     scalar pistonY = piston_.cs().origin().y();
172     return
173     (
174         sqrt(sqr(p.x() - pistonX) + sqr(p.y() - pistonY))
175         < 0.5*engTime().bore().value()
176     );
180 bool Foam::engineValveSliding::isACylinderHeadFace
182     const labelList& cylHeadFaces,
183     const label face
186     forAll(cylHeadFaces, i)
187     {
188         if(cylHeadFaces[i] == face)
189         {
190             return true;
191         }
192     }
194     return false;
199 // ************************************************************************* //