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 "subsetMotionSolverFvMesh.H"
28 #include "addToRunTimeSelectionTable.H"
30 #include "motionSolver.H"
31 #include "volFields.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(subsetMotionSolverFvMesh, 0);
39 addToRunTimeSelectionTable
42 subsetMotionSolverFvMesh,
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::subsetMotionSolverFvMesh::subsetMotionSolverFvMesh(const IOobject& io)
65 ).subDict(typeName + "Coeffs")
80 alpha_(readScalar(movingMeshCoeffs_.lookup("alpha")))
83 word setName = movingMeshCoeffs_.lookup("set");
91 polyMesh::meshSubDir/"sets",
98 subsetMesh_.setLargeCellSubset(currentSet, -1);
100 // Create motion solver on the subset
101 motionPtr_ = motionSolver::New(subsetMesh_.subMesh());
103 // Read motion under-relaxation
104 if (alpha_ < 0 || alpha_ > 1.0)
108 "subsetMotionSolverFvMesh::subsetMotionSolverFvMesh"
109 "(const IOobject& io)"
110 ) << "Ill-defined motion under-relaxation: "
111 << "should be between 0 and 1."
112 << " Alpha = " << alpha_ << abort(FatalError);
117 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
119 Foam::subsetMotionSolverFvMesh::~subsetMotionSolverFvMesh()
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 const Foam::fvMeshSubset& Foam::subsetMotionSolverFvMesh::subsetMesh() const
131 bool Foam::subsetMotionSolverFvMesh::update()
133 // Get the points from the moving part
134 pointField subsetPoints = motionPtr_->newPoints();
136 //- Get copy of mesh points
137 pointField p = allPoints();
139 //- Map the moving part
140 const labelList& subsetPointAddr = subsetMesh_.pointMap();
142 forAll (subsetPoints, subsetI)
144 p[subsetPointAddr[subsetI]] = subsetPoints[subsetI];
147 subsetMesh_.subMesh().movePoints(subsetPoints);
149 // Under-relax mesh motion
150 p = alpha_*p + (1 - alpha_)*allPoints();
152 fvMesh::movePoints(p);
154 // Mesh motion only - return false
159 // ************************************************************************* //