Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / simpleTwoStroke / simpleTwoStroke.C
blob2ce0e1e54188b6582150296094ae37738f7a96c9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 \*---------------------------------------------------------------------------*/
27 #include "simpleTwoStroke.H"
28 #include "layerAdditionRemoval.H"
29 #include "componentMixedTetPolyPatchVectorField.H"
30 #include "mapPolyMesh.H"
31 #include "polyTopoChange.H"
32 #include "addToRunTimeSelectionTable.H"
33 #include "GeometricField.H"
34 #include "volMesh.H"
35 #include "engineTime.H"
36 #include "pointField.H"
37 #include "fvPatchField.H"
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 namespace Foam
43     defineTypeNameAndDebug(simpleTwoStroke, 0);
44     addToRunTimeSelectionTable(engineTopoChangerMesh, simpleTwoStroke, IOobject);
48 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
52     
53 bool Foam::simpleTwoStroke::realDeformation() const
57     if (virtualPistonPosition()+ engTime().pistonDisplacement().value() > deckHeight()-engTime().clearance().value()-SMALL)
58     {
59         return true;
60     }
61     else
62     {
63         return deformation();
64     }
68 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
70 // Construct from components
71 Foam::simpleTwoStroke::simpleTwoStroke
73     const IOobject& io
76     engineTopoChangerMesh(io),
77     piston_(*this, engTime().engineDict().subDict("piston")),
78     scavInCylPatchName_(engTime().engineDict().lookup("scavInCylPatch")),
79     scavInPortPatchName_(engTime().engineDict().lookup("scavInPortPatch")),
80     movingPointsMaskPtr_(NULL),
81     deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
82     delta_(readScalar(engTime().engineDict().lookup("delta"))),
83     offSet_(readScalar(engTime().engineDict().lookup("offSet"))),
84     pistonPosition_(-GREAT),
85     virtualPistonPosition_(-GREAT),
86     deckHeight_(GREAT),
87     csPtr_
88     (
89         coordinateSystem::New
90         (
91             "coordinateSystem",
92             engTime().engineDict().subDict("coordinateSystem")
93         )
94     ),
95     foundScavPorts_
96     (
97         boundaryMesh().findPatchID(scavInCylPatchName_) != -1
98         &&
99         boundaryMesh().findPatchID(scavInPortPatchName_) != -1
100     ),
101     scavPortsTol_(readScalar(engTime().engineDict().lookup("scavPortsTol")))
103     // Add zones and modifiers if not already there.
104     addZonesAndModifiers();
108 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
114 void Foam::simpleTwoStroke::setBoundaryVelocity(volVectorField& U)
116     vector pistonVel = piston().cs().axis()*engTime().pistonSpeed().value();
118     // On the piston movingWallVelocity is used. There is no need to update
119     // the piston velocity
121 //    U.boundaryField()[piston().patchID().index()] = pistonVel;
123     Info << "setting the boundary velocity" << endl;
124     U.boundaryField()[boundaryMesh().findPatchID(scavInPortPatchName_)] ==
125         pistonVel;
129 bool Foam::simpleTwoStroke::portsOpened() const
132     scalar maxScavPortsZ = max
133        (
134            boundary()
135            [
136                boundaryMesh().findPatchID(scavInPortPatchName_)
137            ].patch().localPoints()
138        ).z();
141     scalar minLinerZ = min
142        (
143            boundary()
144            [
145                boundaryMesh().findPatchID(scavInCylPatchName_)
146            ].patch().localPoints()
147        ).z();
150     if (maxScavPortsZ - scavPortsTol_ < minLinerZ)
151     {
152         return false;
153     }
154     else
155     {
156         return true;
157     }
161 // ************************************************************************* //