Merge commit 'd3b269b7c6ffa0cd68845adfecdfb849316dba71' into nextRelease
[foam-extend-3.2.git] / src / engine / engineTopoChangerMesh / thoboisMesh / thoboisMesh.C
blob5a6ebec6f3f74e064928ab18122b14554bbad6cc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     |
5     \\  /    A nd           | For copyright notice see file Copyright
6      \\/     M anipulation  |
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 \*---------------------------------------------------------------------------*/
26 #include "thoboisMesh.H"
27 #include "layerAdditionRemoval.H"
28 #include "attachDetach.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"
38 #include "Switch.H"
39 #include "symmetryFvPatch.H"
40 #include "tetMotionSolver.H"
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44 namespace Foam
46     defineTypeNameAndDebug(thoboisMesh, 0);
47     addToRunTimeSelectionTable(engineTopoChangerMesh, thoboisMesh, IOobject);
51 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
56 bool Foam::thoboisMesh::realDeformation() const
59     if (virtualPistonPosition() + engTime().pistonDisplacement().value() > deckHeight_ - SMALL)
60     {
61         return true;
62     }
63     else
64     {
65         return deformation();
66     }
69 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
71 // Construct from components
72 Foam::thoboisMesh::thoboisMesh
74     const IOobject& io
77     engineTopoChangerMesh(io),
78     piston_(*this, engTime().engineDict().subDict("piston")),
79     valves_(*this, engTime().engineDict().lookup("thoboisMesh")),
80     deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
81     delta_(readScalar(engTime().engineDict().lookup("delta"))),
82     offSet_(readScalar(engTime().engineDict().lookup("offSet"))),
83     pistonPosition_(-GREAT),
84     virtualPistonPosition_(-GREAT),
85     deckHeight_(GREAT),
86     msPtr_(motionSolver::New(*this)),
87     cylinderHeadName_(engTime().engineDict().lookup("cylinderHeadName"))
90     // Add zones and modifiers if not already there.
91     addZonesAndModifiers();
95 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
98 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
101 void Foam::thoboisMesh::setBoundaryVelocity(volVectorField& U)
103     // Set valve velociaty
104     forAll (valves(), valveI)
105     {
106         vector valveVel =
107             valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
109         // If valve is present in geometry, set the motion
110         if (valves()[valveI].stemPatchID().active())
111         {
112             // Bottom of the valve moves with given velocity
113             U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
114                 valveVel;
115         }
117         // If valve is present in geometry, set the motion
118         if (valves()[valveI].detachInPortPatchID().active())
119         {
120             // Bottom of the valve moves with given velocity
121             U.boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
122                 vector::zero;
123             U.oldTime().boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
124                 vector::zero;
125         }
127         // If valve is present in geometry, set the motion
128         if (valves()[valveI].detachInCylinderPatchID().active())
129         {
130             // Bottom of the valve moves with given velocity
131             U.boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
132                vector::zero;
133             U.oldTime().boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
134                vector::zero;
135         }
137     }
144 // ************************************************************************* //