LabelField change for pointLevel and cellLevel
This commit is contained in:
parent
96a2f708c6
commit
fbed59fec8
4 changed files with 137 additions and 21 deletions
|
@ -1228,7 +1228,7 @@ Foam::refinement::refinement
|
|||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
labelList(mesh_.nCells(), 0)
|
||||
labelField(mesh_.nCells(), 0)
|
||||
),
|
||||
pointLevel_
|
||||
(
|
||||
|
@ -1241,7 +1241,7 @@ Foam::refinement::refinement
|
|||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
labelList(mesh_.nPoints(), 0)
|
||||
labelField(mesh_.nPoints(), 0)
|
||||
),
|
||||
refinementLevelIndicator_(0), // Must be empty before setting refinement
|
||||
faceRemover_(mesh_, GREAT), // Merge boundary faces wherever possible
|
||||
|
@ -1260,6 +1260,9 @@ Foam::refinement::refinement
|
|||
readScalar(dict.lookup("nUnrefinementBufferLayers"))
|
||||
)
|
||||
{
|
||||
Info<< "refinement::refinement: " << "Created pointLevel and cellLevel"
|
||||
<< endl;
|
||||
|
||||
// Check consistency between cellLevel and number of cells and pointLevel
|
||||
// and number of points in the mesh
|
||||
if
|
||||
|
|
|
@ -32,7 +32,6 @@ Description
|
|||
The common interface includes (pure virtuals) following member functions:
|
||||
- setCellsToRefine
|
||||
- setSplitPointsToUnrefine
|
||||
- calcLevel0EdgeLength
|
||||
|
||||
With a lot of ordinary protected member functions which are used by both
|
||||
derived classes.
|
||||
|
@ -58,7 +57,7 @@ Notes
|
|||
#define refinement_H
|
||||
|
||||
#include "polyMeshModifier.H"
|
||||
#include "labelIOList.H"
|
||||
#include "labelIOField.H"
|
||||
#include "removeFaces.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -67,7 +66,7 @@ namespace Foam
|
|||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class refinement Declaration
|
||||
Class refinement Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class refinement
|
||||
|
@ -100,10 +99,10 @@ protected:
|
|||
mutable labelList splitPointsToUnrefine_;
|
||||
|
||||
//- Cell refinement level
|
||||
mutable labelIOList cellLevel_;
|
||||
mutable labelIOField cellLevel_;
|
||||
|
||||
//- Point refinement level
|
||||
mutable labelIOList pointLevel_;
|
||||
mutable labelIOField pointLevel_;
|
||||
|
||||
//- Helper list for original (old) cells that will be refined or
|
||||
// unrefined. The list is updated in setPolyhedralRefinement and
|
||||
|
@ -311,21 +310,22 @@ public:
|
|||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~refinement();
|
||||
//- Destructor
|
||||
virtual ~refinement();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const labelIOList& cellLevel() const
|
||||
//- Return refinement cell level
|
||||
const labelIOField& cellLevel() const
|
||||
{
|
||||
return cellLevel_;
|
||||
}
|
||||
|
||||
const labelIOList& pointLevel() const
|
||||
//- Return refinement point level
|
||||
const labelIOField& pointLevel() const
|
||||
{
|
||||
return pointLevel_;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,9 @@ Author
|
|||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "protectedInitialRefinement.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "labelIOField.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -51,7 +52,7 @@ Foam::tmp<Foam::volScalarField>
|
|||
Foam::protectedInitialRefinement::cellLevelAsField() const
|
||||
{
|
||||
// Get cell level
|
||||
const labelIOList& cLevel = mesh().lookupObject<labelIOList>("cellLevel");
|
||||
const labelIOField& cLevel = mesh().lookupObject<labelIOField>("cellLevel");
|
||||
|
||||
// Create cell level field as volScalarField
|
||||
tmp<volScalarField> tCellLevelField
|
||||
|
@ -156,8 +157,8 @@ Foam::protectedInitialRefinement::unrefinementPointCandidates() const
|
|||
label nProtectedPoints = 0;
|
||||
|
||||
// Get current cell level
|
||||
const labelIOList& curCellLevel =
|
||||
mesh().lookupObject<labelIOList>("cellLevel");
|
||||
const labelIOField& curCellLevel =
|
||||
mesh().lookupObject<labelIOField>("cellLevel");
|
||||
|
||||
forAll (initialCellLevelIn, cellI)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ License
|
|||
#include "topoChangerFvMesh.H"
|
||||
#include "domainDecomposition.H"
|
||||
#include "fvFieldDecomposer.H"
|
||||
#include "labelIOField.H"
|
||||
#include "processorMeshesReconstructor.H"
|
||||
#include "fvFieldReconstructor.H"
|
||||
#include "passiveProcessorPolyPatch.H"
|
||||
|
@ -161,10 +162,15 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
// Particles
|
||||
HashTable<const cloud*> clouds = thisDb().lookupClass<cloud>();
|
||||
|
||||
forAllConstIter(HashTable<const cloud*>, clouds, iter)
|
||||
{
|
||||
cloud& c = const_cast<cloud&>(*iter());
|
||||
}
|
||||
// Distribute cell and point level for AMR + DLB runs. VV, 18/May/2018
|
||||
|
||||
// Get (non-const) reference to cellLevel
|
||||
labelIOField& cellLevel = const_cast<labelIOField&>
|
||||
(this->lookupObject<labelIOField>("cellLevel"));
|
||||
|
||||
// Get (non-const) reference to pointLevel
|
||||
labelIOField& pointLevel = const_cast<labelIOField&>
|
||||
(this->lookupObject<labelIOField>("pointLevel"));
|
||||
|
||||
//HJ, HERE: remove the fields that should not be load balanced
|
||||
|
||||
|
@ -211,6 +217,12 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
receivedSurfaceVectorFields[fieldI].setSize(Pstream::nProcs());
|
||||
}
|
||||
|
||||
// Cell and point level
|
||||
// Note: ordinary lists instead of IO lists
|
||||
PtrList<labelList> receivedCellLevel(Pstream::nProcs());
|
||||
PtrList<labelList> receivedPointLevel(Pstream::nProcs());
|
||||
|
||||
// Clouds
|
||||
PtrList<cloudDistribute> cloudDistributes(clouds.size());
|
||||
{
|
||||
label cloudI = 0;
|
||||
|
@ -230,7 +242,6 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
for (label procI = 0; procI < meshDecomp.nProcs(); procI++)
|
||||
{
|
||||
// Check if there is a mesh to send
|
||||
|
@ -277,6 +288,24 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
sendFields(surfaceScalarFields, fieldDecomposer, toProc);
|
||||
sendFields(surfaceVectorFields, fieldDecomposer, toProc);
|
||||
|
||||
// Send cell level with procCellAddressing
|
||||
toProc <<
|
||||
labelList
|
||||
(
|
||||
cellLevel,
|
||||
meshDecomp.procCellAddressing()[procI]
|
||||
)
|
||||
<< nl;
|
||||
|
||||
// Send point level with procPointAddressing
|
||||
toProc <<
|
||||
labelList
|
||||
(
|
||||
pointLevel,
|
||||
meshDecomp.procPointAddressing()[procI]
|
||||
)
|
||||
<< nl;
|
||||
|
||||
// Send clouds
|
||||
forAll(cloudDistributes, cloudI)
|
||||
{
|
||||
|
@ -325,6 +354,32 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
fieldDecomposer,
|
||||
receivedSurfaceVectorFields
|
||||
);
|
||||
|
||||
// Insert cell level
|
||||
receivedCellLevel.set
|
||||
(
|
||||
Pstream::myProcNo(),
|
||||
new labelList
|
||||
(
|
||||
cellLevel,
|
||||
meshDecomp.procCellAddressing()
|
||||
[Pstream::myProcNo()]
|
||||
)
|
||||
);
|
||||
|
||||
// Insert point level
|
||||
receivedPointLevel.set
|
||||
(
|
||||
Pstream::myProcNo(),
|
||||
new labelList
|
||||
(
|
||||
pointLevel,
|
||||
meshDecomp.procPointAddressing()
|
||||
[Pstream::myProcNo()]
|
||||
)
|
||||
);
|
||||
|
||||
//HJ Insert clouds missing. HJ, 12/Oct/2018
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -401,6 +456,21 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
fromProc
|
||||
);
|
||||
|
||||
// Receive cell level
|
||||
receivedCellLevel.set
|
||||
(
|
||||
procI,
|
||||
new labelList(fromProc)
|
||||
);
|
||||
|
||||
// Receive point level
|
||||
receivedPointLevel.set
|
||||
(
|
||||
procI,
|
||||
new labelList(fromProc)
|
||||
);
|
||||
|
||||
// Receive clouds
|
||||
forAll(cloudDistributes, cloudI)
|
||||
{
|
||||
cloudDistributes[cloudI].receive(fromProc, procI);
|
||||
|
@ -687,6 +757,7 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
oldPatchNMeshPoints // oldPatchNMeshPoints
|
||||
);
|
||||
|
||||
|
||||
// Reset fvMesh and patches
|
||||
resetFvPrimitives
|
||||
(
|
||||
|
@ -744,6 +815,47 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict)
|
|||
meshMap
|
||||
);
|
||||
|
||||
// Rebuild cell level field from components
|
||||
if (cellLevel.size() != this->nCells())
|
||||
{
|
||||
Pout<< "Setting cell level size from: "
|
||||
<< cellLevel.size() << " to " << this->nCells() << endl;
|
||||
cellLevel.setSize(this->nCells());
|
||||
}
|
||||
|
||||
forAll (receivedCellLevel, procI)
|
||||
{
|
||||
if (receivedCellLevel.set(procI))
|
||||
{
|
||||
cellLevel.rmap
|
||||
(
|
||||
receivedCellLevel[procI],
|
||||
meshRecon.cellProcAddressing()[procI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild point level field from components
|
||||
if (pointLevel.size() != this->nPoints())
|
||||
{
|
||||
Pout<< "Setting point level size from: "
|
||||
<< pointLevel.size() << " to " << this->nPoints() << endl;
|
||||
pointLevel.setSize(this->nPoints());
|
||||
}
|
||||
|
||||
forAll (receivedPointLevel, procI)
|
||||
{
|
||||
if (receivedPointLevel.set(procI))
|
||||
{
|
||||
pointLevel.rmap
|
||||
(
|
||||
receivedPointLevel[procI],
|
||||
meshRecon.pointProcAddressing()[procI]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild clouds
|
||||
forAll(cloudDistributes, cloudI)
|
||||
{
|
||||
cloudDistributes[cloudI].rebuild
|
||||
|
|
Reference in a new issue