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 "accordionEngineMesh.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(accordionEngineMesh, 0);
48 addToRunTimeSelectionTable(engineTopoChangerMesh, accordionEngineMesh, IOobject);
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
57 bool Foam::accordionEngineMesh::realDeformation() const
60 if (virtualPistonPosition() + engTime().pistonDisplacement().value() > deckHeight_ - SMALL)
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
72 // Construct from components
73 Foam::accordionEngineMesh::accordionEngineMesh
78 engineTopoChangerMesh(io),
79 piston_(*this, engTime().engineDict().subDict("piston")),
80 valves_(*this, engTime().engineDict().lookup("accordionEngineMesh")),
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")),
89 linerName_(engTime().engineDict().lookup("linerName")),
90 pistonAuxPoints_(engTime().engineDict().lookup("pistonAuxPoints")),
91 moveDetach_(engTime().engineDict().lookup("moveDetach"))
94 // Add zones and modifiers if not already there.
95 addZonesAndModifiers();
99 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 void Foam::accordionEngineMesh::setBoundaryVelocity(volVectorField& U)
107 // Set valve velociaty
108 forAll (valves(), valveI)
111 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
114 // If valve is present in geometry, set the motion
115 if (valves()[valveI].stemPatchID().active())
117 // Bottom of the valve moves with given velocity
118 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
122 // If valve is present in geometry, set the motion
123 if (valves()[valveI].detachInPortPatchID().active())
125 // Bottom of the valve moves with given velocity
126 U.boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
128 U.oldTime().boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
132 // If valve is present in geometry, set the motion
133 if (valves()[valveI].detachInCylinderPatchID().active())
135 // Bottom of the valve moves with given velocity
136 U.boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
138 U.oldTime().boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
149 // ************************************************************************* //