ENH: Add components to allow overset with multiple motion solvers

1) Add softWall rigidBody restrain
2) Add linearSpringDamper sixDoF restrain to work as soft rope
3) dynamicMotionSolverListFvMesh changed to dictionary based input
4) Add Time reference access to sixDof restraints
5) Add drivenLinearMotion to solidBodyMotionFunctions.
This commit is contained in:
sergio
2019-08-16 11:27:59 -07:00
committed by Andrew Heather
parent 60517236fd
commit d96ad1cd09
30 changed files with 1368 additions and 65 deletions

View File

@ -17,13 +17,6 @@
#include "interpolatedFaces.H" #include "interpolatedFaces.H"
} }
if (runTime.outputTime())
{
H.write();
rAU.write();
HbyA.write();
}
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA)); surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
if (ddtCorr) if (ddtCorr)

View File

@ -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 | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2016 OpenFOAM Foundation | Copyright (C) 2016 OpenFOAM Foundation
@ -53,22 +53,57 @@ Foam::dynamicMotionSolverListFvMesh::dynamicMotionSolverListFvMesh
) )
: :
dynamicFvMesh(io), dynamicFvMesh(io),
motionSolvers_ motionSolvers_()
{
IOobject ioDict
( (
IOdictionary "dynamicMeshDict",
( time().constant(),
IOobject *this,
( IOobject::MUST_READ,
"dynamicMeshDict", IOobject::NO_WRITE,
time().constant(), false
*this, );
IOobject::MUST_READ_IF_MODIFIED,
IOobject::AUTO_WRITE IOdictionary dict(ioDict);
)
).lookup("solvers"), label i = 0;
motionSolver::iNew(*this) if (dict.found("solvers"))
) {
{} const dictionary& solvertDict = dict.subDict("solvers");
motionSolvers_.setSize(solvertDict.size());
for (const entry& dEntry : solvertDict)
{
if (dEntry.isDict())
{
IOobject io(ioDict);
io.readOpt() = IOobject::NO_READ;
io.writeOpt() = IOobject::AUTO_WRITE;
io.rename(dEntry.dict().dictName());
IOdictionary IOsolverDict
(
io,
dEntry.dict()
);
motionSolvers_.set
(
i++,
motionSolver::New(*this, IOsolverDict)
);
}
}
motionSolvers_.setSize(i);
}
else
{
motionSolvers_.setSize(1);
motionSolvers_.set(i++, motionSolver::New(*this));
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -27,7 +27,9 @@ Class
Foam::dynamicMotionSolverListFvMesh Foam::dynamicMotionSolverListFvMesh
Description Description
Foam::dynamicMotionSolverListFvMesh Dynamic mesh able to handle multiple motion solvers.
NOTE: If the word entry "solvers" is not found it falls back to a single
motion solver behavior.
SourceFiles SourceFiles
dynamicMotionSolverListFvMesh.C dynamicMotionSolverListFvMesh.C

View File

@ -102,6 +102,7 @@ motionSmoother/badQualityToFace/badQualityToFace.C
motionSolvers/motionSolver/motionSolver.C motionSolvers/motionSolver/motionSolver.C
motionSolvers/displacement/points0/points0MotionSolver.C motionSolvers/displacement/points0/points0MotionSolver.C
motionSolvers/displacement/displacement/zoneMotion.C
motionSolvers/displacement/displacement/displacementMotionSolver.C motionSolvers/displacement/displacement/displacementMotionSolver.C
motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C
motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C
@ -120,6 +121,7 @@ $(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunctionNew.C
$(solidBodyMotionFunctions)/SDA/SDA.C $(solidBodyMotionFunctions)/SDA/SDA.C
$(solidBodyMotionFunctions)/tabulated6DoFMotion/tabulated6DoFMotion.C $(solidBodyMotionFunctions)/tabulated6DoFMotion/tabulated6DoFMotion.C
$(solidBodyMotionFunctions)/linearMotion/linearMotion.C $(solidBodyMotionFunctions)/linearMotion/linearMotion.C
$(solidBodyMotionFunctions)/drivenLinearMotion/drivenLinearMotion.C
$(solidBodyMotionFunctions)/rotatingMotion/rotatingMotion.C $(solidBodyMotionFunctions)/rotatingMotion/rotatingMotion.C
$(solidBodyMotionFunctions)/axisRotationMotion/axisRotationMotion.C $(solidBodyMotionFunctions)/axisRotationMotion/axisRotationMotion.C
$(solidBodyMotionFunctions)/multiMotion/multiMotion.C $(solidBodyMotionFunctions)/multiMotion/multiMotion.C

View File

@ -0,0 +1,149 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 "zoneMotion.H"
#include "syncTools.H"
#include "cellZoneMesh.H"
#include "cellSet.H"
#include "boolList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::zoneMotion::zoneMotion
(
const dictionary& dict,
const polyMesh& mesh
)
:
pointIDs_(),
moveAllCells_(false)
{
word cellZoneName =
dict.lookupOrDefault<word>("cellZone", "none");
word cellSetName =
dict.lookupOrDefault<word>("cellSet", "none");
if ((cellZoneName != "none") && (cellSetName != "none"))
{
FatalIOErrorInFunction(dict)
<< "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
{
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::zoneMotion::~zoneMotion()
{}
// * * * * * * * * * * * * * * * * Members * * * * * * * * * * * * * * //
const Foam::labelList& Foam::zoneMotion::pointIDs() const
{
return pointIDs_;
}
bool Foam::zoneMotion::moveAllCells() const
{
return moveAllCells_;
}
// ************************************************************************* //

View File

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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 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::zoneMotion
Description
SourceFiles
zoneMotion.C
\*---------------------------------------------------------------------------*/
#ifndef zoneMotion_H
#define zoneMotion_H
#include "labelList.H"
#include "dictionary.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
/*---------------------------------------------------------------------------*\
Class zoneMotion Declaration
\*---------------------------------------------------------------------------*/
class zoneMotion
{
// Private data
//- Points to move when cell zone is supplied
labelList pointIDs_;
//- Flag to indicate whether all cells should move
bool moveAllCells_;
// Private Member Functions
//- No copy construct
zoneMotion(const zoneMotion&) = delete;
//- No copy assignment
void operator=(const zoneMotion&) = delete;
public:
// Member functions
//- Return pointsID
const labelList& pointIDs() const;
//- Return flag
bool moveAllCells() const;
// Constructors
//- Construct from dictionary
zoneMotion
(
const dictionary&,
const polyMesh&
);
//- Destructor
virtual ~zoneMotion();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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) 2015-2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2012-2017 OpenFOAM Foundation | Copyright (C) 2012-2017 OpenFOAM Foundation
@ -113,6 +113,7 @@ Foam::points0MotionSolver::points0MotionSolver
) )
: :
motionSolver(mesh, dict, type), motionSolver(mesh, dict, type),
zoneMotion(dict, mesh),
points0_(points0IO(mesh)) points0_(points0IO(mesh))
{ {
if if
@ -156,6 +157,7 @@ Foam::points0MotionSolver::points0MotionSolver
) )
: :
motionSolver(mesh, dict, type), motionSolver(mesh, dict, type),
zoneMotion(dict, mesh),
points0_(points0) points0_(points0)
{ {
if (points0_.size() != mesh.nPoints()) if (points0_.size() != mesh.nPoints())

View File

@ -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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2016 OpenFOAM Foundation | Copyright (C) 2016 OpenFOAM Foundation
@ -41,6 +41,7 @@ SourceFiles
#include "motionSolver.H" #include "motionSolver.H"
#include "pointFields.H" #include "pointFields.H"
#include "pointIOField.H" #include "pointIOField.H"
#include "zoneMotion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +56,8 @@ class mapPolyMesh;
class points0MotionSolver class points0MotionSolver
: :
public motionSolver public motionSolver,
public zoneMotion
{ {
protected: protected:

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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 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 "drivenLinearMotion.H"
#include "addToRunTimeSelectionTable.H"
#include "dimensionedVector.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace solidBodyMotionFunctions
{
defineTypeNameAndDebug(drivenLinearMotion, 0);
addToRunTimeSelectionTable
(
solidBodyMotionFunction,
drivenLinearMotion,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidBodyMotionFunctions::drivenLinearMotion::drivenLinearMotion
(
const dictionary& SBMFCoeffs,
const Time& runTime
)
:
solidBodyMotionFunction(SBMFCoeffs, runTime),
CofGvelocity_(SBMFCoeffs.get<word>("CofGvelocity")),
normal_(SBMFCoeffs.lookupOrDefault<vector>("normal", Zero)),
CofGvel_
(
IOobject
(
CofGvelocity_,
time_.timeName(),
time_,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
dimensionedVector(dimless, Zero)
),
displacement_(Zero)
{
read(SBMFCoeffs);
if (mag(normal_) > SMALL)
{
normal_ /= (mag(normal_) + SMALL);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::solidBodyMotionFunctions::drivenLinearMotion::~drivenLinearMotion()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::septernion
Foam::solidBodyMotionFunctions::drivenLinearMotion::transformation() const
{
scalar deltaT = time_.deltaT().value();
vector velocity = CofGvel_.value();
// Take out normal component
if (mag(normal_) > SMALL)
{
velocity = CofGvel_.value() - ((CofGvel_.value() & normal_)*normal_);
}
DebugInFunction << "Vel on plane :" << velocity << endl;
// Translation of centre of gravity with constant velocity
//const vector displacement = velocity*t;
displacement_ += velocity*deltaT;
quaternion R(1);
septernion TR(septernion(-displacement_)*R);
DebugInFunction << "Time = " << time_.value()
<< " transformation: " << TR << endl;
return TR;
}
bool Foam::solidBodyMotionFunctions::drivenLinearMotion::read
(
const dictionary& SBMFCoeffs
)
{
solidBodyMotionFunction::read(SBMFCoeffs);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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 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::solidBodyMotionFunctions::drivenLinearMotion
Description
Variable velocity displacement. The velocity is read from a
uniformVectorField from the time registry with the name CofGvelocity.
Optional plane of motion can be added with the normal vector
SourceFiles
drivenLinearMotion.C
\*---------------------------------------------------------------------------*/
#ifndef drivenLinearMotion_H
#define drivenLinearMotion_H
#include "solidBodyMotionFunction.H"
#include "primitiveFields.H"
#include "point.H"
#include "uniformDimensionedFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace solidBodyMotionFunctions
{
/*---------------------------------------------------------------------------*\
Class drivenLinearMotion Declaration
\*---------------------------------------------------------------------------*/
class drivenLinearMotion
:
public solidBodyMotionFunction
{
// Private data
//- Name of the meshObject to dum CofG velocity
word CofGvelocity_;
//- Normal plane direction to restrict movement on a plane
vector normal_;
//- Uniform vector to follow
uniformDimensionedVectorField CofGvel_;
//- Last displacement
mutable vector displacement_;
// Private Member Functions
//- No copy construct
drivenLinearMotion(const drivenLinearMotion&) = delete;
//- No copy assignment
void operator=(const drivenLinearMotion&) = delete;
public:
//- Runtime type information
TypeName("drivenLinearMotion");
// Constructors
//- Construct from components
drivenLinearMotion
(
const dictionary& SBMFCoeffs,
const Time& runTime
);
//- Construct and return a clone
virtual autoPtr<solidBodyMotionFunction> clone() const
{
return autoPtr<solidBodyMotionFunction>
(
new drivenLinearMotion
(
SBMFCoeffs_,
time_
)
);
}
//- Destructor
virtual ~drivenLinearMotion();
// Member Functions
//- Return the solid-body motion transformation septernion
virtual septernion transformation() const;
//- Update properties from given dictionary
virtual bool read(const dictionary& SBMFCoeffs);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solidBodyMotionFunctions
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -52,9 +52,8 @@ Foam::IOobject Foam::motionSolver::stealRegistration
{ {
// De-register if necessary // De-register if necessary
const_cast<IOdictionary&>(dict).checkOut(); const_cast<IOdictionary&>(dict).checkOut();
io.registerObject() = true;
} }
io.registerObject() = true;
return io; return io;
} }

View File

@ -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 | \\ / A nd | Copyright (C) 2004-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation

View File

@ -50,7 +50,8 @@ bool Foam::dynamicOversetFvMesh::updateAddressing() const
const labelListList& stencil = overlap.cellStencil(); const labelListList& stencil = overlap.cellStencil();
// Get the base addressing // Get the base addressing
const lduAddressing& baseAddr = dynamicMotionSolverFvMesh::lduAddr(); //const lduAddressing& baseAddr = dynamicMotionSolverFvMesh::lduAddr();
const lduAddressing& baseAddr = dynamicFvMesh::lduAddr();
// Add to the base addressing // Add to the base addressing
labelList lowerAddr; labelList lowerAddr;
@ -277,7 +278,8 @@ bool Foam::dynamicOversetFvMesh::updateAddressing() const
patchAddr.setSize(fvp.size() + remoteStencilInterfaces_.size()); patchAddr.setSize(fvp.size() + remoteStencilInterfaces_.size());
allInterfaces_ = dynamicMotionSolverFvMesh::interfaces(); //allInterfaces_ = dynamicMotionSolverFvMesh::interfaces();
allInterfaces_ = dynamicFvMesh::interfaces();
allInterfaces_.setSize(patchAddr.size()); allInterfaces_.setSize(patchAddr.size());
forAll(fvp, patchI) forAll(fvp, patchI)
@ -526,7 +528,7 @@ void Foam::dynamicOversetFvMesh::writeAgglomeration
Foam::dynamicOversetFvMesh::dynamicOversetFvMesh(const IOobject& io) Foam::dynamicOversetFvMesh::dynamicOversetFvMesh(const IOobject& io)
: :
dynamicMotionSolverFvMesh(io), dynamicMotionSolverListFvMesh(io),
active_(false) active_(false)
{ {
// Load stencil (but do not update) // Load stencil (but do not update)
@ -546,7 +548,8 @@ const Foam::lduAddressing& Foam::dynamicOversetFvMesh::lduAddr() const
{ {
if (!active_) if (!active_)
{ {
return dynamicMotionSolverFvMesh::lduAddr(); //return dynamicMotionSolverFvMesh::lduAddr();
return dynamicFvMesh::lduAddr();
} }
if (lduPtr_.empty()) if (lduPtr_.empty())
{ {
@ -561,7 +564,8 @@ Foam::lduInterfacePtrsList Foam::dynamicOversetFvMesh::interfaces() const
{ {
if (!active_) if (!active_)
{ {
return dynamicMotionSolverFvMesh::interfaces(); //return dynamicMotionSolverFvMesh::interfaces();
return dynamicFvMesh::interfaces();
} }
if (lduPtr_.empty()) if (lduPtr_.empty())
{ {
@ -587,7 +591,8 @@ Foam::dynamicOversetFvMesh::primitiveLduAddr() const
bool Foam::dynamicOversetFvMesh::update() bool Foam::dynamicOversetFvMesh::update()
{ {
if (dynamicMotionSolverFvMesh::update()) //if (dynamicMotionSolverFvMesh::update())
if (dynamicMotionSolverListFvMesh::update())
{ {
// Calculate the local extra faces for the interpolation. Note: could // Calculate the local extra faces for the interpolation. Note: could
// let demand-driven lduAddr() trigger it but just to make sure. // let demand-driven lduAddr() trigger it but just to make sure.
@ -649,7 +654,8 @@ bool Foam::dynamicOversetFvMesh::writeObject
const bool valid const bool valid
) const ) const
{ {
bool ok = dynamicMotionSolverFvMesh::writeObject(fmt, ver, cmp, valid); //bool ok = dynamicMotionSolverFvMesh::writeObject(fmt, ver, cmp, valid);
bool ok = dynamicMotionSolverListFvMesh::writeObject(fmt, ver, cmp, valid);
// For postprocessing : write cellTypes and zoneID // For postprocessing : write cellTypes and zoneID
{ {

View File

@ -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) 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -35,7 +35,7 @@ SourceFiles
#ifndef dynamicOversetFvMesh_H #ifndef dynamicOversetFvMesh_H
#define dynamicOversetFvMesh_H #define dynamicOversetFvMesh_H
#include "dynamicMotionSolverFvMesh.H" #include "dynamicMotionSolverListFvMesh.H"
#include "labelIOList.H" #include "labelIOList.H"
#include "fvMeshPrimitiveLduAddressing.H" #include "fvMeshPrimitiveLduAddressing.H"
#include "lduInterfaceFieldPtrsList.H" #include "lduInterfaceFieldPtrsList.H"
@ -56,7 +56,7 @@ class GAMGAgglomeration;
class dynamicOversetFvMesh class dynamicOversetFvMesh
: :
public dynamicMotionSolverFvMesh public dynamicMotionSolverListFvMesh
{ {
protected: protected:

View File

@ -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) 2014-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2014-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -369,7 +369,9 @@ void Foam::dynamicOversetFvMesh::addInterpolation
inplaceReorder(reverseFaceMap_, lower); inplaceReorder(reverseFaceMap_, lower);
const label nOldInterfaces = dynamicMotionSolverFvMesh::interfaces().size(); //const label nOldInterfaces = dynamicMotionSolverFvMesh::interfaces().size();
const label nOldInterfaces = dynamicFvMesh::interfaces().size();
if (interfaces.size() > nOldInterfaces) if (interfaces.size() > nOldInterfaces)
{ {
@ -666,7 +668,8 @@ Foam::SolverPerformance<Type> Foam::dynamicOversetFvMesh::solve
<< " bypassing matrix adjustment for field " << m.psi().name() << " bypassing matrix adjustment for field " << m.psi().name()
<< endl; << endl;
} }
return dynamicMotionSolverFvMesh::solve(m, dict); //return dynamicMotionSolverFvMesh::solve(m, dict);
return dynamicFvMesh::solve(m, dict);
} }
if (debug) if (debug)
@ -742,7 +745,8 @@ Foam::SolverPerformance<Type> Foam::dynamicOversetFvMesh::solve
//} //}
// Use lower level solver // Use lower level solver
SolverPerformance<Type> s(dynamicMotionSolverFvMesh::solve(m, dict)); //SolverPerformance<Type> s(dynamicMotionSolverFvMesh::solve(m, dict));
SolverPerformance<Type> s(dynamicFvMesh::solve(m, dict));
// Restore boundary field // Restore boundary field
bpsi.setSize(oldSize); bpsi.setSize(oldSize);

View File

@ -33,6 +33,7 @@ restraints/linearDamper/linearDamper.C
restraints/linearAxialAngularSpring/linearAxialAngularSpring.C restraints/linearAxialAngularSpring/linearAxialAngularSpring.C
restraints/sphericalAngularDamper/sphericalAngularDamper.C restraints/sphericalAngularDamper/sphericalAngularDamper.C
restraints/prescribedRotation/prescribedRotation.C restraints/prescribedRotation/prescribedRotation.C
restraints/softWall/softWall.C
rigidBodyModel/rigidBodyModel.C rigidBodyModel/rigidBodyModel.C
rigidBodyModel/forwardDynamics.C rigidBodyModel/forwardDynamics.C

View File

@ -0,0 +1,160 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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 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 "softWall.H"
#include "rigidBodyModel.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace restraints
{
defineTypeNameAndDebug(softWall, 0);
addToRunTimeSelectionTable
(
restraint,
softWall,
dictionary
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::restraints::softWall::softWall
(
const word& name,
const dictionary& dict,
const rigidBodyModel& model
)
:
restraint(name, dict, model)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::RBD::restraints::softWall::~softWall()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::RBD::restraints::softWall::restrain
(
scalarField& tau,
Field<spatialVector>& fx
) const
{
point p = bodyPoint(refAttachmentPt_);
// Current axis of the spring
vector r = p - anchor_;
vector force = vector::zero;
vector moment = vector::zero;
vector v = bodyPointVelocity(refAttachmentPt_).l();
scalar m = model_.bodies()[bodyID_].m();
scalar d = (wallNormal_/mag(wallNormal_)) & r;
vector rDir = r/(mag(r) + VSMALL);
scalar wn = 3.14/C_;
scalar damping = psi_*2*m*wn;
scalar stiffness = sqr(wn)*m;
if (d < 0)
{
force =
(-damping*(rDir & v) + stiffness*d)*rDir;
moment = (p ^ force);
}
if (model_.debug)
{
Info<< " stiffness :" << stiffness*d << nl
<< " damping :" << -damping*mag(rDir & v) << nl
<< " force : " << force << nl
<< " d : " << d << nl
<< " r : " << r << nl
<< " p : " << p << nl
<< " velocity : " << v
<< endl;
}
// Accumulate the force for the restrained body
fx[bodyIndex_] += spatialVector(moment, force);
}
bool Foam::RBD::restraints::softWall::read
(
const dictionary& dict
)
{
restraint::read(dict);
coeffs_.readEntry("anchor", anchor_);
coeffs_.readEntry("refAttachmentPt", refAttachmentPt_);
coeffs_.readEntry("psi", psi_);
coeffs_.readEntry("C", C_);
coeffs_.readEntry("wallNormal", wallNormal_);
return true;
}
void Foam::RBD::restraints::softWall::write
(
Ostream& os
) const
{
restraint::write(os);
os.writeEntry("anchor", anchor_);
os.writeEntry("refAttachmentPt", refAttachmentPt_);
os.writeEntry("psi", psi_);
os.writeEntry("C", C_);
os.writeEntry("wallNormal", wallNormal_);
}
// ************************************************************************* //

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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 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::RBD::restraints::softWall
Group
grpRigidBodyDynamicsRestraints
Description
Soft wall is a Damper-Linear spring restraint. Acts as a "soft" wall
when the distance between 'anchor' and 'refAttachmentPt' in the
wallNormal direction becomes negative.
A system of spring-damper is activated to simulate a soft collision
de-acceleration.
SourceFiles
softWall.C
\*---------------------------------------------------------------------------*/
#ifndef RBD_restraints_softWall_H
#define RBD_restraints_softWall_H
#include "rigidBodyRestraint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace restraints
{
/*---------------------------------------------------------------------------*\
Class softWall Declaration
\*---------------------------------------------------------------------------*/
class softWall
:
public restraint
{
// Private data
//- Anchor point, where the spring is attached to an immovable
// object
point anchor_;
//- Reference point of attachment to the solid body
point refAttachmentPt_;
//- Damping factor
scalar psi_;
//- Damping coefficient [1/sec]
scalar C_;
//- Wall normal
vector wallNormal_;
public:
//- Runtime type information
TypeName("softWall");
// Constructors
//- Construct from components
softWall
(
const word& name,
const dictionary& dict,
const rigidBodyModel& model
);
//- Construct and return a clone
virtual autoPtr<restraint> clone() const
{
return autoPtr<restraint>
(
new softWall(*this)
);
}
//- Destructor
virtual ~softWall();
// Member Functions
// Restrain forces
virtual void restrain
(
scalarField& tau,
Field<spatialVector>& fx
) const;
//- Update properties from given dictionary
virtual bool read(const dictionary& dict);
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace restraints
} // End namespace RBD
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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 | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2016 OpenFOAM Foundation | Copyright (C) 2016 OpenFOAM Foundation
@ -270,6 +270,9 @@ public:
//- Return the spatial velocity of the bodies //- Return the spatial velocity of the bodies
inline const spatialVector& v(const label i) const; inline const spatialVector& v(const label i) const;
//- Return the spatial acceleration of the bodies
inline const spatialVector& a(const label i) const;
//- Join the given body to the parent with ID parentID via the given //- Join the given body to the parent with ID parentID via the given
// joint with transform from the parent frame to the joint frame XT. // joint with transform from the parent frame to the joint frame XT.
virtual label join virtual label join

View File

@ -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 | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2016 OpenFOAM Foundation | Copyright (C) 2016 OpenFOAM Foundation
@ -113,6 +113,11 @@ Foam::RBD::rigidBodyModel::v(const label i) const
return v_[i]; return v_[i];
} }
inline const Foam::spatialVector&
Foam::RBD::rigidBodyModel::a(const label i) const
{
return a_[i];
}
inline bool Foam::RBD::rigidBodyModel::merged(label bodyID) const inline bool Foam::RBD::rigidBodyModel::merged(label bodyID) const
{ {

View File

@ -13,6 +13,7 @@ $(restraints)/sphericalAngularSpring/sphericalAngularSpring.C
$(restraints)/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C $(restraints)/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C
$(restraints)/linearDamper/linearDamper.C $(restraints)/linearDamper/linearDamper.C
$(restraints)/sphericalAngularDamper/sphericalAngularDamper.C $(restraints)/sphericalAngularDamper/sphericalAngularDamper.C
$(restraints)/linearSpringDamper/linearSpringDamper.C
constraints = sixDoFRigidBodyMotion/constraints constraints = sixDoFRigidBodyMotion/constraints

View File

@ -49,7 +49,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
) )
: :
fixedValuePointPatchField<vector>(p, iF), fixedValuePointPatchField<vector>(p, iF),
motion_(), motion_(db().time()),
initialPoints_(p.localPoints()), initialPoints_(p.localPoints()),
rhoInf_(1.0), rhoInf_(1.0),
rhoName_("rho"), rhoName_("rho"),
@ -68,7 +68,7 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
) )
: :
fixedValuePointPatchField<vector>(p, iF, dict), fixedValuePointPatchField<vector>(p, iF, dict),
motion_(dict, dict), motion_(dict, dict, db().time()),
rhoInf_(1.0), rhoInf_(1.0),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
lookupGravity_(-1), lookupGravity_(-1),

View File

@ -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 | \\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -48,7 +48,7 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
) )
: :
fixedValuePointPatchField<vector>(p, iF), fixedValuePointPatchField<vector>(p, iF),
motion_(), motion_(db().time()),
initialPoints_(p.localPoints()), initialPoints_(p.localPoints()),
curTimeIndex_(-1) curTimeIndex_(-1)
{} {}
@ -63,7 +63,7 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
) )
: :
fixedValuePointPatchField<vector>(p, iF, dict), fixedValuePointPatchField<vector>(p, iF, dict),
motion_(dict, dict), motion_(dict, dict, db().time()),
curTimeIndex_(-1) curTimeIndex_(-1)
{ {
if (!dict.found("value")) if (!dict.found("value"))

View File

@ -0,0 +1,189 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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 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 "linearSpringDamper.H"
#include "addToRunTimeSelectionTable.H"
#include "sixDoFRigidBodyMotion.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace sixDoFRigidBodyMotionRestraints
{
defineTypeNameAndDebug(linearSpringDamper, 0);
addToRunTimeSelectionTable
(
sixDoFRigidBodyMotionRestraint,
linearSpringDamper,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::linearSpringDamper
(
const word& name,
const dictionary& sDoFRBMRDict
)
:
sixDoFRigidBodyMotionRestraint(name, sDoFRBMRDict)
{
oldRestraintForce_ = Zero;
read(sDoFRBMRDict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::~linearSpringDamper()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::restrain
(
const sixDoFRigidBodyMotion& motion,
vector& restraintPosition,
vector& restraintForce,
vector& restraintMoment
) const
{
if (anchor_.empty())
{
anchor_.reset
(
new TimeFunction1<vector>
(
motion.time(),
"anchor",
coeffDict()
)
);
}
scalar t = motion.time().value();
restraintPosition = motion.transform(refAttachmentPt_);
// Current axis of the spring
vector r = restraintPosition - anchor_->value(t);
vector rDir = r/(mag(r) + VSMALL);
vector v = motion.velocity(restraintPosition);
scalar m = motion.mass();
restraintMoment = Zero;
// scalar dt = motion.time().deltaTValue();
//
// oldError_ = error_;
// oldErrorIntegral_ = errorIntegral_;
// error_ = (mag(r) - restLength_)/restLength_;
// errorIntegral_ =
// oldErrorIntegral_ + 0.5*(error_ + oldError_);
//
// scalar errorDifferential = (error_ - oldError_)/dt;
if (mag(r) > restLength_)
{
// factor_ =
// P_*error_ + I_*errorIntegral_ + D_*errorDifferential;
//
// factor_ = max(factor_, -1);
scalar damping = psi_*2*m*wn_/numberOfChains_;
scalar stiffness = sqr(wn_)*m/numberOfChains_;
restraintForce =
frelax_
*(
- damping*(rDir & v)*rDir
- stiffness*(mag(r) - restLength_)*rDir
)
+ (1-frelax_)*oldRestraintForce_;
oldRestraintForce_ = restraintForce;
}
else
{
restraintForce = Zero;
oldRestraintForce_ = Zero;
}
if (motion.report())
{
Info<< t << " " << restraintForce.x() //2
<< " " << restraintForce.y() //3
<< " " << restraintForce.z() //4
<< " " << mag(r) - restLength_ //5
<< endl;
}
}
bool Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::read
(
const dictionary& sDoFRBMRDict
)
{
sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
sDoFRBMRCoeffs_.readEntry("refAttachmentPt", refAttachmentPt_);
psi_ = sDoFRBMRCoeffs_.lookupOrDefault<scalar>("psi", 1.0);
sDoFRBMRCoeffs_.readEntry("wn", wn_);
sDoFRBMRCoeffs_.readEntry("restLength", restLength_);
sDoFRBMRCoeffs_.readEntry("numberOfChains", numberOfChains_);
frelax_ = sDoFRBMRCoeffs_.lookupOrDefault<scalar>("frelax", 0.8);
return true;
}
void Foam::sixDoFRigidBodyMotionRestraints::linearSpringDamper::write
(
Ostream& os
) const
{
os.writeEntry("refAttachmentPt", refAttachmentPt_);
os.writeEntry("psi", psi_);
os.writeEntry("wn", wn_);
os.writeEntry("restLength", restLength_);
os.writeEntry("numberOfChains", numberOfChains_);
os.writeEntryIfDifferent<scalar>("psi", 1.0, psi_);
os.writeEntryIfDifferent<scalar>("frelax", 0.8, frelax_);
}
// ************************************************************************* //

View File

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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 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::sixDoFRigidBodyMotionRestraints::linearSpringDamper
Description
sixDoFRigidBodyMotionRestraints model. Linear Spring-Damper system.
Spring-damper system for restraint. Acts as a "soft" rope when the
distance between anchor and refAttachmentPt exceed the restLength,
a system of spring-damper is activated to simulate a soft rope
de-acceleration
SourceFiles
linearSpringDamper.C
\*---------------------------------------------------------------------------*/
#ifndef linearSpringDamper_H
#define linearSpringDamper_H
#include "sixDoFRigidBodyMotionRestraint.H"
#include "point.H"
#include "TimeFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace sixDoFRigidBodyMotionRestraints
{
/*---------------------------------------------------------------------------*\
Class linearSpringDamper Declaration
\*---------------------------------------------------------------------------*/
class linearSpringDamper
:
public sixDoFRigidBodyMotionRestraint
{
// Private data
//- Anchor point, where the spring is attached to an immovable
// object
mutable autoPtr<TimeFunction1<vector>> anchor_;
//- Reference point of attachment to the solid body
point refAttachmentPt_;
//- Damping factor
scalar psi_;
//- System frequency [1/s]
scalar wn_;
//- Number of chains in the same system
scalar numberOfChains_;
//- Rest length - length of spring when no forces are applied to it
scalar restLength_;
//- Cache old restrain force
mutable vector oldRestraintForce_;
//- Relaxation factor
scalar frelax_;
/*
//- Error between ideal length and actual length
mutable scalar error_;
//- Old error between ideal length and actual length
mutable scalar oldError_;
//- Integral length error in time
mutable scalar errorIntegral_;
//- Old integral length error in time
mutable scalar oldErrorIntegral_;
//- Proportional constant
scalar P_;
//- Integral constant
scalar I_;
//- Differential constant
scalar D_;
//- Initial force
vector f0_;
mutable scalar wn_;
*/
public:
//- Runtime type information
TypeName("linearSpringDamper");
// Constructors
//- Construct from components
linearSpringDamper
(
const word& name,
const dictionary& sDoFRBMRDict
);
//- Construct and return a clone
virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
{
return autoPtr<sixDoFRigidBodyMotionRestraint>
(
new linearSpringDamper(*this)
);
}
//- Destructor
virtual ~linearSpringDamper();
// Member Functions
//- Calculate the restraint position, force and moment.
// Global reference frame vectors.
virtual void restrain
(
const sixDoFRigidBodyMotion& motion,
vector& restraintPosition,
vector& restraintForce,
vector& restraintMoment
) const;
//- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMRCoeff);
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solidBodyMotionFunctions
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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 | \\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -72,8 +72,9 @@ void Foam::sixDoFRigidBodyMotion::applyRestraints()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion() Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const Time& time)
: :
time_(time),
motionState_(), motionState_(),
motionState0_(), motionState0_(),
restraints_(), restraints_(),
@ -95,9 +96,11 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
( (
const dictionary& dict, const dictionary& dict,
const dictionary& stateDict const dictionary& stateDict,
const Time& time
) )
: :
time_(time),
motionState_(stateDict), motionState_(stateDict),
motionState0_(), motionState0_(),
restraints_(), restraints_(),
@ -159,6 +162,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
const sixDoFRigidBodyMotion& sDoFRBM const sixDoFRigidBodyMotion& sDoFRBM
) )
: :
time_(sDoFRBM.time_),
motionState_(sDoFRBM.motionState_), motionState_(sDoFRBM.motionState_),
motionState0_(sDoFRBM.motionState0_), motionState0_(sDoFRBM.motionState0_),
restraints_(sDoFRBM.restraints_), restraints_(sDoFRBM.restraints_),

View File

@ -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 | \\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation | Copyright (C) 2011-2015 OpenFOAM Foundation
@ -73,6 +73,9 @@ class sixDoFRigidBodyMotion
// Private data // Private data
//- Reference to time database
const Time& time_;
//- Motion state data object //- Motion state data object
sixDoFRigidBodyMotionState motionState_; sixDoFRigidBodyMotionState motionState_;
@ -193,9 +196,6 @@ class sixDoFRigidBodyMotion
//- Return non-const access to the orientation //- Return non-const access to the orientation
inline tensor& Q(); inline tensor& Q();
//- Return non-const access to vector
inline vector& v();
//- Return non-const access to acceleration //- Return non-const access to acceleration
inline vector& a(); inline vector& a();
@ -211,13 +211,14 @@ public:
// Constructors // Constructors
//- Construct null //- Construct null
sixDoFRigidBodyMotion(); sixDoFRigidBodyMotion(const Time&);
//- Construct from constant and state dictionaries //- Construct from constant and state dictionaries
sixDoFRigidBodyMotion sixDoFRigidBodyMotion
( (
const dictionary& dict, const dictionary& dict,
const dictionary& stateDict const dictionary& stateDict,
const Time& time
); );
//- Construct as copy //- Construct as copy
@ -261,11 +262,18 @@ public:
//- Return the current velocity //- Return the current velocity
inline const vector& v() const; inline const vector& v() const;
//- Return non-const access to vector
inline vector& v();
//- Return the current momentArm
inline vector momentArm() const; inline vector momentArm() const;
//- Return the report Switch //- Return the report Switch
inline bool report() const; inline bool report() const;
//- Return time
inline const Time& time() const;
// Edit // Edit

View File

@ -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 | \\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation | Copyright (C) 2011-2015 OpenFOAM Foundation
@ -264,6 +264,10 @@ inline Foam::vector Foam::sixDoFRigidBodyMotion::omega() const
return Q() & (inv(momentOfInertia_) & pi()); return Q() & (inv(momentOfInertia_) & pi());
} }
inline const Foam::Time& Foam::sixDoFRigidBodyMotion::time() const
{
return time_;
}
inline bool Foam::sixDoFRigidBodyMotion::report() const inline bool Foam::sixDoFRigidBodyMotion::report() const
{ {

View File

@ -81,7 +81,8 @@ Foam::sixDoFRigidBodyMotionSolver::sixDoFRigidBodyMotionSolver
false false
) )
) )
: coeffDict() : coeffDict(),
mesh.time()
), ),
patches_(coeffDict().get<wordRes>("patches")), patches_(coeffDict().get<wordRes>("patches")),
patchSet_(mesh.boundaryMesh().patchSet(patches_)), patchSet_(mesh.boundaryMesh().patchSet(patches_)),
@ -104,7 +105,8 @@ Foam::sixDoFRigidBodyMotionSolver::sixDoFRigidBodyMotionSolver
pointMesh::New(mesh), pointMesh::New(mesh),
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
), ),
curTimeIndex_(-1) curTimeIndex_(-1),
CofGvelocity_(coeffDict().lookupOrDefault<word>("CofGvelocity", "none"))
{ {
if (rhoName_ == "rhoInf") if (rhoName_ == "rhoInf")
{ {
@ -163,7 +165,23 @@ Foam::sixDoFRigidBodyMotionSolver::motion() const
Foam::tmp<Foam::pointField> Foam::tmp<Foam::pointField>
Foam::sixDoFRigidBodyMotionSolver::curPoints() const Foam::sixDoFRigidBodyMotionSolver::curPoints() const
{ {
return points0() + pointDisplacement_.primitiveField(); tmp<pointField> newPoints
(
points0() + pointDisplacement_.primitiveField()
);
if (!moveAllCells())
{
tmp<pointField> ttransformedPts(new pointField(mesh().points()));
pointField& transformedPts = ttransformedPts.ref();
UIndirectList<point>(transformedPts, pointIDs()) =
pointField(newPoints.ref(), pointIDs());
return ttransformedPts;
}
return newPoints;
} }
@ -240,6 +258,25 @@ void Foam::sixDoFRigidBodyMotionSolver::solve()
t.deltaTValue(), t.deltaTValue(),
t.deltaT0Value() t.deltaT0Value()
); );
if (CofGvelocity_ != "none")
{
if
(
db().time().foundObject<uniformDimensionedVectorField>
(
CofGvelocity_
)
)
{
uniformDimensionedVectorField& vel =
db().time().lookupObjectRef<uniformDimensionedVectorField>
(
CofGvelocity_
);
vel = motion_.v();
}
}
} }
// Update the displacements // Update the displacements

View File

@ -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 | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2013-2017 OpenFOAM Foundation | Copyright (C) 2013-2017 OpenFOAM Foundation
@ -93,6 +93,9 @@ class sixDoFRigidBodyMotionSolver
//- Current time index (used for updating) //- Current time index (used for updating)
label curTimeIndex_; label curTimeIndex_;
//- Name of the uniformVectorField for CofG velocity
word CofGvelocity_;
// Private Member Functions // Private Member Functions