e.g. the motion of two counter-rotating AMI regions could be defined:
dynamicFvMesh dynamicMotionSolverListFvMesh;
solvers
(
rotor1
{
solver solidBody;
cellZone rotor1;
solidBodyMotionFunction rotatingMotion;
rotatingMotionCoeffs
{
origin (0 0 0);
axis (0 0 1);
omega 6.2832; // rad/s
}
}
rotor2
{
solver solidBody;
cellZone rotor2;
solidBodyMotionFunction rotatingMotion;
rotatingMotionCoeffs
{
origin (0 0 0);
axis (0 0 1);
omega -6.2832; // rad/s
}
}
);
Any combination of motion solvers may be selected but there is no special
handling of motion interaction; the motions are applied sequentially and
potentially cumulatively.
To support this new general framework the solidBodyMotionFvMesh and
multiSolidBodyMotionFvMesh dynamicFvMeshes have been converted into the
corresponding motionSolvers solidBody and multiSolidBody and the tutorials
updated to reflect this change e.g. the motion in the mixerVesselAMI2D tutorial
is now defined thus:
dynamicFvMesh dynamicMotionSolverFvMesh;
solver solidBody;
solidBodyCoeffs
{
cellZone rotor;
solidBodyMotionFunction rotatingMotion;
rotatingMotionCoeffs
{
origin (0 0 0);
axis (0 0 1);
omega 6.2832; // rad/s
}
}
182 lines
5 KiB
C
182 lines
5 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "solidBodyMotionSolver.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
#include "transformField.H"
|
|
#include "cellZoneMesh.H"
|
|
#include "cellSet.H"
|
|
#include "boolList.H"
|
|
#include "syncTools.H"
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
defineTypeNameAndDebug(solidBodyMotionSolver, 0);
|
|
addToRunTimeSelectionTable
|
|
(
|
|
motionSolver,
|
|
solidBodyMotionSolver,
|
|
dictionary
|
|
);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::solidBodyMotionSolver::solidBodyMotionSolver
|
|
(
|
|
const polyMesh& mesh,
|
|
const IOdictionary& dict
|
|
)
|
|
:
|
|
points0MotionSolver(mesh, dict, typeName),
|
|
SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time())),
|
|
pointIDs_(),
|
|
moveAllCells_(false)
|
|
{
|
|
word cellZoneName =
|
|
coeffDict().lookupOrDefault<word>("cellZone", "none");
|
|
|
|
word cellSetName =
|
|
coeffDict().lookupOrDefault<word>("cellSet", "none");
|
|
|
|
if ((cellZoneName != "none") && (cellSetName != "none"))
|
|
{
|
|
FatalIOErrorInFunction(coeffDict())
|
|
<< "Either cellZone OR cellSet can be supplied, but not both. "
|
|
<< "If neither is supplied, all cells will be included"
|
|
<< exit(FatalIOError);
|
|
}
|
|
|
|
labelList cellIDs;
|
|
if (cellZoneName != "none")
|
|
{
|
|
Info<< "Applying solid body motion to cellZone " << cellZoneName
|
|
<< endl;
|
|
|
|
label zoneID = mesh.cellZones().findZoneID(cellZoneName);
|
|
|
|
if (zoneID == -1)
|
|
{
|
|
FatalErrorInFunction
|
|
<< "Unable to find cellZone " << cellZoneName
|
|
<< ". Valid cellZones are:"
|
|
<< mesh.cellZones().names()
|
|
<< exit(FatalError);
|
|
}
|
|
|
|
cellIDs = mesh.cellZones()[zoneID];
|
|
}
|
|
|
|
if (cellSetName != "none")
|
|
{
|
|
Info<< "Applying solid body motion to cellSet " << cellSetName
|
|
<< endl;
|
|
|
|
cellSet set(mesh, cellSetName);
|
|
|
|
cellIDs = set.toc();
|
|
}
|
|
|
|
label nCells = returnReduce(cellIDs.size(), sumOp<label>());
|
|
moveAllCells_ = nCells == 0;
|
|
|
|
if (moveAllCells_)
|
|
{
|
|
Info<< "Applying solid body motion to entire mesh" << endl;
|
|
}
|
|
else
|
|
{
|
|
// collect point IDs of points in cell zone
|
|
|
|
boolList movePts(mesh.nPoints(), false);
|
|
|
|
forAll(cellIDs, i)
|
|
{
|
|
label celli = cellIDs[i];
|
|
const cell& c = mesh.cells()[celli];
|
|
forAll(c, j)
|
|
{
|
|
const face& f = mesh.faces()[c[j]];
|
|
forAll(f, k)
|
|
{
|
|
label pointi = f[k];
|
|
movePts[pointi] = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
syncTools::syncPointList(mesh, movePts, orEqOp<bool>(), false);
|
|
|
|
DynamicList<label> ptIDs(mesh.nPoints());
|
|
forAll(movePts, i)
|
|
{
|
|
if (movePts[i])
|
|
{
|
|
ptIDs.append(i);
|
|
}
|
|
}
|
|
|
|
pointIDs_.transfer(ptIDs);
|
|
}
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
Foam::solidBodyMotionSolver::~solidBodyMotionSolver()
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
Foam::tmp<Foam::pointField> Foam::solidBodyMotionSolver::curPoints() const
|
|
{
|
|
if (moveAllCells_)
|
|
{
|
|
return transformPoints(SBMFPtr_().transformation(), points0_);
|
|
}
|
|
else
|
|
{
|
|
tmp<pointField> ttransformedPts
|
|
(
|
|
new pointField(points0_)
|
|
);
|
|
pointField& transformedPts = ttransformedPts.ref();
|
|
|
|
UIndirectList<point>(transformedPts, pointIDs_) = transformPoints
|
|
(
|
|
SBMFPtr_().transformation(),
|
|
pointField(transformedPts, pointIDs_)
|
|
);
|
|
|
|
return ttransformedPts;
|
|
}
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|