Commit d96ad1cd authored by sergio's avatar sergio Committed by Andrew Heather
Browse files

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.
parent 60517236
......@@ -17,13 +17,6 @@
#include "interpolatedFaces.H"
}
if (runTime.outputTime())
{
H.write();
rAU.write();
HbyA.write();
}
surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA));
if (ddtCorr)
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016 OpenFOAM Foundation
......@@ -53,22 +53,57 @@ Foam::dynamicMotionSolverListFvMesh::dynamicMotionSolverListFvMesh
)
:
dynamicFvMesh(io),
motionSolvers_
motionSolvers_()
{
IOobject ioDict
(
IOdictionary
(
IOobject
(
"dynamicMeshDict",
time().constant(),
*this,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::AUTO_WRITE
)
).lookup("solvers"),
motionSolver::iNew(*this)
)
{}
"dynamicMeshDict",
time().constant(),
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
IOdictionary dict(ioDict);
label i = 0;
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 * * * * * * * * * * * * * * * //
......
......@@ -27,7 +27,9 @@ Class
Foam::dynamicMotionSolverListFvMesh
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
dynamicMotionSolverListFvMesh.C
......
......@@ -102,6 +102,7 @@ motionSmoother/badQualityToFace/badQualityToFace.C
motionSolvers/motionSolver/motionSolver.C
motionSolvers/displacement/points0/points0MotionSolver.C
motionSolvers/displacement/displacement/zoneMotion.C
motionSolvers/displacement/displacement/displacementMotionSolver.C
motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C
motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C
......@@ -120,6 +121,7 @@ $(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunctionNew.C
$(solidBodyMotionFunctions)/SDA/SDA.C
$(solidBodyMotionFunctions)/tabulated6DoFMotion/tabulated6DoFMotion.C
$(solidBodyMotionFunctions)/linearMotion/linearMotion.C
$(solidBodyMotionFunctions)/drivenLinearMotion/drivenLinearMotion.C
$(solidBodyMotionFunctions)/rotatingMotion/rotatingMotion.C
$(solidBodyMotionFunctions)/axisRotationMotion/axisRotationMotion.C
$(solidBodyMotionFunctions)/multiMotion/multiMotion.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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_;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2012-2017 OpenFOAM Foundation
......@@ -113,6 +113,7 @@ Foam::points0MotionSolver::points0MotionSolver
)
:
motionSolver(mesh, dict, type),
zoneMotion(dict, mesh),
points0_(points0IO(mesh))
{
if
......@@ -156,6 +157,7 @@ Foam::points0MotionSolver::points0MotionSolver
)
:
motionSolver(mesh, dict, type),
zoneMotion(dict, mesh),
points0_(points0)
{
if (points0_.size() != mesh.nPoints())
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2016 OpenFOAM Foundation
......@@ -41,6 +41,7 @@ SourceFiles
#include "motionSolver.H"
#include "pointFields.H"
#include "pointIOField.H"
#include "zoneMotion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -55,7 +56,8 @@ class mapPolyMesh;
class points0MotionSolver
:
public motionSolver
public motionSolver,
public zoneMotion
{
protected:
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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