ENH: fvMeshSubset improvements (issue #951)

- what was previously termed 'setLargeCellSubset()' is now simply
  'setCellSubset()' and supports memory efficient interfaces.

  The new parameter ordering avoids ambiguities caused by default
  parameters.

  Old parameter order:

      setLargeCellSubset
      (
          const labelList& region,
          const label currentRegion,
          const label patchID = -1,
          const bool syncCouples = true
      );

  New parameter order:

      setCellSubset
      (
          const label regioni,
          const labelUList& regions,
          const label patchID = -1,
          const bool syncCouples = true
      );

   And without ambiguity:

      setCellSubset
      (
          const labelUList& selectedCells,
          const label patchID = -1,
          const bool syncCouples = true
      );

- support bitSet directly for specifying the selectedCells for
  memory efficiency and ease of use.

- Additional constructors to perform setCellSubset() immediately,
  which simplifies coding.

  For example,

      meshParts.set
      (
          zonei,
          new fvMeshSubset(mesh, selectedCells)
      );

  Or even

      return autoPtr<fvMeshSubset>::New(mesh, selectedCells);
This commit is contained in:
Mark Olesen 2018-07-25 18:58:00 +02:00
parent 7446d30fbd
commit dbe0db1d9a
23 changed files with 1737 additions and 1412 deletions

View File

@ -25,10 +25,15 @@ labelList receptorNeigCell(mesh.nInternalFaces(), -1);
PtrList<fvMeshSubset> meshParts(nZones); PtrList<fvMeshSubset> meshParts(nZones);
labelList nCellsPerZone(nZones, 0); labelList nCellsPerZone(nZones, 0);
forAll(nCellsPerZone, zoneI) // A mesh subset for each zone
forAll(meshParts, zonei)
{ {
meshParts.set(zoneI, new fvMeshSubset(mesh)); meshParts.set
meshParts[zoneI].setLargeCellSubset(zoneID, zoneI); (
zonei,
// Select cells where the zoneID == zonei
new fvMeshSubset(mesh, zonei, zoneID)
);
} }
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)

View File

@ -51,6 +51,7 @@ Description
#include "fvMeshSubset.H" #include "fvMeshSubset.H"
#include "argList.H" #include "argList.H"
#include "cellSet.H" #include "cellSet.H"
#include "BitOps.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "volFields.H" #include "volFields.H"
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
@ -774,19 +775,19 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// //
// Create mesh subsetting engine // Mesh subsetting engine
fvMeshSubset subsetter(mesh); fvMeshSubset subsetter
(
{ mesh,
BitSetOps::create
cellSet blockedCells(mesh, blockedSetName); (
mesh.nCells(),
// invert cellSet(mesh, blockedSetName), // Blocked cells as labelHashSet
blockedCells.invert(mesh.nCells()); false // on=false: invert logic => retain the unblocked cells
),
// Create subsetted mesh. defaultPatchi,
subsetter.setLargeCellSubset(blockedCells, defaultPatchi, true); true
} );
// Subset wantedPatch. Note that might also include boundary faces // Subset wantedPatch. Note that might also include boundary faces

View File

@ -570,17 +570,16 @@ labelList regionRenumber
label celli = 0; label celli = 0;
forAll(regionToCells, regionI) forAll(regionToCells, regioni)
{ {
Info<< " region " << regionI << " starts at " << celli << endl; Info<< " region " << regioni << " starts at " << celli << endl;
// Make sure no parallel comms // Make sure no parallel comms
bool oldParRun = UPstream::parRun(); const bool oldParRun = UPstream::parRun();
UPstream::parRun() = false; UPstream::parRun() = false;
// Per region do a reordering. // Per region do a reordering.
fvMeshSubset subsetter(mesh); fvMeshSubset subsetter(mesh, regioni, cellToRegion);
subsetter.setLargeCellSubset(cellToRegion, regionI);
const fvMesh& subMesh = subsetter.subMesh(); const fvMesh& subMesh = subsetter.subMesh();

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,6 +45,7 @@ Description
#include "volFields.H" #include "volFields.H"
#include "topoDistanceData.H" #include "topoDistanceData.H"
#include "FaceCellWave.H" #include "FaceCellWave.H"
#include "BitOps.H"
#include "cellSet.H" #include "cellSet.H"
#include "faceSet.H" #include "faceSet.H"
#include "pointSet.H" #include "pointSet.H"
@ -311,7 +312,7 @@ void subsetTopoSets
label nSet = 0; label nSet = 0;
forAll(map, i) forAll(map, i)
{ {
if (isSet[map[i]]) if (isSet.test(map[i]))
{ {
++nSet; ++nSet;
} }
@ -325,7 +326,7 @@ void subsetTopoSets
TopoSet& subSet = subSets[i]; TopoSet& subSet = subSets[i];
forAll(map, i) forAll(map, i)
{ {
if (isSet[map[i]]) if (isSet.test(map[i]))
{ {
subSet.insert(i); subSet.insert(i);
} }
@ -371,7 +372,7 @@ int main(int argc, char *argv[])
#include "createNamedMesh.H" #include "createNamedMesh.H"
const word setName = args[1]; const word selectionName = args[1];
word meshInstance = mesh.pointsInstance(); word meshInstance = mesh.pointsInstance();
word fieldsInstance = runTime.timeName(); word fieldsInstance = runTime.timeName();
@ -389,30 +390,13 @@ int main(int argc, char *argv[])
} }
Info<< "Reading cell set from " << setName << nl << endl; Info<< "Reading cell set from " << selectionName << nl << endl;
// Create mesh subsetting engine
fvMeshSubset subsetter(mesh);
labelList exposedPatchIDs; // Default exposed patch id
labelList exposedPatchIDs(one(), -1);
if (args.found("patch")) if (args.found("patches"))
{
const word patchName = args["patch"];
exposedPatchIDs = { mesh.boundaryMesh().findPatchID(patchName) };
if (exposedPatchIDs[0] == -1)
{
FatalErrorInFunction
<< nl << "Valid patches are " << mesh.boundaryMesh().names()
<< exit(FatalError);
}
Info<< "Adding exposed internal faces to patch " << patchName
<< nl << endl;
}
else if (args.found("patches"))
{ {
const wordRes patchNames(args.readList<wordRe>("patches")); const wordRes patchNames(args.readList<wordRe>("patches"));
@ -420,42 +404,77 @@ int main(int argc, char *argv[])
Info<< "Adding exposed internal faces to nearest of patches " Info<< "Adding exposed internal faces to nearest of patches "
<< patchNames << nl << endl; << patchNames << nl << endl;
if (exposedPatchIDs.empty())
{
FatalErrorInFunction
<< nl << "No patches matched. Patches: "
<< mesh.boundaryMesh().names()
<< exit(FatalError);
}
}
else if (args.found("patch"))
{
const word patchName = args["patch"];
exposedPatchIDs.first() = mesh.boundaryMesh().findPatchID(patchName);
Info<< "Adding exposed internal faces to patch " << patchName
<< nl << endl;
if (exposedPatchIDs.first() == -1)
{
FatalErrorInFunction
<< nl << "No such patch. Patches: "
<< mesh.boundaryMesh().names()
<< exit(FatalError);
}
} }
else else
{ {
Info<< "Adding exposed internal faces to a patch called" Info<< "Adding exposed internal faces to a patch called"
<< " \"oldInternalFaces\" (created if necessary)" << endl << " \"oldInternalFaces\" (created if necessary)" << endl
<< endl; << endl;
exposedPatchIDs = { -1 };
} }
cellSet currentSet(mesh, setName); // Mesh subsetting engine
fvMeshSubset subsetter(mesh);
if (exposedPatchIDs.size() == 1) cellSet currentSet(mesh, selectionName);
{
subsetter.setLargeCellSubset(currentSet, exposedPatchIDs[0], true);
}
else
{
// Find per face the nearest patch
labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs));
labelList region(mesh.nCells(), 0); {
forAllConstIter(cellSet, currentSet, iter) bitSet selectedCells = BitSetOps::create(mesh.nCells(), currentSet);
if (exposedPatchIDs.size() == 1)
{ {
region[iter.key()] = 1; // Single patch for exposed faces
subsetter.setCellSubset
(
selectedCells,
exposedPatchIDs.first(),
true
);
} }
else
{
// The nearest patch per face
labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs));
labelList exposedFaces(subsetter.getExposedFaces(region, 1, true)); labelList exposedFaces
subsetter.setLargeCellSubset (
( subsetter.getExposedFaces(selectedCells, true)
region, );
1,
exposedFaces, subsetter.setCellSubset
labelUIndList(nearestExposedPatch, exposedFaces)(), (
true selectedCells,
); exposedFaces,
labelUIndList(nearestExposedPatch, exposedFaces)(),
true
);
}
} }

