From 8081fc72345abbeaf4f4f88cef917b62dbcfe028 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 30 May 2022 19:55:47 +0200 Subject: [PATCH] ENH: refactor cell selections into cellBitSet - ensightWrite, vtkWrite, fv::cellSetOption ENH: additional topoSet "ignore" action - this no-op can be used to skip an action step, instead of removing the entire entry --- .../mesh/manipulation/setSet/setSet.C | 67 ++++++----- .../mesh/manipulation/topoSet/topoSet.C | 107 +++++++++++------- .../lagrangian/common/parcelSelectionDetail.C | 9 -- .../lagrangian/common/parcelSelectionDetail.H | 7 +- .../utilities/ensightWrite/ensightWrite.H | 3 +- .../ensightWrite/ensightWriteUpdate.C | 89 +-------------- .../utilities/vtkWrite/vtkWrite.H | 1 + .../utilities/vtkWrite/vtkWriteUpdate.C | 88 +------------- src/fvOptions/cellSetOption/cellSetOption.C | 35 ++---- src/fvOptions/cellSetOption/cellSetOption.H | 8 +- .../topoSet/topoSetSource/topoSetSource.C | 20 +++- .../topoSet/topoSetSource/topoSetSource.H | 21 +++- src/meshTools/topoSet/topoSets/cellBitSet.C | 98 +++++++++++++++- src/meshTools/topoSet/topoSets/cellBitSet.H | 54 ++++++++- .../RAS/mixerVessel2D/system/scalarTransport | 1 + 15 files changed, 316 insertions(+), 292 deletions(-) diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index 3bc06af23d..73a5727663 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2018 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -344,29 +344,39 @@ bool doCommand topoSetSource::setAction action = topoSetSource::actionNames[actionName]; + switch (action) + { + case topoSetSource::REMOVE : + { + removeSet(mesh, setType, setName); + break; + } - IOobject::readOption r; + case topoSetSource::NEW : + case topoSetSource::CLEAR : + { + currentSetPtr = topoSet::New(setType, mesh, setName, typSize); + break; + } - if (action == topoSetSource::REMOVE) - { - removeSet(mesh, setType, setName); - } - else if - ( - (action == topoSetSource::NEW) - || (action == topoSetSource::CLEAR) - ) - { - r = IOobject::NO_READ; - currentSetPtr = topoSet::New(setType, mesh, setName, typSize); - } - else - { - r = IOobject::MUST_READ; - currentSetPtr = topoSet::New(setType, mesh, setName, r); - topoSet& currentSet = currentSetPtr(); - // Presize it according to current mesh data. - currentSet.resize(max(currentSet.size(), typSize)); + case topoSetSource::IGNORE : + // Nothing to do + break; + + default: + { + currentSetPtr = topoSet::New + ( + setType, + mesh, + setName, + IOobject::MUST_READ + ); + + topoSet& currentSet = currentSetPtr(); + // Presize it according to current mesh data. + currentSet.resize(max(currentSet.size(), typSize)); + } } if (currentSetPtr) @@ -380,23 +390,26 @@ bool doCommand switch (action) { - case topoSetSource::CLEAR: + case topoSetSource::CLEAR : { // Already handled above by not reading break; } - case topoSetSource::INVERT: + + case topoSetSource::INVERT : { currentSet.invert(currentSet.maxSize(mesh)); break; } - case topoSetSource::LIST: + + case topoSetSource::LIST : { currentSet.writeDebug(Pout, mesh, 100); Pout<< endl; break; } - case topoSetSource::SUBSET: + + case topoSetSource::SUBSET : { if (is >> sourceType) { @@ -430,6 +443,7 @@ bool doCommand } break; } + default: { if (is >> sourceType) @@ -449,7 +463,6 @@ bool doCommand } } - if (action != topoSetSource::LIST) { // Set will have been modified. diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSet.C b/applications/utilities/mesh/manipulation/topoSet/topoSet.C index 6e590a82bb..b6ef76dff0 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSet.C +++ b/applications/utilities/mesh/manipulation/topoSet/topoSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -263,43 +263,52 @@ int main(int argc, char *argv[]) topoSetSource::actionNames.get("action", dict); autoPtr currentSet; - if - ( - action == topoSetSource::NEW - || action == topoSetSource::CLEAR - ) - { - currentSet = topoSet::New(setType, mesh, setName, 16384); - Info<< "Created " << currentSet().type() << ' ' - << setName << endl; - } - else if (action == topoSetSource::REMOVE) - { - //? - } - else - { - currentSet = topoSet::New - ( - setType, - mesh, - setName, - IOobject::MUST_READ - ); - Info<< "Read set " << currentSet().type() << ' ' - << setName << " with size " - << returnReduce(currentSet().size(), sumOp