Go to the documentation of this file.
65 targetVolumeToCell::typeName,
66 "\n Usage: targetVolumeToCell (nx ny nz)\n\n"
67 " Adjust plane until obtained selected volume\n\n"
73 Foam::scalar Foam::targetVolumeToCell::volumeOfSet
75 const bitSet& selected
81 for (
const label celli : selected)
90 Foam::label Foam::targetVolumeToCell::selectCells
92 const scalar normalComp,
93 const bitSet& maskSet,
97 selected.resize(mesh_.nCells());
102 forAll(mesh_.cellCentres(), celli)
104 const point& cc = mesh_.cellCentres()[celli];
106 if (maskSet.test(celli) && ((cc & normal_) < normalComp))
117 void Foam::targetVolumeToCell::combine(topoSet&
set,
const bool add)
const
125 bitSet maskSet(mesh_.nCells(),
true);
126 label nTotCells = mesh_.globalData().nTotalCells();
127 if (maskSetName_.size())
132 Info<<
" Operating on subset defined by cellSet "
133 << maskSetName_ <<
endl;
137 cellSet
subset(mesh_, maskSetName_);
140 maskSet.setMany(cellLabels.begin(), cellLabels.end());
150 scalar maxComp = -GREAT;
153 scalar minComp = GREAT;
155 const boundBox& bb = mesh_.bounds();
159 label maxPointi = -1;
162 const scalar
c = (
points[pointi] & normal_);
168 else if (
c < minComp)
175 bitSet maxSelected(mesh_.nCells());
176 maxCells = selectCells(maxComp, maskSet, maxSelected);
180 if (maxCells != nTotCells)
183 <<
"Plane " << plane(
points[maxPointi], normal_)
184 <<
" selects " << maxCells
185 <<
" cells instead of all " << nTotCells
186 <<
" cells. Results might be wrong." <<
endl;
194 bitSet selected(mesh_.nCells());
195 label nSelected = -1;
196 scalar selectedVol = 0.0;
200 scalar low = minComp;
201 scalar high = maxComp;
203 const scalar tolerance = SMALL*100*(maxComp-minComp);
205 while ((high-low) > tolerance)
207 const scalar mid = 0.5*(low + high);
209 nSelected = selectCells(mid, maskSet, selected);
210 selectedVol = volumeOfSet(selected);
217 if (selectedVol < vol_)
221 bitSet highSelected(mesh_.nCells());
222 label nHigh = selectCells(high, maskSet, selected);
223 if (nSelected == nHigh)
232 bitSet lowSelected(mesh_.nCells());
233 label nLow = selectCells(low, maskSet, selected);
234 if (nSelected == nLow)
241 nSelected = selectCells(high, maskSet, selected);
242 selectedVol = volumeOfSet(selected);
244 if (selectedVol < vol_)
250 nSelected = selectCells(low, maskSet, selected);
251 selectedVol = volumeOfSet(selected);
253 if (selectedVol < vol_)
260 <<
"Did not converge onto plane. " <<
nl
262 << plane(high*normal_, normal_)
265 << plane(low*normal_, normal_)
273 Info<<
" Selected " << nSelected <<
" with actual volume "
274 << selectedVol <<
endl;
277 addOrDelete(
set, selected,
add);
288 const word& maskSetName
294 maskSetName_(maskSetName)
321 vol_(readScalar(checkIs(is))),
338 Info<<
" Adding cells up to target volume " << vol_
339 <<
" out of total volume "
340 <<
gSum(mesh_.cellVolumes()) <<
endl;
349 Info<<
" Removing cells up to target volume " << vol_
350 <<
" out of total volume "
351 <<
gSum(mesh_.cellVolumes()) <<
endl;
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
vectorField pointField
pointField is a vectorField.
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
A class for handling words, derived from Foam::string.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Class with constructor to add usage string to table.
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Ostream & endl(Ostream &os)
Add newline and flush stream.
setAction
Enumeration defining the valid actions.
Type gSum(const FieldField< Field, Type > &f)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Create a new set and ADD elements to it.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
A topoSetCellSource to select cells based on a target volume of cells. Adapts a plane until it has en...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
messageStream Info
Information stream (uses stdout - output is on the master only)
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
General set of labels of mesh quantity (points, cells, faces).
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Macros for easy insertion into run-time selection tables.
Subtract elements from the set.
const scalarField & cellVolumes() const
static MinMax< T > ge(const T &minVal)
A semi-infinite range from minVal to the type max.
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
T getCheck(const word &keyword, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
const dimensionedScalar c
Speed of light in a vacuum.
targetVolumeToCell(const polyMesh &mesh, const scalar vol, const vector &normal, const word &maskSetName="")
Construct from components.
vector point
Point is a vector.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
const polyMesh & mesh_
Reference to the mesh.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.