From f54400d5cc38a31a2b40c727fef68649b1e97fed Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Tue, 18 Jul 2023 09:21:02 +0100 Subject: [PATCH] ENH: cellSetOption: add new selectionMode for moving points --- src/fvOptions/cellSetOption/cellSetOption.C | 86 ++++++++++++++++++++- src/fvOptions/cellSetOption/cellSetOption.H | 21 ++++- 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/src/fvOptions/cellSetOption/cellSetOption.C b/src/fvOptions/cellSetOption/cellSetOption.C index 3f0310dd4c..297f13e8b7 100644 --- a/src/fvOptions/cellSetOption/cellSetOption.C +++ b/src/fvOptions/cellSetOption/cellSetOption.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,6 +52,7 @@ Foam::fv::cellSetOption::selectionModeTypeNames_ { selectionModeType::smAll, "all" }, { selectionModeType::smGeometric, "geometric" }, { selectionModeType::smPoints, "points" }, + { selectionModeType::smMovingPoints, "movingPoints" }, { selectionModeType::smCellSet, "cellSet" }, { selectionModeType::smCellZone, "cellZone" }, { selectionModeType::smCellType, "cellType" } @@ -80,6 +81,31 @@ void Foam::fv::cellSetOption::setSelection(const dictionary& dict) dict.readEntry("points", points_); break; } + case smMovingPoints: + { + const dictionary& mpsDict = dict.subDict("movingPoints"); + + movingPoints_.resize_null(mpsDict.size()); + + label pointi = 0; + for (const entry& dEntry : mpsDict) + { + const word& key = dEntry.keyword(); + + movingPoints_.set + ( + pointi, + Function1::New + ( + key, + mpsDict, + &mesh_ + ) + ); + ++pointi; + } + break; + } case smCellSet: { selectionNames_.resize(1); @@ -196,6 +222,50 @@ void Foam::fv::cellSetOption::setCellSelection() cells_ = selectedCells.sortedToc(); break; } + case smMovingPoints: + { + Info<< indent << "- selecting cells using moving points" << endl; + + const scalar t = mesh_.time().timeOutputValue(); + + labelHashSet selectedCells; + + forAll(movingPoints_, i) + { + if (!movingPoints_.set(i)) + { + continue; + } + + const point p(movingPoints_[i].value(t)); + + const label celli = mesh_.findCell(p); + + const bool found = (celli >= 0); + + // Ensure that only one processor inserts this cell + label proci = -1; + if (found) + { + proci = Pstream::myProcNo(); + } + reduce(proci, maxOp