-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional refinement selection algorithms for polyhedral AMR
1. minCellVolumeRefinement: selects all cells with volume higher than specified one 2. minPatchDistanceRefinement: selects all cells at the distance greater than specified distance from a set of patches 3. compositeRefinementSelection: selects intersection of all sets obtained from other (basic) refinement selections
- Loading branch information
Vuko Vukcevic
committed
Mar 16, 2018
1 parent
21f058c
commit f9f1154
Showing
7 changed files
with
832 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
...entFvMesh/refinementSelection/compositeRefinementSelection/compositeRefinementSelection.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
/*---------------------------------------------------------------------------*\ | ||
========= | | ||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox | ||
\\ / O peration | | ||
\\ / A nd | Copyright held by original author | ||
\\/ 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 2 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, write to the Free Software Foundation, | ||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
Author | ||
Vuko Vukcevic, Wikki Ltd. All rights reserved. | ||
\*---------------------------------------------------------------------------*/ | ||
|
||
#include "compositeRefinementSelection.H" | ||
#include "addToRunTimeSelectionTable.H" | ||
#include "volFields.H" | ||
|
||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | ||
|
||
namespace Foam | ||
{ | ||
|
||
defineTypeNameAndDebug(compositeRefinementSelection, 0); | ||
addToRunTimeSelectionTable | ||
( | ||
refinementSelection, | ||
compositeRefinementSelection, | ||
dictionary | ||
); | ||
|
||
} | ||
|
||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // | ||
|
||
Foam::compositeRefinementSelection::compositeRefinementSelection | ||
( | ||
const fvMesh& mesh, | ||
const dictionary& dict | ||
) | ||
: | ||
refinementSelection(mesh, dict), | ||
baseRefinementSelections_() | ||
{ | ||
// Read basic refinement selections | ||
PtrList<entry> baseRefSelectionEntries | ||
( | ||
coeffDict().lookup("baseRefinementSelections") | ||
); | ||
|
||
baseRefinementSelections_.setSize(baseRefSelectionEntries.size()); | ||
|
||
forAll (baseRefinementSelections_, brsI) | ||
{ | ||
baseRefinementSelections_.set | ||
( | ||
brsI, | ||
refinementSelection::New | ||
( | ||
mesh, | ||
baseRefSelectionEntries[brsI].dict() | ||
) | ||
); | ||
} | ||
} | ||
|
||
|
||
// * * * * * * * * * * * * * * * * Destructor* * * * * * * * * * * * * * * * // | ||
|
||
Foam::compositeRefinementSelection::~compositeRefinementSelection() | ||
{} | ||
|
||
|
||
// * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * // | ||
|
||
Foam::Xfer<Foam::labelList> | ||
Foam::compositeRefinementSelection::refinementCellCandidates() const | ||
{ | ||
// Final refinement cell candidates are defined as the intersection of all | ||
// sets (obtained with different refinement selection algorithms) | ||
// In order to define the intersection in a straightforward and efficient | ||
// way, we will create a labelField for all cells counting the number of | ||
// times this cell has been selected for refinement. If all selection | ||
// algorithms have selected the cell, this cell is marked as a final | ||
// refinement candidate. | ||
|
||
// Create field counting the number of selections | ||
labelField nSelections(mesh().nCells(), 0); | ||
|
||
// Loop through all base refinement selections | ||
forAll (baseRefinementSelections_, brsI) | ||
{ | ||
// Get refinement candidates from this base selection algorithm. Note: | ||
// list is transferred | ||
const labelList curRefCandidates | ||
( | ||
baseRefinementSelections_[brsI].refinementCellCandidates() | ||
); | ||
|
||
// Increment the number of selections for selected cells | ||
forAll (curRefCandidates, i) | ||
{ | ||
++nSelections[curRefCandidates[i]]; | ||
} | ||
} | ||
|
||
// Create storage for collection of final cell candidates. Assume that | ||
// one fifth of the cells will be marked to prevent excessive resizing | ||
dynamicLabelList refinementCandidates(mesh().nCells()/5); | ||
|
||
// Get number of active selection algorithms | ||
const label nBaseSelections = baseRefinementSelections_.size(); | ||
|
||
// Loop through all cells and collect final refinement candidates | ||
forAll (nSelections, cellI) | ||
{ | ||
if (nSelections[cellI] == nBaseSelections) | ||
{ | ||
// Cell has been marked by all selection algorithms, append it | ||
refinementCandidates.append(cellI); | ||
} | ||
} | ||
|
||
// Print out some information | ||
Info<< "Selection algorithm " << type() << " selected " | ||
<< returnReduce(refinementCandidates.size(), sumOp<label>()) | ||
<< " cells as refinement candidates." | ||
<< endl; | ||
|
||
// Return the list in the Xfer container to prevent copying | ||
return refinementCandidates.xfer(); | ||
} | ||
|
||
|
||
Foam::Xfer<Foam::labelList> | ||
Foam::compositeRefinementSelection::unrefinementPointCandidates() const | ||
{ | ||
// Final unrefinement point candidates are defined as the intersection of | ||
// all sets (obtained with different refinement selection algorithms) In | ||
// order to define the intersection in a straightforward and efficient way, | ||
// we will create a labelField for all points counting the number of times | ||
// this point has been selected for unrefinement. If all selection | ||
// algorithms have selected the point, this point is marked as a final | ||
// unrefinement split point candidate. | ||
|
||
// Create a field counting the number of selections | ||
labelField nSelections(mesh().nPoints(), 0); | ||
|
||
// Loop through all base refinement selections | ||
forAll (baseRefinementSelections_, brsI) | ||
{ | ||
// Get unrefinement candidates from this base selection algorithm. Note: | ||
// list is transferred | ||
const labelList curUnrefCandidates | ||
( | ||
baseRefinementSelections_[brsI].unrefinementPointCandidates() | ||
); | ||
|
||
// Increment the number of selections for selected points | ||
forAll (curUnrefCandidates, i) | ||
{ | ||
++nSelections[curUnrefCandidates[i]]; | ||
} | ||
} | ||
|
||
// Create storage for collection of final point candidates. Assume that one | ||
// tenth of the points will be marked to prevent excessive resizing | ||
dynamicLabelList unrefinementCandidates(mesh().nPoints()/10); | ||
|
||
// Get number of active selection algorithms | ||
const label nBaseSelections = baseRefinementSelections_.size(); | ||
|
||
// Loop through all points and collect final unrefinement candidates | ||
forAll (nSelections, pointI) | ||
{ | ||
if (nSelections[pointI] == nBaseSelections) | ||
{ | ||
// Point has been marked by all selection algorithms, append it | ||
unrefinementCandidates.append(pointI); | ||
} | ||
} | ||
|
||
// Print out some information | ||
Info<< "Selection algorithm " << type() << " selected " | ||
<< returnReduce(unrefinementCandidates.size(), sumOp<label>()) | ||
<< " points as unrefinement candidates." | ||
<< endl; | ||
|
||
// Return the list in the Xfer container to prevent copying | ||
return unrefinementCandidates.xfer(); | ||
} | ||
|
||
|
||
// ************************************************************************* // |
113 changes: 113 additions & 0 deletions
113
...entFvMesh/refinementSelection/compositeRefinementSelection/compositeRefinementSelection.H
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/*---------------------------------------------------------------------------*\ | ||
========= | | ||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox | ||
\\ / O peration | | ||
\\ / A nd | Copyright held by original author | ||
\\/ 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 2 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, write to the Free Software Foundation, | ||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
Class | ||
Foam::compositeRefinementSelection | ||
Description | ||
Selection of refinement cells based on an arbitrary number of combined | ||
"basic" selection algorithms. | ||
SourceFiles | ||
compositeRefinementSelection.C | ||
Author | ||
Vuko Vukcevic, Wikki Ltd. All rights reserved. | ||
\*---------------------------------------------------------------------------*/ | ||
|
||
#ifndef compositeRefinementSelection_H | ||
#define compositeRefinementSelection_H | ||
|
||
#include "refinementSelection.H" | ||
|
||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | ||
|
||
namespace Foam | ||
{ | ||
|
||
/*---------------------------------------------------------------------------*\ | ||
Class compositeRefinementSelection Declaration | ||
\*---------------------------------------------------------------------------*/ | ||
|
||
class compositeRefinementSelection | ||
: | ||
public refinementSelection | ||
{ | ||
// Private data | ||
|
||
//- List of basic refinement selection algorithms | ||
PtrList<refinementSelection> baseRefinementSelections_; | ||
|
||
|
||
// Private Member Functions | ||
|
||
//- Disallow default bitwise copy construct | ||
compositeRefinementSelection(const compositeRefinementSelection&); | ||
|
||
//- Disallow default bitwise assignment | ||
void operator=(const compositeRefinementSelection&); | ||
|
||
|
||
public: | ||
|
||
//- Runtime type information | ||
TypeName("compositeRefinementSelection"); | ||
|
||
|
||
// Constructors | ||
|
||
//- Construct from components | ||
compositeRefinementSelection | ||
( | ||
const fvMesh& mesh, | ||
const dictionary& dict | ||
); | ||
|
||
|
||
//- Destructor | ||
virtual ~compositeRefinementSelection(); | ||
|
||
|
||
// Member Functions | ||
|
||
// Selection of refinement/unrefinement candidates | ||
|
||
//- Return transferable list of cells to refine | ||
virtual Xfer<labelList> refinementCellCandidates() const; | ||
|
||
//- Return transferable list of split points to unrefine | ||
virtual Xfer<labelList> unrefinementPointCandidates() const; | ||
}; | ||
|
||
|
||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | ||
|
||
} // End namespace Foam | ||
|
||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | ||
|
||
#endif | ||
|
||
// ************************************************************************* // |
Oops, something went wrong.