ENH: relocate/refactor fvMeshSubset

- direct construct and reset method for creating a zero-sized (dummy)
  subMesh. Has no exposed faces and no parallel synchronization
  required.

- core mapping (interpolate) functionality with direct handling
  of subsetting in fvMeshSubset (src/finiteVolume).
  Does not use dynamicMesh topology changes

- two-step subsetting as fvMeshSubsetter (src/dynamicMesh).
  Does use dynamicMesh topology changes.
  This is apparently only needed by the subsetMesh application itself.

DEFEATURE: remove deprecated setLargeCellSubset() method

- was deprecated JUL-2018, now removed (see issue #951)
This commit is contained in:
Mark Olesen 2022-04-07 11:25:57 +02:00
parent 6e21d6f78c
commit cf7dbf4d42
24 changed files with 846 additions and 579 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,7 +42,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvMeshSubset.H"
#include "fvMeshSubsetter.H" // Not fvMeshSubset (need two-step subsetting)
#include "argList.H"
#include "IOobjectList.H"
#include "volFields.H"
@ -517,8 +517,8 @@ int main(int argc, char *argv[])
}
// Mesh subsetting engine
fvMeshSubset subsetter(mesh);
// Two-step mesh subsetting engine
fvMeshSubsetter subsetter(mesh);
{
bitSet selectedCells =
@ -530,13 +530,8 @@ int main(int argc, char *argv[])
if (exposedPatchIDs.size() == 1)
{
// Single patch for exposed faces
subsetter.setCellSubset
(
selectedCells,
exposedPatchIDs.first(),
true
);
// Single patch for exposed faces (syncPar)
subsetter.reset(selectedCells, exposedPatchIDs.first(), true);
}
else
{
@ -545,7 +540,7 @@ int main(int argc, char *argv[])
labelList exposedFaces
(
subsetter.getExposedFaces(selectedCells, true)
subsetter.getExposedFaces(selectedCells, true) // syncPar
);
subsetter.setCellSubset
@ -553,7 +548,7 @@ int main(int argc, char *argv[])
selectedCells,
exposedFaces,
labelUIndList(nearestExposedPatch, exposedFaces)(),
true
true // syncPar
);
}

View File

@ -1031,10 +1031,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
// Subset 0 cells, no parallel comms.
// This is used to create zero-sized fields.
subsetterPtr.reset
(
new fvMeshSubset(mesh, bitSet(), nonProcI, false)
);
subsetterPtr.reset(new fvMeshSubset(mesh, zero{}));
}

View File

@ -86,8 +86,7 @@ polyMeshAdder/polyMeshAdder.C
fvMeshTools/fvMeshTools.C
fvMeshSubset/fvMeshSubset.C
fvMeshSubsetProxy/fvMeshSubsetProxy.C
fvMeshSubset/fvMeshSubsetter.C
motionSmoother/motionSmoother.C
motionSmoother/motionSmootherAlgo.C

View File

@ -28,6 +28,7 @@ License
#include "fvMeshDistribute.H"
#include "fvMeshAdder.H"
#include "fvMeshSubset.H"
#include "faceCoupleInfo.H"
#include "processorFvPatchField.H"
#include "processorFvsPatchField.H"

View File

