36#undef USE_ZERO_INSTANCE_GROUPS
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
90 || typeId == PDRobstacle::MESH_PLANE
100 const label groupId = typeId / 100;
103 if (typeId == PDRobstacle::OLD_INLET)
105 Info<<
"Ignored old-inlet type" <<
nl;
110 Info<<
"Ignored grating" <<
nl;
117 groups(groupId).append(
x,
y, z);
119 else if (PDRobstacle::isCylinder(typeId))
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
290 || typeId == PDRobstacle::MESH_PLANE
296 int groupId = typeId / 100;
301 typeId == PDRobstacle::OLD_INLET
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,
363 for (
const point& origin : group)
368 const scalar shift2 = shift * 2.0;
372 case PDRobstacle::CYLINDER:
394 case volumeType::OUTSIDE:
399 case volumeType::MIXED:
411 obs.sortBias = obs.len();
414 obs.sortBias = 0.5*obs.dia();
417 obs.sortBias = 0.5*obs.dia();
421 totVolume += obs.volume();
427 case PDRobstacle::DIAG_BEAM:
443 totVolume += obs.volume();
449 case PDRobstacle::CUBOID_1:
450 case PDRobstacle::LOUVRE_BLOWOFF:
451 case PDRobstacle::CUBOID:
452 case PDRobstacle::WALL_BEAM:
453 case PDRobstacle::GRATING:
454 case PDRobstacle::RECT_PATCH:
462 if (typeId == PDRobstacle::GRATING)
464 if (obs.slat_width <= 0)
483 case volumeType::OUTSIDE:
488 case volumeType::MIXED:
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,
Preparation of fields for PDRFoam.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
void reserve(const label len)
T & first() noexcept
The first element of the list, position [0].
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool found(const Key &key) const
Return true if hashed entry is found in table.
label size() const noexcept
The number of elements in table.
void clear()
Clear all entries from table.
Input from file stream, using an ISstream.
A HashTable to objects of type <T> with a label key.
Obstacle definitions for PDR.
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.
bool tooSmall(const scalar minWidth) const
True if the obstacle is considered to be too small.
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.
void scale(const scalar factor)
Scale obstacle dimensions by specified scaling factor.
scalar def_grating_slat_w
Default slat thickness grating.
scalar scale
Overall scale factor.
scalar min_width
Ignore obstacles with second dimension (or diameter) less than this.
const T & second() const noexcept
Return second element, which is also the last element.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
A bounding box defined in terms of min/max extrema points.
A class for handling file names.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
A class for handling words, derived from Foam::string.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
labelPair readObstacleFiles(const fileName &obsFileDir, const wordList &obsFileNames, Map< obstacleGrouping > &groups)
Read obstacle files, do counting only.
constexpr const char *const group
Group name for atomic constants.
Different types of constants.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::PDRparams pars
Globals for program parameters (ugly hack)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
A non-counting (dummy) refCount.