Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / engine / engineTopoChangerMesh / thoboisMesh / thoboisMesh.C
blobccfce35cae6c77b99b10e22bdfcdd7762f9efcd4
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 "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"
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(thoboisMesh, 0);
48     addToRunTimeSelectionTable(engineTopoChangerMesh, thoboisMesh, IOobject);
52 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
56     
57 bool Foam::thoboisMesh::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::thoboisMesh::thoboisMesh
75     const IOobject& io
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),
86     deckHeight_(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)
106     {
107         vector valveVel =
108             valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
110         // If valve is present in geometry, set the motion
111         if (valves()[valveI].stemPatchID().active())
112         {
113             // Bottom of the valve moves with given velocity
114             U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
115                 valveVel;
116         }
118         // If valve is present in geometry, set the motion
119         if (valves()[valveI].detachInPortPatchID().active())
120         {
121             // Bottom of the valve moves with given velocity
122             U.boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
123                 vector::zero;
124             U.oldTime().boundaryField()[valves()[valveI].detachInPortPatchID().index()] ==
125                 vector::zero;
126         }
128         // If valve is present in geometry, set the motion
129         if (valves()[valveI].detachInCylinderPatchID().active())
130         {
131             // Bottom of the valve moves with given velocity
132             U.boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
133                vector::zero;
134             U.oldTime().boundaryField()[valves()[valveI].detachInCylinderPatchID().index()] ==
135                vector::zero;
136         }
137      
138     }
145 // ************************************************************************* //