View File

@ -872,30 +872,23 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
// Find last non-processor patch. // Find last non-processor patch.
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
label nonProcI = -1; const label nonProcI = (patches.nNonProcessor() - 1);
forAll(patches, patchI) if (nonProcI < 0)
{
if (isA<processorPolyPatch>(patches[patchI]))
{
break;
}
nonProcI++;
}
if (nonProcI == -1)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Cannot find non-processor patch on processor " << "Cannot find non-processor patch on processor "
<< Pstream::myProcNo() << endl << Pstream::myProcNo() << nl
<< " Current patches:" << patches.names() << " Current patches:" << patches.names()
<< abort(FatalError); << abort(FatalError);
} }
// Subset 0 cells, no parallel comms. This is used to create // Subset 0 cells, no parallel comms.
// zero-sized fields. // This is used to create zero-sized fields.
subsetterPtr.reset(new fvMeshSubset(mesh)); subsetterPtr.reset
subsetterPtr().setLargeCellSubset(labelHashSet(0), nonProcI, false); (
new fvMeshSubset(mesh, bitSet(), nonProcI, false)
);
} }

View File

@ -423,8 +423,7 @@ void Foam::vtkPVFoam::convertMeshCellZones()
if (!vtkgeom) if (!vtkgeom)
{ {
fvMeshSubset subsetter(mesh); fvMeshSubset subsetter(mesh, zMesh[zoneId]);
subsetter.setLargeCellSubset(zMesh[zoneId]);
vtkgeom = vtuData.subset(subsetter, this->decomposePoly_); vtkgeom = vtuData.subset(subsetter, this->decomposePoly_);
} }
@ -490,8 +489,7 @@ void Foam::vtkPVFoam::convertMeshCellSets()
if (!vtkgeom) if (!vtkgeom)
{ {
fvMeshSubset subsetter(mesh); fvMeshSubset subsetter(mesh, cellSet(mesh, partName));
subsetter.setLargeCellSubset(cellSet(mesh, partName));
vtkgeom = vtuData.subset(subsetter, this->decomposePoly_); vtkgeom = vtuData.subset(subsetter, this->decomposePoly_);
} }

View File

@ -2022,14 +2022,12 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
//OPstream str(Pstream::commsTypes::blocking, recvProc); //OPstream str(Pstream::commsTypes::blocking, recvProc);
UOPstream str(recvProc, pBufs); UOPstream str(recvProc, pBufs);
// Mesh subsetting engine // Mesh subsetting engine - subset the cells of the current domain.
fvMeshSubset subsetter(mesh_); fvMeshSubset subsetter
// Subset the cells of the current domain.
subsetter.setLargeCellSubset
( (
distribution, mesh_,
recvProc, recvProc,
distribution,
oldInternalPatchi, // oldInternalFaces patch oldInternalPatchi, // oldInternalFaces patch
false // no parallel sync false // no parallel sync
); );

File diff suppressed because it is too large Load Diff

View File

