interpolatingSolidBodyMotionSolver: New solid-body mesh-motion solver which intepolates the motion

Description
    Solid-body motion of the mesh specified by a run-time selectable motion
    function.  Applies SLERP interpolation of movement as function of
    distance to the object surface to move the mesh points.
This commit is contained in:
Henry Weller
2018-07-26 16:15:37 +01:00
parent d627582dd6
commit 34f0cae5a3
7 changed files with 292 additions and 2 deletions

View File

@ -0,0 +1,159 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 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 "interpolatingSolidBodyMotionSolver.H"
#include "addToRunTimeSelectionTable.H"
#include "pointPatchDist.H"
#include "pointConstraints.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(interpolatingSolidBodyMotionSolver, 0);
addToRunTimeSelectionTable
(
motionSolver,
interpolatingSolidBodyMotionSolver,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::interpolatingSolidBodyMotionSolver::interpolatingSolidBodyMotionSolver
(
const polyMesh& mesh,
const IOdictionary& dict
)
:
points0MotionSolver(mesh, dict, typeName),
SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time())),
patches_(wordReList(coeffDict().lookup("patches"))),
patchSet_(mesh.boundaryMesh().patchSet(patches_)),
CofG_(coeffDict().lookup("CofG")),
di_(readScalar(coeffDict().lookup("innerDistance"))),
do_(readScalar(coeffDict().lookup("outerDistance"))),
scale_
(
IOobject
(
"motionScale",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
pointMesh::New(mesh),
dimensionedScalar("zero", dimless, 0.0)
)
{
// Calculate scaling factor everywhere
{
const pointMesh& pMesh = pointMesh::New(mesh);
pointPatchDist pDist(pMesh, patchSet_, points0());
// Scaling: 1 up to di then linear down to 0 at do away from patches
scale_.primitiveFieldRef() =
min
(
max
(
(do_ - pDist.primitiveField())/(do_ - di_),
scalar(0)
),
scalar(1)
);
// Convert the scale function to a cosine
scale_.primitiveFieldRef() =
min
(
max
(
0.5
- 0.5
*cos(scale_.primitiveField()
*Foam::constant::mathematical::pi),
scalar(0)
),
scalar(1)
);
pointConstraints::New(pMesh).constrain(scale_);
scale_.write();
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::interpolatingSolidBodyMotionSolver::~interpolatingSolidBodyMotionSolver()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::pointField>
Foam::interpolatingSolidBodyMotionSolver::curPoints() const
{
const pointField& points0 = this->points0();
const septernion s = SBMFPtr_().transformation();
tmp<pointField> tpoints(new pointField(points0));
pointField& points = tpoints.ref();
forAll(points, pointi)
{
// Move non-stationary points
if (scale_[pointi] > small)
{
// Use solid-body motion where scale = 1
if (scale_[pointi] > 1 - small)
{
points[pointi] =
CofG_ + s.transformPoint(points0[pointi] - CofG_);
}
// Slerp septernion interpolation
else
{
const septernion ss(slerp(septernion::I, s, scale_[pointi]));
points[pointi] =
CofG_ + ss.transformPoint(points0[pointi] - CofG_);
}
}
}
return tpoints;
}
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 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/>.
Class
Foam::interpolatingSolidBodyMotionSolver
Description
Solid-body motion of the mesh specified by a run-time selectable motion
function. Applies SLERP interpolation of movement as function of
distance to the object surface to move the mesh points.
SourceFiles
interpolatingSolidBodyMotionSolver.C
\*---------------------------------------------------------------------------*/
#ifndef interpolatingSolidBodyMotionSolver_H
#define interpolatingSolidBodyMotionSolver_H
#include "points0MotionSolver.H"
#include "solidBodyMotionFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class interpolatingSolidBodyMotionSolver Declaration
\*---------------------------------------------------------------------------*/
class interpolatingSolidBodyMotionSolver
:
public points0MotionSolver
{
// Private data
//- The motion control function
autoPtr<solidBodyMotionFunction> SBMFPtr_;
wordReList patches_;
//- Patches to integrate forces
const labelHashSet patchSet_;
//- Center of gravity read from dictionary
vector CofG_;
//- Inner morphing distance (limit of solid-body region)
const scalar di_;
//- Outer morphing distance (limit of linear interpolation region)
const scalar do_;
//- Current interpolation scale (1 at patches, 0 at distance_)
pointScalarField scale_;
// Private Member Functions
//- Disallow default bitwise copy construct
interpolatingSolidBodyMotionSolver
(
const interpolatingSolidBodyMotionSolver&
);
//- Disallow default bitwise assignment
void operator=(const interpolatingSolidBodyMotionSolver&);
public:
//- Runtime type information
TypeName("interpolatingSolidBody");
// Constructors
//- Construct from polyMesh and IOdictionary
interpolatingSolidBodyMotionSolver
(
const polyMesh&,
const IOdictionary& dict
);
//- Destructor
~interpolatingSolidBodyMotionSolver();
// Member Functions
//- Return point location obtained from the current motion field
virtual tmp<pointField> curPoints() const;
//- Solve for motion
virtual void solve()
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //