52 { selectionModeType::smAll,
"all" },
53 { selectionModeType::smGeometric,
"geometric" },
54 { selectionModeType::smPoints,
"points" },
55 { selectionModeType::smMovingPoints,
"movingPoints" },
56 { selectionModeType::smCellSet,
"cellSet" },
58 { selectionModeType::smCellType,
"cellType" }
91 for (
const entry& dEntry : mpsDict)
93 const word&
key = dEntry.keyword();
135 <<
"Unknown selectionMode "
137 <<
". Valid selectionMode types : "
150 for (
const label celli : cells_)
152 sumVol += mesh_.V()[celli];
154 reduce(sumVol, sumOp<scalar>());
156 const scalar old(V_);
168 <<
" cell(s) with volume " <<
V_ <<
endl;
175 switch (selectionMode_)
195 cells_ = selectedCells.sortedToc();
204 for (
const point&
p : points_)
206 const label celli = mesh_.findCell(
p);
208 const bool found = (celli >= 0);
212 selectedCells.insert(celli);
218 <<
"No owner cell found for point " <<
p <<
endl;
229 const scalar t = mesh_.time().timeOutputValue();
235 if (!movingPoints_.set(i))
240 const point p(movingPoints_[i].value(t));
242 const label celli = mesh_.findCell(
p);
244 const bool found = (celli >= 0);
252 reduce(proci, maxOp<label>());
256 selectedCells.insert(celli);
262 <<
"No owner cell found for point " <<
p <<
endl;
266 cells_ = selectedCells.sortedToc();
272 <<
"- selecting cells using cellSet "
273 << zoneName() <<
endl;
275 cells_ = cellSet(mesh_, zoneName()).sortedToc();
281 <<
"- selecting cells using cellZones "
284 const auto& zones = mesh_.cellZones();
292 <<
"No matching cellZones: "
304 cells_ = zones[
zoneIDs.first()];
309 cells_ = zones.selection(
zoneIDs).sortedToc();
322 selectedCells.insert(celli);
324 cells_ = selectedCells.sortedToc();
331 <<
"Unknown selectionMode "
332 << selectionModeTypeNames_[selectionMode_]
333 <<
". Valid selectionMode types are "
334 << selectionModeTypeNames_
341 !(smAll == selectionMode_ || smMovingPoints == selectionMode_)
346 <<
"No cells selected!" <<
endl;
356 const word& modelType,
362 selectionMode_(selectionModeTypeNames_.get(
"selectionMode", coeffs_)),
363 updateSelection_(false),
369 geometricSelection_(),
388 if (mesh_.changing())
390 if (mesh_.topoChanging())
398 selectionMode_ == smGeometric
399 || selectionMode_ == smPoints
400 || selectionMode_ == smCellType
401 || selectionMode_ == smMovingPoints
413 selectionMode_ == smMovingPoints
414 || selectionMode_ == smGeometric
438 if (coeffs_.readIfPresent(
"timeStart", timeStart_))
440 coeffs_.readEntry(
"duration", duration_);
444 updateSelection_ = coeffs_.getOrDefault(
"updateSelection",
false);
446 if (updateSelection_)
448 setSelection(coeffs_);
label size() const noexcept
The number of elements in list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
static unsigned int defaultPrecision() noexcept
Return the default precision.
void clear()
Clear the list, i.e. set size to zero.
static FOAM_NO_DANGLING_REFERENCE const cellCellStencilObject & New(const fvMesh &mesh, Args &&... args)
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
const word & timeName() const noexcept
The current time name.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
labelList sortedToc() const
The indices of the on bits as a sorted labelList.
static bitSet select(const polyMesh &mesh, const dictionary &dict, const bool verbosity=false)
Return a cell selection according to the dictionary specification of actions.
A collection of cell labels.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
Mesh data needed to do the Finite Volume discretisation.
Intermediate abstract class for handling cell-set options for the derived fvOptions.
dictionary geometricSelection_
Dictionary entries for "geometric" (topoSetCellSource) selection.
List< point > points_
List of points for "points" selectionMode.
wordRes selectionNames_
Face selection names (for set or zone selections).
void setSelection(const dictionary &dict)
Set cell selection name or points selection from dictionary input.
labelList cells_
Set of cells to apply source to.
virtual bool read(const dictionary &dict)
Read source dictionary.
cellSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
scalar V_
Sum of cell volumes.
scalar duration_
Duration of fvOption execution starting from timeStart.
scalar timeStart_
Start time of fvOption.
const wordRe & zoneName() const
Return const access to the first set/zone name.
virtual bool isActive()
Is the source active?
selectionModeType selectionMode_
Cell selection mode.
static const Enum< selectionModeType > selectionModeTypeNames_
List of selection mode type names.
void setCellSelection()
Set the cell selection based on user input selection mode.
bool updateSelection_
Flag to enable dictionary-based updates of selections.
selectionModeType
Enumeration for selection mode types.
@ smCellType
"overset type cells"
@ smMovingPoints
"movingPoints"
bool inTimeLimits(const scalar timeValue) const
True if within time limits.
PtrList< Function1< point > > movingPoints_
List of points for "movingPoints" selectionMode.
void setVol()
Recalculate the volume.
const word & name() const noexcept
Return const access to the source name.
const fvMesh & mesh_
Reference to the mesh database.
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
virtual bool read(const dictionary &dict)
Read source dictionary.
dictionary coeffs_
Dictionary containing source coefficients.
virtual bool isActive()
Is the source active?
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const cellCellStencilObject & overlap
const labelIOList & zoneIDs
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for finite-volume.
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
messageStream Info
Information stream (stdout output on master, null elsewhere).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
constexpr char nl
The newline '\n' character (0x0a).
const labelUList & cellTypes
#define forAll(list, i)
Loop across all elements in list.