fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / twoStrokeEngine / twoStrokeEngine.C
blobe82612044f73cdae50784943bda97c2ed8425220
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 "twoStrokeEngine.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(twoStrokeEngine, 0);
44     addToRunTimeSelectionTable
45     (
46         engineTopoChangerMesh,
47         twoStrokeEngine,
48         IOobject
49     );
53 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
55 bool Foam::twoStrokeEngine::realDeformation() const
57     if
58     (
59         virtualPistonPosition() + engTime().pistonDisplacement().value()
60       > deckHeight() - engTime().clearance().value() - SMALL
61     )
62     {
63         return true;
64     }
65     else
66     {
67         return deformation();
68     }
72 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
74 // Construct from components
75 Foam::twoStrokeEngine::twoStrokeEngine
77     const IOobject& io
80     engineTopoChangerMesh(io),
81     piston_(*this, engTime().engineDict().subDict("piston")),
82     scavInPortPatches_(engTime().engineDict().lookup("scavInPortPatches")),
83     scavInCylPatches_(engTime().engineDict().lookup("scavInCylPatches")),
84     headPointsSetName_(engTime().engineDict().lookup("headPointsSetName")),
85     headCellsSetName_(engTime().engineDict().lookup("headCellsSetName")),
86     movingCellSetName_(engTime().engineDict().lookup("movingCellSetName")),
87     movingPointsMaskPtr_(NULL),
88     deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
89     pistonPosition_(-GREAT),
90     virtualPistonPosition_(-GREAT),
91     deckHeight_(GREAT),
92     csPtr_
93     (
94         coordinateSystem::New
95         (
96             "coordinateSystem",
97             engTime().engineDict().subDict("coordinateSystem")
98         )
99     )
102     if(scavInPortPatches_.size() != scavInCylPatches_.size())
103     {
104             FatalErrorIn
105             (
106                 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
107             )   << "The size of the scavenging-cylinder patches is not"
108                 << "the same of the scavenging-port patches"
109                 << abort(FatalError);
110     }
112     forAll(scavInPortPatches_, patchi)
113     {
114         if(boundaryMesh().findPatchID(scavInPortPatches_[patchi]) == -1)
115         {
116             FatalErrorIn
117             (
118                 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
119             )   << "patch called" << scavInPortPatches_[patchi]
120                 << "does not exist"
121                 << abort(FatalError);
122         }
123     }
125     forAll(scavInCylPatches_, patchi)
126     {
127         if(boundaryMesh().findPatchID(scavInCylPatches_[patchi]) == -1)
128         {
129             FatalErrorIn
130             (
131                 "Foam::twoStrokeEngine::twoStrokeEngine(const IOobject& io)"
132             )   << "patch called" << scavInCylPatches_[patchi]
133                 << "does not exist"
134                 << abort(FatalError);
135         }
136     }
138     // Add zones and modifiers if not already there.
139     addZonesAndModifiers();
143 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
146 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
149 void Foam::twoStrokeEngine::setBoundaryVelocity(volVectorField& U)
151     vector pistonVel = piston().cs().axis()*engTime().pistonSpeed().value();
153     //  On the piston movingWallVelocity is used.
154     // There is no need to update the piston velocity
155 //    U.boundaryField()[piston().patchID().index()] = pistonVel;
157     forAll(scavInPortPatches_, patchi)
158     {
159         U.boundaryField()
160             [boundaryMesh().findPatchID(scavInPortPatches_[patchi])] ==
161             pistonVel;
162     }
166 // ************************************************************************* //