@ -25,18 +25,15 @@ Class
Foam::fvMeshSubset Foam::fvMeshSubset
Description Description
Post-processing mesh subset tool. Given the original mesh and the Given the original mesh and the list of selected cells, it creates the
list of selected cells, it creates the mesh consisting only of the mesh consisting only of the desired cells, with the mapping list for
desired cells, with the mapping list for points, faces, and cells. points, faces, and cells.
Puts all exposed internal faces into either Puts all exposed internal faces into either
- a user supplied patch - a user supplied patch
- a newly created patch "oldInternalFaces" - a newly created patch "oldInternalFaces"
- setLargeCellSubset is for largish subsets (>10% of mesh). - setCellSubset does coupled patch subsetting as well. If it detects
Uses labelLists instead.
- setLargeCellSubset does coupled patch subsetting as well. If it detects
a face on a coupled patch 'losing' its neighbour it will move the a face on a coupled patch 'losing' its neighbour it will move the
face into the oldInternalFaces patch. face into the oldInternalFaces patch.
@ -58,6 +55,7 @@ SourceFiles
#include "fvMesh.H" #include "fvMesh.H"
#include "pointMesh.H" #include "pointMesh.H"
#include "GeometricField.H" #include "GeometricField.H"
#include "bitSet.H"
#include "HashSet.H" #include "HashSet.H"
#include "surfaceMesh.H" #include "surfaceMesh.H"
@ -77,9 +75,12 @@ class fvMeshSubset
//- Mesh to subset from //- Mesh to subset from
const fvMesh& baseMesh_; const fvMesh& baseMesh_;
//- Subset mesh pointer //- Demand-driven subset mesh pointer
autoPtr<fvMesh> fvMeshSubsetPtr_; autoPtr<fvMesh> fvMeshSubsetPtr_;
//- Optional face mapping array with flip encoded (-1/+1)
mutable autoPtr<labelList> faceFlipMapPtr_;
//- Point mapping array //- Point mapping array
labelList pointMap_; labelList pointMap_;
@ -92,21 +93,14 @@ class fvMeshSubset
//- Patch mapping array //- Patch mapping array
labelList patchMap_; labelList patchMap_;
//- Optional face mapping array with flip encoded
mutable autoPtr<labelList> faceFlipMapPtr_;
// Private Member Functions // Private Member Functions
//- Check if subset has been performed //- Check if subset has been performed
bool checkCellSubset() const; bool checkCellSubset() const;
//- Mark points (with 0) in labelList //- Calculate face flip map
static void markPoints void calcFaceFlipMap() const;
(
const labelUList& curPoints,
labelList& pointMap
);
//- Adapt nCellsUsingFace for coupled faces becoming 'uncoupled'. //- Adapt nCellsUsingFace for coupled faces becoming 'uncoupled'.
void doCoupledPatches void doCoupledPatches
@ -115,24 +109,41 @@ class fvMeshSubset
labelList& nCellsUsingFace labelList& nCellsUsingFace
) const; ) const;
//- Forwarding to Foam::removeCells
void removeCellsImpl
(
const bitSet& cellsToRemove,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples
);
//- Subset of subset //- Subset of subset
static labelList subset static labelList subsetSubset
( (
const label nElems, const label nElems,
const labelList& selectedElements, const labelUList& selectedElements,
const labelList& subsetMap const labelUList& subsetMap
); );
//- Create zones for submesh //- Create zones for submesh
void subsetZones(); void subsetZones();
//- Helper: extract cells-to-remove from cells-to-keep //- Helper: extract cells-to-remove from cells-to-keep
labelList getCellsToRemove bitSet getCellsToRemove
( (
const labelList& region, const bitSet& selectedCells
const label currentRegion
) const; ) const;
//- Helper: extract cells-to-remove from cells-to-keep
bitSet getCellsToRemove
(
const label regioni,
const labelUList& regions
) const;
//- No copy construct //- No copy construct
fvMeshSubset(const fvMeshSubset&) = delete; fvMeshSubset(const fvMeshSubset&) = delete;
@ -145,173 +156,316 @@ public:
// Constructors // Constructors
//- Construct given a mesh to subset //- Construct given a mesh to subset
explicit fvMeshSubset(const fvMesh&); explicit fvMeshSubset(const fvMesh& baseMesh);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
const bitSet& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
const labelUList& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
const labelHashSet& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
const label regioni,
const labelUList& regions,
const label patchID = -1,
const bool syncPar = true
);
// Member Functions // Member Functions
// Edit // Access
//- Set the subset from all cells with region == currentRegion. //- Original mesh
// Create "oldInternalFaces" patch for exposed inline const fvMesh& baseMesh() const;
// internal faces (patchID==-1) or use supplied patch.
// Handles coupled patches by if necessary making coupled patch //- Have subMesh?
// face part of patchID (so uncoupled) inline bool hasSubMesh() const;
void setLargeCellSubset
//- Return reference to subset mesh
inline const fvMesh& subMesh() const;
//- Return reference to subset mesh
inline fvMesh& subMesh();
//- Return point map
inline const labelList& pointMap() const;
//- Return face map
inline const labelList& faceMap() const;
//- Return face map with sign to encode flipped faces
inline const labelList& faceFlipMap() const;
//- Return cell map
inline const labelList& cellMap() const;
//- Return patch map
inline const labelList& patchMap() const;
// Edit
//- Reset maps and subsetting
void clear();
//- Define the cell subset based on the selectedCells.
// Create "oldInternalFaces" patch for exposed
// internal faces (patchID==-1) or use supplied patch.
// Handles coupled patches by if necessary making coupled patch
// face part of patchID (so uncoupled)
void setCellSubset
(
const bitSet& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Define the cell subset, using the specified cells
//- to define the selection
void setCellSubset
(
const labelUList& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Define the cell subset, using the specified cells
//- labelHashSet to define the selection
void setCellSubset
(
const labelHashSet& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Define the cell subset, using the cells for which
// region == regioni.
void setCellSubset
(
const label regioni,
const labelUList& regions,
const label patchID = -1,
const bool syncCouples = true
);
// Two step subsetting
//- Get labels of exposed faces.
// These are
// - internal faces that become boundary faces
// - coupled faces that become uncoupled (since one of the
// sides gets deleted)
labelList getExposedFaces
(
const bitSet& selectedCells,
const bool syncCouples = true
) const;
//- Get labels of exposed faces.
// These are
// - internal faces that become boundary faces
// - coupled faces that become uncoupled (since one of the
// sides gets deleted)
labelList getExposedFaces
(
const label regioni,
const labelUList& regions,
const bool syncCouples = true
) const;
//- For every exposed face (from above getExposedFaces)
// used supplied (existing!) patch
void setCellSubset
(
const bitSet& selectedCells,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples = true
);
//- For every exposed face (from above getExposedFaces)
// used supplied (existing!) patch
void setCellSubset
(
const label regioni,
const labelList& regions,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples = true
);
// Field mapping
//- Map volume field
template<class Type>
static tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate
(
const GeometricField<Type, fvPatchField, volMesh>&,
const fvMesh& sMesh,
const labelList& patchMap,
const labelList& cellMap,
const labelList& faceMap
);
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate
(
const GeometricField<Type, fvPatchField, volMesh>&
) const;
//- Map surface field. Optionally negates value if flipping
// a face (from exposing an internal face)
template<class Type>
static tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const fvMesh& sMesh,
const labelList& patchMap,
const labelList& cellMap,
const labelList& faceMap
);
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&
) const;
//- Map point field
template<class Type>
static tmp<GeometricField<Type, pointPatchField, pointMesh>>
interpolate
(
const GeometricField<Type, pointPatchField, pointMesh>&,
const pointMesh& sMesh,
const labelList& patchMap,
const labelList& pointMap
);
template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>>
interpolate
(
const GeometricField<Type, pointPatchField, pointMesh>&
) const;
//- Map dimensioned field
template<class Type>
static tmp<DimensionedField<Type, volMesh>>
interpolate
(
const DimensionedField<Type, volMesh>&,
const fvMesh& sMesh,
const labelList& cellMap
);
template<class Type>
tmp<DimensionedField<Type, volMesh>>
interpolate(const DimensionedField<Type, volMesh>&) const;
// Compatibility
//- Old method name and old parameter ordering.
// \deprecated use setCellSubset instead (JUL-2018)
inline void setLargeCellSubset
(
const labelUList& region,
const label currentRegion,
const label patchID = -1,
const bool syncCouples = true
)
{
Info<< "WARNING: using highly deprecated method: "
<< "fvMeshSubset::setLargeCellSubset()" << nl;
setCellSubset
( (
const labelList& region, currentRegion,
const label currentRegion, region,
const label patchID = -1, patchID,
const bool syncCouples = true syncCouples
); );
}
//- setLargeCellSubset but only marking certain cells
void setLargeCellSubset //- Old method name.
// \deprecated use setCellSubset instead (JUL-2018)
inline void setLargeCellSubset
(
const labelHashSet& globalCellMap,
const label patchID = -1,
const bool syncPar = true
)
{
Info<< "WARNING: using highly deprecated method: "
<< "fvMeshSubset::setLargeCellSubset()" << nl;
setCellSubset(globalCellMap, patchID, syncPar);
}
//- For every exposed face (from getExposedFaces) use supplied
//- (existing!) patch ids
// \deprecated use setCellSubset instead (JUL-2018)
inline void setLargeCellSubset
(
const labelList& regions,
const label regioni,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples = true
)
{
Info<< "WARNING: using highly deprecated method: "
<< "fvMeshSubset::setLargeCellSubset()" << nl;
setCellSubset
( (
const labelUList& globalCellMap, regioni,
const label patchID = -1, regions,
const bool syncPar = true exposedFaces,
patchIDs,
syncCouples
); );
}
//- setLargeCellSubset but with labelHashSet.
void setLargeCellSubset
(
const labelHashSet& globalCellMap,
const label patchID = -1,
const bool syncPar = true
);
//- Two step subsetting
//- Get labels of exposed faces.
// These are
// - internal faces that become boundary faces
// - coupled faces that become uncoupled (since one of the
// sides gets deleted)
labelList getExposedFaces
(
const labelList& region,
const label currentRegion,
const bool syncCouples = true
) const;
//- For every exposed face (from above getExposedFaces)
// used supplied (existing!) patch
void setLargeCellSubset
(
const labelList& region,
const label currentRegion,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples = true
);
// Access
//- Original mesh
const fvMesh& baseMesh() const
{
return baseMesh_;
}
//- Have subMesh?
bool hasSubMesh() const;
//- Return reference to subset mesh
const fvMesh& subMesh() const;
fvMesh& subMesh();
//- Return point map
const labelList& pointMap() const;
//- Return face map
const labelList& faceMap() const;
//- Return face map with sign to encode flipped faces
const labelList& faceFlipMap() const;
//- Return cell map
const labelList& cellMap() const;
//- Return patch map
const labelList& patchMap() const;
// Field mapping
//- Map volume field
template<class Type>
static tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate
(
const GeometricField<Type, fvPatchField, volMesh>&,
const fvMesh& sMesh,
const labelList& patchMap,
const labelList& cellMap,
const labelList& faceMap
);
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate
(
const GeometricField<Type, fvPatchField, volMesh>&
) const;
//- Map surface field. Optionally negates value if flipping
// a face (from exposing an internal face)
template<class Type>
static tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const fvMesh& sMesh,
const labelList& patchMap,
const labelList& cellMap,
const labelList& faceMap
);
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&
) const;
//- Map point field
template<class Type>
static tmp<GeometricField<Type, pointPatchField, pointMesh>>
interpolate
(
const GeometricField<Type, pointPatchField, pointMesh>&,
const pointMesh& sMesh,
const labelList& patchMap,
const labelList& pointMap
);
template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>>
interpolate
(
const GeometricField<Type, pointPatchField, pointMesh>&
) const;
//- Map dimensioned field
template<class Type>
static tmp<DimensionedField<Type, volMesh>>
interpolate
(
const DimensionedField<Type, volMesh>&,
const fvMesh& sMesh,
const labelList& cellMap
);
template<class Type>
tmp<DimensionedField<Type, volMesh>>
interpolate(const DimensionedField<Type, volMesh>&) const;
}; };
@ -321,6 +475,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "fvMeshSubsetI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository #ifdef NoRepository
#include "fvMeshSubsetInterpolate.C" #include "fvMeshSubsetInterpolate.C"
#endif #endif

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::fvMesh& Foam::fvMeshSubset::baseMesh() const
{
return baseMesh_;
}
inline bool Foam::fvMeshSubset::hasSubMesh() const
{
return fvMeshSubsetPtr_.valid();
}
inline const Foam::fvMesh& Foam::fvMeshSubset::subMesh() const
{
checkCellSubset();
return *fvMeshSubsetPtr_;
}
inline Foam::fvMesh& Foam::fvMeshSubset::subMesh()
{
checkCellSubset();
return *fvMeshSubsetPtr_;
}
inline const Foam::labelList& Foam::fvMeshSubset::pointMap() const
{
checkCellSubset();
return pointMap_;
}
inline const Foam::labelList& Foam::fvMeshSubset::faceMap() const
{
checkCellSubset();
return faceMap_;
}
inline const Foam::labelList& Foam::fvMeshSubset::faceFlipMap() const
{
if (!faceFlipMapPtr_.valid())
{
calcFaceFlipMap();
}
return *faceFlipMapPtr_;
}
inline const Foam::labelList& Foam::fvMeshSubset::cellMap() const
{
checkCellSubset();
return cellMap_;
}
inline const Foam::labelList& Foam::fvMeshSubset::patchMap() const
{
checkCellSubset();
return patchMap_;
}
// ************************************************************************* //

