1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | 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 "layerSmooth.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"
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 defineTypeNameAndDebug(Foam::layerSmooth, 0);
44 addToRunTimeSelectionTable
46 Foam::engineTopoChangerMesh,
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
54 bool Foam::layerSmooth::realDeformation() const
59 virtualPistonPosition() + engTime().pistonDisplacement().value()
72 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
74 // Construct from components
75 Foam::layerSmooth::layerSmooth
80 engineTopoChangerMesh(io),
81 piston_(*this, engTime().engineDict().subDict("piston")),
82 valves_(*this, engTime().engineDict().lookup("layerSmooth")),
83 deformSwitch_(readScalar(engTime().engineDict().lookup("deformAngle"))),
84 delta_(readScalar(engTime().engineDict().lookup("delta"))),
85 offSet_(readScalar(engTime().engineDict().lookup("offSet"))),
86 pistonPosition_(-GREAT),
87 virtualPistonPosition_(-GREAT),
89 msPtr_(motionSolver::New(*this)),
90 valvePlaneTol_(readScalar(engTime().engineDict().lookup("valvePlaneTol")))
94 forAll(valves(), valveI)
98 valves()[valveI].stemPatchID().active()
99 && valves()[valveI].bottomPatchID().active()
102 label bottomIndex = valves()[valveI].bottomPatchID().index();
103 label stemIndex = valves()[valveI].stemPatchID().index();
105 const polyPatch& stemPatch =
106 boundaryMesh()[stemIndex];
108 const polyPatch& bottomPatch =
109 boundaryMesh()[bottomIndex];
111 point bottomPatchCentre = vector::zero;
112 point stemPatchCentre = vector::zero;
114 scalar bottomArea = 0;
117 Switch halfGeometry(engTime().engineDict().lookup("halfGeometry"));
122 stemPatch.faceCentres()[i]*mag(stemPatch.faceAreas()[i]);
124 stemArea += mag(stemPatch.faceAreas()[i]);
127 forAll(bottomPatch, i)
129 bottomPatchCentre +=bottomPatch.faceCentres()[i]*
130 mag(bottomPatch.faceAreas()[i]);
132 bottomArea += mag(bottomPatch.faceAreas()[i]);
137 Info << "half Geometry active" << endl;
144 stemPatch.faceCentres()[i].x(),
145 -1.0*stemPatch.faceCentres()[i].y(),
146 stemPatch.faceCentres()[i].z()
147 )*mag(stemPatch.faceAreas()[i]);
149 stemArea += mag(stemPatch.faceAreas()[i]);
152 forAll(bottomPatch, i)
157 bottomPatch.faceCentres()[i].x(),
158 -1.0*bottomPatch.faceCentres()[i].y(),
159 bottomPatch.faceCentres()[i].z()
160 )*mag(bottomPatch.faceAreas()[i]);
162 bottomArea += mag(bottomPatch.faceAreas()[i]);
166 stemPatchCentre /= stemArea;
167 bottomPatchCentre /= bottomArea;
170 Info<< "Foam::layerSmooth::layerSmooth"
171 << " calculated origin for valve n. " << valveI
172 << " is " << (stemPatchCentre) << endl;
174 Info<< "Foam::layerSmooth::layerSmooth"
175 << " calculated axis for valve n. " << valveI
177 << (stemPatchCentre - bottomPatchCentre)/
178 mag(stemPatchCentre-bottomPatchCentre)
183 // Add zones and modifiers if not already there.
184 addZonesAndModifiers();
188 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
191 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
194 void Foam::layerSmooth::setBoundaryVelocity(volVectorField& U)
196 // Set valve velociaty
197 forAll (valves(), valveI)
200 valves()[valveI].curVelocity()*valves()[valveI].cs().axis();
202 // If valve is present in geometry, set the motion
203 if (valves()[valveI].curtainInPortPatchID().active())
205 // Bottom of the valve moves with given velocity
207 [valves()[valveI].curtainInPortPatchID().index()] == valveVel;
210 // If valve is present in geometry, set the motion
211 if (valves()[valveI].curtainInCylinderPatchID().active())
213 // Bottom of the valve moves with given velocity
215 [valves()[valveI].curtainInCylinderPatchID().index()] ==
219 // If valve is present in geometry, set the motion
220 if (valves()[valveI].stemPatchID().active())
222 // Bottom of the valve moves with given velocity
223 U.boundaryField()[valves()[valveI].stemPatchID().index()] ==
227 // If valve is present in geometry, set the motion
228 if (valves()[valveI].detachInPortPatchID().active())
230 // Bottom of the valve moves with given velocity
232 [valves()[valveI].detachInPortPatchID().index()] ==
235 U.oldTime().boundaryField()
236 [valves()[valveI].detachInPortPatchID().index()] ==
240 // If valve is present in geometry, set the motion
241 if (valves()[valveI].detachInCylinderPatchID().active())
243 // Bottom of the valve moves with given velocity
245 [valves()[valveI].detachInCylinderPatchID().index()] ==
248 U.oldTime().boundaryField()
249 [valves()[valveI].detachInCylinderPatchID().index()] ==
256 bool Foam::layerSmooth::isACylinderHeadFace
258 const labelList& cylHeadFaces,
262 if(face >= cylHeadFaces[0] && face <= cylHeadFaces[cylHeadFaces.size()-1])
268 forAll(cylHeadFaces, i)
270 if(cylHeadFaces[i] == face)
282 // ************************************************************************* //