diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C index fbf6d58560..4b05c04281 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C @@ -572,7 +572,7 @@ Foam::autoPtr Foam::fvMeshDistribute::repatch autoPtr map = meshMod.changeMesh(mesh_, false, true); // Update fields. No inflation, parallel sync. - mesh_.updateMesh(map); + mapFields(map); // Map patch fields using stored boundary fields. Note: assumes order // of fields has not changed in object registry! @@ -769,7 +769,7 @@ Foam::autoPtr Foam::fvMeshDistribute::mergeSharedPoints autoPtr map = meshMod.changeMesh(mesh_, false, true); // Update fields. No inflation, parallel sync. - mesh_.updateMesh(map); + mapFields(map); // Adapt constructMaps for merged points. forAll(constructPointMap, proci) @@ -798,6 +798,7 @@ Foam::autoPtr Foam::fvMeshDistribute::mergeSharedPoints } } } + return map; } @@ -1282,8 +1283,7 @@ Foam::autoPtr Foam::fvMeshDistribute::doRemoveCells autoPtr map = meshMod.changeMesh(mesh_, false, false); // Update fields - mesh_.updateMesh(map); - + mapFields(map); // Any exposed faces in a surfaceField will not be mapped. Map the value // of these separately (until there is support in all PatchFields for @@ -1310,6 +1310,13 @@ Foam::autoPtr Foam::fvMeshDistribute::doRemoveCells } +void Foam::fvMeshDistribute::mapFields(const mapPolyMesh& map) +{ + mesh_.mapFields(map); + meshObject::updateMesh(mesh_, map); +} + + // Delete and add processor patches. Changes mesh and returns per neighbour proc // the processor patchID. void Foam::fvMeshDistribute::addProcPatches diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H index 11f66b165d..3e40db12c0 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.H @@ -160,6 +160,9 @@ class fvMeshDistribute labelListList& constructPointMap ); + //- Map the fields + void mapFields(const mapPolyMesh& map); + // Coupling information diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index a8f7c573a7..94d7c96c76 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -93,18 +93,24 @@ $(faceToCell)/extendedFaceToCellStencil.C $(faceToCell)/extendedCentredFaceToCellStencil.C $(faceToCell)/MeshObjects/centredCFCFaceToCellStencilObject.C -fvMeshMovers = fvMesh/fvMeshMovers - -$(fvMeshMovers)/fvMeshMover/fvMeshMover.C -$(fvMeshMovers)/fvMeshMover/fvMeshMoverNew.C -$(fvMeshMovers)/none/fvMeshMoversNone.C - fvMeshTopoChangers = fvMesh/fvMeshTopoChangers $(fvMeshTopoChangers)/fvMeshTopoChanger/fvMeshTopoChanger.C $(fvMeshTopoChangers)/fvMeshTopoChanger/fvMeshTopoChangerNew.C $(fvMeshTopoChangers)/none/fvMeshTopoChangersNone.C +fvMeshDistributors = fvMesh/fvMeshDistributors + +$(fvMeshDistributors)/fvMeshDistributor/fvMeshDistributor.C +$(fvMeshDistributors)/fvMeshDistributor/fvMeshDistributorNew.C +$(fvMeshDistributors)/none/fvMeshDistributorsNone.C + +fvMeshMovers = fvMesh/fvMeshMovers + +$(fvMeshMovers)/fvMeshMover/fvMeshMover.C +$(fvMeshMovers)/fvMeshMover/fvMeshMoverNew.C +$(fvMeshMovers)/none/fvMeshMoversNone.C + functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C functionObjects/volRegion/volRegion.C diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index b25219310e..dfc7f1d1bd 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -32,6 +32,7 @@ License #include "demandDrivenData.H" #include "fvMeshLduAddressing.H" #include "fvMeshTopoChanger.H" +#include "fvMeshDistributor.H" #include "fvMeshMover.H" #include "mapPolyMesh.H" #include "MapFvFields.H" @@ -271,6 +272,12 @@ Foam::fvMesh::fvMesh(const IOobject& io, const bool changers) ? fvMeshTopoChanger::New(*this) : autoPtr(nullptr) ), + distributor_ + ( + changers + ? fvMeshDistributor::New(*this) + : autoPtr(nullptr) + ), mover_ ( changers @@ -476,6 +483,7 @@ bool Foam::fvMesh::dynamic() const bool Foam::fvMesh::update() { bool updated = topoChanger_->update(); + updated = distributor_->update() || updated; updated = mover_->update() || updated; return updated; @@ -591,6 +599,12 @@ const Foam::fvMeshTopoChanger& Foam::fvMesh::topoChanger() const } +const Foam::fvMeshDistributor& Foam::fvMesh::distributor() const +{ + return distributor_(); +} + + const Foam::fvMeshMover& Foam::fvMesh::mover() const { return mover_(); @@ -891,6 +905,16 @@ void Foam::fvMesh::updateMesh(const mapPolyMesh& mpm) meshObject::updateMesh(*this, mpm); meshObject::updateMesh(*this, mpm); + if (topoChanger_.valid()) + { + topoChanger_->updateMesh(mpm); + } + + if (distributor_.valid()) + { + distributor_->updateMesh(mpm); + } + if (mover_.valid()) { mover_->updateMesh(mpm); @@ -904,10 +928,10 @@ void Foam::fvMesh::updateMesh(const mapPolyMesh& mpm) } -void Foam::fvMesh::updateMesh(const mapDistributePolyMesh& mdpm) +void Foam::fvMesh::distribute(const mapDistributePolyMesh& mdpm) { // Update polyMesh. This needs to keep volume existent! - // polyMesh::updateMesh(mdpm); + // polyMesh::distribute(mdpm); // if (VPtr_) // { @@ -960,6 +984,10 @@ void Foam::fvMesh::updateMesh(const mapDistributePolyMesh& mdpm) // meshObject::updateMesh(*this, mdpm); // meshObject::updateMesh(*this, mdpm); + + topoChanger_->distribute(mdpm); + distributor_->distribute(mdpm); + mover_->distribute(mdpm); } @@ -1145,6 +1173,11 @@ bool Foam::fvMesh::writeObject topoChanger_->write(write); } + if (distributor_.valid()) + { + distributor_->write(write); + } + if (mover_.valid()) { mover_->write(write); diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 4beb987db7..4a4e41cf69 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -70,6 +70,7 @@ namespace Foam class fvMeshLduAddressing; class fvMeshTopoChanger; +class fvMeshDistributor; class fvMeshMover; class volMesh; class mapDistributePolyMesh; @@ -95,6 +96,9 @@ class fvMesh //- The topo-changer function class autoPtr topoChanger_; + //- The distributor function class + autoPtr distributor_; + //- The mover function class autoPtr mover_; @@ -299,6 +303,9 @@ public: //- Return the topo-changer function class const fvMeshTopoChanger& topoChanger() const; + //- Return the distributor function class + const fvMeshDistributor& distributor() const; + //- Return the mover function class const fvMeshMover& mover() const; @@ -368,7 +375,7 @@ public: //- Update mesh corresponding to the given distribution map // This is a prototype implementation without field mapping // or handling of old-time volumes for mesh-morphing - virtual void updateMesh(const mapDistributePolyMesh& mdpm); + virtual void distribute(const mapDistributePolyMesh& mdpm); //- Move points, returns volumes swept by faces in motion virtual tmp movePoints(const pointField&); diff --git a/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributor.C b/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributor.C new file mode 100644 index 0000000000..e9ec8ebcae --- /dev/null +++ b/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributor.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 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 "fvMeshDistributor.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(fvMeshDistributor, 0); + defineRunTimeSelectionTable(fvMeshDistributor, fvMesh); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fvMeshDistributor::fvMeshDistributor(fvMesh& mesh) +: + mesh_(mesh), + dynamicMeshDict_ + ( + IOdictionary + ( + IOobject + ( + "dynamicMeshDict", + mesh.time().constant(), + mesh.dbDir(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + false + ) + ) + ) +{} + + +Foam::fvMeshDistributor::velocityMotionCorrection::velocityMotionCorrection +( + const fvMesh& mesh, + const dictionary& dict +) +: + mesh_(mesh), + velocityFields_(dict.lookupOrDefault("velocityFields", wordList())) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fvMeshDistributor::~fvMeshDistributor() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fvMeshDistributor::velocityMotionCorrection::update() const +{ + forAll(velocityFields_, i) + { + if (mesh_.foundObject(velocityFields_[i])) + { + mesh_.lookupObjectRef + ( + velocityFields_[i] + ).correctBoundaryConditions(); + } + } +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributor.H b/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributor.H new file mode 100644 index 0000000000..2a2820c167 --- /dev/null +++ b/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributor.H @@ -0,0 +1,188 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 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::fvMeshDistributor + +Description + Abstract base class for fvMesh movers. + + These classes move the mesh points, update the cell volumes and generate + the corresponding mesh fluxes without any topology change. + +SourceFiles + fvMeshDistributor.C + fvMeshDistributorNew.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fvMeshDistributor_H +#define fvMeshDistributor_H + +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fvMeshDistributor Declaration +\*---------------------------------------------------------------------------*/ + +class fvMeshDistributor +{ + // Private Data + + //- Non-const fvMesh reference to allow update + fvMesh& mesh_; + + //- The dynamicMeshDict + dictionary dynamicMeshDict_; + + +public: + + //- Runtime type information + TypeName("fvMeshDistributor"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + fvMeshDistributor, + fvMesh, + (fvMesh& mesh), + (mesh) + ); + + + //- Helper class to update the velocity boundary conditions + // following mesh motion + class velocityMotionCorrection + { + // Private Data + + const fvMesh& mesh_; + + wordList velocityFields_; + + public: + + // Constructors + + velocityMotionCorrection + ( + const fvMesh& mesh, + const dictionary& dict + ); + + + // Member Functions + + void update() const; + }; + + + // Constructors + + //- Construct from fvMesh + explicit fvMeshDistributor(fvMesh&); + + //- Disallow default bitwise copy construction + fvMeshDistributor(const fvMeshDistributor&) = delete; + + + // Selectors + + //- Select, construct and return the fvMeshDistributor + // If the constant/dynamicMeshDict does not exist + // a staticFvMesh is returned + static autoPtr New(fvMesh&); + + + //- Destructor + virtual ~fvMeshDistributor(); + + + // Member Functions + + //- Return the fvMesh + fvMesh& mesh() + { + return mesh_; + } + + //- Return the fvMesh + const fvMesh& mesh() const + { + return mesh_; + } + + //- Return the dynamicMeshDict/distributor sub-dict + const dictionary& dict() const + { + return dynamicMeshDict_.subDict("distributor"); + } + + //- Is mesh dynamic, i.e. might it change? + // Defaults to true, set to false in the fvMeshDistributors::none + virtual bool dynamic() const + { + return true; + } + + //- Update the mesh for both mesh motion and topology change + virtual bool update() = 0; + + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh& mpm) = 0; + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh& mdpm) = 0; + + //- Write the mover state + virtual bool write(const bool write = true) const + { + return true; + } + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const fvMeshDistributor&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributorNew.C b/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributorNew.C new file mode 100644 index 0000000000..ed9db5341a --- /dev/null +++ b/src/finiteVolume/fvMesh/fvMeshDistributors/fvMeshDistributor/fvMeshDistributorNew.C @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 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 "fvMeshDistributorsNone.H" + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::fvMeshDistributor::New +( + fvMesh& mesh +) +{ + typeIOobject dictHeader + ( + IOobject + ( + "dynamicMeshDict", + mesh.time().constant(), + mesh.dbDir(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + false + ) + ); + + if (dictHeader.headerOk()) + { + IOdictionary dict(dictHeader); + + if (dict.found("distributor")) + { + const dictionary& distributorDict = dict.subDict("distributor"); + + const word fvMeshDistributorTypeName + ( + distributorDict.lookup("type") + ); + + Info<< "Selecting fvMeshDistributor " + << fvMeshDistributorTypeName << endl; + + libs.open + ( + distributorDict, + "libs", + fvMeshConstructorTablePtr_ + ); + + if (!fvMeshConstructorTablePtr_) + { + FatalErrorInFunction + << "fvMeshDistributors table is empty" + << exit(FatalError); + } + + fvMeshConstructorTable::iterator cstrIter = + fvMeshConstructorTablePtr_->find(fvMeshDistributorTypeName); + + if (cstrIter == fvMeshConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown fvMeshDistributor type " + << fvMeshDistributorTypeName << nl << nl + << "Valid fvMeshDistributors are :" << endl + << fvMeshConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr(cstrIter()(mesh)); + } + } + + return autoPtr(new fvMeshDistributors::none(mesh)); +} + + +// ************************************************************************* // diff --git a/src/fvMeshTopoChangers/topoChangerFvMesh/topoChangerFvMesh.C b/src/finiteVolume/fvMesh/fvMeshDistributors/none/fvMeshDistributorsNone.C similarity index 72% rename from src/fvMeshTopoChangers/topoChangerFvMesh/topoChangerFvMesh.C rename to src/finiteVolume/fvMesh/fvMeshDistributors/none/fvMeshDistributorsNone.C index 79d842a754..cb59008c2a 100644 --- a/src/fvMeshTopoChangers/topoChangerFvMesh/topoChangerFvMesh.C +++ b/src/finiteVolume/fvMesh/fvMeshDistributors/none/fvMeshDistributorsNone.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,29 +23,41 @@ License \*---------------------------------------------------------------------------*/ -#include "topoChangerFvMesh.H" -#include "Time.H" +#include "fvMeshDistributorsNone.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(topoChangerFvMesh, 0); +namespace fvMeshDistributors +{ + defineTypeNameAndDebug(none, 0); + addToRunTimeSelectionTable(fvMeshDistributor, none, fvMesh); +} } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::topoChangerFvMesh::topoChangerFvMesh(const IOobject& io) +Foam::fvMeshDistributors::none::none(fvMesh& mesh) : - dynamicFvMesh(io), - topoChanger_(*this) + fvMeshDistributor(mesh) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::topoChangerFvMesh::~topoChangerFvMesh() +Foam::fvMeshDistributors::none::~none() {} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fvMeshDistributors::none::update() +{ + return false; +} + + // ************************************************************************* // diff --git a/src/fvMeshTopoChangers/topoChangerFvMesh/topoChangerFvMesh.H b/src/finiteVolume/fvMesh/fvMeshDistributors/none/fvMeshDistributorsNone.H similarity index 63% rename from src/fvMeshTopoChangers/topoChangerFvMesh/topoChangerFvMesh.H rename to src/finiteVolume/fvMesh/fvMeshDistributors/none/fvMeshDistributorsNone.H index 58f1a32360..a9425fa0b4 100644 --- a/src/fvMeshTopoChangers/topoChangerFvMesh/topoChangerFvMesh.H +++ b/src/finiteVolume/fvMesh/fvMeshDistributors/none/fvMeshDistributorsNone.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,77 +22,85 @@ License along with OpenFOAM. If not, see . Class - Foam::topoChangerFvMesh + Foam::fvMeshDistributors::none Description - Abstract base class for a topology changing fvMesh + Dummy fvMeshDistributor which does not move the mesh points SourceFiles - topoChangerFvMesh.C - newTopoFvMesh.C + none.C \*---------------------------------------------------------------------------*/ -#ifndef topoChangerFvMesh_H -#define topoChangerFvMesh_H +#ifndef fvMeshDistributorsNone_H +#define fvMeshDistributorsNone_H -#include "dynamicFvMesh.H" -#include "polyTopoChanger.H" +#include "fvMeshDistributor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +namespace fvMeshDistributors +{ /*---------------------------------------------------------------------------*\ - Class topoChangerFvMesh Declaration + Class none Declaration \*---------------------------------------------------------------------------*/ -class topoChangerFvMesh +class none : - public dynamicFvMesh + public fvMeshDistributor { -protected: - - // Protected Data - - polyTopoChanger topoChanger_; - - public: //- Runtime type information - TypeName("topoChangerFvMesh"); + TypeName("none"); // Constructors - //- Construct from objectRegistry, and read/write options - explicit topoChangerFvMesh(const IOobject& io); + //- Construct from fvMesh + none(fvMesh& mesh); //- Disallow default bitwise copy construction - topoChangerFvMesh(const topoChangerFvMesh&) = delete; + none(const none&) = delete; //- Destructor - virtual ~topoChangerFvMesh(); + ~none(); // Member Functions - //- Update the mesh for both mesh motion and topology change - virtual bool update() = 0; + //- The mesh is static and does not change so return false + virtual bool dynamic() const + { + return false; + } + + //- Dummy update function which does not change the mesh + virtual bool update(); + + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&) + {} // Member Operators //- Disallow default bitwise assignment - void operator=(const topoChangerFvMesh&) = delete; + void operator=(const none&) = delete; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace fvMeshDistributors } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H b/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H index 1b14819485..689d582755 100644 --- a/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H +++ b/src/finiteVolume/fvMesh/fvMeshMovers/fvMeshMover/fvMeshMover.H @@ -154,11 +154,14 @@ public: return true; } + //- Update the mesh for both mesh motion and topology change + virtual bool update() = 0; + //- Update local data for topology changes virtual void updateMesh(const mapPolyMesh&) = 0; - //- Update the mesh for both mesh motion and topology change - virtual bool update() = 0; + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh& mdpm) = 0; //- Write the mover state virtual bool write(const bool write = true) const diff --git a/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H b/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H index 067d710c1d..1c6d7ae215 100644 --- a/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H +++ b/src/finiteVolume/fvMesh/fvMeshMovers/none/fvMeshMoversNone.H @@ -79,12 +79,16 @@ public: return false; } + //- Dummy update function which does not change the mesh + virtual bool update(); + //- Update local data for topology changes virtual void updateMesh(const mapPolyMesh&) {} - //- Dummy update function which does not change the mesh - virtual bool update(); + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&) + {} // Member Operators diff --git a/src/finiteVolume/fvMesh/fvMeshTopoChangers/fvMeshTopoChanger/fvMeshTopoChanger.H b/src/finiteVolume/fvMesh/fvMeshTopoChangers/fvMeshTopoChanger/fvMeshTopoChanger.H index a66c77c8b9..7faeba5913 100644 --- a/src/finiteVolume/fvMesh/fvMeshTopoChangers/fvMeshTopoChanger/fvMeshTopoChanger.H +++ b/src/finiteVolume/fvMesh/fvMeshTopoChangers/fvMeshTopoChanger/fvMeshTopoChanger.H @@ -157,6 +157,12 @@ public: //- Update the mesh for both mesh motion and topology change virtual bool update() = 0; + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh& mpm) = 0; + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh& mdpm) = 0; + //- Write the mover state virtual bool write(const bool write = true) const { diff --git a/src/finiteVolume/fvMesh/fvMeshTopoChangers/none/fvMeshTopoChangersNone.H b/src/finiteVolume/fvMesh/fvMeshTopoChangers/none/fvMeshTopoChangersNone.H index 78981b50da..d1816f060c 100644 --- a/src/finiteVolume/fvMesh/fvMeshTopoChangers/none/fvMeshTopoChangersNone.H +++ b/src/finiteVolume/fvMesh/fvMeshTopoChangers/none/fvMeshTopoChangersNone.H @@ -82,6 +82,14 @@ public: //- Dummy update function which does not change the mesh virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&) + {} + // Member Operators diff --git a/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.C b/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.C index 105da24fc1..a1e505fdee 100644 --- a/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.C +++ b/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.C @@ -55,12 +55,6 @@ Foam::fvMeshMovers::layeredEngine::~layeredEngine() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::fvMeshMovers::layeredEngine::updateMesh(const mapPolyMesh& mpm) -{ - NotImplemented; -} - - bool Foam::fvMeshMovers::layeredEngine::update() { const scalar deltaZ = pistonDisplacement().value(); @@ -101,4 +95,19 @@ bool Foam::fvMeshMovers::layeredEngine::update() } +void Foam::fvMeshMovers::layeredEngine::updateMesh(const mapPolyMesh&) +{ + NotImplemented; +} + + +void Foam::fvMeshMovers::layeredEngine::distribute +( + const mapDistributePolyMesh& +) +{ + NotImplemented; +} + + // ************************************************************************* // diff --git a/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.H b/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.H index deb6c61501..ce1e1fb664 100644 --- a/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.H +++ b/src/fvMeshMovers/engine/layered/fvMeshMoversLayeredEngine.H @@ -78,12 +78,15 @@ public: // Member Functions - //- Update local data for topology changes - virtual void updateMesh(const mapPolyMesh&); - //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.C b/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.C index ed5cf016dc..512b40b8c4 100644 --- a/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.C +++ b/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.C @@ -78,12 +78,6 @@ Foam::fvMeshMovers::inkJet::~inkJet() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::fvMeshMovers::inkJet::updateMesh(const mapPolyMesh& mpm) -{ - NotImplemented; -} - - bool Foam::fvMeshMovers::inkJet::update() { const scalar scalingFunction = @@ -120,4 +114,19 @@ bool Foam::fvMeshMovers::inkJet::update() } +void Foam::fvMeshMovers::inkJet::updateMesh(const mapPolyMesh&) +{ + NotImplemented; +} + + +void Foam::fvMeshMovers::inkJet::distribute +( + const mapDistributePolyMesh& +) +{ + NotImplemented; +} + + // ************************************************************************* // diff --git a/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.H b/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.H index 6d4daa58b5..35dc569a36 100644 --- a/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.H +++ b/src/fvMeshMovers/inkJet/fvMeshMoversInkJet.H @@ -96,12 +96,15 @@ public: // Member Functions - //- Update local data for topology changes - virtual void updateMesh(const mapPolyMesh&); - //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.C b/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.C index c4205acf04..61f186522a 100644 --- a/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.C +++ b/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.C @@ -66,11 +66,6 @@ Foam::fvMeshMovers::interpolator::~interpolator() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::fvMeshMovers::interpolator::updateMesh(const mapPolyMesh& mpm) -{ - NotImplemented; -} - bool Foam::fvMeshMovers::interpolator::update() { @@ -89,4 +84,19 @@ bool Foam::fvMeshMovers::interpolator::update() } +void Foam::fvMeshMovers::interpolator::updateMesh(const mapPolyMesh&) +{ + NotImplemented; +} + + +void Foam::fvMeshMovers::interpolator::distribute +( + const mapDistributePolyMesh& +) +{ + NotImplemented; +} + + // ************************************************************************* // diff --git a/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.H b/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.H index 076810d72f..fa3891ee4a 100644 --- a/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.H +++ b/src/fvMeshMovers/interpolator/fvMeshMoversInterpolator.H @@ -114,12 +114,15 @@ public: // Member Functions - //- Update local data for topology changes - virtual void updateMesh(const mapPolyMesh&); - //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C index a65d0e4469..b9fad43f7a 100644 --- a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C +++ b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.C @@ -63,12 +63,6 @@ const Foam::motionSolver& Foam::fvMeshMovers::motionSolver::motion() const } -void Foam::fvMeshMovers::motionSolver::updateMesh(const mapPolyMesh& mpm) -{ - motionPtr_->updateMesh(mpm); -} - - bool Foam::fvMeshMovers::motionSolver::update() { mesh().movePoints(motionPtr_->newPoints()); @@ -78,6 +72,19 @@ bool Foam::fvMeshMovers::motionSolver::update() } +void Foam::fvMeshMovers::motionSolver::updateMesh(const mapPolyMesh& mpm) +{ + motionPtr_->updateMesh(mpm); +} + + +void Foam::fvMeshMovers::motionSolver::distribute +( + const mapDistributePolyMesh& +) +{} + + bool Foam::fvMeshMovers::motionSolver::write(const bool write) const { if (write) diff --git a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H index 30cc37bb8c..762c46aa4e 100644 --- a/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H +++ b/src/fvMeshMovers/motionSolver/fvMeshMoversMotionSolver.H @@ -88,12 +88,15 @@ public: //- Return the motionSolver const Foam::motionSolver& motion() const; - //- Update local data for topology changes - virtual void updateMesh(const mapPolyMesh&); - //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Write diff --git a/src/fvMeshTopoChangers/linearValveFvMesh/linearValveFvMesh.H b/src/fvMeshTopoChangers/linearValveFvMesh/linearValveFvMesh.H index 4955e4bfca..711b5bd54d 100644 --- a/src/fvMeshTopoChangers/linearValveFvMesh/linearValveFvMesh.H +++ b/src/fvMeshTopoChangers/linearValveFvMesh/linearValveFvMesh.H @@ -99,6 +99,12 @@ public: //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshTopoChangers/linearValveLayersFvMesh/linearValveLayersFvMesh.H b/src/fvMeshTopoChangers/linearValveLayersFvMesh/linearValveLayersFvMesh.H index 66e906ddf5..10fd68bcc0 100644 --- a/src/fvMeshTopoChangers/linearValveLayersFvMesh/linearValveLayersFvMesh.H +++ b/src/fvMeshTopoChangers/linearValveLayersFvMesh/linearValveLayersFvMesh.H @@ -96,6 +96,12 @@ public: //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshTopoChangers/mixerFvMesh/mixerFvMesh.H b/src/fvMeshTopoChangers/mixerFvMesh/mixerFvMesh.H index 4ad1499811..30a76afe89 100644 --- a/src/fvMeshTopoChangers/mixerFvMesh/mixerFvMesh.H +++ b/src/fvMeshTopoChangers/mixerFvMesh/mixerFvMesh.H @@ -110,6 +110,12 @@ public: //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.C b/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.C index c1aad66be0..2f39e8306c 100644 --- a/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.C +++ b/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.C @@ -384,4 +384,15 @@ bool Foam::fvMeshTopoChangers::movingCone::update() } +void Foam::fvMeshTopoChangers::movingCone::updateMesh(const mapPolyMesh& map) +{} + + +void Foam::fvMeshTopoChangers::movingCone::distribute +( + const mapDistributePolyMesh& map +) +{} + + // ************************************************************************* // diff --git a/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.H b/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.H index e39d28b8dc..d63f2d2a5e 100644 --- a/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.H +++ b/src/fvMeshTopoChangers/movingCone/fvMeshTopoChangersMovingCone.H @@ -121,6 +121,12 @@ public: //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.C b/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.C index ccf1aaa181..9963510c9c 100644 --- a/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.C +++ b/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.C @@ -166,4 +166,15 @@ bool Foam::fvMeshTopoChangers::raw::update() } +void Foam::fvMeshTopoChangers::raw::updateMesh(const mapPolyMesh& map) +{} + + +void Foam::fvMeshTopoChangers::raw::distribute +( + const mapDistributePolyMesh& map +) +{} + + // ************************************************************************* // diff --git a/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.H b/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.H index 798f2a9990..c8d3dad1c0 100644 --- a/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.H +++ b/src/fvMeshTopoChangers/raw/fvMeshTopoChangersRaw.H @@ -100,6 +100,12 @@ public: //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Member Operators diff --git a/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C b/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C index 462b59c955..0d8877cbca 100644 --- a/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C +++ b/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C @@ -257,7 +257,7 @@ Foam::fvMeshTopoChangers::refiner::refine } // Update fields - mesh().updateMesh(map()); + mesh().updateMesh(map); { // Correct the flux for modified/added faces. All the faces which only @@ -300,9 +300,6 @@ Foam::fvMeshTopoChangers::refiner::refine refineUfs(masterFaces, map()); } - // Update numbering of cells/vertices. - meshCutter_.updateMesh(map()); - // Update numbering of protectedCells_ if (protectedCells_.size()) { @@ -383,9 +380,6 @@ Foam::fvMeshTopoChangers::refiner::unrefine // Correct the face velocities for modified faces unrefineUfs(faceToSplitPoint, map()); - // Update numbering of cells/vertices. - meshCutter_.updateMesh(map); - // Update numbering of protectedCells_ if (protectedCells_.size()) { @@ -1661,6 +1655,7 @@ bool Foam::fvMeshTopoChangers::refiner::update() } mesh().topoChanging(hasChanged); + if (hasChanged) { // Reset moving flag (if any). If not using inflation we'll not move, @@ -1672,6 +1667,24 @@ bool Foam::fvMeshTopoChangers::refiner::update() } +void Foam::fvMeshTopoChangers::refiner::updateMesh(const mapPolyMesh& map) +{ + // Update numbering of cells/vertices. + meshCutter_.updateMesh(map); +} + + +void Foam::fvMeshTopoChangers::refiner::distribute +( + const mapDistributePolyMesh& map +) +{ + InfoInFunction << endl; + // Redistribute the mesh cutting engine + meshCutter_.distribute(map); +} + + bool Foam::fvMeshTopoChangers::refiner::write(const bool write) const { // Force refinement data to go to the current time directory. diff --git a/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.H b/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.H index c0c5430a79..4ab466f225 100644 --- a/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.H +++ b/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.H @@ -363,6 +363,12 @@ public: //- Update the mesh for both mesh motion and topology change virtual bool update(); + //- Update corresponding to the given map + virtual void updateMesh(const mapPolyMesh&); + + //- Update corresponding to the given distribution map + virtual void distribute(const mapDistributePolyMesh&); + // Writing