Go to the documentation of this file.
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;
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;
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)
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 class for handling words, derived from Foam::string.
labelPair readObstacleFiles(const fileName &obsFileDir, const wordList &obsFileNames, Map< obstacleGrouping > &groups)
static Form uniform(const Cmpt &s)
A class for handling file names.
constexpr const char *const group
Input from file stream, using an ISstream.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Different types of constants.
Foam::PDRparams pars
Globals for program parameters (ugly hack)
bool setFromLegacy(const int groupTypeId, const string &buffer, const label lineNo=-1, const word &inputFile=word::null)
A HashTable to objects of type <T> with a label key.
void reserve(const label len)
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
bool tooSmall(const scalar minWidth) const
Pair< label > labelPair
A pair of labels.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
DynamicList< T, SizeMin > & append(const T &val)
@ MIXED
A location that is partly inside and outside.
static scalar legacyReadFiles(const fileName &obsFileDir, const wordList &obsFileNames, const boundBox &meshBb, DynamicList< PDRobstacle > &blocks, DynamicList< PDRobstacle > &cylinders)
label max(const labelHashSet &set, label maxValue=labelMin)
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
An ordered pair of two objects of type <T> with first() and second() elements.
forAllConstIters(mixture.phases(), phase)
const T & second() const noexcept
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Obstacle definitions for PDR.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
A bounding box defined in terms of min/max extrema points.
void scale(const scalar factor)
@ OUTSIDE
A location outside the volume.
scalar def_grating_slat_w