38 #define addObstacleReader(obsType, obsName) \ 41 namespace PDRobstacles \ 43 addNamedToMemberFunctionSelectionTable \ 63 inline scalar getPorosity(
const dictionary&
dict)
65 return 1 -
clamp(
dict.getOrDefault<scalar>(
"porosity", 0), zero_one{});
69 inline vector getPorosities(
const dictionary&
dict)
71 vector blockage(vector::one);
73 if (
dict.readIfPresent(
"porosities", blockage))
75 for (scalar& val : blockage)
77 val = 1 -
clamp(val, zero_one{});
95 { vector::components::X,
"x" },
97 { vector::components::Z,
"z" },
114 { inletDirnType::_X,
"-x" },
115 { inletDirnType::_Y,
"-y" },
116 { inletDirnType::_Z,
"-z" },
117 { inletDirnType::_X,
"_x" },
118 { inletDirnType::_Y,
"_y" },
119 { inletDirnType::_Z,
"_z" },
120 { inletDirnType::X,
"+x" },
122 { inletDirnType::Z,
"+z" },
123 { inletDirnType::X,
"x" },
125 { inletDirnType::Z,
"z" },
133 addObstacleReader(cylinder, cyl);
134 addObstacleReader(cylinder, cylinder);
139 const dictionary&
dict 142 obs.PDRobstacle::readProperties(
dict);
143 obs.typeId = enumTypeId;
146 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1;
150 dict.readEntry(
"point", obs.pt);
151 dict.readEntry(
"length", obs.len());
152 dict.readEntry(
"diameter", obs.dia());
154 obs.orient = vectorComponentsNames.get(
"direction",
dict);
160 obs.sortBias = obs.len();
164 obs.sortBias = 0.5*obs.dia();
172 addObstacleReader(diagbeam,
diag);
173 addObstacleReader(diagbeam, diagbeam);
178 const dictionary&
dict 181 obs.PDRobstacle::readProperties(
dict);
182 obs.typeId = enumTypeId;
185 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1;
189 dict.readEntry(
"point", obs.pt);
190 dict.readEntry(
"length", obs.len());
194 obs.orient = vectorComponentsNames.get(
"direction",
dict);
197 scalar angle =
dict.get<scalar>(
"angle");
199 while (angle > 180) angle -= 180;
200 while (angle < 0) angle += 180;
203 dict.readEntry(
"width", dims);
215 obs.wa = dims.first();
216 obs.wb = dims.second();
218 const scalar ctheta =
cos(obs.theta());
219 const scalar stheta =
sin(obs.theta());
225 obs.sortBias = obs.len();
229 obs.sortBias = 0.5*(obs.wa * stheta + obs.wb * ctheta);
233 obs.sortBias = 0.5*(obs.wa * ctheta + obs.wb * stheta);
241 Info<<
"... changed diag-beam to box" <<
nl;
246 obs.span =
vector(obs.len(), obs.wa, obs.wb);
250 obs.span =
vector(obs.wb, obs.len(), obs.wa);
254 obs.span =
vector(obs.wa, obs.wb, obs.len());
259 vector adjustPt = -0.5*obs.span;
260 adjustPt[obs.orient] = 0;
266 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1.0;
267 obs.blowoff_type = 0;
274 addObstacleReader(cuboid, box);
279 const dictionary&
dict 282 obs.PDRobstacle::readProperties(
dict);
283 obs.typeId = enumTypeId;
286 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1;
289 dict.readEntry(
"point", obs.pt);
290 dict.readEntry(
"size", obs.span);
293 obs.vbkge = getPorosity(
dict);
297 obs.xbkge = blockages.x();
298 obs.ybkge = blockages.y();
299 obs.zbkge = blockages.z();
305 addObstacleReader(wallbeam, wallbeam);
310 const dictionary&
dict 314 obs.typeId = enumTypeId;
317 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1;
327 addObstacleReader(grating, grating);
328 addObstacleReader(grating, grate);
333 const dictionary&
dict 336 obs.PDRobstacle::readProperties(
dict);
337 obs.typeId = enumTypeId;
340 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1;
342 dict.readEntry(
"point", obs.pt);
343 dict.readEntry(
"size", obs.span);
352 obs.vbkge = getPorosity(
dict);
355 obs.xbkge = blockages.x();
356 obs.ybkge = blockages.y();
357 obs.zbkge = blockages.z();
363 obs.slat_width =
dict.getOrDefault<scalar>(
"slats",
Zero);
366 if (
equal(obs.span.x(), 0))
368 obs.orient = vector::X;
370 else if (
equal(obs.span.y(), 0))
376 obs.orient = vector::Z;
383 addObstacleReader(louver, louver);
384 addObstacleReader(louver, louvre);
389 const dictionary&
dict 392 obs.PDRobstacle::readProperties(
dict);
393 obs.typeId = enumTypeId;
396 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1;
398 dict.readEntry(
"point", obs.pt);
399 dict.readEntry(
"size", obs.span);
408 obs.vbkge = getPorosity(
dict);
411 obs.xbkge = blockages.x();
412 obs.ybkge = blockages.y();
413 obs.zbkge = blockages.z();
419 const scalar blowoffPress =
dict.get<scalar>(
"pressure");
421 obs.blowoff_press =
barToPa(blowoffPress);
422 obs.blowoff_time =
dict.getOrDefault<scalar>(
"time", 0);
423 obs.blowoff_type =
dict.getOrDefault<label>(
"type", 2);
425 if (obs.blowoff_type == 1)
427 Info<<
"Louver : blowoff-type 1 not yet implemented." <<
nl;
430 if (obs.blowoff_time != 0)
432 Info<<
"Louver : has blowoff time set," 433 <<
" not set to blow off cell-by-cell" <<
nl;
441 (obs.blowoff_type == 1 || obs.blowoff_type == 2)
442 && (blowoffPress > 0)
445 if (blowoffPress > maxBlowoffPressure)
447 Info<<
"Blowoff pressure (" << blowoffPress
448 <<
") too high for blowoff type " 449 << obs.blowoff_type <<
nl;
455 Info<<
"Problem with blowoff parameters" <<
nl;
457 Info<<
"Pressure[bar] " << blowoffPress
458 <<
" Blowoff type " << obs.blowoff_type
459 <<
", blowoff pressure " << obs.blowoff_press <<
nl;
472 const dictionary&
dict 475 obs.PDRobstacle::readProperties(
dict);
476 obs.typeId = enumTypeId;
478 const auto nameLen = obs.identifier.length();
482 if (patchName.empty())
485 <<
"RECT_PATCH without a patch name" 488 else if (patchName.length() != nameLen)
491 <<
"RECT_PATCH stripped invalid characters from patch name: " 495 obs.identifier = std::move(patchName);
499 obs.xbkge = obs.ybkge = obs.zbkge = obs.vbkge = 1;
501 dict.readEntry(
"point", obs.pt);
502 dict.readEntry(
"size", obs.span);
503 obs.inlet_dirn = inletDirnNames.get(
"direction",
dict);
509 #undef addObstacleReader Different types of constants.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
static void read(PDRobstacle &obs, const dictionary &dict)
constexpr scalar barToPa(const scalar bar) noexcept
Conversion from bar to Pa.
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...
bool equal(const T &a, const T &b)
Compare two values for equality.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void read(PDRobstacle &obs, const dictionary &dict)
Unit conversion functions.
constexpr char nl
The newline '\n' character (0x0a)
static void read(PDRobstacle &obs, const dictionary &dict)
static void read(PDRobstacle &obs, const dictionary &dict)
static constexpr int enumTypeId
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
dimensionedScalar cos(const dimensionedScalar &ds)
static void read(PDRobstacle &obs, const dictionary &dict)
static void read(PDRobstacle &obs, const dictionary &dict)
dimensionedScalar sin(const dimensionedScalar &ds)
Pair< label > labelPair
A pair of labels.
static void read(PDRobstacle &obs, const dictionary &dict)
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
PtrList< volScalarField > & Y
const std::string patch
OpenFOAM patch number as a std::string.
Macros for easy insertion into member function selection tables.
messageStream Info
Information stream (stdout output on master, null elsewhere)
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
static constexpr const zero Zero
Global zero (0)