@ -0,0 +1,201 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
\*---------------------------------------------------------------------------*/
#include "fvMeshSubsetter.H"
#include "mapPolyMesh.H"
#include "polyTopoChange.H"
#include "removeCells.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Helper: extract cells-to-remove from cells-to-keep
static bitSet invertCellSelection
(
const label nCells,
const bitSet& selectedCells
)
{
// Work on a copy
bitSet cellsToRemove(selectedCells);
// Ensure we have the full range
cellsToRemove.resize(nCells, false);
// Invert the selection
cellsToRemove.flip();
return cellsToRemove;
}
// Helper: extract cells-to-remove from cells-to-keep
static inline bitSet invertCellSelection
(
const label nCells,
const label regioni,
const labelUList& regions
)
{
return BitSetOps::create
(
nCells,
regioni,
regions,
false // on=false: invert return cells to remove
);
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fvMeshSubsetter::removeCellsImpl
(
const bitSet& cellsToRemove,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncPar
)
{
// Clear out all existing maps
clear();
// Mesh changing engine.
polyTopoChange meshMod(baseMesh());
removeCells cellRemover(baseMesh(), syncPar);
cellRemover.setRefinement
(
cellsToRemove,
exposedFaces,
patchIDs,
meshMod
);
// Create mesh, return map from old to new mesh.
autoPtr<fvMesh> newMeshPtr;
autoPtr<mapPolyMesh> map = meshMod.makeMesh
(
newMeshPtr,
IOobject
(
baseMesh().name(),
baseMesh().time().timeName(),
baseMesh().time(),
IOobject::READ_IF_PRESENT, // read fv* if present
IOobject::NO_WRITE
),
baseMesh(),
syncPar
);
reset
(
std::move(newMeshPtr),
labelList(map().pointMap()),
labelList(map().faceMap()),
labelList(map().cellMap()),
identity(baseMesh().boundaryMesh().size())
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::fvMeshSubsetter::getExposedFaces
(
const bitSet& selectedCells,
const bool syncPar
) const
{
return
Foam::removeCells(baseMesh(), syncPar).getExposedFaces
(
invertCellSelection(baseMesh().nCells(), selectedCells)
);
}
Foam::labelList Foam::fvMeshSubsetter::getExposedFaces
(
const label regioni,
const labelUList& regions,
const bool syncPar
) const
{
return
Foam::removeCells(baseMesh(), syncPar).getExposedFaces
(
invertCellSelection(baseMesh().nCells(), regioni, regions)
);
}
void Foam::fvMeshSubsetter::setCellSubset
(
const bitSet& selectedCells,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncPar
)
{
removeCellsImpl
(
invertCellSelection(baseMesh().nCells(), selectedCells),
exposedFaces,
patchIDs,
syncPar
);
}
void Foam::fvMeshSubsetter::setCellSubset
(
const label regioni,
const labelList& regions,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples
)
{
removeCellsImpl
(
invertCellSelection(baseMesh().nCells(), regioni, regions),
exposedFaces,
patchIDs,
syncCouples
);
}
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Class
Foam::fvMeshSubsetter
Description
Extends Foam::fvMeshSubset with two-step subsetting
(uses polyTopoChange modification).
SourceFiles
fvMeshSubsetter.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_fvMeshSubsetter_H
#define Foam_fvMeshSubsetter_H
#include "fvMeshSubset.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fvMeshSubsetter Declaration
\*---------------------------------------------------------------------------*/
class fvMeshSubsetter
:
public fvMeshSubset
{
// Private Member Functions
//- Forwarding to Foam::removeCells
void removeCellsImpl
(
const bitSet& cellsToRemove,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncPar
);
//- No copy construct
fvMeshSubsetter(const fvMeshSubsetter&) = delete;
//- No copy assignment
void operator=(const fvMeshSubset&) = delete;
public:
// Constructors
//- Inherit constructors from fvMeshSubset
using fvMeshSubset::fvMeshSubset;
// Member Functions
//- Inherit all one-step subsetting
using fvMeshSubset::setCellSubset;
// 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 syncPar = 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 syncPar = true
) const;
//- For every exposed face (from above getExposedFaces)
// Uses supplied (existing!) patches
void setCellSubset
(
const bitSet& selectedCells,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncPar = true
);
//- For every exposed face (from above getExposedFaces)
// Uses supplied (existing!) patches
void setCellSubset
(
const label regioni,
const labelList& regions,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncPar = true
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -71,20 +71,7 @@ inline void decrCount(const Foam::labelUList& list, Foam::labelList& counter)
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::removeCells::removeCells
(
const polyMesh& mesh
)
:
removeCells(mesh, true)
{}
Foam::removeCells::removeCells
(
const polyMesh& mesh,
const bool syncPar
)
Foam::removeCells::removeCells(const polyMesh& mesh, const bool syncPar)
:
mesh_(mesh),
syncPar_(syncPar)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,8 +40,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef removeCells_H
#define removeCells_H
#ifndef Foam_removeCells_H
#define Foam_removeCells_H
#include "labelList.H"
#include "typeInfo.H"
@ -63,7 +63,7 @@ class mapPolyMesh;
class removeCells
{
// Private data
// Private Data
//- Reference to mesh
const polyMesh& mesh_;
@ -71,6 +71,7 @@ class removeCells
//- Whether or not to synchronize parallel case.
const bool syncPar_;
public:
//- Runtime type information
@ -79,11 +80,8 @@ public:
// Constructors
//- Construct from mesh. With parallel synchronization.
explicit removeCells(const polyMesh& mesh);
//- Construct from mesh, optionally with parallel synchronization.
removeCells(const polyMesh& mesh, const bool syncPar);
//- Construct from mesh. Parallel synchronized by default
explicit removeCells(const polyMesh& mesh, const bool syncPar = true);
//- Destructor

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,7 +95,7 @@ bool Foam::Detail::zoneSubSet::correct()
<< endl;
}
subsetter_.setCellSubset(selectedCells.addressing());
subsetter_.reset(selectedCells.addressing());
return true;
}

View File

@ -62,8 +62,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef zoneSubSet_H
#define zoneSubSet_H
#ifndef Foam_zoneSubSet_H
#define Foam_zoneSubSet_H
#include "fvMeshSubset.H"

View File

@ -12,6 +12,9 @@ $(fvGeometryScheme)/stabilised/stabilisedFvGeometryScheme.C
surfaceInterpolation = interpolation/surfaceInterpolation
$(surfaceInterpolation)/surfaceInterpolation/surfaceInterpolation.C
fvMesh/fvMeshSubset/fvMeshSubset.C
fvMesh/fvMeshSubset/fvMeshSubsetProxy.C
fvMesh/singleCellFvMesh/singleCellFvMesh.C
fvMesh/simplifiedFvMesh/simplifiedFvMesh/simplifiedFvMesh.C

View File

@ -1,12 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lOpenFOAM \
-lfileFormats \
-lsurfMesh \
-lmeshTools

View File

@ -27,15 +27,15 @@ License
\*---------------------------------------------------------------------------*/
#include "fvMeshSubset.H"
#include "boolList.H"
#include "BitOps.H"
#include "pointIndList.H"
#include "Pstream.H"
#include "emptyPolyPatch.H"
#include "cyclicPolyPatch.H"
#include "removeCells.H"
#include "polyTopoChange.H"
#include "mapPolyMesh.H"
#include "emptyPolyPatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::word Foam::fvMeshSubset::exposedPatchName("oldInternalFaces");
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
@ -58,20 +58,63 @@ inline void markUsed
} // End anonymous namespace
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::word Foam::fvMeshSubset::exposedPatchName("oldInternalFaces");
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::fvMeshSubset::checkCellSubset() const
namespace Foam
{
if (!fvMeshSubsetPtr_)
// Perform a subset of a subset
static labelList subsetSubset
(
const label nElems,
const labelUList& selectedElements, // First subset
const labelUList& subsetMap // Subset within first subset
)
{
if (selectedElements.empty() || subsetMap.empty())
{
// Trivial case
return labelList();
}
// Mark selected elements.
const bitSet selected(nElems, selectedElements);
// Count subset of selected elements
label n = 0;
forAll(subsetMap, i)
{
if (selected[subsetMap[i]])
{
++n;
}
}
// Collect selected elements
labelList subsettedElements(n);
n = 0;
forAll(subsetMap, i)
{
if (selected[subsetMap[i]])
{
subsettedElements[n] = i;
++n;
}
}
return subsettedElements;
}
} // End namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::fvMeshSubset::checkHasSubMesh() const
{
if (!subMeshPtr_)
{
FatalErrorInFunction
<< "setCellSubset()" << nl
<< "before attempting to access subset data"
<< "Mesh is not subsetted!" << nl
<< abort(FatalError);
return false;
@ -118,7 +161,7 @@ void Foam::fvMeshSubset::calcFaceFlipMap() const
void Foam::fvMeshSubset::doCoupledPatches
(
const bool syncPar,
labelList& nCellsUsingFace
labelUList& nCellsUsingFace
) const
{
// Synchronize facesToSubset on both sides of coupled patches.
@ -186,8 +229,8 @@ void Foam::fvMeshSubset::doCoupledPatches
&& nbrCellsUsingFace[i] == 0
)
{
// Face's neighbour is no longer there. Mark face
// off as coupled
// Face's neighbour is no longer there.
// Mark face off as coupled
nCellsUsingFace[pp.start()+i] = 3;
++nUncoupled;
}
@ -229,7 +272,7 @@ void Foam::fvMeshSubset::doCoupledPatches
reduce(nUncoupled, sumOp<label>());
}
if (nUncoupled > 0)
if (nUncoupled)
{
Info<< "Uncoupled " << nUncoupled << " faces on coupled patches. "
<< "(processorPolyPatch, cyclicPolyPatch)" << endl;
@ -237,107 +280,32 @@ void Foam::fvMeshSubset::doCoupledPatches
}
void Foam::fvMeshSubset::removeCellsImpl
(
const bitSet& cellsToRemove,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples
)
{
// Mesh changing engine.
polyTopoChange meshMod(baseMesh());
removeCells cellRemover(baseMesh(), syncCouples);
cellRemover.setRefinement
(
cellsToRemove,
exposedFaces,
patchIDs,
meshMod
);
// Create mesh, return map from old to new mesh.
autoPtr<mapPolyMesh> map = meshMod.makeMesh
(
fvMeshSubsetPtr_,
IOobject
(
baseMesh().name(),
baseMesh().time().timeName(),
baseMesh().time(),
IOobject::READ_IF_PRESENT, // read fv* if present
IOobject::NO_WRITE
),
baseMesh(),
syncCouples
);
pointMap_ = map().pointMap();
faceMap_ = map().faceMap();
cellMap_ = map().cellMap();
patchMap_ = identity(baseMesh().boundaryMesh().size());
}
Foam::labelList Foam::fvMeshSubset::subsetSubset
(
const label nElems,
const labelUList& selectedElements,
const labelUList& subsetMap
)
{
// Mark selected elements.
const bitSet selected(nElems, selectedElements);
// Count subset of selected elements
label n = 0;
forAll(subsetMap, i)
{
if (selected[subsetMap[i]])
{
++n;
}
}
// Collect selected elements
labelList subsettedElements(n);
n = 0;
forAll(subsetMap, i)
{
if (selected[subsetMap[i]])
{
subsettedElements[n] = i;
++n;
}
}
return subsettedElements;
}
void Foam::fvMeshSubset::subsetZones()
{
// Keep all zones, even if zero size.
#ifdef FULLDEBUG
checkHasSubMesh();
#endif
auto& newSubMesh = subMeshPtr_();
// PointZones
const pointZoneMesh& pointZones = baseMesh().pointZones();
List<pointZone*> pZonePtrs(pointZones.size());
List<pointZone*> pZones(pointZones.size());
forAll(pointZones, zonei)
{
const pointZone& pz = pointZones[zonei];
pZonePtrs[zonei] = new pointZone
pZones[zonei] = new pointZone
(
pz.name(),
subsetSubset(baseMesh().nPoints(), pz, pointMap()),
zonei,
fvMeshSubsetPtr_().pointZones()
newSubMesh.pointZones()
);
}
@ -348,7 +316,7 @@ void Foam::fvMeshSubset::subsetZones()
const faceZoneMesh& faceZones = baseMesh().faceZones();
List<faceZone*> fZonePtrs(faceZones.size());
List<faceZone*> fZones(faceZones.size());
forAll(faceZones, zonei)
{
@ -361,14 +329,7 @@ void Foam::fvMeshSubset::subsetZones()
labelList zone(baseMesh().nFaces(), Zero);
forAll(fz, j)
{
if (fz.flipMap()[j])
{
zone[fz[j]] = 1;
}
else
{
zone[fz[j]] = -1;
}
zone[fz[j]] = (fz.flipMap()[j] ? 1 : -1);
}
// Select faces
@ -400,72 +361,38 @@ void Foam::fvMeshSubset::subsetZones()
}
}
fZonePtrs[zonei] = new faceZone
fZones[zonei] = new faceZone
(
fz.name(),
subAddressing,
subFlipStatus,
zonei,
fvMeshSubsetPtr_().faceZones()
newSubMesh.faceZones()
);
}
// Cell Zones
const cellZoneMesh& cellZones = baseMesh().cellZones();
List<cellZone*> cZonePtrs(cellZones.size());
List<cellZone*> cZones(cellZones.size());
forAll(cellZones, zonei)
{
const cellZone& cz = cellZones[zonei];
cZonePtrs[zonei] = new cellZone
cZones[zonei] = new cellZone
(
cz.name(),
subsetSubset(baseMesh().nCells(), cz, cellMap()),
zonei,
fvMeshSubsetPtr_().cellZones()
newSubMesh.cellZones()
);
}
// Add the zones
fvMeshSubsetPtr_().addZones(pZonePtrs, fZonePtrs, cZonePtrs);
}
Foam::bitSet Foam::fvMeshSubset::getCellsToRemove
(
const bitSet& selectedCells
) const
{
// Work on a copy
bitSet cellsToRemove(selectedCells);
// Ensure we have the full range
cellsToRemove.resize(baseMesh().nCells(), false);
// Invert the selection
cellsToRemove.flip();
return cellsToRemove;
}
Foam::bitSet Foam::fvMeshSubset::getCellsToRemove
(
const label regioni,
const labelUList& regions
) const
{
return BitSetOps::create
(
baseMesh().nCells(),
regioni,
regions,
false // on=false: invert return cells to remove
);
newSubMesh.addZones(pZones, fZones, cZones);
}
@ -474,7 +401,7 @@ Foam::bitSet Foam::fvMeshSubset::getCellsToRemove
Foam::fvMeshSubset::fvMeshSubset(const fvMesh& baseMesh)
:
baseMesh_(baseMesh),
fvMeshSubsetPtr_(nullptr),
subMeshPtr_(nullptr),
faceFlipMapPtr_(nullptr),
pointMap_(),
faceMap_(),
@ -483,31 +410,25 @@ Foam::fvMeshSubset::fvMeshSubset(const fvMesh& baseMesh)
{}
Foam::fvMeshSubset::fvMeshSubset
(
const fvMesh& baseMesh,
const bitSet& selectedCells,
const label patchID,
const bool syncCouples
)
Foam::fvMeshSubset::fvMeshSubset(const fvMesh& baseMesh, const Foam::zero)
:
fvMeshSubset(baseMesh)
{
setCellSubset(selectedCells, patchID, syncCouples);
reset(Foam::zero{});
}
Foam::fvMeshSubset::fvMeshSubset
(
const fvMesh& baseMesh,
const labelHashSet& selectedCells,
const bitSet& selectedCells,
const label patchID,
const bool syncCouples
const bool syncPar
)
:
fvMeshSubset(baseMesh)
{
setCellSubset(selectedCells, patchID, syncCouples);
reset(selectedCells, patchID, syncPar);
}
@ -516,12 +437,26 @@ Foam::fvMeshSubset::fvMeshSubset
const fvMesh& baseMesh,
const labelUList& selectedCells,
const label patchID,
const bool syncCouples
const bool syncPar
)
:
fvMeshSubset(baseMesh)
{
setCellSubset(selectedCells, patchID, syncCouples);
reset(selectedCells, patchID, syncPar);
}
Foam::fvMeshSubset::fvMeshSubset
(
const fvMesh& baseMesh,
const labelHashSet& selectedCells,
const label patchID,
const bool syncPar
)
:
fvMeshSubset(baseMesh)
{
reset(selectedCells, patchID, syncPar);
}
@ -531,12 +466,12 @@ Foam::fvMeshSubset::fvMeshSubset
const label regioni,
const labelUList& regions,
const label patchID,
const bool syncCouples
const bool syncPar
)
:
fvMeshSubset(baseMesh)
{
setCellSubset(regioni, regions, patchID, syncCouples);
reset(regioni, regions, patchID, syncPar);
}
@ -544,7 +479,7 @@ Foam::fvMeshSubset::fvMeshSubset
void Foam::fvMeshSubset::clear()
{
fvMeshSubsetPtr_.reset(nullptr);
subMeshPtr_.reset(nullptr);
faceFlipMapPtr_.reset(nullptr);
pointMap_.clear();
@ -554,13 +489,104 @@ void Foam::fvMeshSubset::clear()
}
void Foam::fvMeshSubset::setCellSubset
void Foam::fvMeshSubset::reset()
{
clear();
}
void Foam::fvMeshSubset::reset
(
autoPtr<fvMesh>&& subMeshPtr,
labelList&& pointMap,
labelList&& faceMap,
labelList&& cellMap,
labelList&& patchMap
)
{
subMeshPtr_.reset(std::move(subMeshPtr));
faceFlipMapPtr_.reset(nullptr);
pointMap_ = std::move(pointMap);
faceMap_ = std::move(faceMap);
cellMap_ = std::move(cellMap);
patchMap_ = std::move(patchMap);
// Sanity
if (!subMeshPtr_)
{
clear();
}
}
void Foam::fvMeshSubset::reset(const Foam::zero)
{
clear();
// Create zero-sized subMesh
subMeshPtr_.reset
(
new fvMesh
(
IOobject
(
baseMesh_.name(),
baseMesh_.time().timeName(),
baseMesh_.time(),
IOobject::READ_IF_PRESENT, // Read fv* if present
IOobject::NO_WRITE
),
Foam::zero{} // zero-sized
// Uses syncPar (bounds) - should generally be OK
)
);
auto& newSubMesh = subMeshPtr_();
// Clone non-processor patches
{
const polyBoundaryMesh& oldBoundary = baseMesh_.boundaryMesh();
const polyBoundaryMesh& newBoundary = newSubMesh.boundaryMesh();
polyPatchList newPatches(oldBoundary.nNonProcessor());
patchMap_ = identity(newPatches.size());
forAll(newPatches, patchi)
{
newPatches.set
(
patchi,
oldBoundary[patchi].clone
(
newBoundary,
patchi,
0, // patch size
0 // patch start
)
);
}
newSubMesh.addFvPatches(newPatches);
}
// Add the zones
subsetZones();
}
void Foam::fvMeshSubset::reset
(
const bitSet& selectedCells,
const label patchID,
const bool syncPar
)
{
// Clear all old maps and pointers
clear();
const cellList& oldCells = baseMesh().cells();
const faceList& oldFaces = baseMesh().faces();
const pointField& oldPoints = baseMesh().points();
@ -587,9 +613,6 @@ void Foam::fvMeshSubset::setCellSubset
<< abort(FatalError);
}
// Clear all old maps and pointers
clear();
// The selected cells - sorted in ascending order
cellMap_ = selectedCells.sortedToc();
@ -623,6 +646,7 @@ void Foam::fvMeshSubset::setCellSubset
labelList nCellsUsingFace(oldFaces.size(), Zero);
label nFacesInSet = 0;
forAll(oldFaces, oldFacei)
{
bool faceUsed = false;
@ -648,7 +672,7 @@ void Foam::fvMeshSubset::setCellSubset
++nFacesInSet;
}
}
faceMap_.setSize(nFacesInSet);
faceMap_.resize(nFacesInSet);
// Handle coupled faces. Modifies patch faces to be uncoupled to 3.
doCoupledPatches(syncPar, nCellsUsingFace);
@ -878,7 +902,7 @@ void Foam::fvMeshSubset::setCellSubset
//
// Create new points
//
pointField newPoints(pointUIndList(oldPoints, pointMap_));
pointField newPoints(oldPoints, pointMap_);
//
@ -972,7 +996,7 @@ void Foam::fvMeshSubset::setCellSubset
// surfaceInterpolation cannot find its fvSchemes.
// It will try to read, for example. "system/region0SubSet/fvSchemes"
//
fvMeshSubsetPtr_ = autoPtr<fvMesh>::New
subMeshPtr_ = autoPtr<fvMesh>::New
(
IOobject
(
@ -991,8 +1015,8 @@ void Foam::fvMeshSubset::setCellSubset
// Add old patches
List<polyPatch*> newBoundary(nbSize);
patchMap_.setSize(nbSize);
polyPatchList newBoundary(nbSize);
patchMap_.resize(nbSize);
label nNewPatches = 0;
label patchStart = nInternalFaces;
@ -1065,24 +1089,32 @@ void Foam::fvMeshSubset::setCellSubset
map[patchFacei] = oldPatches[oldPatchi].whichFace(oldFacei);
}
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
newBoundary.set
(
fvMeshSubsetPtr_().boundaryMesh(),
nNewPatches,
map,
patchStart
).ptr();
oldPatches[oldPatchi].clone
(
subMeshPtr_().boundaryMesh(),
nNewPatches,
map,
patchStart
)
);
}
else
{
// Clone (even if 0 size)
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
newBoundary.set
(
fvMeshSubsetPtr_().boundaryMesh(),
nNewPatches,
newSize,
patchStart
).ptr();
oldPatches[oldPatchi].clone
(
subMeshPtr_().boundaryMesh(),
nNewPatches,
newSize,
patchStart
)
);
}
patchStart += newSize;
@ -1104,14 +1136,18 @@ void Foam::fvMeshSubset::setCellSubset
// Newly created patch so is at end. Check if any faces in it.
if (oldInternalSize > 0)
{
newBoundary[nNewPatches] = new emptyPolyPatch
newBoundary.set
(
exposedPatchName,
boundaryPatchSizes[oldInternalPatchID],
patchStart,
nNewPatches,
fvMeshSubsetPtr_().boundaryMesh(),
emptyPolyPatch::typeName
new emptyPolyPatch
(
exposedPatchName,
boundaryPatchSizes[oldInternalPatchID],
patchStart,
nNewPatches,
subMeshPtr_().boundaryMesh(),
emptyPolyPatch::typeName
)
);
//Pout<< " " << exposedPatchName << " : "
@ -1148,24 +1184,32 @@ void Foam::fvMeshSubset::setCellSubset
map[patchFacei] = oldPatches[oldPatchi].whichFace(oldFacei);
}
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
newBoundary.set
(
fvMeshSubsetPtr_().boundaryMesh(),
nNewPatches,
map,
patchStart
).ptr();
oldPatches[oldPatchi].clone
(
subMeshPtr_().boundaryMesh(),
nNewPatches,
map,
patchStart
)
);
}
else
{
// Patch still exists. Add it
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
newBoundary.set
(
fvMeshSubsetPtr_().boundaryMesh(),
nNewPatches,
newSize,
patchStart
).ptr();
oldPatches[oldPatchi].clone
(
subMeshPtr_().boundaryMesh(),
nNewPatches,
newSize,
patchStart
)
);
}
//Pout<< " " << oldPatches[oldPatchi].name() << " : "
@ -1178,26 +1222,26 @@ void Foam::fvMeshSubset::setCellSubset
// Reset the patch lists
newBoundary.setSize(nNewPatches);
patchMap_.setSize(nNewPatches);
newBoundary.resize(nNewPatches);
patchMap_.resize(nNewPatches);
// Add the fvPatches
fvMeshSubsetPtr_().addFvPatches(newBoundary, syncPar);
subMeshPtr_().addFvPatches(newBoundary, syncPar);
// Subset and add any zones
subsetZones();
}
void Foam::fvMeshSubset::setCellSubset
void Foam::fvMeshSubset::reset
(
const labelUList& selectedCells,
const label patchID,
const bool syncPar
)
{
setCellSubset
reset
(
BitSetOps::create(baseMesh().nCells(), selectedCells),
patchID,
@ -1206,14 +1250,14 @@ void Foam::fvMeshSubset::setCellSubset
}
void Foam::fvMeshSubset::setCellSubset
void Foam::fvMeshSubset::reset
(
const labelHashSet& selectedCells,
const label patchID,
const bool syncPar
)
{
setCellSubset
reset
(
BitSetOps::create(baseMesh().nCells(), selectedCells),
patchID,
@ -1222,7 +1266,7 @@ void Foam::fvMeshSubset::setCellSubset
}
void Foam::fvMeshSubset::setCellSubset
void Foam::fvMeshSubset::reset
(
const label regioni,
const labelUList& regions,
@ -1230,7 +1274,7 @@ void Foam::fvMeshSubset::setCellSubset
const bool syncPar
)
{
setCellSubset
reset
(
BitSetOps::create(baseMesh().nCells(), regioni, regions),
patchID,
@ -1239,66 +1283,4 @@ void Foam::fvMeshSubset::setCellSubset
}
Foam::labelList Foam::fvMeshSubset::getExposedFaces
(
const bitSet& selectedCells,
const bool syncCouples
) const
{
return
removeCells(baseMesh(), syncCouples)
.getExposedFaces(getCellsToRemove(selectedCells));
}
Foam::labelList Foam::fvMeshSubset::getExposedFaces
(
const label regioni,
const labelUList& regions,
const bool syncCouples
) const
{
return
removeCells(baseMesh(), syncCouples)
.getExposedFaces(getCellsToRemove(regioni, regions));
}
void Foam::fvMeshSubset::setCellSubset
(
const bitSet& selectedCells,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples
)
{
removeCellsImpl
(
getCellsToRemove(selectedCells),
exposedFaces,
patchIDs,
syncCouples
);
}
void Foam::fvMeshSubset::setCellSubset
(
const label selectRegion,
const labelList& regions,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples
)
{
removeCellsImpl
(
getCellsToRemove(selectRegion, regions),
exposedFaces,
patchIDs,
syncCouples
);
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,19 +28,23 @@ Class
Foam::fvMeshSubset
Description
Given the original mesh and the list of selected cells, it creates the
mesh consisting only of the desired cells, with the mapping list for
points, faces, and cells.
Holds a reference to the original mesh (the baseMesh)
and optionally to a subset of that mesh (the subMesh)
with mapping lists for points, faces, and cells.
Puts all exposed internal faces into either
Can be constructed or reset to subset on the list of selected cells,
which it creates as subMesh consisting only of the desired cells,
with the mapping list for points, faces, and cells.
Places all exposed internal faces into either
- a user supplied patch
- a newly created patch "oldInternalFaces"
- setCellSubset does coupled patch subsetting as well. If it detects
a face on a coupled patch 'losing' its neighbour it will move the
face into the oldInternalFaces patch.
- reset() does coupled patch subsetting as well.
If it detects a face on a coupled patch 'losing' its neighbour
it will move the face into the oldInternalFaces patch.
- if a user supplied patch is used it is up to the destination
- if a user supplied patch is used, it is up to the destination
patchField to handle exposed internal faces (mapping from face -1).
If not provided the default is to assign the internalField. All the
basic patch field types (e.g. fixedValue) will give a warning and
@ -49,18 +53,20 @@ Description
SourceFiles
fvMeshSubset.C
fvMeshSubsetI.H
fvMeshSubsetTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef fvMeshSubset_H
#define fvMeshSubset_H
#ifndef Foam_fvMeshSubset_H
#define Foam_fvMeshSubset_H
#include "fvMesh.H"
#include "pointMesh.H"
#include "surfaceMesh.H"
#include "GeometricField.H"
#include "bitSet.H"
#include "HashSet.H"
#include "surfaceMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -75,11 +81,11 @@ class fvMeshSubset
{
// Private Data
//- Mesh to subset from
//- The base mesh to subset from
const fvMesh& baseMesh_;
//- Demand-driven subset mesh pointer
autoPtr<fvMesh> fvMeshSubsetPtr_;
//- Demand-driven subset mesh (pointer)
autoPtr<fvMesh> subMeshPtr_;
//- Optional face mapping array with flip encoded (-1/+1)
mutable autoPtr<labelList> faceFlipMapPtr_;
@ -99,53 +105,26 @@ class fvMeshSubset
// Private Member Functions
//- Check if subset has been performed
bool checkCellSubset() const;
//- Modify nCellsUsingFace for coupled faces becoming 'uncoupled.
void doCoupledPatches
(
const bool syncPar,
labelUList& nCellsUsingFace
) const;
//- Create zones for subMesh
void subsetZones();
//- Calculate face flip map
void calcFaceFlipMap() const;
//- Adapt nCellsUsingFace for coupled faces becoming 'uncoupled'.
void doCoupledPatches
(
const bool syncPar,
labelList& nCellsUsingFace
) const;
//- Forwarding to Foam::removeCells
void removeCellsImpl
(
const bitSet& cellsToRemove,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples
);
protected:
// Protected Member Functions
//- Subset of subset
static labelList subsetSubset
(
const label nElems,
const labelUList& selectedElements,
const labelUList& subsetMap
);
//- Create zones for submesh
void subsetZones();
//- Helper: extract cells-to-remove from cells-to-keep
bitSet getCellsToRemove
(
const bitSet& selectedCells
) const;
//- Helper: extract cells-to-remove from cells-to-keep
bitSet getCellsToRemove
(
const label regioni,
const labelUList& regions
) const;
//- FatalError if subset has not been performed
bool checkHasSubMesh() const;
//- No copy construct
fvMeshSubset(const fvMeshSubset&) = delete;
@ -164,11 +143,14 @@ public:
// Constructors
//- Construct given a mesh to subset
//- Construct using the entire mesh (no subset)
explicit fvMeshSubset(const fvMesh& baseMesh);
//- Construct a zero-sized subset mesh, non-processor patches only
fvMeshSubset(const fvMesh& baseMesh, const Foam::zero);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
// See reset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
@ -178,7 +160,7 @@ public:
);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
// See reset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
@ -188,7 +170,7 @@ public:
);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
// See reset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
@ -198,7 +180,7 @@ public:
);
//- Construct for a cell-subset of the given mesh
// See setCellSubset() for more details.
// See reset() for more details.
fvMeshSubset
(
const fvMesh& baseMesh,
@ -246,42 +228,59 @@ public:
// Edit
//- Reset maps and subsetting
//- Reset subMesh and all maps
void clear();
//- Reset subMesh and all maps. Same as clear()
void reset();
//- Define cell subset based on the selectedCells.
// Create "oldInternalFaces" patch for exposed
// internal faces (patchID==-1) or use supplied patch.
// Handles coupled patches if necessary by making coupled patch
// face part of patchID (so uncoupled)
void setCellSubset
//- Reset to a zero-sized subset mesh, non-processor patches only
void reset(const Foam::zero);
//- Reset from components
void reset
(
autoPtr<fvMesh>&& subMeshPtr, //!< Mesh subset
labelList&& pointMap, //!< Point mapping
labelList&& faceMap, //!< Face mapping
labelList&& cellMap, //!< Cell mapping
labelList&& patchMap //!< Patch mapping
);
//- Use the specified subset of cells.
//
// \par selectedCells The subset of cells to use
// \par patchID Patch id for exposed internal faces.
// Uses existing or creates "oldInternalFaces" for patchID == -1.
// \par syncPar
//
// \note Handles coupled patches if necessary by making
// coupled patch faces part of patchID (ie, uncoupled)
void reset
(
const bitSet& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Define cell subset, using the specified cells
//- to define the selection
void setCellSubset
//- Use the specified subset of cells.
void reset
(
const labelUList& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Define cell subset, using the specified cells
//- labelHashSet to define the selection
void setCellSubset
//- Use the specified subset of cells.
void reset
(
const labelHashSet& selectedCells,
const label patchID = -1,
const bool syncPar = true
);
//- Define cell subset, using the cells for which region == regioni.
void setCellSubset
//- Use the cells of cells corresponding to where region == regioni.
void reset
(
const label regioni,
const labelUList& regions,
@ -290,57 +289,68 @@ public:
);
// Two-step subsetting
// Legacy method names (v2112 and earlier)
//- 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
//- Use the specified subset of cells. Same as reset()
void setCellSubset
(
const bitSet& selectedCells,
const bool syncCouples = true
) const;
const label patchID = -1,
const bool syncPar = true
)
{
reset(selectedCells, patchID, syncPar);
}
//- 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
//- Use the specified subset of cells. Same as reset()
void setCellSubset
(
const labelUList& selectedCells,
const label patchID = -1,
const bool syncPar = true
)
{
reset(selectedCells, patchID, syncPar);
}
//- Use the specified subset of cells. Same as reset()
void setCellSubset
(
const labelHashSet& selectedCells,
const label patchID = -1,
const bool syncPar = true
)
{
reset(selectedCells, patchID, syncPar);
}
//- Use the specified subset of cells. Same as reset()
void setCellSubset
(
const label regioni,
const labelUList& regions,
const bool syncCouples = true
) const;
const label patchID = -1,
const bool syncPar = true
)
{
reset(regioni, regions, patchID, syncPar);
}
//- For every exposed face (from above getExposedFaces)
// used supplied (existing!) patch
void setCellSubset
// Field Mapping (static functions)
//- Map volume internal (dimensioned) field
template<class Type>
static tmp<DimensionedField<Type, volMesh>>
interpolate
(
const bitSet& selectedCells,
const labelList& exposedFaces,
const labelList& patchIDs,
const bool syncCouples = true
const DimensionedField<Type, volMesh>&,
const fvMesh& sMesh,
const labelUList& cellMap
);
//- 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. Optionally allow unmapped faces not to produce
// a warning
//- Map volume field.
// Optionally allow unmapped faces not to produce a warning
template<class Type>
static tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate
@ -353,16 +363,9 @@ public:
const bool allowUnmapped = false
);
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate
(
const GeometricField<Type, fvPatchField, volMesh>&,
const bool allowUnmapped = false
) const;
//- Map surface field. Optionally negates value if flipping
// a face (from exposing an internal face)
//- 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
@ -374,16 +377,6 @@ public:
const labelUList& faceMap
);
//- Map surface field. Optionally allow unmapped faces not to produce
// a warning (not currently used)
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const bool allowUnmapped = false
) const;
//- Map point field
template<class Type>
static tmp<GeometricField<Type, pointPatchField, pointMesh>>
@ -395,27 +388,11 @@ public:
const labelUList& pointMap
);
//- Map point field. Optionally allow unmapped points not to produce
// a warning (not currently used)
template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>>
interpolate
(
const GeometricField<Type, pointPatchField, pointMesh>&,
const bool allowUnmapped = false
) const;
//- Map dimensioned field
template<class Type>
static tmp<DimensionedField<Type, volMesh>>
interpolate
(
const DimensionedField<Type, volMesh>&,
const fvMesh& sMesh,
const labelUList& cellMap
);
// Field Mapping
//- Map Dimensioned. Optional unmapped argument not used
//- Map volume internal (dimensioned) field
//- Optional unmapped argument (currently unused)
template<class Type>
tmp<DimensionedField<Type, volMesh>>
interpolate
@ -424,73 +401,37 @@ public:
const bool allowUnmapped = false
) const;
// Compatibility
//- Deprecated(2018-07) old method name and old parameter ordering.
// \deprecated(2018-07) - use setCellSubset() method
inline void setLargeCellSubset
//- Map volume field.
// Optionally allow unmapped faces not to produce a warning
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate
(
const labelUList& region,
const label currentRegion,
const label patchID = -1,
const bool syncCouples = true
)
{
Info<< "WARNING: using highly deprecated method: "
<< "fvMeshSubset::setLargeCellSubset()" << nl;
const GeometricField<Type, fvPatchField, volMesh>&,
const bool allowUnmapped = false
) const;
setCellSubset
(
currentRegion,
region,
patchID,
syncCouples
);
}
//- Deprecated(2018-07) old method name
// \deprecated(2018-07) - use setCellSubset() method
inline void setLargeCellSubset
//- Map surface field.
// Optionally allow unmapped faces not to produce a warning
// (currently unused)
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate
(
const labelHashSet& globalCellMap,
const label patchID = -1,
const bool syncPar = true
)
{
Info<< "WARNING: using highly deprecated method: "
<< "fvMeshSubset::setLargeCellSubset()" << nl;
const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const bool allowUnmapped = false
) const;
setCellSubset(globalCellMap, patchID, syncPar);
}
//- Deprecated(2018-07) method
// For every exposed face (from getExposedFaces) use supplied
// (existing!) patch ids
// \deprecated(2018-07) - use setCellSubset() method
inline void setLargeCellSubset
//- Map point field.
// Optionally allow unmapped points not to produce a warning
// (currently unused)
template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>>
interpolate
(
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
(
regioni,
regions,
exposedFaces,
patchIDs,
syncCouples
);
}
const GeometricField<Type, pointPatchField, pointMesh>&,
const bool allowUnmapped = false
) const;
};
@ -505,7 +446,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "fvMeshSubsetInterpolate.C"
#include "fvMeshSubsetTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,35 +35,35 @@ inline const Foam::fvMesh& Foam::fvMeshSubset::baseMesh() const noexcept
inline const Foam::fvMesh& Foam::fvMeshSubset::mesh() const noexcept
{
return fvMeshSubsetPtr_ ? *fvMeshSubsetPtr_ : baseMesh_;
return subMeshPtr_ ? *subMeshPtr_ : baseMesh_;
}
inline bool Foam::fvMeshSubset::hasSubMesh() const noexcept
{
return bool(fvMeshSubsetPtr_);
return bool(subMeshPtr_);
}
inline const Foam::fvMesh& Foam::fvMeshSubset::subMesh() const
{
checkCellSubset();
checkHasSubMesh();
return *fvMeshSubsetPtr_;
return *subMeshPtr_;
}
inline Foam::fvMesh& Foam::fvMeshSubset::subMesh()
{
checkCellSubset();
checkHasSubMesh();
return *fvMeshSubsetPtr_;
return *subMeshPtr_;
}
inline const Foam::labelList& Foam::fvMeshSubset::pointMap() const
{
checkCellSubset();
checkHasSubMesh();
return pointMap_;
}
@ -71,7 +71,7 @@ inline const Foam::labelList& Foam::fvMeshSubset::pointMap() const
inline const Foam::labelList& Foam::fvMeshSubset::faceMap() const
{
checkCellSubset();
checkHasSubMesh();
return faceMap_;
}
@ -90,7 +90,7 @@ inline const Foam::labelList& Foam::fvMeshSubset::faceFlipMap() const
inline const Foam::labelList& Foam::fvMeshSubset::cellMap() const
{
checkCellSubset();
checkHasSubMesh();
return cellMap_;
}
@ -98,7 +98,7 @@ inline const Foam::labelList& Foam::fvMeshSubset::cellMap() const
inline const Foam::labelList& Foam::fvMeshSubset::patchMap() const
{
checkCellSubset();
checkHasSubMesh();
return patchMap_;
}

