sixDoFRigidBody: adding constraints.

Adding fixedPlane and fixedLine constraints.
This commit is contained in:
graham
2010-01-28 15:27:08 +00:00
parent d5829988d8
commit c6701df1f6
8 changed files with 530 additions and 3 deletions

View File

@ -22,6 +22,8 @@ sDoFRBMC = $(sDoFRBM)/sixDoFRigidBodyMotionConstraint
$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C
$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/newSixDoFRigidBodyMotionConstraint.C
$(sDoFRBMC)/fixedPoint/fixedPoint.C
$(sDoFRBMC)/fixedPlane/fixedPlane.C
$(sDoFRBMC)/fixedLine/fixedLine.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C

View File

@ -90,7 +90,7 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
forAll(constraints_, cI)
{
// Info<< "Constraint " << cI << endl;
Info<< nl << "Constraint " << cI << endl;
// constraint position
point cP = vector::zero;

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fixedLine.H"
#include "addToRunTimeSelectionTable.H"
#include "sixDoFRigidBodyMotion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace sixDoFRigidBodyMotionConstraints
{
defineTypeNameAndDebug(fixedLine, 0);
addToRunTimeSelectionTable
(
sixDoFRigidBodyMotionConstraint,
fixedLine,
dictionary
);
};
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotionConstraints::fixedLine::fixedLine
(
const dictionary& sDoFRBMCDict
)
:
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
refPt_(),
dir_()
{
read(sDoFRBMCDict);
}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotionConstraints::fixedLine::~fixedLine()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::sixDoFRigidBodyMotionConstraints::fixedLine::constrain
(
const sixDoFRigidBodyMotion& motion,
const vector& existingConstraintForce,
const vector& existingConstraintMoment,
scalar deltaT,
vector& constraintPosition,
vector& constraintForceIncrement,
vector& constraintMomentIncrement
) const
{
point predictedPosition = motion.predictedPosition
(
refPt_,
existingConstraintForce,
existingConstraintMoment,
deltaT
);
constraintPosition = motion.currentPosition(refPt_);
Info<< "current position " << constraintPosition << nl
<< "next predictedPosition " << predictedPosition
<< endl;
// Vector from reference point to predicted point
vector rC = predictedPosition - refPt_;
vector error = rC - ((rC) & dir_)*dir_;
Info<< "error " << error << endl;
constraintForceIncrement =
-relaxationFactor_*error*motion.mass()/sqr(deltaT);
constraintMomentIncrement = vector::zero;
return (mag(error) < tolerance_);
}
bool Foam::sixDoFRigidBodyMotionConstraints::fixedLine::read
(
const dictionary& sDoFRBMCDict
)
{
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
sDoFRBMCCoeffs_.lookup("refPoint") >> refPt_;
sDoFRBMCCoeffs_.lookup("direction") >> dir_;
scalar magDir(mag(dir_));
if (magDir > VSMALL)
{
dir_ /= magDir;
}
else
{
FatalErrorIn
(
"Foam::sixDoFRigidBodyMotionConstraints::fixedLine::read"
"("
"const dictionary& sDoFRBMCDict"
")"
)
<< "line direction has zero length"
<< abort(FatalError);
}
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::sixDoFRigidBodyMotionConstraints::fixedLine
Description
sixDoFRigidBodyMotionConstraint. Reference point may only move
along a line.
SourceFiles
fixedLine.C
\*---------------------------------------------------------------------------*/
#ifndef fixedLine_H
#define fixedLine_H
#include "sixDoFRigidBodyMotionConstraint.H"
#include "point.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace sixDoFRigidBodyMotionConstraints
{
/*---------------------------------------------------------------------------*\
Class fixedLine Declaration
\*---------------------------------------------------------------------------*/
class fixedLine
:
public sixDoFRigidBodyMotionConstraint
{
// Private data
//- Reference point for the constraining line
point refPt_;
//- Direction of the constraining line
vector dir_;
public:
//- Runtime type information
TypeName("fixedLine");
// Constructors
//- Construct from components
fixedLine
(
const dictionary& sDoFRBMCDict
);
//- Construct and return a clone
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const
{
return autoPtr<sixDoFRigidBodyMotionConstraint>
(
new fixedLine(*this)
);
}
// Destructor
virtual ~fixedLine();
// Member Functions
//- Calculate the constraint position, force and moment.
// Global reference frame vectors. Returns boolean stating
// whether the constraint been converged to tolerance.
virtual bool constrain
(
const sixDoFRigidBodyMotion& motion,
const vector& existingConstraintForce,
const vector& existingConstraintMoment,
scalar deltaT,
vector& constraintPosition,
vector& constraintForceIncrement,
vector& constraintMomentIncrement
) const;
//- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCCoeff);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solidBodyMotionFunctions
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fixedPlane.H"
#include "addToRunTimeSelectionTable.H"
#include "sixDoFRigidBodyMotion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace sixDoFRigidBodyMotionConstraints
{
defineTypeNameAndDebug(fixedPlane, 0);
addToRunTimeSelectionTable
(
sixDoFRigidBodyMotionConstraint,
fixedPlane,
dictionary
);
};
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::fixedPlane
(
const dictionary& sDoFRBMCDict
)
:
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
fixedPlane_(vector::one)
{
read(sDoFRBMCDict);
}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::~fixedPlane()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::constrain
(
const sixDoFRigidBodyMotion& motion,
const vector& existingConstraintForce,
const vector& existingConstraintMoment,
scalar deltaT,
vector& constraintPosition,
vector& constraintForceIncrement,
vector& constraintMomentIncrement
) const
{
const point& refPt = fixedPlane_.refPoint();
const vector& n = fixedPlane_.normal();
point predictedPosition = motion.predictedPosition
(
refPt,
existingConstraintForce,
existingConstraintMoment,
deltaT
);
constraintPosition = motion.currentPosition(refPt);
Info<< "current position " << constraintPosition << nl
<< "next predictedPosition " << predictedPosition
<< endl;
vector error = ((predictedPosition - refPt) & n)*n;
Info<< "error " << error << endl;
constraintForceIncrement =
-relaxationFactor_*error*motion.mass()/sqr(deltaT);
constraintMomentIncrement = vector::zero;
return (mag(error) < tolerance_);
}
bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::read
(
const dictionary& sDoFRBMCDict
)
{
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
point refPt = sDoFRBMCCoeffs_.lookup("refPoint");
vector normal = sDoFRBMCCoeffs_.lookup("normal");
fixedPlane_ = plane(refPt, normal);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,125 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::sixDoFRigidBodyMotionConstraints::fixedPlane
Description
sixDoFRigidBodyMotionConstraint. Reference point may only move
along a plane.
SourceFiles
fixedPlane.C
\*---------------------------------------------------------------------------*/
#ifndef fixedPlane_H
#define fixedPlane_H
#include "sixDoFRigidBodyMotionConstraint.H"
#include "plane.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace sixDoFRigidBodyMotionConstraints
{
/*---------------------------------------------------------------------------*\
Class fixedPlane Declaration
\*---------------------------------------------------------------------------*/
class fixedPlane
:
public sixDoFRigidBodyMotionConstraint
{
// Private data
//- Plane which the transformed reference point is constrained
// to move along
plane fixedPlane_;
public:
//- Runtime type information
TypeName("fixedPlane");
// Constructors
//- Construct from components
fixedPlane
(
const dictionary& sDoFRBMCDict
);
//- Construct and return a clone
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const
{
return autoPtr<sixDoFRigidBodyMotionConstraint>
(
new fixedPlane(*this)
);
}
// Destructor
virtual ~fixedPlane();
// Member Functions
//- Calculate the constraint position, force and moment.
// Global reference frame vectors. Returns boolean stating
// whether the constraint been converged to tolerance.
virtual bool constrain
(
const sixDoFRigidBodyMotion& motion,
const vector& existingConstraintForce,
const vector& existingConstraintMoment,
scalar deltaT,
vector& constraintPosition,
vector& constraintForceIncrement,
vector& constraintMomentIncrement
) const;
//- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCCoeff);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solidBodyMotionFunctions
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -53,7 +53,7 @@ Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::fixedPoint
)
:
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
fixedPoint_()
fixedPoint_(sDoFRBMCCoeffs_.lookup("fixedPoint"))
{
read(sDoFRBMCDict);
}