View File

@ -39,7 +39,8 @@ namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> fvMeshSubset::interpolate tmp<GeometricField<Type, fvPatchField, volMesh>>
fvMeshSubset::interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>& vf, const GeometricField<Type, fvPatchField, volMesh>& vf,
const fvMesh& sMesh, const fvMesh& sMesh,
@ -83,33 +84,29 @@ tmp<GeometricField<Type, fvPatchField, volMesh>> fvMeshSubset::interpolate
} }
} }
tmp<GeometricField<Type, fvPatchField, volMesh>> tresF auto tresF = tmp<GeometricField<Type, fvPatchField, volMesh>>::New
( (
new GeometricField<Type, fvPatchField, volMesh> IOobject
( (
IOobject "subset"+vf.name(),
( sMesh.time().timeName(),
"subset"+vf.name(),
sMesh.time().timeName(),
sMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
sMesh, sMesh,
vf.dimensions(), IOobject::NO_READ,
Field<Type>(vf.primitiveField(), cellMap), IOobject::NO_WRITE
patchFields ),
) sMesh,
vf.dimensions(),
Field<Type>(vf.primitiveField(), cellMap),
patchFields
); );
GeometricField<Type, fvPatchField, volMesh>& resF = tresF.ref(); auto& resF = tresF.ref();
resF.oriented() = vf.oriented(); resF.oriented() = vf.oriented();
// 2. Change the fvPatchFields to the correct type using a mapper // 2. Change the fvPatchFields to the correct type using a mapper
// constructor (with reference to the now correct internal field) // constructor (with reference to the now correct internal field)
typename GeometricField<Type, fvPatchField, volMesh>:: auto& bf = resF.boundaryFieldRef();
Boundary& bf = resF.boundaryFieldRef();
forAll(bf, patchi) forAll(bf, patchi)
{ {
@ -158,7 +155,8 @@ tmp<GeometricField<Type, fvPatchField, volMesh>> fvMeshSubset::interpolate
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> fvMeshSubset::interpolate tmp<GeometricField<Type, fvPatchField, volMesh>>
fvMeshSubset::interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>& vf const GeometricField<Type, fvPatchField, volMesh>& vf
) const ) const
@ -175,7 +173,8 @@ tmp<GeometricField<Type, fvPatchField, volMesh>> fvMeshSubset::interpolate
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
fvMeshSubset::interpolate
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& vf, const GeometricField<Type, fvsPatchField, surfaceMesh>& vf,
const fvMesh& sMesh, const fvMesh& sMesh,
@ -220,41 +219,37 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate
} }
// Create the complete field from the pieces // Create the complete field from the pieces
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tresF auto tresF = tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>::New
( (
new GeometricField<Type, fvsPatchField, surfaceMesh> IOobject
( (
IOobject "subset"+vf.name(),
( sMesh.time().timeName(),
"subset"+vf.name(),
sMesh.time().timeName(),
sMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
sMesh, sMesh,
vf.dimensions(), IOobject::NO_READ,
Field<Type> IOobject::NO_WRITE
),
sMesh,
vf.dimensions(),
Field<Type>
(
vf.primitiveField(),
SubList<label>
( (
vf.primitiveField(), faceMap,
SubList<label> sMesh.nInternalFaces()
( )
faceMap, ),
sMesh.nInternalFaces() patchFields
)
),
patchFields
)
); );
GeometricField<Type, fvsPatchField, surfaceMesh>& resF = tresF.ref(); auto& resF = tresF.ref();
resF.oriented() = vf.oriented(); resF.oriented() = vf.oriented();
// 2. Change the fvsPatchFields to the correct type using a mapper // 2. Change the fvsPatchFields to the correct type using a mapper
// constructor (with reference to the now correct internal field) // constructor (with reference to the now correct internal field)
typename GeometricField<Type, fvsPatchField, surfaceMesh>:: auto& bf = resF.boundaryFieldRef();
Boundary& bf = resF.boundaryFieldRef();
forAll(bf, patchi) forAll(bf, patchi)
{ {
@ -341,7 +336,8 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> fvMeshSubset::interpolate tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
fvMeshSubset::interpolate
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& sf const GeometricField<Type, fvsPatchField, surfaceMesh>& sf
) const ) const
@ -403,33 +399,29 @@ fvMeshSubset::interpolate
} }
// Create the complete field from the pieces // Create the complete field from the pieces
tmp<GeometricField<Type, pointPatchField, pointMesh>> tresF auto tresF = tmp<GeometricField<Type, pointPatchField, pointMesh>>::New
( (
new GeometricField<Type, pointPatchField, pointMesh> IOobject
( (
IOobject "subset"+vf.name(),
( sMesh.time().timeName(),
"subset"+vf.name(), sMesh.thisDb(),
sMesh.time().timeName(), IOobject::NO_READ,
sMesh.thisDb(), IOobject::NO_WRITE
IOobject::NO_READ, ),
IOobject::NO_WRITE sMesh,
), vf.dimensions(),
sMesh, Field<Type>(vf.primitiveField(), pointMap),
vf.dimensions(), patchFields
Field<Type>(vf.primitiveField(), pointMap),
patchFields
)
); );
GeometricField<Type, pointPatchField, pointMesh>& resF = tresF.ref(); auto& resF = tresF.ref();
resF.oriented() = vf.oriented(); resF.oriented() = vf.oriented();
// 2. Change the pointPatchFields to the correct type using a mapper // 2. Change the pointPatchFields to the correct type using a mapper
// constructor (with reference to the now correct internal field) // constructor (with reference to the now correct internal field)
typename GeometricField<Type, pointPatchField, pointMesh>:: auto& bf = resF.boundaryFieldRef();
Boundary& bf = resF.boundaryFieldRef();
forAll(bf, patchi) forAll(bf, patchi)
{ {
@ -490,7 +482,8 @@ fvMeshSubset::interpolate
template<class Type> template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>> fvMeshSubset::interpolate tmp<GeometricField<Type, pointPatchField, pointMesh>>
fvMeshSubset::interpolate
( (
const GeometricField<Type, pointPatchField, pointMesh>& sf const GeometricField<Type, pointPatchField, pointMesh>& sf
) const ) const
@ -506,7 +499,8 @@ tmp<GeometricField<Type, pointPatchField, pointMesh>> fvMeshSubset::interpolate
template<class Type> template<class Type>
tmp<DimensionedField<Type, volMesh>> fvMeshSubset::interpolate tmp<DimensionedField<Type, volMesh>>
fvMeshSubset::interpolate
( (
const DimensionedField<Type, volMesh>& df, const DimensionedField<Type, volMesh>& df,
const fvMesh& sMesh, const fvMesh& sMesh,
@ -514,24 +508,20 @@ tmp<DimensionedField<Type, volMesh>> fvMeshSubset::interpolate
) )
{ {
// Create the complete field from the pieces // Create the complete field from the pieces
tmp<DimensionedField<Type, volMesh>> tresF auto tresF = tmp<DimensionedField<Type, volMesh>>::New
( (
new DimensionedField<Type, volMesh> IOobject
( (
IOobject "subset"+df.name(),
( sMesh.time().timeName(),
"subset"+df.name(),
sMesh.time().timeName(),
sMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
sMesh, sMesh,
df.dimensions(), IOobject::NO_READ,
Field<Type>(df, cellMap) IOobject::NO_WRITE
) ),
sMesh,
df.dimensions(),
Field<Type>(df, cellMap)
); );
tresF.ref().oriented() = df.oriented(); tresF.ref().oriented() = df.oriented();
return tresF; return tresF;
@ -539,7 +529,8 @@ tmp<DimensionedField<Type, volMesh>> fvMeshSubset::interpolate
template<class Type> template<class Type>
tmp<DimensionedField<Type, volMesh>> fvMeshSubset::interpolate tmp<DimensionedField<Type, volMesh>>
fvMeshSubset::interpolate
( (
const DimensionedField<Type, volMesh>& df const DimensionedField<Type, volMesh>& df
) const ) const

View File

@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "meshSubsetHelper.H" #include "meshSubsetHelper.H"
#include "cellSet.H" #include "cellSet.H"
#include "cellZone.H" #include "cellZone.H"
#include "Time.H" #include "Time.H"
@ -39,7 +38,8 @@ Foam::meshSubsetHelper::meshSubsetHelper
baseMesh_(baseMesh), baseMesh_(baseMesh),
subsetter_(baseMesh), subsetter_(baseMesh),
type_(NONE), type_(NONE),
name_() name_(),
exposedPatchId_(-1)
{ {
correct(); correct();
} }
@ -49,13 +49,15 @@ Foam::meshSubsetHelper::meshSubsetHelper
( (
fvMesh& baseMesh, fvMesh& baseMesh,
const subsetType type, const subsetType type,
const word& name const word& name,
const label exposedPatchId
) )
: :
baseMesh_(baseMesh), baseMesh_(baseMesh),
subsetter_(baseMesh), subsetter_(baseMesh),
type_(name.empty() ? NONE : type), type_(name.empty() ? NONE : type),
name_(name) name_(name),
exposedPatchId_(exposedPatchId)
{ {
correct(); correct();
} }
@ -72,9 +74,10 @@ void Foam::meshSubsetHelper::correct(bool verbose)
Info<< "Subsetting mesh based on cellSet " << name_ << endl; Info<< "Subsetting mesh based on cellSet " << name_ << endl;
} }
subsetter_.setLargeCellSubset subsetter_.setCellSubset
( (
cellSet(baseMesh_, name_) cellSet(baseMesh_, name_),
exposedPatchId_
); );
} }
else if (type_ == ZONE) else if (type_ == ZONE)
@ -84,8 +87,11 @@ void Foam::meshSubsetHelper::correct(bool verbose)
Info<< "Subsetting mesh based on cellZone " << name_ << endl; Info<< "Subsetting mesh based on cellZone " << name_ << endl;
} }
labelHashSet subset(baseMesh_.cellZones()[name_]); subsetter_.setCellSubset
subsetter_.setLargeCellSubset(subset, 0); (
baseMesh_.cellZones()[name_],
exposedPatchId_
);
} }
} }

