Refactored dynamicPolyRefinementFvMesh class
Enabled automatic switching between polyhedralRefinement engine for 3D and prismatic2DRefinement engine for 2D.
This commit is contained in:
parent
2d845a809c
commit
a29e1ead28
2 changed files with 86 additions and 26 deletions
|
@ -26,6 +26,7 @@ License
|
||||||
#include "dynamicPolyRefinementFvMesh.H"
|
#include "dynamicPolyRefinementFvMesh.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "refinementSelection.H"
|
#include "refinementSelection.H"
|
||||||
|
#include "prismatic2DRefinement.H"
|
||||||
#include "polyhedralRefinement.H"
|
#include "polyhedralRefinement.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
@ -112,21 +113,76 @@ Foam::dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh
|
||||||
|
|
||||||
refinementSelectionPtr_(refinementSelection::New(*this, refinementDict_))
|
refinementSelectionPtr_(refinementSelection::New(*this, refinementDict_))
|
||||||
{
|
{
|
||||||
// Add the topology modifier engine
|
// Only one topo changer engine
|
||||||
Info<< "Adding polyhedralRefinement topology modifier" << endl;
|
|
||||||
|
|
||||||
topoChanger_.setSize(1);
|
topoChanger_.setSize(1);
|
||||||
topoChanger_.set
|
|
||||||
(
|
// Get number of valid geometric dimensions
|
||||||
0,
|
const label nGeometricDirs = this->nGeometricD();
|
||||||
new polyhedralRefinement
|
|
||||||
(
|
switch(nGeometricDirs)
|
||||||
"polyhedralRefinement",
|
{
|
||||||
refinementDict_,
|
case 3:
|
||||||
0,
|
// Add the polyhedralRefinement engine for 3D isotropic refinement
|
||||||
topoChanger_
|
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(FatalErrorIn);
|
||||||
|
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(FatalErrorIn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Write mesh and modifiers
|
// Write mesh and modifiers
|
||||||
topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
|
topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
|
||||||
|
@ -185,9 +241,8 @@ bool Foam::dynamicPolyRefinementFvMesh::update()
|
||||||
// time step
|
// time step
|
||||||
curTimeIndex_ = time().timeIndex();
|
curTimeIndex_ = time().timeIndex();
|
||||||
|
|
||||||
// Get reference to polyhedralRefinement polyMeshModifier
|
// Get reference to base class refinement polyMeshModifier
|
||||||
polyhedralRefinement& polyRefModifier =
|
refinement& refModifier = refCast<refinement>(topoChanger_[0]);
|
||||||
refCast<polyhedralRefinement>(topoChanger_[0]);
|
|
||||||
|
|
||||||
// Create empty list for refinement candidates
|
// Create empty list for refinement candidates
|
||||||
labelList refCandidates;
|
labelList refCandidates;
|
||||||
|
@ -208,9 +263,9 @@ bool Foam::dynamicPolyRefinementFvMesh::update()
|
||||||
Info<< "Skipping refinement for this time-step..." << endl;
|
Info<< "Skipping refinement for this time-step..." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set cells to refine. Note: polyhedralRefinement ensures that face and
|
// Set cells to refine. Note: refinement needs to make sure that face
|
||||||
// point consistent refinement is performed
|
// and point consistent refinement is performed
|
||||||
polyRefModifier.setCellsToRefine(refCandidates);
|
refModifier.setCellsToRefine(refCandidates);
|
||||||
|
|
||||||
// Create empty list for unrefinement candidates
|
// Create empty list for unrefinement candidates
|
||||||
labelList unrefCandidates;
|
labelList unrefCandidates;
|
||||||
|
@ -233,10 +288,10 @@ bool Foam::dynamicPolyRefinementFvMesh::update()
|
||||||
|
|
||||||
// Set split points to unrefine around.
|
// Set split points to unrefine around.
|
||||||
// Notes:
|
// Notes:
|
||||||
// 1. polyhedralRefinement ensures that only a consistent set of split
|
// 1. refinement needs to make sure that only a consistent set of split
|
||||||
// points is used for unrefinement
|
// points is used for unrefinement
|
||||||
// 2. Must be called after polyhedralRefinement::setCellsToRefine
|
// 2. Must be called after refinement::setCellsToRefine
|
||||||
polyRefModifier.setSplitPointsToUnrefine(unrefCandidates);
|
refModifier.setSplitPointsToUnrefine(unrefCandidates);
|
||||||
|
|
||||||
// Activate the polyhedral refinement engine if there are some cells to
|
// Activate the polyhedral refinement engine if there are some cells to
|
||||||
// refine or there are some split points to unrefine around
|
// refine or there are some split points to unrefine around
|
||||||
|
@ -249,11 +304,11 @@ bool Foam::dynamicPolyRefinementFvMesh::update()
|
||||||
|
|
||||||
if (enableTopoChange)
|
if (enableTopoChange)
|
||||||
{
|
{
|
||||||
polyRefModifier.enable();
|
refModifier.enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
polyRefModifier.disable();
|
refModifier.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform refinement and unrefinement in one go
|
// Perform refinement and unrefinement in one go
|
||||||
|
|
|
@ -25,7 +25,11 @@ Class
|
||||||
Foam::dynamicPolyRefinementFvMesh
|
Foam::dynamicPolyRefinementFvMesh
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Adaptive mesh refinement for arbitrary polyhedral cells.
|
Adaptive mesh refinement for isotropic refinement of arbitrary polyhedral
|
||||||
|
cells in 3D and arbitrary prismatic cells in 2D.
|
||||||
|
Automatically switches between:
|
||||||
|
- 3D refinement uses polyhedralRefinement engine
|
||||||
|
- 2D refinement uses prismatic2DRefinement engine
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
dynamicPolyRefinementFvMesh.C
|
dynamicPolyRefinementFvMesh.C
|
||||||
|
@ -35,6 +39,7 @@ Author
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
Generalisation and refactorisation of dynamicRefineMesh for polyhedral cells
|
Generalisation and refactorisation of dynamicRefineMesh for polyhedral cells
|
||||||
|
in 3D and prismatic cells in 2D.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Reference in a new issue