44 Foam::scalar Foam::targetVolumeToCell::volumeOfSet
46 const PackedBoolList& selected
54 sumVol += mesh_.cellVolumes()[celli];
63 const scalar normalComp,
64 const PackedBoolList& maskSet,
65 PackedBoolList& selected
68 selected.setSize(mesh_.nCells());
73 forAll(mesh_.cellCentres(), celli)
75 const point& cc = mesh_.cellCentres()[celli];
77 if (maskSet[celli] && ((cc&n_) < normalComp))
79 selected[celli] =
true;
87 void Foam::targetVolumeToCell::combine(topoSet&
set,
const bool add)
const 96 PackedBoolList maskSet(mesh_.nCells(), 1);
97 label nTotCells = mesh_.globalData().nTotalCells();
98 if (maskSetName_.size())
101 Info<<
" Operating on subset defined by cellSet " << maskSetName_
105 cellSet
subset(mesh_, maskSetName_);
109 maskSet[iter.key()] = 1;
120 scalar maxComp = -great;
123 scalar minComp = great;
125 const boundBox& bb = mesh_.bounds();
129 label maxPointi = -1;
132 scalar c = (
points[pointi]&n_);
138 else if (c < minComp)
145 PackedBoolList maxSelected(mesh_.nCells());
146 maxCells = selectCells(maxComp, maskSet, maxSelected);
150 if (maxCells != nTotCells)
153 <<
"Plane " << plane(
points[maxPointi], n_)
154 <<
" selects " << maxCells
155 <<
" cells instead of all " << nTotCells
156 <<
" cells. Results might be wrong." <<
endl;
165 PackedBoolList selected(mesh_.nCells());
166 label nSelected = -1;
167 scalar selectedVol = 0.0;
171 scalar low = minComp;
172 scalar high = maxComp;
174 const scalar tolerance = small*100*(maxComp-minComp);
176 while ((high-low) > tolerance)
178 scalar mid = 0.5*(low + high);
180 nSelected = selectCells(mid, maskSet, selected);
181 selectedVol = volumeOfSet(selected);
188 if (selectedVol < vol_)
192 PackedBoolList highSelected(mesh_.nCells());
193 label nHigh = selectCells(high, maskSet, selected);
194 if (nSelected == nHigh)
203 PackedBoolList lowSelected(mesh_.nCells());
204 label nLow = selectCells(low, maskSet, selected);
205 if (nSelected == nLow)
212 nSelected = selectCells(high, maskSet, selected);
213 selectedVol = volumeOfSet(selected);
215 if (selectedVol < vol_)
221 nSelected = selectCells(low, maskSet, selected);
222 selectedVol = volumeOfSet(selected);
224 if (selectedVol < vol_)
231 <<
"Did not converge onto plane. " <<
nl 233 << plane(high*n_, n_)
242 Info<<
" Selected " << nSelected <<
" with actual volume " << selectedVol
249 addOrDelete(
set, celli, add);
277 vol_(dict.
lookup<scalar>(
"volume")),
278 n_(dict.
lookup(
"normal")),
299 Info<<
" Adding cells up to target volume " << vol_
300 <<
" out of total volume " <<
gSum(mesh_.cellVolumes()) << endl;
306 Info<<
" Removing cells up to target volume " << vol_
307 <<
" out of total volume " <<
gSum(mesh_.cellVolumes()) << endl;
#define forAll(list, i)
Loop across all elements in list.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual ~targetVolumeToCell()
Destructor.
Holds information (coordinate and normal) regarding nearest wall point.
const dimensionedScalar c
Speed of light in a vacuum.
Macros for easy insertion into run-time selection tables.
Base class of a source for a topoSet.
vectorField pointField
pointField is a vectorField.
Type gSum(const FieldField< Field, Type > &f)
A class for handling words, derived from string.
setAction
Enumeration defining the valid actions.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
General set of labels of mesh quantity (points, cells, faces).
vector point
Point is a vector.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
targetVolumeToCell(const polyMesh &mesh, const scalar vol, const vector &)
Construct from components.
ListType subset(const UList< T > &select, const T &value, const ListType &)
Extract elements of List when select is a certain value.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.