Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / engineValveSliding / engineValveSliding.C
blobbf31cc7eff73ceade1513a2f392fc64cfc640911
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2005-2010 Tommaso Lucchini
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     verticalValvesGambit
28 \*---------------------------------------------------------------------------*/
30 #include "engineValveSliding.H"
31 #include "layerAdditionRemoval.H"
32 #include "attachDetach.H"
33 #include "componentMixedTetPolyPatchVectorField.H"
34 #include "mapPolyMesh.H"
35 #include "polyTopoChange.H"
36 #include "addToRunTimeSelectionTable.H"
37 #include "GeometricField.H"
38 #include "volMesh.H"
39 #include "engineTime.H"
40 #include "pointField.H"
41 #include "fvPatchField.H"
42 #include "Switch.H"
43 #include "symmetryFvPatch.H"
44 #include "tetDecompositionMotionSolver.H"
46 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
48 namespace Foam
50     defineTypeNameAndDebug(Foam::engineValveSliding, 0);
52     addToRunTimeSelectionTable
53     (
54         engineTopoChangerMesh,
55         engineValveSliding,
56         IOobject
57     );
61 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
63 bool Foam::engineValveSliding::realDeformation() const
65     return deformation();
68 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
70 // Construct from components
71 Foam::engineValveSliding::engineValveSliding
73     const IOobject& io
76     engineTopoChangerMesh(io),
77     piston_(*this, engTime().engineDict().subDict("piston")),
78     valves_(*this, engTime().engineDict().lookup("engineValveSliding")),
79     deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
80     valveTopTol_(readScalar(engTime().engineDict().lookup("valveTopTol"))),
81     pistonPosition_(-GREAT),
82     deckHeight_(GREAT),
83     minValveZ_(nValves()),
84     poppetValveTol_
85     (
86         readScalar(engTime().engineDict().lookup("poppetValveTol"))
87     ),
88     bottomValveTol_
89     (
90         readScalar(engTime().engineDict().lookup("bottomValveTol"))
91     ),
92     msPtr_(motionSolver::New(*this)),
93     isReallyClosed_(valves().size(), false),
94     correctPointsMotion_(engTime().engineDict().lookup("correctPointsMotion"))
96     // Add zones and modifiers if not already there.
97     addZonesAndModifiers();
101 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
103 void Foam::engineValveSliding::setBoundaryVelocity(volVectorField& U)
105     // Set valve velociaty
106     forAll (valves(), valveI)
107     {
108         vector valveVel =
109             valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
111         // If valve is present in geometry, set the motion
112         if (valves()[valveI].curtainInPortPatchID().active())
113         {
114             // Bottom of the valve moves with given velocity
115             U.boundaryField()
116                 [valves()[valveI].curtainInPortPatchID().index()] ==
117 //                valveVel;
118                 vector::zero;
119         }
121         // If valve is present in geometry, set the motion
122         if (valves()[valveI].curtainInCylinderPatchID().active())
123         {
124             // Bottom of the valve moves with given velocity
125             U.boundaryField()
126                 [valves()[valveI].curtainInCylinderPatchID().index()] ==
127 //                valveVel;
128                 vector::zero;
129         }
131         // If valve is present in geometry, set the motion
132         if (valves()[valveI].poppetPatchID().active())
133         {
134             // Bottom of the valve moves with given velocity
135             U.boundaryField()[valves()[valveI].poppetPatchID().index()] ==
136                 valveVel;
137         }
139         if (valves()[valveI].bottomPatchID().active())
140         {
141             // Bottom of the valve moves with given velocity
142             U.boundaryField()[valves()[valveI].bottomPatchID().index()] ==
143                 valveVel;
144         }
146         // If valve is present in geometry, set the motion
147         if (valves()[valveI].stemPatchID().active())
148         {
149             // Bottom of the valve moves with given velocity
150             U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
151                 valveVel;
152         }
153     }
158 bool Foam::engineValveSliding::inValve(const point& p, const label& i) const
160     scalar valveX = valves_[i].cs().origin().x();
161     scalar valveY = valves_[i].cs().origin().y();
162     return
163     (
164         sqrt(sqr(p.x() - valveX) + sqr(p.y() - valveY))
165       < 0.5*valves_[i].diameter()
166     );
169 bool Foam::engineValveSliding::inPiston(const point& p) const
171     scalar pistonX = piston_.cs().origin().x();
172     scalar pistonY = piston_.cs().origin().y();
173     return
174     (
175         sqrt(sqr(p.x() - pistonX) + sqr(p.y() - pistonY))
176         < 0.5*engTime().bore().value()
177     );
181 bool Foam::engineValveSliding::isACylinderHeadFace
183     const labelList& cylHeadFaces,
184     const label face
187     forAll(cylHeadFaces, i)
188     {
189         if(cylHeadFaces[i] == face)
190         {
191             return true;
192         }
193     }
195     return false;
200 // ************************************************************************* //