diff --git a/applications/solvers/modules/solid/solid.C b/applications/solvers/modules/solid/solid.C index 4ad044677a..fcf594ad71 100644 --- a/applications/solvers/modules/solid/solid.C +++ b/applications/solvers/modules/solid/solid.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "solid.H" +#include "fvMeshMover.H" #include "localEulerDdtScheme.H" #include "addToRunTimeSelectionTable.H" @@ -161,7 +162,25 @@ void Foam::solvers::solid::preSolve() bool Foam::solvers::solid::moveMesh() { - return true; + if (pimple.firstIter() || pimple.moveMeshOuterCorrectors()) + { + if (!mesh.mover().solidBody()) + { + FatalErrorInFunction + << "Region " << name() << " of type " << type() + << " does not support non-solid body mesh motion" + << exit(FatalError); + } + + mesh.move(); + + if (mesh.changing()) + { + return mesh.moving(); + } + } + + return false; } diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver/multiSolidBodyMotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver/multiSolidBodyMotionSolver.H index 2c98db5418..c82fb54bb6 100644 --- a/src/dynamicMesh/motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver/multiSolidBodyMotionSolver.H +++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver/multiSolidBodyMotionSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,6 +93,12 @@ public: //- Return point location obtained from the current motion field virtual tmp curPoints() const; + //- This is a solid body motion + virtual bool solidBody() const + { + return true; + } + //- Solve for motion virtual void solve() {} diff --git a/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionSolver/solidBodyMotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionSolver/solidBodyMotionSolver.H index bb45a7ae60..515386a6dd 100644 --- a/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionSolver/solidBodyMotionSolver.H +++ b/src/dynamicMesh/motionSolvers/displacement/solidBody/solidBodyMotionSolver/solidBodyMotionSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -96,6 +96,12 @@ public: //- Return point location obtained from the current motion field virtual tmp curPoints() const; + //- This is a solid body motion + virtual bool solidBody() const + { + return true; + } + //- Solve for motion virtual void solve() {} diff --git a/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.H b/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.H index 96b76d91ac..7cd3f1e250 100644 --- a/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.H +++ b/src/dynamicMesh/motionSolvers/motionSolver/motionSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -152,8 +152,17 @@ public: //- Provide current points for motion. Uses current motion field virtual tmp curPoints() const = 0; + //- Correct point field for reduced-dimensionality cases virtual void twoDCorrectPoints(pointField&) const; + //- Is the motion solid body? I.e., are the volumes and area magnitudes + // unchanged? Defaults to false. Set to true by + // motionSolvers::solidBody. + virtual bool solidBody() const + { + return false; + } + //- Solve for motion virtual void solve() = 0; diff --git a/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H b/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H index c7550902be..180b2bf537 100644 --- a/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H +++ b/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -154,6 +154,14 @@ public: return true; } + //- Is the motion solid body? I.e., are the volumes and area magnitudes + // unchanged? Defaults to false. Set to true by fvMeshMovers::none and + // delegated to the motion solver by fvMeshMovers::motionSolver. + virtual bool solidBody() const + { + return false; + } + //- Update the mesh for both mesh motion and topology change virtual bool update() = 0; diff --git a/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H b/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H index cff24ada40..11e742653d 100644 --- a/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H +++ b/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -79,6 +79,12 @@ public: return false; } + //- The mesh is static, which meets the criteria of a solid body motion + virtual bool solidBody() const + { + return true; + } + //- Dummy update function which does not change the mesh virtual bool update(); diff --git a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C index d04604ca73..34fa85edab 100644 --- a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C +++ b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -63,6 +63,12 @@ const Foam::motionSolver& Foam::fvMeshMovers::motionSolver::motion() const } +bool Foam::fvMeshMovers::motionSolver::solidBody() const +{ + return motion().solidBody(); +} + + bool Foam::fvMeshMovers::motionSolver::update() { mesh().movePoints(motionPtr_->newPoints()); diff --git a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H index ad27597ba0..bf76c1641c 100644 --- a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H +++ b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2021-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,6 +88,9 @@ public: //- Return the motionSolver const Foam::motionSolver& motion() const; + //- Is this motion solid body? Delegate to the motion solver. + virtual bool solidBody() const; + //- Update the mesh for both mesh motion and topology change virtual bool update();