Skip to content
Permalink
Browse files

motionSolvers::motionSolverList: New motion solver where the motion o…

…f the mesh specified as a list of motion solvers

The motion solvers are executed in order and the resulting displacements
accumulated into an overall displacement and the displaced point positions
returned.

This functionality replaces the dynamicMotionSolverListFvMesh class with the
equivalent specification of a "solvers" list rather than a "solver" entry in
dynamicMeshDict e.g.

dynamicFvMesh   dynamicMotionSolverFvMesh;

solvers
(
    Rotor
    {
        solver solidBody;

        solidBodyCoeffs
        {
            cellZone region1;

            solidBodyMotionFunction rotatingMotion;

            rotatingMotionCoeffs
            {
                origin        (0 0 0);
                axis          (0 0 1);
                omega         100; // rad/s
            }
        }
    }

    Piston
    {
        solver velocityComponentLaplacian;

        motionSolverLibs ("libfvMotionSolvers.so");

        velocityComponentLaplacianCoeffs
        {
            component       z;
            diffusivity  inverseDistance 1(wall1);
        }
    }
);
  • Loading branch information...
Henry Weller
Henry Weller committed Jan 23, 2019
1 parent c5db440 commit faf6e24ba39589d31cfdd951f2949a8ebc4d7d01
@@ -5,6 +5,5 @@ dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C
dynamicInkJetFvMesh/dynamicInkJetFvMesh.C
dynamicInterpolatedFvMesh/dynamicInterpolatedFvMesh.C
dynamicRefineFvMesh/dynamicRefineFvMesh.C
dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C

LIB = $(FOAM_LIBBIN)/libdynamicFvMesh
@@ -111,6 +111,7 @@ motionSolvers/componentVelocity/componentVelocityMotionSolver.C
motionSolvers/displacement/solidBody/solidBodyMotionSolver/solidBodyMotionSolver.C
motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver/multiSolidBodyMotionSolver.C
motionSolvers/displacement/solidBody/interpolatingSolidBodyMotionSolver/interpolatingSolidBodyMotionSolver.C
motionSolvers/motionSolverList/motionSolverList.C

solidBodyMotionFunctions = motionSolvers/displacement/solidBody/solidBodyMotionFunctions
$(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunction.C
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -23,10 +23,7 @@ License
\*---------------------------------------------------------------------------*/

#include "motionSolver.H"
#include "Time.H"
#include "polyMesh.H"
#include "dlLibraryTable.H"
#include "motionSolverList.H"
#include "twoDPointCorrector.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -104,43 +101,50 @@ Foam::autoPtr<Foam::motionSolver> Foam::motionSolver::New
const IOdictionary& solverDict
)
{
const word solverTypeName
(
solverDict.found("motionSolver")
? solverDict.lookup("motionSolver")
: solverDict.lookup("solver")
);

Info<< "Selecting motion solver: " << solverTypeName << endl;

const_cast<Time&>(mesh.time()).libs().open
(
solverDict,
"motionSolverLibs",
dictionaryConstructorTablePtr_
);

if (!dictionaryConstructorTablePtr_)
if (solverDict.found("solvers"))
{
FatalErrorInFunction
<< "solver table is empty"
<< exit(FatalError);
return autoPtr<motionSolver>(new motionSolverList(mesh, solverDict));
}
else
{
const word solverTypeName
(
solverDict.found("motionSolver")
? solverDict.lookup("motionSolver")
: solverDict.lookup("solver")
);

dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(solverTypeName);
Info<< "Selecting motion solver: " << solverTypeName << endl;

if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown solver type "
<< solverTypeName << nl << nl
<< "Valid solver types are:" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
const_cast<Time&>(mesh.time()).libs().open
(
solverDict,
"motionSolverLibs",
dictionaryConstructorTablePtr_
);

if (!dictionaryConstructorTablePtr_)
{
FatalErrorInFunction
<< "solver table is empty"
<< exit(FatalError);
}

dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(solverTypeName);

if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown solver type "
<< solverTypeName << nl << nl
<< "Valid solver types are:" << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}

return autoPtr<motionSolver>(cstrIter()(mesh, solverDict));
}

return autoPtr<motionSolver>(cstrIter()(mesh, solverDict));
}


@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -23,81 +23,93 @@ License
\*---------------------------------------------------------------------------*/

