50 targetVolumeToCell::typeName,
51 "\n Usage: targetVolumeToCell (nx ny nz)\n\n" 52 " Adjust plane until obtained selected volume\n\n" 58 Foam::scalar Foam::targetVolumeToCell::volumeOfSet
60 const PackedBoolList& selected
68 sumVol += mesh_.cellVolumes()[celli];
77 const scalar normalComp,
78 const PackedBoolList& maskSet,
79 PackedBoolList& selected
82 selected.setSize(mesh_.nCells());
87 forAll(mesh_.cellCentres(), celli)
89 const point& cc = mesh_.cellCentres()[celli];
91 if (maskSet[celli] && ((cc&n_) < normalComp))
93 selected[celli] =
true;
101 void Foam::targetVolumeToCell::combine(topoSet&
set,
const bool add)
const 110 PackedBoolList maskSet(mesh_.nCells(), 1);
111 label nTotCells = mesh_.globalData().nTotalCells();
112 if (maskSetName_.size())
115 Info<<
" Operating on subset defined by cellSet " << maskSetName_
119 cellSet
subset(mesh_, maskSetName_);
123 maskSet[iter.key()] = 1;
134 scalar maxComp = -GREAT;
137 scalar minComp = GREAT;
139 const boundBox& bb = mesh_.bounds();
143 label maxPointi = -1;
146 scalar c = (
points[pointi]&n_);
152 else if (c < minComp)
159 PackedBoolList maxSelected(mesh_.nCells());
160 maxCells = selectCells(maxComp, maskSet, maxSelected);
164 if (maxCells != nTotCells)
167 <<
"Plane " << plane(
points[maxPointi], n_)
168 <<
" selects " << maxCells
169 <<
" cells instead of all " << nTotCells
170 <<
" cells. Results might be wrong." <<
endl;
179 PackedBoolList selected(mesh_.nCells());
180 label nSelected = -1;
181 scalar selectedVol = 0.0;
185 scalar low = minComp;
186 scalar high = maxComp;
188 const scalar tolerance = SMALL*100*(maxComp-minComp);
190 while ((high-low) > tolerance)
192 scalar mid = 0.5*(low + high);
194 nSelected = selectCells(mid, maskSet, selected);
195 selectedVol = volumeOfSet(selected);
202 if (selectedVol < vol_)
206 PackedBoolList highSelected(mesh_.nCells());
207 label nHigh = selectCells(high, maskSet, selected);
208 if (nSelected == nHigh)
217 PackedBoolList lowSelected(mesh_.nCells());
218 label nLow = selectCells(low, maskSet, selected);
219 if (nSelected == nLow)
226 nSelected = selectCells(high, maskSet, selected);
227 selectedVol = volumeOfSet(selected);
229 if (selectedVol < vol_)
235 nSelected = selectCells(low, maskSet, selected);
236 selectedVol = volumeOfSet(selected);
238 if (selectedVol < vol_)
245 <<
"Did not converge onto plane. " <<
nl 247 << plane(high*n_, n_)
256 Info<<
" Selected " << nSelected <<
" with actual volume " << selectedVol
263 addOrDelete(
set, celli, add);
294 n_(dict.
lookup(
"normal")),
327 Info<<
" Adding cells up to target volume " << vol_
328 <<
" out of total volume " <<
gSum(mesh_.cellVolumes()) << endl;
334 Info<<
" Removing cells up to target volume " << vol_
335 <<
" out of total volume " <<
gSum(mesh_.cellVolumes()) << endl;
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t 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...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual ~targetVolumeToCell()
Destructor.
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
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.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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.
Class with constructor to add usage string to table.
targetVolumeToCell(const polyMesh &mesh, const scalar vol, const vector &)
Construct from components.
const dimensionedScalar c
Speed of light in a vacuum.
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.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.