1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
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"
35 #include "engineTime.H"
36 #include "pointField.H"
37 #include "fvPatchField.H"
39 #include "symmetryFvPatch.H"
40 #include "tetMotionSolver.H"
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
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)
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 // Construct from components
72 Foam::thoboisMesh::thoboisMesh
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),
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)
107 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
109 // If valve is present in geometry, set the motion
110 if (valves()[valveI].stemPatchID().active())
112 // Bottom of the valve moves with given velocity
113 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
117 // If valve is present in geometry, set the motion
118 if (valves()[valveI].detachInPortPatchID().active())
120 // Bottom of the valve moves with given velocity
121 U.boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
123 U.oldTime().boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
127 // If valve is present in geometry, set the motion
128 if (valves()[valveI].detachInCylinderPatchID().active())
130 // Bottom of the valve moves with given velocity
131 U.boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
133 U.oldTime().boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
144 // ************************************************************************* //