1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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 "thoboisMesh.H"
28 #include "layerAdditionRemoval.H"
29 #include "attachDetach.H"
30 #include "componentMixedTetPolyPatchVectorField.H"
31 #include "mapPolyMesh.H"
32 #include "polyTopoChange.H"
33 #include "addToRunTimeSelectionTable.H"
34 #include "GeometricField.H"
36 #include "engineTime.H"
37 #include "pointField.H"
38 #include "fvPatchField.H"
40 #include "symmetryFvPatch.H"
41 #include "tetDecompositionMotionSolver.H"
43 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
47 defineTypeNameAndDebug(thoboisMesh, 0);
48 addToRunTimeSelectionTable(engineTopoChangerMesh, thoboisMesh, IOobject);
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
57 bool Foam::thoboisMesh::realDeformation() const
60 if (virtualPistonPosition() + engTime().pistonDisplacement().value() > deckHeight_ - SMALL)
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
72 // Construct from components
73 Foam::thoboisMesh::thoboisMesh
78 engineTopoChangerMesh(io),
79 piston_(*this, engTime().engineDict().subDict("piston")),
80 valves_(*this, engTime().engineDict().lookup("thoboisMesh")),
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),
87 msPtr_(motionSolver::New(*this)),
88 cylinderHeadName_(engTime().engineDict().lookup("cylinderHeadName"))
91 // Add zones and modifiers if not already there.
92 addZonesAndModifiers();
96 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 void Foam::thoboisMesh::setBoundaryVelocity(volVectorField& U)
104 // Set valve velociaty
105 forAll (valves(), valveI)
108 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
110 // If valve is present in geometry, set the motion
111 if (valves()[valveI].stemPatchID().active())
113 // Bottom of the valve moves with given velocity
114 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
118 // If valve is present in geometry, set the motion
119 if (valves()[valveI].detachInPortPatchID().active())
121 // Bottom of the valve moves with given velocity
122 U.boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
124 U.oldTime().boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
128 // If valve is present in geometry, set the motion
129 if (valves()[valveI].detachInCylinderPatchID().active())
131 // Bottom of the valve moves with given velocity
132 U.boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
134 U.oldTime().boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
145 // ************************************************************************* //