From d5948f3fb76d699b4fe91676a58489fa1b275fed Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Fri, 31 May 2019 10:39:45 +0200 Subject: [PATCH] Start/restart handling in dynamicPolyRefinementFvMesh If the constant/polyMesh/meshModifiers file is present, we simply neglect it and use the controls from dynamicMeshDict to avoid confusion. --- .../dynamicPolyRefinementFvMesh.C | 174 ++++++++++-------- 1 file changed, 95 insertions(+), 79 deletions(-) diff --git a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C index 680e7186b..4013e0681 100644 --- a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C +++ b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C @@ -117,89 +117,105 @@ Foam::dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh // protectedInitialRefinement) refinementSelectionPtr_() { - // Only create topo modifiers if they haven't been read in - // HJ, 16/Oct/2018 - if (topoChanger_.empty()) + // Check whether we read polyMeshModifiers from + // constant/polyMesh/meshModifiers file in the base class + if (!topoChanger_.empty()) { - // Only one topo changer engine - topoChanger_.setSize(1); + // Already initialized, warn the user that we'll neglect it + WarningIn + ( + "dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh" + "\n(" + "\n const IOobject& io" + "\n const word subDictName" + "\n)" + ) << "Using controls from constant/dynamicMeshDict instead of" + << " constant/polyMesh/meshModifiers." + << nl + << "To supress this warning, delete meshModifiers file." + << endl; - // Get number of valid geometric dimensions - const label nGeometricDirs = this->nGeometricD(); - - switch(nGeometricDirs) - { - case 3: - // Add the polyhedralRefinement engine for - // 3D isotropic refinement - Info<< "3D case detected. " - << "Adding polyhedralRefinement topology modifier" << endl; - topoChanger_.set - ( - 0, - new polyhedralRefinement - ( - "polyhedralRefinement", - refinementDict_, - 0, - topoChanger_ - ) - ); - break; - - case 2: - // Add the prismatic2DRefinement engine for - // 2D isotropic refinement - Info<< "2D case detected. " - << "Adding prismatic2DRefinement topology modifier" << endl; - topoChanger_.set - ( - 0, - new prismatic2DRefinement - ( - "prismatic2DRefinement", - refinementDict_, - 0, - topoChanger_ - ) - ); - break; - - case 1: - FatalErrorIn - ( - "dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh" - "\n(" - "\n const IOobject& io," - "\n const word subDictName" - "\n)" - ) << "1D case detected. No valid refinement strategy is" - << " available for 1D cases." - << abort(FatalError); - break; - - default: - FatalErrorIn - ( - "dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh" - "\n(" - "\n const IOobject& io," - "\n const word subDictName" - "\n)" - ) << "Invalid number of geometric meshes detected: " - << nGeometricDirs - << nl << "It appears that this mesh is neither 1D, 2D or 3D." - << nl << " the mesh." - << abort(FatalError); - - } - - // Write mesh and modifiers - topoChanger_.writeOpt() = IOobject::AUTO_WRITE; - topoChanger_.write(); - write(); + // Clear the list + topoChanger_.clear(); } + // Only one topo changer engine + topoChanger_.setSize(1); + + // Get number of valid geometric dimensions + const label nGeometricDirs = this->nGeometricD(); + + switch(nGeometricDirs) + { + case 3: + // Add the polyhedralRefinement engine for + // 3D isotropic refinement + Info<< "3D case detected. " + << "Adding polyhedralRefinement topology modifier" << endl; + topoChanger_.set + ( + 0, + new polyhedralRefinement + ( + "polyhedralRefinement", + refinementDict_, + 0, + topoChanger_ + ) + ); + break; + + case 2: + // Add the prismatic2DRefinement engine for + // 2D isotropic refinement + Info<< "2D case detected. " + << "Adding prismatic2DRefinement topology modifier" << endl; + topoChanger_.set + ( + 0, + new prismatic2DRefinement + ( + "prismatic2DRefinement", + refinementDict_, + 0, + topoChanger_ + ) + ); + break; + + case 1: + FatalErrorIn + ( + "dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh" + "\n(" + "\n const IOobject& io," + "\n const word subDictName" + "\n)" + ) << "1D case detected. No valid refinement strategy is" + << " available for 1D cases." + << abort(FatalError); + break; + + default: + FatalErrorIn + ( + "dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh" + "\n(" + "\n const IOobject& io," + "\n const word subDictName" + "\n)" + ) << "Invalid number of geometric meshes detected: " + << nGeometricDirs + << nl << "It appears that this mesh is neither 1D, 2D or 3D." + << abort(FatalError); + + } + + // Write mesh and modifiers + topoChanger_.writeOpt() = IOobject::AUTO_WRITE; + topoChanger_.write(); + write(); + // Initialize refinement selection algorithm after modifiers refinementSelectionPtr_ = refinementSelection::New(*this, refinementDict_); }