diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C index 80232d4498..e5818171d5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C @@ -45,6 +45,7 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm) << "Updating addressing and (optional) pointMesh/pointFields" << endl; // Update boundaryMesh (note that patches themselves already ok) +// boundary_.updateMesh(mpm); boundary_.updateMesh(); // Update zones diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index 3e915b3e7e..6db7dc22fc 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -63,6 +63,7 @@ void Foam::polyPatch::movePoints(PstreamBuffers&, const pointField& p) primitivePatch::movePoints(p); } + void Foam::polyPatch::updateMesh(PstreamBuffers&) { primitivePatch::clearGeom(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H index 08bbf0c732..f7f01abb09 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H @@ -55,6 +55,7 @@ namespace Foam // Forward declarations class polyBoundaryMesh; class polyPatch; +class polyTopoChange; class PstreamBuffers; Ostream& operator<<(Ostream&, const polyPatch&); @@ -419,6 +420,19 @@ public: labelList& rotation ) const; + //- For dynamic mesh cases - return true if this patch will change the + //- topology + virtual bool changeTopology() const + { + return false; + } + + //- Collect topology changes in a polyTopoChange object + virtual bool setTopology(polyTopoChange&) + { + return false; + } + // Member operators diff --git a/src/dynamicFvMesh/Make/files b/src/dynamicFvMesh/Make/files index b8432c07c9..794af6f3d0 100644 --- a/src/dynamicFvMesh/Make/files +++ b/src/dynamicFvMesh/Make/files @@ -10,4 +10,9 @@ dynamicMotionSolverListFvMesh/dynamicMotionSolverListFvMesh.C simplifiedDynamicFvMesh/simplifiedDynamicFvMeshes.C simplifiedDynamicFvMesh/simplifiedDynamicFvMesh.C + + +dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C + + LIB = $(FOAM_LIBBIN)/libdynamicFvMesh diff --git a/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C b/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C index ba1d636969..5b7a90cddc 100644 --- a/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C +++ b/src/dynamicFvMesh/dynamicMotionSolverFvMesh/dynamicMotionSolverFvMesh.C @@ -92,6 +92,9 @@ const Foam::motionSolver& Foam::dynamicMotionSolverFvMesh::motion() const bool Foam::dynamicMotionSolverFvMesh::update() { + // Scan through AMI patches and update + + fvMesh::movePoints(motionPtr_->newPoints()); volVectorField* Uptr = getObjectPtr("U"); diff --git a/src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C b/src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C new file mode 100644 index 0000000000..5de3713a53 --- /dev/null +++ b/src/dynamicFvMesh/dynamicMotionSolverFvMeshAMI/dynamicMotionSolverFvMeshAMI.C @@ -0,0 +1,216 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019-2020 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 . + +\*---------------------------------------------------------------------------*/ + +#include "dynamicMotionSolverFvMeshAMI.H" +#include "addToRunTimeSelectionTable.H" +#include "motionSolver.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "cyclicAMIPolyPatch.H" +#include "polyTopoChange.H" +#include "MeshObject.H" +#include "lduMesh.H" + +#include "processorFvPatch.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(dynamicMotionSolverFvMeshAMI, 0); + addToRunTimeSelectionTable + ( + dynamicFvMesh, + dynamicMotionSolverFvMeshAMI, + IOobject + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dynamicMotionSolverFvMeshAMI::dynamicMotionSolverFvMeshAMI +( + const IOobject& io +) +: + dynamicFvMesh(io), + motionPtr_(motionSolver::New(*this)) +{} + + +Foam::dynamicMotionSolverFvMeshAMI::dynamicMotionSolverFvMeshAMI +( + const IOobject& io, + pointField&& points, + faceList&& faces, + labelList&& allOwner, + labelList&& allNeighbour, + const bool syncPar +) +: + dynamicFvMesh + ( + io, + std::move(points), + std::move(faces), + std::move(allOwner), + std::move(allNeighbour), + syncPar + ), + motionPtr_(motionSolver::New(*this)) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::motionSolver& Foam::dynamicMotionSolverFvMeshAMI::motion() const +{ + return *motionPtr_; +} + + +bool Foam::dynamicMotionSolverFvMeshAMI::update() +{ + // Mesh not moved/changed yet + moving(false); + topoChanging(false); + + if (debug) + { + for (const fvPatch& fvp : boundary()) + { + if (!isA(fvp)) + { + Info<< "1 --- patch:" << fvp.patch().name() + << " area:" << gSum(fvp.magSf()) << endl; + } + } + } + + pointField newPoints(motionPtr_->curPoints()); + + polyBoundaryMesh& pbm = const_cast(boundaryMesh()); + + // Scan all patches and see if we want to apply a mesh topology update + bool changeRequired = false; + for (polyPatch& pp : pbm) + { + DebugInfo + << "pre-topology change: patch " << pp.name() + << " size:" << returnReduce(pp.size(), sumOp