View File

@ -197,7 +197,7 @@ bool Foam::fvMeshSubsetProxy::correct(bool verbose)
if (changed || selectedCells_.empty())
{
subsetter_.setCellSubset(selectedCells_, exposedPatchId_);
subsetter_.reset(selectedCells_, exposedPatchId_);
}
return returnReduce(changed, orOp<bool>());

View File

@ -37,11 +37,11 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef fvMeshSubsetProxy_H
#define fvMeshSubsetProxy_H
#ifndef Foam_fvMeshSubsetProxy_H
#define Foam_fvMeshSubsetProxy_H
#include "wordRes.H"
#include "fvMeshSubset.H"
#include "wordRes.H"
#include "zeroGradientFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -34,7 +34,7 @@ License
#include "directPointPatchFieldMapper.H"
#include "flipOp.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
Foam::tmp
@ -145,6 +145,7 @@ Foam::fvMeshSubset::interpolate
// allowUnmapped : special mode for if we do not want to be
// warned for unmapped faces (e.g. from fvMeshDistribute).
const bool hasUnmapped = mapper.hasUnmapped();
if (allowUnmapped)
{
@ -190,6 +191,8 @@ Foam::fvMeshSubset::interpolate
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
@ -213,6 +216,8 @@ Foam::fvMeshSubset::interpolate
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
@ -375,6 +380,8 @@ Foam::fvMeshSubset::interpolate
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
@ -397,6 +404,8 @@ Foam::fvMeshSubset::interpolate
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
@ -528,6 +537,8 @@ Foam::fvMeshSubset::interpolate
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
@ -549,6 +560,8 @@ Foam::fvMeshSubset::interpolate
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<
@ -581,6 +594,8 @@ Foam::fvMeshSubset::interpolate
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp
<

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -125,7 +125,7 @@ bool Foam::functionObjects::ensightWrite::updateSubset
}
}
subsetter.setCellSubset(cellsToSelect.addressing());
subsetter.reset(cellsToSelect.addressing());
return true;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -123,7 +123,7 @@ bool Foam::functionObjects::vtkWrite::updateSubset
}
}
subsetter.setCellSubset(cellsToSelect.addressing());
subsetter.reset(cellsToSelect.addressing());
return true;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -242,7 +242,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
{
const polyBoundaryMesh& oldPatches = mesh.boundaryMesh();
List<polyPatch*> newBoundary(patchMap.size());
polyPatchList newBoundary(patchMap.size());
forAll(patchMap, patchi)
{
@ -250,25 +250,33 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
if (oldPatchi != -1)
{
newBoundary[patchi] = oldPatches[oldPatchi].clone
newBoundary.set
(
newMesh.boundaryMesh(),
patchi,
patchSizes[patchi],
patchStarts[patchi]
).ptr();
oldPatches[oldPatchi].clone
(
newMesh.boundaryMesh(),
patchi,
patchSizes[patchi],
patchStarts[patchi]
)
);
}
else
{
// Added patch
newBoundary[patchi] = new emptyPolyPatch
newBoundary.set
(
"patch" + Foam::name(patchi),
patchSizes[patchi],
patchStarts[patchi],
patchi,
newMesh.boundaryMesh(),
word::null
new emptyPolyPatch
(
"patch" + Foam::name(patchi),
patchSizes[patchi],
patchStarts[patchi],
patchi,
newMesh.boundaryMesh(),
word::null
)
);
}
}

View File

@ -1,10 +1,8 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude
LIB_LIBS = \
-lmeshTools \
-ldynamicMesh \
-ldecompositionMethods