36 #undef USE_ZERO_INSTANCE_GROUPS 50 groups(0).append(point::zero);
54 if (!obsFileNames.
empty())
56 Info<<
"Counting groups in obstacle files" <<
nl;
58 for (
const word& inputFile : obsFileNames)
60 Info<<
" file: " << inputFile <<
nl;
71 const auto firstCh = buffer.find_first_not_of(
" \t\n\v\f\r");
75 firstCh == std::string::npos
76 || buffer[firstCh] ==
'#' 88 sscanf(buffer.c_str(),
"%d %lf %lf %lf", &typeId, &
x, &
y, &z)<4
100 const label groupId = typeId / 100;
105 Info<<
"Ignored old-inlet type" <<
nl;
110 Info<<
"Ignored grating" <<
nl;
117 groups(groupId).append(
x,
y, z);
122 groups(groupId).addCylinder();
127 groups(groupId).addObstacle();
136 label nMissedObs = 0;
137 label nMissedCyl = 0;
141 const auto&
group = iter.val();
143 nTotalObs +=
group.nTotalObstacle();
144 nTotalCyl +=
group.nTotalCylinder();
148 nMissedObs +=
group.nObstacle();
149 nMissedCyl +=
group.nCylinder();
153 for (
const label groupId : groups.
sortedToc())
155 const auto&
group = groups[groupId];
162 <<
" instances of group " << groupId <<
" (" 163 <<
group.nObstacle() <<
" obstacles " 164 <<
group.nCylinder() <<
" cylinders)" 172 <<
group.nObstacle() <<
" obstacles " 173 <<
group.nCylinder() <<
" cylinders not in groups" <<
nl;
177 Info<<
"Number of obstacles: " 178 << (nTotalObs + nTotalCyl) <<
" (" 179 << nTotalCyl <<
" cylinders)" <<
nl;
181 if (nMissedObs + nMissedCyl)
183 #ifdef USE_ZERO_INSTANCE_GROUPS 185 nTotalObs += nMissedObs;
186 nTotalCyl += nMissedCyl;
187 Info<<
"Adding " << (nMissedObs + nMissedCyl)
188 <<
" obstacles in groups without instances to default group" <<
nl;
193 <<
nl <<
"Found " << (nMissedObs + nMissedCyl)
194 <<
" obstacles in groups without instances" <<
nl <<
nl;
198 for (
const label groupId : groups.
sortedToc())
200 const auto&
group = groups[groupId];
204 groupId &&
group.empty()
208 Info<<
" Group " << groupId <<
" (" 209 <<
group.nObstacle() <<
" obstacles " 210 <<
group.nCylinder() <<
" cylinders)" 234 if (!groups.
found(0))
237 <<
"No default group 0 defined!" <<
nl 241 scalar totVolume = 0;
243 label nProtruding = 0;
249 if (!obsFileNames.
empty())
251 Info<<
"Reading obstacle files" <<
nl;
254 for (
const word& inputFile : obsFileNames)
256 Info<<
" file: " << inputFile <<
nl;
269 const auto firstCh = buffer.find_first_not_of(
" \t\n\v\f\r");
273 firstCh == std::string::npos
274 || buffer[firstCh] ==
'#' 288 sscanf(buffer.c_str(),
"%d %lf %lf %lf", &typeId, &
x, &
y, &z) < 4
296 int groupId = typeId / 100;
315 if (!groups.
found(groupId))
320 <<
"Encountered undefined group: " << groupId <<
nl;
324 #ifdef USE_ZERO_INSTANCE_GROUPS 325 const obstacleGrouping&
group =
327 groups[groups[groupId].
size() ? groupId : 0]
330 const obstacleGrouping&
group = groups[groupId];
344 (groupId * 100) + typeId,
368 const scalar shift2 = shift * 2.0;
383 obs.pt -= point::uniform(shift);
411 obs.sortBias = obs.len();
414 obs.sortBias = 0.5*obs.dia();
417 obs.sortBias = 0.5*obs.dia();
421 totVolume += obs.volume();
438 obs.pt -= point::uniform(shift);
443 totVolume += obs.volume();
464 if (obs.slat_width <= 0)
473 obs.pt -= point::uniform(shift);
474 obs.span += point::uniform(shift2);
496 totVolume += obs.volume();
506 if (nOutside || nProtruding)
508 Info<<
"Warning: " << nOutside <<
" obstacles outside domain, " 509 << nProtruding <<
" obstacles partly outside domain" <<
nl;
539 const label nObstacle = obsCounts.
first();
540 const label nCylinder = obsCounts.
second();
544 if (!nObstacle && !nCylinder)
547 <<
"No obstacles in domain" <<
nl 559 obsFileDir, obsFileNames, groups,
Different types of constants.
const T & first() const noexcept
Access the first element.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool found(const label &key) const
Same as contains()
labelPair readObstacleFiles(const fileName &obsFileDir, const wordList &obsFileNames, Map< obstacleGrouping > &groups)
Read obstacle files, do counting only.
static scalar legacyReadFiles(const fileName &obsFileDir, const wordList &obsFileNames, const boundBox &meshBb, DynamicList< PDRobstacle > &blocks, DynamicList< PDRobstacle > &cylinders)
Read obstacle files and add to the lists.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
scalar def_grating_slat_w
Default slat thickness grating.
A bounding box defined in terms of min/max extrema points.
An enumeration wrapper for classification of a location as being inside/outside of a volume...
constexpr const char *const group
Group name for atomic constants.
label size() const noexcept
The number of elements in table.
scalar min_width
Ignore obstacles with second dimension (or diameter) less than this.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
A class for handling words, derived from Foam::string.
void clear()
Remove all entries from table.
Preparation of fields for PDRFoam.
void append(const T &val)
Copy append an element to the end of this list.
A location outside the volume.
bool isCylinder() const
Is obstacle cylinder-like?
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
A location that is partly inside and outside.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Pair< label > labelPair
A pair of labels.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Input from file stream, using an ISstream.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
bool setFromLegacy(const int groupTypeId, const string &buffer, const label lineNo=-1, const word &inputFile=word::null)
Set values from single-line, multi-column format.
PtrList< volScalarField > & Y
List< label > sortedToc() const
The table of contents (the keys) in sorted order.
Foam::PDRparams pars
Globals for program parameters (ugly hack)
messageStream Info
Information stream (stdout output on master, null elsewhere)
scalar scale
Overall scale factor.
bool tooSmall(const scalar minWidth) const
True if the obstacle is considered to be too small.
const T & second() const noexcept
Access the second element.
void scale(const scalar factor)
Scale obstacle dimensions by specified scaling factor.
Obstacle definitions for PDR.
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.