View File

@ -39,13 +39,12 @@ SourceFiles
#include "fvMeshSubset.H" #include "fvMeshSubset.H"
#include "zeroGradientFvPatchField.H" #include "zeroGradientFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of classes // Forward declarations
class Time; class Time;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -65,6 +64,8 @@ public:
}; };
private:
// Private data // Private data
//- Reference to mesh //- Reference to mesh
@ -79,6 +80,9 @@ public:
//- Name of current cellSet/cellZone (or empty) //- Name of current cellSet/cellZone (or empty)
const word name_; const word name_;
//- Patch ID for exposed internal faces
const label exposedPatchId_;
// Private Member Functions // Private Member Functions
@ -101,7 +105,8 @@ public:
( (
fvMesh& baseMesh, fvMesh& baseMesh,
const subsetType, const subsetType,
const word& name const word& name,
const label exposedPatchId = -1
); );
@ -121,13 +126,13 @@ public:
return subsetter_; return subsetter_;
} }
//- Check if running a sub-mesh is being used //- Check if a sub-mesh is being used
inline bool useSubMesh() const inline bool useSubMesh() const
{ {
return type_ != NONE; return type_ != NONE;
} }
//- Access either mesh or submesh //- Access either base-mesh or sub-mesh
inline const fvMesh& mesh() const inline const fvMesh& mesh() const
{ {
if (useSubMesh()) if (useSubMesh())
@ -164,7 +169,7 @@ public:
Type, Type,
fvPatchField, fvPatchField,
volMesh volMesh
>::Internal& >::Internal& fld
); );
@ -175,7 +180,7 @@ public:
tmp<GeometricField<Type, fvPatchField, volMesh>> tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>& const GeometricField<Type, fvPatchField, volMesh>& fld
) const; ) const;
@ -189,12 +194,11 @@ public:
Type, Type,
fvPatchField, fvPatchField,
volMesh volMesh
>::Internal& >::Internal& fld
) const; ) const;
//- Map volume field (does in fact do very little interpolation; //- Map volume field. Just forwards to fvMeshSubset
// just copied from fvMeshSubset)
template<class GeoField> template<class GeoField>
tmp<GeoField> interpolate(const GeoField& fld) const; tmp<GeoField> interpolate(const GeoField& fld) const;
}; };

