mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
sixDoFRigidBodyState: New functionObject which writes the rigid-body state
Based on code contributed by SeongMo Yeon Resolves feature request https://bugs.openfoam.org/view.php?id=2656
This commit is contained in:
committed by
Andrew Heather
parent
e6717b6e72
commit
f80334415c
@ -59,6 +59,12 @@ Foam::dynamicMotionSolverFvMesh::~dynamicMotionSolverFvMesh()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::motionSolver& Foam::dynamicMotionSolverFvMesh::motion() const
|
||||||
|
{
|
||||||
|
return motionPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::dynamicMotionSolverFvMesh::update()
|
bool Foam::dynamicMotionSolverFvMesh::update()
|
||||||
{
|
{
|
||||||
fvMesh::movePoints(motionPtr_->newPoints());
|
fvMesh::movePoints(motionPtr_->newPoints());
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -84,6 +84,9 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the motionSolver
|
||||||
|
const motionSolver& motion() const;
|
||||||
|
|
||||||
//- Update the mesh for both mesh motion and topology change
|
//- Update the mesh for both mesh motion and topology change
|
||||||
virtual bool update();
|
virtual bool update();
|
||||||
};
|
};
|
||||||
|
|||||||
3
src/functionObjects/sixDoFRigidBodyState/Make/files
Normal file
3
src/functionObjects/sixDoFRigidBodyState/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
sixDoFRigidBodyState.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_LIBBIN)/libsixDoFRigidBodyState
|
||||||
11
src/functionObjects/sixDoFRigidBodyState/Make/options
Normal file
11
src/functionObjects/sixDoFRigidBodyState/Make/options
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sixDoFRigidBodyMotion/lnInclude \
|
||||||
|
-I$(LIB_SRC)/OpenFOAM/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-lmeshTools
|
||||||
153
src/functionObjects/sixDoFRigidBodyState/sixDoFRigidBodyState.C
Normal file
153
src/functionObjects/sixDoFRigidBodyState/sixDoFRigidBodyState.C
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 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 "sixDoFRigidBodyState.H"
|
||||||
|
#include "dynamicMotionSolverFvMesh.H"
|
||||||
|
#include "sixDoFRigidBodyMotionSolver.H"
|
||||||
|
#include "unitConversion.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(sixDoFRigidBodyState, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
functionObject,
|
||||||
|
sixDoFRigidBodyState,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::sixDoFRigidBodyState::sixDoFRigidBodyState
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
|
logFiles(obr_, name)
|
||||||
|
{
|
||||||
|
read(dict);
|
||||||
|
resetName(typeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::sixDoFRigidBodyState::~sixDoFRigidBodyState()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::sixDoFRigidBodyState::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
fvMeshFunctionObject::read(dict);
|
||||||
|
angleFormat_ = dict.lookupOrDefault<word>("angleFormat", "radians");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::functionObjects::sixDoFRigidBodyState::writeFileHeader(const label)
|
||||||
|
{
|
||||||
|
OFstream& file = this->file();
|
||||||
|
|
||||||
|
writeHeader(file, "Motion State");
|
||||||
|
writeHeaderValue(file, "Angle Units", angleFormat_);
|
||||||
|
writeCommented(file, "Time");
|
||||||
|
|
||||||
|
file<< tab
|
||||||
|
<< "centreOfRotation" << tab
|
||||||
|
<< "centreOfMass" << tab
|
||||||
|
<< "rotation" << tab
|
||||||
|
<< "velocity" << tab
|
||||||
|
<< "omega" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::sixDoFRigidBodyState::execute()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::sixDoFRigidBodyState::write()
|
||||||
|
{
|
||||||
|
logFiles::write();
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
const dynamicMotionSolverFvMesh& mesh =
|
||||||
|
refCast<const dynamicMotionSolverFvMesh>(obr_);
|
||||||
|
|
||||||
|
const sixDoFRigidBodyMotionSolver& motionSolver_ =
|
||||||
|
refCast<const sixDoFRigidBodyMotionSolver>(mesh.motion());
|
||||||
|
|
||||||
|
const sixDoFRigidBodyMotion& motion = motionSolver_.motion();
|
||||||
|
|
||||||
|
vector rotationAngle
|
||||||
|
(
|
||||||
|
quaternion(motion.orientation()).eulerAngles(quaternion::XYZ)
|
||||||
|
);
|
||||||
|
|
||||||
|
vector angularVelocity(motion.omega());
|
||||||
|
|
||||||
|
if (angleFormat_ == "degrees")
|
||||||
|
{
|
||||||
|
rotationAngle.x() = radToDeg(rotationAngle.x());
|
||||||
|
rotationAngle.y() = radToDeg(rotationAngle.y());
|
||||||
|
rotationAngle.z() = radToDeg(rotationAngle.z());
|
||||||
|
|
||||||
|
angularVelocity.x() = radToDeg(angularVelocity.x());
|
||||||
|
angularVelocity.y() = radToDeg(angularVelocity.y());
|
||||||
|
angularVelocity.z() = radToDeg(angularVelocity.z());
|
||||||
|
}
|
||||||
|
|
||||||
|
writeTime(file());
|
||||||
|
file()
|
||||||
|
<< tab
|
||||||
|
<< motion.centreOfRotation() << tab
|
||||||
|
<< motion.centreOfMass() << tab
|
||||||
|
<< rotationAngle << tab
|
||||||
|
<< motion.v() << tab
|
||||||
|
<< angularVelocity << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
146
src/functionObjects/sixDoFRigidBodyState/sixDoFRigidBodyState.H
Normal file
146
src/functionObjects/sixDoFRigidBodyState/sixDoFRigidBodyState.H
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 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::functionObjects::sixDoFRigidBodyState
|
||||||
|
|
||||||
|
Group
|
||||||
|
grpFieldFunctionObjects
|
||||||
|
|
||||||
|
Description
|
||||||
|
Writes the 6-DoF motion state.
|
||||||
|
|
||||||
|
Example of function object specification:
|
||||||
|
\verbatim
|
||||||
|
sixDoFRigidBodyState
|
||||||
|
{
|
||||||
|
type sixDoFRigidBodyState;
|
||||||
|
libs ("libsixDoFRigidBodyState.so");
|
||||||
|
angleFormat degrees;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
Usage
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default value
|
||||||
|
type | type name: sixDoFRigidBodyState | yes |
|
||||||
|
angleFormat | degrees or radians | no | radian
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::functionObjects::fvMeshFunctionObject
|
||||||
|
Foam::functionObjects::logFiles
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
sixDoFRigidBodyState.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef sixDoFRigidBodyState_H
|
||||||
|
#define sixDoFRigidBodyState_H
|
||||||
|
|
||||||
|
#include "fvMeshFunctionObject.H"
|
||||||
|
#include "logFiles.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class sixDoFRigidBodyState Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class sixDoFRigidBodyState
|
||||||
|
:
|
||||||
|
public fvMeshFunctionObject,
|
||||||
|
public logFiles
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
word angleFormat_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
sixDoFRigidBodyState(const sixDoFRigidBodyState&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const sixDoFRigidBodyState&);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- overloaded writeFileHeader from writeFile
|
||||||
|
virtual void writeFileHeader(const label i = 0);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("sixDoFRigidBodyState");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from Time and dictionary
|
||||||
|
sixDoFRigidBodyState
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~sixDoFRigidBodyState();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Read the sixDoFRigidBodyState data
|
||||||
|
virtual bool read(const dictionary&);
|
||||||
|
|
||||||
|
//- Execute, currently does nothing
|
||||||
|
virtual bool execute();
|
||||||
|
|
||||||
|
//- Write the sixDoFRigidBodyState
|
||||||
|
virtual bool write();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -158,6 +158,13 @@ Foam::sixDoFRigidBodyMotionSolver::~sixDoFRigidBodyMotionSolver()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::sixDoFRigidBodyMotion&
|
||||||
|
Foam::sixDoFRigidBodyMotionSolver::motion() const
|
||||||
|
{
|
||||||
|
return motion_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::pointField>
|
Foam::tmp<Foam::pointField>
|
||||||
Foam::sixDoFRigidBodyMotionSolver::curPoints() const
|
Foam::sixDoFRigidBodyMotionSolver::curPoints() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class sixDoFRigidBodyMotionSolver
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Six dof motion object
|
//- Six DoF motion object
|
||||||
sixDoFRigidBodyMotion motion_;
|
sixDoFRigidBodyMotion motion_;
|
||||||
|
|
||||||
wordReList patches_;
|
wordReList patches_;
|
||||||
@ -127,6 +127,9 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the six DoF motion object
|
||||||
|
const sixDoFRigidBodyMotion& motion() const;
|
||||||
|
|
||||||
//- Return point location obtained from the current motion field
|
//- Return point location obtained from the current motion field
|
||||||
virtual tmp<pointField> curPoints() const;
|
virtual tmp<pointField> curPoints() const;
|
||||||
|
|
||||||
|
|||||||
@ -49,4 +49,14 @@ adjustTimeStep yes;
|
|||||||
|
|
||||||
maxCo 0.9;
|
maxCo 0.9;
|
||||||
|
|
||||||
|
functions
|
||||||
|
{
|
||||||
|
sixDoFRigidBodyState
|
||||||
|
{
|
||||||
|
type sixDoFRigidBodyState;
|
||||||
|
libs ("libsixDoFRigidBodyState.so");
|
||||||
|
angleFormat degrees;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user