From 31fee136e14b0c38cd1d2af6924f43e047793862 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 8 Dec 2021 11:48:40 +0000 Subject: [PATCH] fvMotionSolvers: Reinstated velocity and componentVelocity motion solvers There are cases still using these deprecated motion solvers pending update to use interpolated displacement motion methods. --- src/fvMotionSolver/Make/files | 4 + ...lacementComponentLaplacianFvMotionSolver.C | 25 ++- ...velocityComponentLaplacianFvMotionSolver.C | 151 +++++++++++++++++ ...velocityComponentLaplacianFvMotionSolver.H | 131 +++++++++++++++ .../displacementLaplacianFvMotionSolver.C | 1 - .../velocityLaplacianFvMotionSolver.C | 158 ++++++++++++++++++ .../velocityLaplacianFvMotionSolver.H | 133 +++++++++++++++ .../SnakeRiverCanyon/constant/dynamicMeshDict | 3 +- 8 files changed, 594 insertions(+), 12 deletions(-) create mode 100644 src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C create mode 100644 src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H create mode 100644 src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C create mode 100644 src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index 11ccdb82d6..377026fea0 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -4,6 +4,10 @@ fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C +fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C + +fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C + motionDiffusivity/motionDiffusivity/motionDiffusivity.C motionDiffusivity/uniform/uniformDiffusivity.C motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C diff --git a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C index ecb503e90a..05c80ed30c 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -82,16 +82,23 @@ displacementComponentLaplacianFvMotionSolver : -1 ) { - Switch applyPointLocation + typeIOobject io ( - coeffDict().lookupOrDefault - ( - "applyPointLocation", - true - ) + "pointLocation", + fvMesh_.time().timeName(), + fvMesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE ); - if (applyPointLocation) + if (debug) + { + Info<< "displacementComponentLaplacianFvMotionSolver:" << nl + << " diffusivity : " << diffusivityPtr_().type() << nl + << " frozenPoints zone : " << frozenPointsZone_ << endl; + } + + if (io.headerOk()) { pointLocation_.reset ( @@ -109,7 +116,7 @@ displacementComponentLaplacianFvMotionSolver ) ); - // if (debug) + if (debug) { Info<< "displacementComponentLaplacianFvMotionSolver :" << " Read pointVectorField " diff --git a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C new file mode 100644 index 0000000000..0da38bfc06 --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2021 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 . + +\*---------------------------------------------------------------------------*/ + +#include "velocityComponentLaplacianFvMotionSolver.H" +#include "motionDiffusivity.H" +#include "fvmLaplacian.H" +#include "addToRunTimeSelectionTable.H" +#include "volPointInterpolation.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(velocityComponentLaplacianFvMotionSolver, 0); + + addToRunTimeSelectionTable + ( + motionSolver, + velocityComponentLaplacianFvMotionSolver, + dictionary + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::velocityComponentLaplacianFvMotionSolver:: +velocityComponentLaplacianFvMotionSolver +( + const polyMesh& mesh, + const dictionary& dict +) +: + componentVelocityMotionSolver(mesh, dict, typeName), + fvMotionSolver(mesh), + cellMotionU_ + ( + IOobject + ( + "cellMotionU" + cmptName_, + mesh.time().timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + fvMesh_, + dimensionedScalar(pointMotionU_.dimensions(), 0), + cellMotionBoundaryTypes(pointMotionU_.boundaryField()) + ), + diffusivityPtr_ + ( + motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity")) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::velocityComponentLaplacianFvMotionSolver:: +~velocityComponentLaplacianFvMotionSolver() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp +Foam::velocityComponentLaplacianFvMotionSolver::curPoints() const +{ + volPointInterpolation::New(fvMesh_).interpolate + ( + cellMotionU_, + pointMotionU_ + ); + + tmp tcurPoints(new pointField(fvMesh_.points())); + + tcurPoints.ref().replace + ( + cmpt_, + tcurPoints().component(cmpt_) + + fvMesh_.time().deltaTValue()*pointMotionU_.primitiveField() + ); + + twoDCorrectPoints(tcurPoints.ref()); + + return tcurPoints; +} + + +void Foam::velocityComponentLaplacianFvMotionSolver::solve() +{ + // The points have moved so before interpolation update + // the fvMotionSolver accordingly + movePoints(fvMesh_.points()); + + diffusivityPtr_->correct(); + pointMotionU_.boundaryFieldRef().updateCoeffs(); + + Foam::solve + ( + fvm::laplacian + ( + diffusivityPtr_->operator()(), + cellMotionU_, + "laplacian(diffusivity,cellMotionU)" + ) + ); +} + + +void Foam::velocityComponentLaplacianFvMotionSolver::updateMesh +( + const mapPolyMesh& mpm +) +{ + componentVelocityMotionSolver::updateMesh(mpm); + + // Update diffusivity. Note two stage to make sure old one is de-registered + // before creating/registering new one. + diffusivityPtr_.reset(nullptr); + diffusivityPtr_ = motionDiffusivity::New + ( + fvMesh_, + coeffDict().lookup("diffusivity") + ); +} + + +// ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H new file mode 100644 index 0000000000..9dfd5f5ed5 --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2021 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 . + +Class + Foam::velocityComponentLaplacianFvMotionSolver + +Description + Mesh motion solver for an fvMesh. Based on solving the cell-centre + Laplacian for the given component of the motion velocity. + +SourceFiles + velocityComponentLaplacianFvMotionSolver.C + +\*---------------------------------------------------------------------------*/ + +#ifndef velocityComponentLaplacianFvMotionSolver_H +#define velocityComponentLaplacianFvMotionSolver_H + +#include "componentVelocityMotionSolver.H" +#include "fvMotionSolver.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward class declarations +class motionDiffusivity; + +/*---------------------------------------------------------------------------*\ + Class velocityComponentLaplacianFvMotionSolver Declaration +\*---------------------------------------------------------------------------*/ + +class velocityComponentLaplacianFvMotionSolver +: + public componentVelocityMotionSolver, + public fvMotionSolver +{ + // Private Data + + //- Cell-centre motion field + mutable volScalarField cellMotionU_; + + //- Diffusivity used to control the motion + autoPtr diffusivityPtr_; + + +public: + + //- Runtime type information + TypeName("velocityComponentLaplacian"); + + + // Constructors + + //- Construct from polyMesh and dictionary + velocityComponentLaplacianFvMotionSolver + ( + const polyMesh&, + const dictionary& + ); + + //- Disallow default bitwise copy construction + velocityComponentLaplacianFvMotionSolver + ( + const velocityComponentLaplacianFvMotionSolver& + ) = delete; + + + //- Destructor + ~velocityComponentLaplacianFvMotionSolver(); + + + // Member Functions + + //- Non-const access to the cellMotionU in order to allow changes + // to the boundary motion + volScalarField& cellMotionU() + { + return cellMotionU_; + } + + //- Return point location obtained from the current motion field + virtual tmp curPoints() const; + + //- Solve for motion + virtual void solve(); + + //- Update topology + virtual void updateMesh(const mapPolyMesh&); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator= + ( + const velocityComponentLaplacianFvMotionSolver& + ) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index c040801887..a720221465 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -104,7 +104,6 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver << " frozenPoints zone : " << frozenPointsZone_ << endl; } - if (io.headerOk()) { pointLocation_.reset diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C new file mode 100644 index 0000000000..13613c58cf --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2021 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 . + +\*---------------------------------------------------------------------------*/ + +#include "velocityLaplacianFvMotionSolver.H" +#include "motionDiffusivity.H" +#include "fvmLaplacian.H" +#include "addToRunTimeSelectionTable.H" +#include "volPointInterpolation.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(velocityLaplacianFvMotionSolver, 0); + + addToRunTimeSelectionTable + ( + motionSolver, + velocityLaplacianFvMotionSolver, + dictionary + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::velocityLaplacianFvMotionSolver::velocityLaplacianFvMotionSolver +( + const polyMesh& mesh, + const dictionary& dict +) +: + velocityMotionSolver(mesh, dict, typeName), + fvMotionSolver(mesh), + cellMotionU_ + ( + IOobject + ( + "cellMotionU", + mesh.time().timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + fvMesh_, + dimensionedVector + ( + "cellMotionU", + pointMotionU_.dimensions(), + Zero + ), + cellMotionBoundaryTypes(pointMotionU_.boundaryField()) + ), + diffusivityPtr_ + ( + motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity")) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::velocityLaplacianFvMotionSolver::~velocityLaplacianFvMotionSolver() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp +Foam::velocityLaplacianFvMotionSolver::curPoints() const +{ + volPointInterpolation::New(fvMesh_).interpolate + ( + cellMotionU_, + pointMotionU_ + ); + + tmp tcurPoints + ( + fvMesh_.points() + + fvMesh_.time().deltaTValue()*pointMotionU_.primitiveField() + ); + + twoDCorrectPoints(tcurPoints.ref()); + + return tcurPoints; +} + + +void Foam::velocityLaplacianFvMotionSolver::solve() +{ + // The points have moved so before interpolation update + // the fvMotionSolver accordingly + movePoints(fvMesh_.points()); + + diffusivityPtr_->correct(); + pointMotionU_.boundaryFieldRef().updateCoeffs(); + + Foam::solve + ( + fvm::laplacian + ( + diffusivityPtr_->operator()(), + cellMotionU_, + "laplacian(diffusivity,cellMotionU)" + ) + ); +} + + +//void Foam::velocityLaplacianFvMotionSolver::movePoints(const pointField& p) +//{ +// // Movement of pointMesh and volPointInterpolation already +// // done by polyMesh,fvMesh +//} + + +void Foam::velocityLaplacianFvMotionSolver::updateMesh +( + const mapPolyMesh& mpm +) +{ + velocityMotionSolver::updateMesh(mpm); + + // Update diffusivity. Note two stage to make sure old one is de-registered + // before creating/registering new one. + diffusivityPtr_.reset(nullptr); + diffusivityPtr_ = motionDiffusivity::New + ( + fvMesh_, + coeffDict().lookup("diffusivity") + ); +} + + +// ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H new file mode 100644 index 0000000000..f84eb2c879 --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2021 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 . + +Class + Foam::velocityLaplacianFvMotionSolver + +Description + Mesh motion solver for an fvMesh. Based on solving the cell-centre + Laplacian for the motion velocity. + +SourceFiles + velocityLaplacianFvMotionSolver.C + +\*---------------------------------------------------------------------------*/ + +#ifndef velocityLaplacianFvMotionSolver_H +#define velocityLaplacianFvMotionSolver_H + +#include "velocityMotionSolver.H" +#include "fvMotionSolver.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward class declarations +class motionDiffusivity; + +/*---------------------------------------------------------------------------*\ + Class velocityLaplacianFvMotionSolver Declaration +\*---------------------------------------------------------------------------*/ + +class velocityLaplacianFvMotionSolver +: + public velocityMotionSolver, + public fvMotionSolver +{ + // Private Data + + //- Cell-centre motion field + mutable volVectorField cellMotionU_; + + //- Diffusivity used to control the motion + autoPtr diffusivityPtr_; + + +public: + + //- Runtime type information + TypeName("velocityLaplacian"); + + + // Constructors + + //- Construct from polyMesh and dictionary + velocityLaplacianFvMotionSolver + ( + const polyMesh&, + const dictionary& + ); + + //- Disallow default bitwise copy construction + velocityLaplacianFvMotionSolver + ( + const velocityLaplacianFvMotionSolver& + ); + + + //- Destructor + ~velocityLaplacianFvMotionSolver(); + + + // Member Functions + + //- Return reference to the cell motion velocity field + volVectorField& cellMotionU() + { + return cellMotionU_; + } + + //- Return const reference to the cell motion velocity field + const volVectorField& cellMotionU() const + { + return cellMotionU_; + } + + //- Return point location obtained from the current motion field + virtual tmp curPoints() const; + + //- Solve for motion + virtual void solve(); + + //- Update topology + virtual void updateMesh(const mapPolyMesh&); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const velocityLaplacianFvMotionSolver&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict index 09fdddaf06..e93203f1be 100644 --- a/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict +++ b/tutorials/mesh/moveDynamicMesh/SnakeRiverCanyon/constant/dynamicMeshDict @@ -21,8 +21,7 @@ mover libs ("libfvMeshMovers.so" "libfvMotionSolvers.so"); - motionSolver displacementSBRStress; // displacementLaplacian; - // motionSolver velocityComponentLaplacian z; + motionSolver displacementSBRStress; // diffusivity uniform; // diffusivity directional (1 200 0);