From 08bcee7a3ff049b86207de7da9e2c48945c2ca0e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 8 Dec 2018 22:16:58 +0100 Subject: [PATCH] ENH: support 'use' action for selections in vtkWrite, ensightWrite (#926) - have 'use' as the action appears more intuitive as the first entry instead of 'add'. Was previously also added to vtkCloud. --- .../utilities/ensightWrite/ensightWrite.H | 4 ++-- .../utilities/ensightWrite/ensightWriteUpdate.C | 13 ++++++++++++- src/functionObjects/utilities/vtkWrite/vtkWrite.H | 4 ++-- .../utilities/vtkWrite/vtkWriteUpdate.C | 13 ++++++++++++- src/meshTools/sets/topoSetSource/topoSetSource.H | 2 +- .../simpleFoam/windAroundBuildings/system/vtkWrite | 2 +- .../reactingParcelFoam/filter/system/vtkWrite | 2 +- 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.H b/src/functionObjects/utilities/ensightWrite/ensightWrite.H index 5ce6fe8ddd..d2c695ff3f 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWrite.H +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.H @@ -49,7 +49,7 @@ Description { box { - action add; + action use; source box; box (-0.1 -0.01 -0.1) (0.1 0.30 0.1); } @@ -110,7 +110,7 @@ Description Note The region of interest is defined by the selection dictionary - as a set of actions (add,subtract,subset,invert). + as a set of actions (use,add,subtract,subset,invert). Omitting the selection dictionary is the same as specifying the conversion of all cells (in the selected regions). Omitting the patches entry is the same as specifying the conversion of all diff --git a/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C b/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C index cf2e0b01bd..25f26cbe63 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C @@ -35,6 +35,7 @@ namespace Foam // A limited selection of actions const Enum actionNames ({ + { topoSetSource::NEW, "use" }, { topoSetSource::ADD, "add" }, { topoSetSource::SUBTRACT, "subtract" }, { topoSetSource::SUBSET, "subset" }, @@ -73,7 +74,7 @@ bool Foam::functionObjects::ensightWrite::updateSubset const dictionary& dict = dEntry.dict(); - const auto action = actionNames.get("action", dict); + auto action = actionNames.get("action", dict); // Handle manually if (action == topoSetSource::INVERT) @@ -92,7 +93,17 @@ bool Foam::functionObjects::ensightWrite::updateSubset switch (action) { + case topoSetSource::NEW: // "use" case topoSetSource::ADD: + if (topoSetSource::NEW == action) + { + // NEW (use) = CLEAR + ADD (ie, only use this selection) + cellsToSelect.reset(); + action = topoSetSource::ADD; + } + source->applyToSet(action, cellsToSelect); + break; + case topoSetSource::SUBTRACT: source->applyToSet(action, cellsToSelect); break; diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.H b/src/functionObjects/utilities/vtkWrite/vtkWrite.H index ff9990a0b2..77110505d1 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.H +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.H @@ -49,7 +49,7 @@ Description { box { - action add; + action use; source box; box (-0.1 -0.01 -0.1) (0.1 0.30 0.1); } @@ -112,7 +112,7 @@ Description Note The region of interest is defined by the selection dictionary - as a set of actions (add,subtract,subset,invert). + as a set of actions (use,add,subtract,subset,invert). Omitting the selection dictionary is the same as specifying the conversion of all cells (in the selected regions). Omitting the patches entry is the same as specifying the conversion of all diff --git a/src/functionObjects/utilities/vtkWrite/vtkWriteUpdate.C b/src/functionObjects/utilities/vtkWrite/vtkWriteUpdate.C index 9df872a05e..72669b382a 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWriteUpdate.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWriteUpdate.C @@ -34,6 +34,7 @@ namespace Foam // A limited selection of actions const Enum actionNames ({ + { topoSetSource::NEW, "use" }, { topoSetSource::ADD, "add" }, { topoSetSource::SUBTRACT, "subtract" }, { topoSetSource::SUBSET, "subset" }, @@ -71,7 +72,7 @@ bool Foam::functionObjects::vtkWrite::updateSubset const dictionary& dict = dEntry.dict(); - const auto action = actionNames.get("action", dict); + auto action = actionNames.get("action", dict); // Handle manually if (action == topoSetSource::INVERT) @@ -90,7 +91,17 @@ bool Foam::functionObjects::vtkWrite::updateSubset switch (action) { + case topoSetSource::NEW: // "use" case topoSetSource::ADD: + if (topoSetSource::NEW == action) + { + // NEW (use) = CLEAR + ADD (ie, only use this selection) + cellsToSelect.reset(); + action = topoSetSource::ADD; + } + source->applyToSet(action, cellsToSelect); + break; + case topoSetSource::SUBTRACT: source->applyToSet(action, cellsToSelect); break; diff --git a/src/meshTools/sets/topoSetSource/topoSetSource.H b/src/meshTools/sets/topoSetSource/topoSetSource.H index 4c37698fc3..1ce6ef99a6 100644 --- a/src/meshTools/sets/topoSetSource/topoSetSource.H +++ b/src/meshTools/sets/topoSetSource/topoSetSource.H @@ -82,7 +82,7 @@ public: enum setAction { ADD, //!< Add elements to the set - SUBTRACT, //!< Remove elements from the set + SUBTRACT, //!< Subtract elements from the set SUBSET, //!< Subset with elements in the set INVERT, //!< Invert the elements in the set CLEAR, //!< Clear the set, possibly creating it diff --git a/tutorials/incompressible/simpleFoam/windAroundBuildings/system/vtkWrite b/tutorials/incompressible/simpleFoam/windAroundBuildings/system/vtkWrite index f7e4a56f6d..146bae43ab 100644 --- a/tutorials/incompressible/simpleFoam/windAroundBuildings/system/vtkWrite +++ b/tutorials/incompressible/simpleFoam/windAroundBuildings/system/vtkWrite @@ -51,7 +51,7 @@ subset { dome { - action add; + action use; source sphere; origin (125 100 0); radius 100; diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/system/vtkWrite b/tutorials/lagrangian/reactingParcelFoam/filter/system/vtkWrite index 6e71e5f89e..6b1a04ff27 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/system/vtkWrite +++ b/tutorials/lagrangian/reactingParcelFoam/filter/system/vtkWrite @@ -22,7 +22,7 @@ vtkWrite { inletRegion { - action add; + action use; source zone; zones (leftFluid); }