#include "dynamicMotionSolverListFvMesh.H"
#include "motionSolverList.H"
#include "addToRunTimeSelectionTable.H"
#include "motionSolver.H"
#include "pointMesh.H"
#include "volFields.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
defineTypeNameAndDebug(dynamicMotionSolverListFvMesh, 0);
defineTypeNameAndDebug(motionSolverList, 0);
addToRunTimeSelectionTable
(
dynamicFvMesh,
dynamicMotionSolverListFvMesh,
IOobject
motionSolver,
motionSolverList,
dictionary
);
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::dynamicMotionSolverListFvMesh::dynamicMotionSolverListFvMesh
Foam::motionSolverList::motionSolverList
(
const IOobject& io
const polyMesh& mesh,
const IOdictionary& dict
)
:
dynamicFvMesh(io),
motionSolver(mesh, dict, typeName),
motionSolvers_
(
IOdictionary
(
IOobject
(
"dynamicMeshDict",
time().constant(),
*this,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::AUTO_WRITE
)
).lookup("solvers"),
motionSolver::iNew(*this)
dict.lookup("solvers"),
motionSolver::iNew(mesh)
)
{}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::dynamicMotionSolverListFvMesh::~dynamicMotionSolverListFvMesh()
Foam::motionSolverList::~motionSolverList()
{}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

bool Foam::dynamicMotionSolverListFvMesh::update()
Foam::tmp<Foam::pointField> Foam::motionSolverList::curPoints() const
{
if (motionSolvers_.size())
{
// Accumulated displacement
pointField disp(motionSolvers_[0].newPoints() - fvMesh::points());
pointField disp(motionSolvers_[0].curPoints() - mesh().points());

for (label i = 1; i < motionSolvers_.size(); i++)
{
disp += motionSolvers_[i].newPoints() - fvMesh::points();
disp += motionSolvers_[i].curPoints() - mesh().points();
}

fvMesh::movePoints(points() + disp);
return mesh().points() + disp;
}
else
{
return mesh().points();
}
}

if (foundObject<volVectorField>("U"))
{
lookupObjectRef<volVectorField>("U").correctBoundaryConditions();
}

void Foam::motionSolverList::solve()
{
forAll(motionSolvers_, i)
{
motionSolvers_[i].solve();
}
}


void Foam::motionSolverList::movePoints(const pointField& points)
{
forAll(motionSolvers_, i)
{
motionSolvers_[i].movePoints(points);
}
}


return true;
void Foam::motionSolverList::updateMesh(const mapPolyMesh& mpm)
{
forAll(motionSolvers_, i)
{
motionSolvers_[i].updateMesh(mpm);
}
}


@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -22,35 +22,37 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::dynamicMotionSolverListFvMesh
Foam::motionSolverList
Description
Foam::dynamicMotionSolverListFvMesh
Motion of the mesh specified as a list of motion solvers.
The motion solvers are executed in order and the resulting displacements
accumulated into an overall displacement and the displaced point positions
returned.
SourceFiles
dynamicMotionSolverListFvMesh.C
motionSolverList.C
\*---------------------------------------------------------------------------*/

#ifndef dynamicMotionSolverListFvMesh_H
#define dynamicMotionSolverListFvMesh_H
#ifndef motionSolverList_H
#define motionSolverList_H

#include "dynamicFvMesh.H"
#include "motionSolver.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

class motionSolver;

/*---------------------------------------------------------------------------*\
Class dynamicMotionSolverListFvMesh Declaration
Class motionSolverList Declaration
\*---------------------------------------------------------------------------*/

class dynamicMotionSolverListFvMesh
class motionSolverList
:
public dynamicFvMesh
public motionSolver
{
// Private data

@@ -60,32 +62,41 @@ class dynamicMotionSolverListFvMesh
// Private Member Functions

//- Disallow default bitwise copy construct
dynamicMotionSolverListFvMesh(const dynamicMotionSolverListFvMesh&);
motionSolverList(const motionSolverList&);

//- Disallow default bitwise assignment
void operator=(const dynamicMotionSolverListFvMesh&);
void operator=(const motionSolverList&);


public:

//- Runtime type information
TypeName("dynamicMotionSolverListFvMesh");
TypeName("motionSolverList");


// Constructors

//- Construct from IOobject
dynamicMotionSolverListFvMesh(const IOobject& io);
//- Construct from mesh and dictionary
motionSolverList(const polyMesh&, const IOdictionary&);


//- Destructor
~dynamicMotionSolverListFvMesh();
virtual ~motionSolverList();


// Member Functions

//- Dummy update function which does not change the mesh
virtual bool update();
//- Provide current points for motion. Uses current motion field
virtual tmp<pointField> curPoints() const;

//- Solve for motion
virtual void solve();

//- Update local data for geometry changes
virtual void movePoints(const pointField&);

//- Update local data for topology changes
virtual void updateMesh(const mapPolyMesh&);
};


0 comments on commit faf6e24

Please sign in to comment.
You can’t perform that action at this time.