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
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;
196 if (
pars.debugLevel > 1)
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;
245 scalar shift =
pars.obs_expand;
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,
363 for (
const point& origin : group)
368 const scalar shift2 = shift * 2.0;
411 obs.sortBias = obs.len();
414 obs.sortBias = 0.5*obs.dia();
417 obs.sortBias = 0.5*obs.dia();
421 totVolume += obs.volume();
443 totVolume += obs.volume();
464 if (obs.slat_width <= 0)
466 obs.slat_width =
pars.def_grating_slat_w;
496 totVolume += obs.volume();
506 if (nOutside || nProtruding)
508 Info<<
"Warning: " << nOutside <<
" obstacles outside domain, "
509 << nProtruding <<
" obstacles partly outside domain" <<
nl;
534 Map<PDRlegacy::obstacleGrouping> groups;
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)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool found(const Key &key) const
Same as contains().
label size() const noexcept
The number of elements in table.
void clear()
Remove all entries from table.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
A HashTable to objects of type <T> with a label key.
Obstacle definitions for PDR.
static bool isCylinder(const label id)
Is obstacle type id cylinder-like?
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.
const T & first() const noexcept
Access the first element.
const T & second() const noexcept
Access the second element.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
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.
@ OUTSIDE
A location outside the volume.
@ MIXED
A location that is partly inside and outside.
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.
Pair< label > labelPair
A pair of labels.
List< word > wordList
List of word.
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).
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.