View File

@ -24,11 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "meshSubsetHelper.H" #include "meshSubsetHelper.H"
#include "fvMesh.H"
#include "volFields.H" #include "volFields.H"
#include "globalIndex.H"
#include "zeroGradientFvPatchField.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
@ -49,20 +45,18 @@ Foam::meshSubsetHelper::zeroGradientField
io.writeOpt() = IOobject::NO_WRITE; io.writeOpt() = IOobject::NO_WRITE;
io.registerObject() = false; io.registerObject() = false;
tmp<GeometricField<Type, fvPatchField, volMesh>> tvf auto tfield = tmp<GeometricField<Type, fvPatchField, volMesh>>::New
( (
new GeometricField<Type, fvPatchField, volMesh> io,
( df.mesh(),
io, dimensioned<Type>(df.dimensions(), Zero),
df.mesh(), zeroGradientFvPatchField<Type>::typeName
dimensioned<Type>(df.dimensions(), Zero),
zeroGradientFvPatchField<Type>::typeName
)
); );
tvf.ref().primitiveFieldRef() = df; tfield.ref().primitiveFieldRef() = df;
tvf.ref().correctBoundaryConditions(); tfield.ref().oriented() = df.oriented();
tfield.ref().correctBoundaryConditions();
return tvf; return tfield;
} }
@ -75,18 +69,14 @@ Foam::meshSubsetHelper::interpolate
{ {
if (subsetter_.hasSubMesh()) if (subsetter_.hasSubMesh())
{ {
tmp<GeometricField<Type, fvPatchField, volMesh>> tfld auto tfield(subsetter_.interpolate(vf));
(
subsetter_.interpolate(vf) tfield.ref().checkOut();
); tfield.ref().rename(vf.name());
tfld.ref().checkOut(); return tfield;
tfld.ref().rename(vf.name());
return tfld;
}
else
{
return vf;
} }
return vf;
} }
@ -102,17 +92,14 @@ Foam::meshSubsetHelper::interpolate
>::Internal& df >::Internal& df
) const ) const
{ {
tmp<GeometricField<Type, fvPatchField, volMesh>> tvf = auto tfield = zeroGradientField<Type>(df);
zeroGradientField<Type>(df);
if (subsetter_.hasSubMesh()) if (subsetter_.hasSubMesh())
{ {
return interpolate<Type>(tvf()); return interpolate<Type>(tfield());
}
else
{
return tvf;
} }
return tfield;
} }
@ -125,15 +112,13 @@ Foam::meshSubsetHelper::interpolate
{ {
if (subsetter_.hasSubMesh()) if (subsetter_.hasSubMesh())
{ {
tmp<GeoField> subFld = subsetter_.interpolate(fld); tmp<GeoField> tfield = subsetter_.interpolate(fld);
subFld.ref().checkOut(); tfield.ref().checkOut();
subFld.ref().rename(fld.name()); tfield.ref().rename(fld.name());
return subFld; return tfield;
}
else
{
return fld;
} }
return fld;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,6 +39,7 @@ License
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "CompactListList.H" #include "CompactListList.H"
#include "HashOps.H"
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -184,23 +185,6 @@ void Foam::polyTopoChange::countMap
} }
Foam::labelHashSet Foam::polyTopoChange::getSetIndices
(
const bitSet& lst
)
{
labelHashSet values(lst.count());
forAll(lst, i)
{
if (lst[i])
{
values.insert(i);
}
}
return values;
}
void Foam::polyTopoChange::writeMeshStats(const polyMesh& mesh, Ostream& os) void Foam::polyTopoChange::writeMeshStats(const polyMesh& mesh, Ostream& os)
{ {
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -3192,7 +3176,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh
labelListList faceZonePointMap(mesh.faceZones().size()); labelListList faceZonePointMap(mesh.faceZones().size());
calcFaceZonePointMap(mesh, oldFaceZoneMeshPointMaps, faceZonePointMap); calcFaceZonePointMap(mesh, oldFaceZoneMeshPointMaps, faceZonePointMap);
labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_)); labelHashSet flipFaceFluxSet(HashSetOps::used(flipFaceFlux_));
return autoPtr<mapPolyMesh>::New return autoPtr<mapPolyMesh>::New
( (
@ -3483,7 +3467,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
writeMeshStats(mesh, Pout); writeMeshStats(mesh, Pout);
} }
labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_)); labelHashSet flipFaceFluxSet(HashSetOps::used(flipFaceFlux_));
return autoPtr<mapPolyMesh>::New return autoPtr<mapPolyMesh>::New
( (

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -76,7 +76,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes // Forward declarations
class face; class face;
class primitiveMesh; class primitiveMesh;
class polyMesh; class polyMesh;
@ -240,9 +240,6 @@ class polyTopoChange
labelList& elems labelList& elems
); );
//- Get all set elements as a labelHashSet
static labelHashSet getSetIndices(const bitSet& lst);
//- Count number of added and removed quantities from maps. //- Count number of added and removed quantities from maps.
static void countMap static void countMap
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2014-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2014-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -721,12 +721,16 @@ bool Foam::cellCellStencils::cellVolumeWeight::update()
PtrList<fvMeshSubset> meshParts(nZones); PtrList<fvMeshSubset> meshParts(nZones);
Info<< incrIndent; Info<< incrIndent;
forAll(nCellsPerZone, zoneI) forAll(meshParts, zonei)
{ {
Info<< indent<< "zone:" << zoneI << " nCells:" << nCellsPerZone[zoneI] Info<< indent<< "zone:" << zonei << " nCells:"
<< endl; << nCellsPerZone[zonei] << nl;
meshParts.set(zoneI, new fvMeshSubset(mesh_));
meshParts[zoneI].setLargeCellSubset(zoneID, zoneI); meshParts.set
(
zonei,
new fvMeshSubset(mesh_, zonei, zoneID)
);
} }
Info<< decrIndent; Info<< decrIndent;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -1657,11 +1657,14 @@ bool Foam::cellCellStencils::inverseDistance::update()
List<treeBoundBoxList> procBb(Pstream::nProcs()); List<treeBoundBoxList> procBb(Pstream::nProcs());
procBb[Pstream::myProcNo()].setSize(nZones); procBb[Pstream::myProcNo()].setSize(nZones);
forAll(nCellsPerZone, zoneI) forAll(meshParts, zonei)
{ {
meshParts.set(zoneI, new fvMeshSubset(mesh_)); meshParts.set
meshParts[zoneI].setLargeCellSubset(zoneID, zoneI); (
const fvMesh& subMesh = meshParts[zoneI].subMesh(); zonei,
new fvMeshSubset(mesh_, zonei, zoneID)
);
const fvMesh& subMesh = meshParts[zonei].subMesh();
// Trigger early evaluation of mesh dimension (in case there are // Trigger early evaluation of mesh dimension (in case there are
// zero cells in mesh) // zero cells in mesh)
@ -1669,19 +1672,19 @@ bool Foam::cellCellStencils::inverseDistance::update()
if (subMesh.nPoints()) if (subMesh.nPoints())
{ {
procBb[Pstream::myProcNo()][zoneI] = procBb[Pstream::myProcNo()][zonei] =
treeBoundBox(subMesh.points()); treeBoundBox(subMesh.points());
procBb[Pstream::myProcNo()][zoneI].inflate(1e-6); procBb[Pstream::myProcNo()][zonei].inflate(1e-6);
} }
else else
{ {
// No part of zone on this processor. Make up bb. // No part of zone on this processor. Make up bb.
procBb[Pstream::myProcNo()][zoneI] = treeBoundBox procBb[Pstream::myProcNo()][zonei] = treeBoundBox
( (
allBb.min() - 2*allBb.span(), allBb.min() - 2*allBb.span(),
allBb.min() - allBb.span() allBb.min() - allBb.span()
); );
procBb[Pstream::myProcNo()][zoneI].inflate(1e-6); procBb[Pstream::myProcNo()][zonei].inflate(1e-6);
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -462,10 +462,14 @@ Foam::cellCellStencils::trackingInverseDistance::trackingInverseDistance
meshParts_.setSize(nZones); meshParts_.setSize(nZones);
forAll(meshParts_, zonei) forAll(meshParts_, zonei)
{ {
meshParts_.set(zonei, new fvMeshSubset(mesh_)); meshParts_.set
meshParts_[zonei].setLargeCellSubset(zoneID, zonei); (
// Trigger early evaluation of mesh dimension (in case there are zonei,
// locally zero cells in mesh) new fvMeshSubset(mesh_, zonei, zoneID)
);
// Trigger early evaluation of mesh dimension
// (in case there are locally zero cells in mesh)
(void)meshParts_[zonei].subMesh().nGeometricD(); (void)meshParts_[zonei].subMesh().nGeometricD();
} }

View File

@ -89,8 +89,11 @@ Foam::labelList Foam::structuredDecomp::decompose
} }
// Subset the layer of cells next to the patch // Subset the layer of cells next to the patch
fvMeshSubset subsetter(dynamic_cast<const fvMesh&>(mesh)); fvMeshSubset subsetter
subsetter.setLargeCellSubset(patchCells); (
dynamic_cast<const fvMesh&>(mesh),
patchCells
);
const fvMesh& subMesh = subsetter.subMesh(); const fvMesh& subMesh = subsetter.subMesh();
pointField subCc(cc, subsetter.cellMap()); pointField subCc(cc, subsetter.cellMap());
scalarField subWeights(cWeights, subsetter.cellMap()); scalarField subWeights(cWeights, subsetter.cellMap());

View File

@ -179,8 +179,11 @@ Foam::labelList Foam::structuredRenumber::renumber
// Subset the layer of cells next to the patch // Subset the layer of cells next to the patch
{ {
fvMeshSubset subsetter(dynamic_cast<const fvMesh&>(mesh)); fvMeshSubset subsetter
subsetter.setLargeCellSubset(patchCells); (
dynamic_cast<const fvMesh&>(mesh),
patchCells
);
const fvMesh& subMesh = subsetter.subMesh(); const fvMesh& subMesh = subsetter.subMesh();
pointField subPoints(points, subsetter.cellMap()); pointField subPoints(points, subsetter.cellMap());

View File

@ -376,14 +376,16 @@ bool Foam::sampledIsoSurface::updateGeometry() const
<< patches[exposedPatchi].name() << endl; << patches[exposedPatchi].name() << endl;
} }
// Remove old mesh if any
subMeshPtr_.clear();
subMeshPtr_.reset subMeshPtr_.reset
( (
new fvMeshSubset(fvm) new fvMeshSubset
); (
subMeshPtr_().setLargeCellSubset fvm,
( mesh().cellZones()[zoneID_.index()],
labelHashSet(mesh().cellZones()[zoneID_.index()]), exposedPatchi
exposedPatchi )
); );
} }

View File

@ -78,12 +78,12 @@ void Foam::sampledCuttingPlane::createGeometry()
subMeshPtr_.reset subMeshPtr_.reset
( (
new fvMeshSubset(static_cast<const fvMesh&>(mesh())) new fvMeshSubset
); (
subMeshPtr_().setLargeCellSubset static_cast<const fvMesh&>(mesh()),
( mesh().cellZones()[zoneID_.index()],
labelHashSet(mesh().cellZones()[zoneID_.index()]), exposedPatchi
exposedPatchi )
); );
} }