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
This commit is contained in:
Mark Olesen
2022-05-30 19:55:47 +02:00
parent 1845c28ee4
commit 8081fc7234
15 changed files with 316 additions and 292 deletions

View File

@ -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.

View File

@ -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<topoSet> 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<label>())
<< endl;
}
switch (action)
{
case topoSetSource::NEW :
case topoSetSource::CLEAR :
{
currentSet = topoSet::New(setType, mesh, setName, 16384);
Info<< "Created "
<< currentSet().type() << ' ' << setName << endl;
break;
}
case topoSetSource::IGNORE :
continue; // Nothing to do
break;
case topoSetSource::REMOVE :
// Nothing to load
break;
default:
{
// Load set
currentSet = topoSet::New
(
setType,
mesh,
setName,
IOobject::MUST_READ
);
Info<< "Read set "
<< currentSet().type() << ' ' << setName
<< " size:"
<< returnReduce(currentSet().size(), sumOp<label>())
<< endl;
}
}
// Handle special actions (clear, invert) locally,
// the other actions through sources.
switch (action)
{
case topoSetSource::NEW:
case topoSetSource::ADD:
case topoSetSource::SUBTRACT:
case topoSetSource::NEW :
case topoSetSource::ADD :
case topoSetSource::SUBTRACT :
{
const word sourceType(dict.get<word>("source"));
@ -321,10 +330,10 @@ int main(int argc, char *argv[])
<< currentSet().objectPath() << endl;
}
fileHandler().flush();
break;
}
break;
case topoSetSource::SUBSET:
case topoSetSource::SUBSET :
{
const word sourceType(dict.get<word>("source"));
@ -362,10 +371,12 @@ int main(int argc, char *argv[])
<< currentSet().objectPath() << endl;
}
fileHandler().flush();
}
break;
case topoSetSource::CLEAR:
break;
}
case topoSetSource::CLEAR :
{
Info<< " Clearing " << currentSet().type() << endl;
currentSet().clear();
if (!currentSet().write())
@ -375,9 +386,12 @@ int main(int argc, char *argv[])
<< currentSet().objectPath() << endl;
}
fileHandler().flush();
break;
case topoSetSource::INVERT:
break;
}
case topoSetSource::INVERT :
{
Info<< " Inverting " << currentSet().type() << endl;
currentSet().invert(currentSet().maxSize(mesh));
if (!currentSet().write())
@ -387,17 +401,22 @@ int main(int argc, char *argv[])
<< currentSet().objectPath() << endl;
}
fileHandler().flush();
break;
case topoSetSource::REMOVE:
break;
}
case topoSetSource::REMOVE :
{
Info<< " Removing set" << endl;
removeSet(mesh, setType, setName);
break;
break;
}
default:
WarningInFunction
<< "Unhandled action " << action << endl;
break;
<< "Unhandled action: "
<< topoSetSource::actionNames[action] << endl;
}
if (currentSet)