Skip to content
Snippets Groups Projects
Commit 00ac073e authored by mattijs's avatar mattijs
Browse files

ENH: fvMotionSolvers: added solidBodyDisplacementLaplacian

Applies a displacementLaplacian on top of a solid-body motion function
parent 1f873612
No related merge requests found
......@@ -2,6 +2,7 @@ fvMotionSolvers/fvMotionSolver/fvMotionSolver.C
fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C
fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C
fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C
fvMotionSolvers/displacement/solidBodyDisplacementLaplacian/solidBodyDisplacementLaplacianFvMotionSolver.C
fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C
fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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 "solidBodyDisplacementLaplacianFvMotionSolver.H"
#include "motionInterpolation.H"
#include "motionDiffusivity.H"
#include "fvmLaplacian.H"
#include "addToRunTimeSelectionTable.H"
#include "OFstream.H"
#include "meshTools.H"
#include "mapPolyMesh.H"
#include "solidBodyMotionFunction.H"
#include "transformField.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(solidBodyDisplacementLaplacianFvMotionSolver, 0);
addToRunTimeSelectionTable
(
motionSolver,
solidBodyDisplacementLaplacianFvMotionSolver,
dictionary
);
addToRunTimeSelectionTable
(
displacementMotionSolver,
solidBodyDisplacementLaplacianFvMotionSolver,
displacement
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidBodyDisplacementLaplacianFvMotionSolver::
solidBodyDisplacementLaplacianFvMotionSolver
(
const polyMesh& mesh,
const IOdictionary& dict
)
:
displacementMotionSolver(mesh, dict, typeName),
fvMotionSolver(mesh),
SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time())),
cellDisplacement_
(
IOobject
(
"cellDisplacement",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
fvMesh_,
dimensionedVector
(
"cellDisplacement",
pointDisplacement_.dimensions(),
Zero
),
cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
),
pointLocation_(nullptr),
interpolationPtr_
(
coeffDict().found("interpolation")
? motionInterpolation::New(fvMesh_, coeffDict().lookup("interpolation"))
: motionInterpolation::New(fvMesh_)
),
diffusivityPtr_
(
motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
),
frozenPointsZone_
(
coeffDict().found("frozenPointsZone")
? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone"))
: -1
)
{
IOobject io
(
"pointLocation",
fvMesh_.time().timeName(),
fvMesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
if (debug)
{
Info<< "solidBodyDisplacementLaplacianFvMotionSolver:" << nl
<< " diffusivity : " << diffusivityPtr_().type() << nl
<< " frozenPoints zone : " << frozenPointsZone_ << endl;
}
if (io.typeHeaderOk<pointVectorField>(true))
{
pointLocation_.reset
(
new pointVectorField
(
io,
pointMesh::New(fvMesh_)
)
);
if (debug)
{
Info<< "solidBodyDisplacementLaplacianFvMotionSolver :"
<< " Read pointVectorField "
<< io.name()
<< " to be used for boundary conditions on points."
<< nl
<< "Boundary conditions:"
<< pointLocation_().boundaryField().types() << endl;
}
}
}
Foam::solidBodyDisplacementLaplacianFvMotionSolver::
solidBodyDisplacementLaplacianFvMotionSolver
(
const polyMesh& mesh,
const IOdictionary& dict,
const pointVectorField& pointDisplacement,
const pointIOField& points0
)
:
displacementMotionSolver(mesh, dict, pointDisplacement, points0, typeName),
fvMotionSolver(mesh),
SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time())),
cellDisplacement_
(
IOobject
(
"cellDisplacement",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
fvMesh_,
dimensionedVector
(
"cellDisplacement",
pointDisplacement_.dimensions(),
Zero
),
cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
),
pointLocation_(nullptr),
interpolationPtr_
(
coeffDict().found("interpolation")
? motionInterpolation::New(fvMesh_, coeffDict().lookup("interpolation"))
: motionInterpolation::New(fvMesh_)
),
diffusivityPtr_
(
motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
),
frozenPointsZone_
(
coeffDict().found("frozenPointsZone")
? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone"))
: -1
)
{
IOobject io
(
"pointLocation",
fvMesh_.time().timeName(),
fvMesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
if (debug)
{
Info<< "solidBodyDisplacementLaplacianFvMotionSolver:" << nl
<< " diffusivity : " << diffusivityPtr_().type() << nl
<< " frozenPoints zone : " << frozenPointsZone_ << endl;
}
if (io.typeHeaderOk<pointVectorField>(true))
{
pointLocation_.reset
(
new pointVectorField
(
io,
pointMesh::New(fvMesh_)
)
);
if (debug)
{
Info<< "solidBodyDisplacementLaplacianFvMotionSolver :"
<< " Read pointVectorField "
<< io.name()
<< " to be used for boundary conditions on points."
<< nl
<< "Boundary conditions:"
<< pointLocation_().boundaryField().types() << endl;
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::solidBodyDisplacementLaplacianFvMotionSolver::
~solidBodyDisplacementLaplacianFvMotionSolver()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::motionDiffusivity&
Foam::solidBodyDisplacementLaplacianFvMotionSolver::diffusivity()
{
if (!diffusivityPtr_.valid())
{
diffusivityPtr_ = motionDiffusivity::New
(
fvMesh_,
coeffDict().lookup("diffusivity")
);
}
return diffusivityPtr_();
}
Foam::tmp<Foam::pointField>
Foam::solidBodyDisplacementLaplacianFvMotionSolver::curPoints() const
{
interpolationPtr_->interpolate
(
cellDisplacement_,
pointDisplacement_
);
tmp<pointField> tnewPoints
(
transformPoints(SBMFPtr_().transformation(), points0())
);
const pointField& newPoints = tnewPoints();
if (pointLocation_.valid())
{
if (debug)
{
Info<< "solidBodyDisplacementLaplacianFvMotionSolver : applying "
<< " boundary conditions on " << pointLocation_().name()
<< " to new point location."
<< endl;
}
pointLocation_().primitiveFieldRef() =
newPoints
+ pointDisplacement_.internalField();
pointLocation_().correctBoundaryConditions();
// Implement frozen points
if (frozenPointsZone_ != -1)
{
const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
forAll(pz, i)
{
pointLocation_()[pz[i]] = newPoints[pz[i]];
}
}
twoDCorrectPoints(pointLocation_().primitiveFieldRef());
return tmp<pointField>(pointLocation_().primitiveField());
}
else
{
tmp<pointField> tcurPoints
(
newPoints + pointDisplacement_.primitiveField()
);
pointField& curPoints = tcurPoints.ref();
// Implement frozen points
if (frozenPointsZone_ != -1)
{
const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
forAll(pz, i)
{
curPoints[pz[i]] = newPoints[pz[i]];
}
}
twoDCorrectPoints(curPoints);
return tcurPoints;
}
}
void Foam::solidBodyDisplacementLaplacianFvMotionSolver::solve()
{
// The points have moved so before interpolation update
// the motionSolver accordingly
movePoints(fvMesh_.points());
diffusivity().correct();
pointDisplacement_.boundaryFieldRef().updateCoeffs();
Foam::solve
(
fvm::laplacian
(
diffusivity().operator()(),
cellDisplacement_,
"laplacian(diffusivity,cellDisplacement)"
)
);
}
void Foam::solidBodyDisplacementLaplacianFvMotionSolver::updateMesh
(
const mapPolyMesh& mpm
)
{
displacementMotionSolver::updateMesh(mpm);
// Update diffusivity. Note two stage to make sure old one is de-registered
// before creating/registering new one.
diffusivityPtr_.clear();
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 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::solidBodyDisplacementLaplacianFvMotionSolver
Group
grpMeshMotionSolvers
Description
Applies Laplacian displacement solving on top of a transformation of
the initial points using a solid-body motion.
See also
Foam::displacementLaplacian
SourceFiles
solidBodyDisplacementLaplacianFvMotionSolver.C
\*---------------------------------------------------------------------------*/
#ifndef solidBodyDisplacementLaplacianFvMotionSolver_H
#define solidBodyDisplacementLaplacianFvMotionSolver_H
#include "displacementMotionSolver.H"
#include "fvMotionSolver.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward class declarations
class motionInterpolation;
class motionDiffusivity;
class solidBodyMotionFunction;
/*---------------------------------------------------------------------------*\
Class solidBodyDisplacementLaplacianFvMotionSolver Declaration
\*---------------------------------------------------------------------------*/
class solidBodyDisplacementLaplacianFvMotionSolver
:
public displacementMotionSolver,
public fvMotionSolver
{
// Private data
//- Motion function
autoPtr<solidBodyMotionFunction> SBMFPtr_;
//- Cell-centre motion field
mutable volVectorField cellDisplacement_;
//- Optionally read point-position field. Used only for position
// boundary conditions.
mutable autoPtr<pointVectorField> pointLocation_;
//- Interpolation used to transfer cell displacement to the points
autoPtr<motionInterpolation> interpolationPtr_;
//- Diffusivity used to control the motion
autoPtr<motionDiffusivity> diffusivityPtr_;
//- Frozen points (that are not on patches). -1 or points that are
// fixed to be at points0_ location
label frozenPointsZone_;
// Private Member Functions
//- Disallow default bitwise copy construct
solidBodyDisplacementLaplacianFvMotionSolver
(
const solidBodyDisplacementLaplacianFvMotionSolver&
);
//- Disallow default bitwise assignment
void operator=(const solidBodyDisplacementLaplacianFvMotionSolver&);
public:
//- Runtime type information
TypeName("solidBodyDisplacementLaplacian");
// Constructors
//- Construct from polyMesh and IOdictionary
solidBodyDisplacementLaplacianFvMotionSolver
(
const polyMesh&,
const IOdictionary&
);
//- Construct from components
solidBodyDisplacementLaplacianFvMotionSolver
(
const polyMesh& mesh,
const IOdictionary& dict,
const pointVectorField& pointDisplacement,
const pointIOField& points0
);
//- Destructor
~solidBodyDisplacementLaplacianFvMotionSolver();
// Member Functions
//- Return reference to the diffusivity field
motionDiffusivity& diffusivity();
//- Return point location obtained from the current motion field
virtual tmp<pointField> curPoints() const;
//- Solve for motion
virtual void solve();
//- Update topology
virtual void updateMesh(const mapPolyMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment