mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: motionSolver: added displacementMotionSolver run-time selection table
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,25 +31,23 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(displacementMotionSolver, 0);
|
||||
defineRunTimeSelectionTable(displacementMotionSolver, displacement);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Data Members * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOobject Foam::displacementMotionSolver::points0IO
|
||||
(
|
||||
const polyMesh& mesh
|
||||
) const
|
||||
Foam::IOobject Foam::displacementMotionSolver::points0IO(const polyMesh& mesh)
|
||||
{
|
||||
const word instance =
|
||||
time().findInstance
|
||||
mesh.time().findInstance
|
||||
(
|
||||
mesh.meshDir(),
|
||||
"points0",
|
||||
IOobject::READ_IF_PRESENT
|
||||
);
|
||||
|
||||
if (instance != time().constant())
|
||||
if (instance != mesh.time().constant())
|
||||
{
|
||||
// points0 written to a time folder
|
||||
|
||||
@ -58,7 +56,7 @@ Foam::IOobject Foam::displacementMotionSolver::points0IO
|
||||
(
|
||||
"points0",
|
||||
instance,
|
||||
polyMesh::meshSubDir,
|
||||
mesh.meshDir(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
@ -73,7 +71,7 @@ Foam::IOobject Foam::displacementMotionSolver::points0IO
|
||||
(
|
||||
"points0",
|
||||
instance,
|
||||
polyMesh::meshSubDir,
|
||||
mesh.meshDir(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
@ -93,7 +91,7 @@ Foam::IOobject Foam::displacementMotionSolver::points0IO
|
||||
(
|
||||
"points",
|
||||
instance,
|
||||
polyMesh::meshSubDir,
|
||||
mesh.meshDir(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
@ -142,12 +140,11 @@ Foam::displacementMotionSolver::displacementMotionSolver
|
||||
) << "Number of points in mesh " << mesh.nPoints()
|
||||
<< " differs from number of points " << points0_.size()
|
||||
<< " read from file "
|
||||
<<
|
||||
IOobject
|
||||
<< IOobject
|
||||
(
|
||||
"points",
|
||||
time().constant(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh.meshDir(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
@ -158,6 +155,104 @@ Foam::displacementMotionSolver::displacementMotionSolver
|
||||
}
|
||||
|
||||
|
||||
Foam::displacementMotionSolver::displacementMotionSolver
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const IOdictionary& dict,
|
||||
const pointVectorField& pointDisplacement,
|
||||
const pointIOField& points0,
|
||||
const word& type
|
||||
)
|
||||
:
|
||||
motionSolver(mesh, dict, type),
|
||||
pointDisplacement_
|
||||
(
|
||||
IOobject(pointDisplacement, "pointDisplacement"),
|
||||
pointDisplacement
|
||||
),
|
||||
points0_(points0)
|
||||
{
|
||||
if (points0_.size() != mesh.nPoints())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"displacementMotionSolver::"
|
||||
"displacementMotionSolver\n"
|
||||
"(\n"
|
||||
" const polyMesh&,\n"
|
||||
" const IOdictionary&,\n"
|
||||
" const pointVectorField&,\n"
|
||||
" const pointIOField&,\n"
|
||||
" const word&\n"
|
||||
")"
|
||||
) << "Number of points in mesh " << mesh.nPoints()
|
||||
<< " differs from number of points " << points0_.size()
|
||||
<< " read from file " << points0.filePath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::displacementMotionSolver>
|
||||
Foam::displacementMotionSolver::New
|
||||
(
|
||||
const word& solverTypeName,
|
||||
const polyMesh& mesh,
|
||||
const IOdictionary& solverDict,
|
||||
const pointVectorField& pointDisplacement,
|
||||
const pointIOField& points0
|
||||
)
|
||||
{
|
||||
//const word solverTypeName(solverDict.lookup("solver"));
|
||||
|
||||
Info<< "Selecting motion solver: " << solverTypeName << endl;
|
||||
|
||||
const_cast<Time&>(mesh.time()).libs().open
|
||||
(
|
||||
solverDict,
|
||||
"motionSolverLibs",
|
||||
displacementConstructorTablePtr_
|
||||
);
|
||||
|
||||
if (!displacementConstructorTablePtr_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"displacementMotionSolver::New(const polyMesh& mesh)"
|
||||
) << "solver table is empty"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
displacementConstructorTable::iterator cstrIter =
|
||||
displacementConstructorTablePtr_->find(solverTypeName);
|
||||
|
||||
if (cstrIter == displacementConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"displacementMotionSolver::New(const polyMesh&)"
|
||||
) << "Unknown solver type "
|
||||
<< solverTypeName << nl << nl
|
||||
<< "Valid solver types are:" << endl
|
||||
<< displacementConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<displacementMotionSolver>
|
||||
(
|
||||
cstrIter()
|
||||
(
|
||||
mesh,
|
||||
solverDict,
|
||||
pointDisplacement,
|
||||
points0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::displacementMotionSolver::~displacementMotionSolver()
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -68,14 +68,8 @@ protected:
|
||||
pointIOField points0_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Return IO object for points0
|
||||
IOobject points0IO(const polyMesh& mesh) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -84,12 +78,49 @@ private:
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const displacementMotionSolver&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("displacementMotionSolver");
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
displacementMotionSolver,
|
||||
displacement,
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const IOdictionary& dict,
|
||||
const pointVectorField& pointDisplacement,
|
||||
const pointIOField& points0
|
||||
),
|
||||
(mesh, dict, pointDisplacement, points0)
|
||||
);
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return IO object for points0
|
||||
static IOobject points0IO(const polyMesh& mesh);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from polyMesh, dictionary and components.
|
||||
// If dictionary was registered this will 'steal' that registration.
|
||||
static autoPtr<displacementMotionSolver> New
|
||||
(
|
||||
const word& solverTypeName,
|
||||
const polyMesh&,
|
||||
const IOdictionary&,
|
||||
const pointVectorField& pointDisplacement,
|
||||
const pointIOField& points0
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh and dictionary
|
||||
@ -100,6 +131,16 @@ public:
|
||||
const word& type
|
||||
);
|
||||
|
||||
//- Construct from mesh and dictionary
|
||||
displacementMotionSolver
|
||||
(
|
||||
const polyMesh&,
|
||||
const IOdictionary&,
|
||||
const pointVectorField& pointDisplacement,
|
||||
const pointIOField& points0,
|
||||
const word& type
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~displacementMotionSolver();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -67,7 +67,9 @@ private:
|
||||
dictionary coeffDict_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- De-register object if registered and assign to current
|
||||
static IOobject stealRegistration(const IOdictionary& dict);
|
||||
|
||||
@ -0,0 +1,199 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "velocityDisplacementMotionSolver.H"
|
||||
#include "displacementMotionSolver.H"
|
||||
#include "fixedValuePointPatchField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(velocityDisplacementMotionSolver, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
motionSolver,
|
||||
velocityDisplacementMotionSolver,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::wordList
|
||||
Foam::velocityDisplacementMotionSolver::pointDisplacementBoundaryTypes() const
|
||||
{
|
||||
const pointVectorField::GeometricBoundaryField& pmUbf
|
||||
(
|
||||
pointMotionU().boundaryField()
|
||||
);
|
||||
|
||||
wordList cmUbf = pmUbf.types();
|
||||
|
||||
forAll(pmUbf, patchI)
|
||||
{
|
||||
if (isA<fixedValuePointPatchField<vector> >(pmUbf[patchI]))
|
||||
{
|
||||
cmUbf[patchI] = fixedValuePointPatchField<vector>::typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return cmUbf;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::velocityDisplacementMotionSolver::velocityDisplacementMotionSolver
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const IOdictionary& dict
|
||||
)
|
||||
:
|
||||
velocityMotionSolver(mesh, dict, typeName),
|
||||
displacementMotionSolverPtr_()
|
||||
{
|
||||
pointIOField points0(displacementMotionSolver::points0IO(mesh));
|
||||
|
||||
pointVectorField pointDisplacement
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pointVelocityDisplacement",
|
||||
mesh.time().timeName(),
|
||||
mesh
|
||||
),
|
||||
pointMotionU().mesh(),
|
||||
dimLength,
|
||||
pointDisplacementBoundaryTypes()
|
||||
);
|
||||
|
||||
pointDisplacement.internalField() = mesh.points() - points0;
|
||||
|
||||
displacementMotionSolverPtr_.set
|
||||
(
|
||||
dynamic_cast<displacementMotionSolver*>
|
||||
(
|
||||
displacementMotionSolver::New
|
||||
(
|
||||
coeffDict().lookup("solver"),
|
||||
mesh,
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
dict.name() + "Coeffs",
|
||||
mesh.time().constant(),
|
||||
mesh
|
||||
),
|
||||
coeffDict()
|
||||
),
|
||||
pointDisplacement,
|
||||
points0
|
||||
).ptr()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::velocityDisplacementMotionSolver::~velocityDisplacementMotionSolver()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::pointField>
|
||||
Foam::velocityDisplacementMotionSolver::curPoints() const
|
||||
{
|
||||
return displacementMotionSolverPtr_->curPoints();
|
||||
}
|
||||
|
||||
|
||||
void Foam::velocityDisplacementMotionSolver::solve()
|
||||
{
|
||||
movePoints(mesh().points());
|
||||
|
||||
const scalar deltaT(mesh().time().deltaTValue());
|
||||
|
||||
// Current and old point displacements
|
||||
pointVectorField& displacement
|
||||
(
|
||||
displacementMotionSolverPtr_->pointDisplacement()
|
||||
);
|
||||
const vectorField displacementOld
|
||||
(
|
||||
mesh().points() - displacementMotionSolverPtr_->points0()
|
||||
);
|
||||
|
||||
// Update the velocity boundary conditions
|
||||
pointMotionU().correctBoundaryConditions();
|
||||
|
||||
// Update the displacement boundary conditions
|
||||
forAll(pointMotionU().boundaryField(), patchI)
|
||||
{
|
||||
const pointPatchVectorField& patchField
|
||||
(
|
||||
pointMotionU().boundaryField()[patchI]
|
||||
);
|
||||
|
||||
displacement.boundaryField()[patchI] ==
|
||||
patchField.patchInternalField()*deltaT
|
||||
+ patchField.patchInternalField(displacementOld);
|
||||
}
|
||||
|
||||
// Run the sub-solver
|
||||
displacementMotionSolverPtr_->solve();
|
||||
|
||||
// Update the velocity
|
||||
pointMotionU().internalField() =
|
||||
(displacement.internalField() - displacementOld)/deltaT;
|
||||
}
|
||||
|
||||
|
||||
void Foam::velocityDisplacementMotionSolver::movePoints(const pointField& p)
|
||||
{
|
||||
velocityMotionSolver::movePoints(p);
|
||||
|
||||
displacementMotionSolverPtr_->movePoints(p);
|
||||
}
|
||||
|
||||
|
||||
void Foam::velocityDisplacementMotionSolver::updateMesh
|
||||
(
|
||||
const mapPolyMesh& mpm
|
||||
)
|
||||
{
|
||||
velocityMotionSolver::updateMesh(mpm);
|
||||
|
||||
displacementMotionSolverPtr_->updateMesh(mpm);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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::velocityDisplacementMotionSolver
|
||||
|
||||
Description
|
||||
Mesh motion solver for a polyMesh. Wraps a displacement motion solver in a
|
||||
velocity motion solver.
|
||||
|
||||
SourceFiles
|
||||
velocityDisplacementMotionSolver.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef velocityDisplacementMotionSolver_H
|
||||
#define velocityDisplacementMotionSolver_H
|
||||
|
||||
#include "velocityMotionSolver.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward class declarations
|
||||
class displacementMotionSolver;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class velocityDisplacementMotionSolver Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class velocityDisplacementMotionSolver
|
||||
:
|
||||
public velocityMotionSolver
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Displacement motion solver
|
||||
autoPtr<displacementMotionSolver> displacementMotionSolverPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
velocityDisplacementMotionSolver
|
||||
(
|
||||
const velocityDisplacementMotionSolver&
|
||||
);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const velocityDisplacementMotionSolver&);
|
||||
|
||||
//- Get the boundary condition types for the point displacement
|
||||
wordList pointDisplacementBoundaryTypes() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("velocityDisplacement");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from polyMesh and IOdictionary
|
||||
velocityDisplacementMotionSolver
|
||||
(
|
||||
const polyMesh&,
|
||||
const IOdictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~velocityDisplacementMotionSolver();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return point location obtained from the current motion field
|
||||
virtual tmp<pointField> curPoints() const;
|
||||
|
||||
//- Solve for motion
|
||||
virtual void solve();
|
||||
|
||||
//- Update geometry
|
||||
virtual void movePoints(const pointField&);
|
||||
|
||||
//- Update topology
|
||||
virtual void updateMesh(const mapPolyMesh&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user