Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / accordionEngineMesh / accordionEngineMesh.C
blob0dff51b7fc53babf556229f65111583eebdc7060
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
35 #include "volMesh.H"
36 #include "engineTime.H"
37 #include "pointField.H"
38 #include "fvPatchField.H"
39 #include "Switch.H"
40 #include "symmetryFvPatch.H"
41 #include "tetDecompositionMotionSolver.H"
43 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
45 namespace Foam
47     defineTypeNameAndDebug(accordionEngineMesh, 0);
48     addToRunTimeSelectionTable(engineTopoChangerMesh, accordionEngineMesh, IOobject);
52 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
56     
57 bool Foam::accordionEngineMesh::realDeformation() const
60     if (virtualPistonPosition() + engTime().pistonDisplacement().value() > deckHeight_ - SMALL)
61     {
62         return true;
63     }
64     else
65     {
66         return deformation();
67     }
70 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
72 // Construct from components
73 Foam::accordionEngineMesh::accordionEngineMesh
75     const IOobject& io
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),
86     deckHeight_(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)
109     {
110         vector valveVel =
111             valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
114         // If valve is present in geometry, set the motion
115         if (valves()[valveI].stemPatchID().active())
116         {
117             // Bottom of the valve moves with given velocity
118             U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
119                 valveVel;
120         }
122         // If valve is present in geometry, set the motion
123         if (valves()[valveI].detachInPortPatchID().active())
124         {
125             // Bottom of the valve moves with given velocity
126             U.boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
127                 vector::zero;
128             U.oldTime().boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
129                 vector::zero;
130         }
132         // If valve is present in geometry, set the motion
133         if (valves()[valveI].detachInCylinderPatchID().active())
134         {
135             // Bottom of the valve moves with given velocity
136             U.boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
137                vector::zero;
138             U.oldTime().boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
139                vector::zero;
140         }
141      
142     }
149 // ************************************************************************* //