Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / accordionEngineMesh / accordionEngineMesh.C
blob5e668b29461288d65991617227dfbd25fc1829af
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 \*---------------------------------------------------------------------------*/
27 #include "accordionEngineMesh.H"
28 #include "componentMixedTetPolyPatchVectorField.H"
29 #include "mapPolyMesh.H"
30 #include "polyTopoChange.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "GeometricField.H"
33 #include "volMesh.H"
34 #include "engineTime.H"
35 #include "pointField.H"
36 #include "fvPatchField.H"
37 #include "Switch.H"
38 #include "symmetryFvPatch.H"
39 #include "tetMotionSolver.H"
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 namespace Foam
45     defineTypeNameAndDebug(accordionEngineMesh, 0);
46     addToRunTimeSelectionTable
47     (
48         engineTopoChangerMesh,
49         accordionEngineMesh,
50         IOobject
51     );
55 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
60 bool Foam::accordionEngineMesh::realDeformation() const
63     if
64     (
65         virtualPistonPosition() + engTime().pistonDisplacement().value()
66       > deckHeight_ - SMALL
67     )
68     {
69         return true;
70     }
71     else
72     {
73         return deformation();
74     }
77 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
79 // Construct from components
80 Foam::accordionEngineMesh::accordionEngineMesh
82     const IOobject& io
83 //    bool addZonesAndMods
86     engineTopoChangerMesh(io),
87     piston_(*this, engTime().engineDict().subDict("piston")),
88     valves_(*this, engTime().engineDict().lookup("accordionEngineMesh")),
89     pistonPosition_(-GREAT),
90     virtualPistonPosition_(-GREAT),
91     deckHeight_(GREAT),
92     cylinderHeadName_(engTime().engineDict().lookup("cylinderHeadName")),
93     linerName_(engTime().engineDict().lookup("linerName")),
94     headCellSetName_(engTime().engineDict().lookup("headCellSetName"))
97     // Add zones and modifiers if not already there.
98     addMeshZones();
99     msPtr_ = motionSolver::New(*this);
103 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
106 void Foam::accordionEngineMesh::setBoundaryVelocity(volVectorField& U)
108     // Set valve velociaty
109     forAll (valves(), valveI)
110     {
111         vector valveVel =
112             valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
115         // If valve is present in geometry, set the motion
116         if (valves()[valveI].stemPatchID().active())
117         {
118             // Bottom of the valve moves with given velocity
119             U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
120                 valveVel;
121         }
122     }
126 // ************************************************************************* //