60 {
"Aw",
"surface area per unit volume" },
67 {
"Bv",
"area blockage" },
68 {
"B",
"area blockage" },
70 {
"Blong",
"longitudinal blockage" },
92 static constexpr
unsigned outputPrecision = 8;
96 double brs,
double brr,
bool blocked,
97 double surr_br,
double surr_dr,
98 scalar* drags_p, scalar* dragr_p,
105 void write_scalarField
108 const scalar& deflt,
const scalarMinMax& limits,
const char *wall_bc,
114 void write_uniformField
116 const word& fieldName,
const scalar& deflt,
const char *wall_bc,
129 void write_symmTensorField
138 void write_symmTensorFieldV
147 void write_blocked_face_list
156 double limit_par,
const fileName& casepath
159 void write_blockedCellsSet
170 static inline scalar averageSurrounding
179 mat(i,j) + mat(i,j+1) + mat(i,j+2)
180 + mat(i+1,j) + mat(i+1,j+2)
181 + mat(i+2,j) + mat(i+2,j+1) + mat(i+2,j+2)
196 static void make_header
204 string note = fieldNotes(
object);
208 os <<
"FoamFile\n{\n"
210 <<
" format ascii;\n"
211 <<
" class " << clsName <<
";\n";
215 os <<
" note " << note <<
";\n";
218 if (!location.empty())
220 os <<
" location " << location <<
";\n";
223 os <<
" object " <<
object <<
";\n"
241 <<
"No PDRblock set" <<
nl
250 const int xdim = faceDims.
x();
251 const int ydim = faceDims.
y();
252 const int zdim = faceDims.
z();
277 Info<<
"Calculating fields" <<
nl;
293 const label maxDim =
cmptMax(surrDims);
313 for (label iz = 0; iz <= zdim; ++iz)
316 (iz == 0 ? 0 : iz == zdim ? zdim - 2 : iz - 1);
320 area_block_s(ix,iy,izz).x()
321 + area_block_r(ix,iy,izz).x()
331 for (label iz = 0; iz < surrDims.
z(); ++iz)
336 neiBlock(0, iz) = neiBlock(cellDims.
y(), iz);
337 neiDrag(0, iz) = neiDrag(cellDims.
y(), iz);
338 neiBlock(ydim, iz) = neiBlock(1, iz);
339 neiDrag(ydim, iz) = neiDrag(1, iz);
343 neiBlock(0, iz) = neiBlock(1, iz);
344 neiDrag(0, iz) = neiDrag(1, iz);
345 neiBlock(ydim, iz) = neiBlock(cellDims.
y(), iz);
346 neiDrag(ydim, iz) = neiDrag(cellDims.
y(), iz);
354 const scalar cell_vol = pdrBlock.
V(ix,iy,iz);
356 const scalar surr_br = averageSurrounding(neiBlock, iy, iz);
357 const scalar surr_dr = averageSurrounding(neiDrag, iy, iz);
361 area_block_s(ix,iy,iz).
x(),
362 area_block_r(ix,iy,iz).
x(),
363 dirn_block(ix,iy,iz).
x(),
365 &(drag_s(ix,iy,iz).xx()),
366 &(drag_r(ix,iy,iz).
x()),
368 &(cbdi(ix,iy,iz).
x()),
385 for (label ix = 0; ix <= xdim; ++ix)
388 (ix == 0 ? 0 : ix == xdim ? xdim - 2 : ix - 1);
392 area_block_s(ixx,iy,iz).y()
393 + area_block_r(ixx,iy,iz).y()
402 for (label ix = 0; ix < surrDims.
x(); ++ix)
404 neiBlock(0, ix) = neiBlock(1, ix);
405 neiDrag(0, ix) = neiDrag(1, ix);
406 neiBlock(zdim, ix) = neiBlock(cellDims.
z(), ix);
407 neiDrag(zdim, ix) = neiDrag(cellDims.
z(), ix);
414 const scalar cell_vol = pdrBlock.
V(ix,iy,iz);
416 const scalar surr_br = averageSurrounding(neiBlock, iz, ix);
417 const scalar surr_dr = averageSurrounding(neiDrag, iz, ix);
421 area_block_s(ix,iy,iz).
y(),
422 area_block_r(ix,iy,iz).
y(),
423 dirn_block(ix,iy,iz).
y(),
425 &(drag_s(ix,iy,iz).yy()),
426 &(drag_r(ix,iy,iz).
y()),
428 &(cbdi(ix,iy,iz).
y()),
445 for (label iy = 0; iy <= ydim; ++iy)
451 iyy = (iy == 0 ? ydim - 2 : iy == ydim ? 0 : iy - 1);
455 iyy = (iy == 0 ? 0 : iy == ydim ? ydim - 2 : iy - 1);
460 area_block_s(ix,iyy,iz).z()
461 + area_block_r(ix,iyy,iz).z()
470 for (label iy = 0; iy < surrDims.
y(); ++iy)
472 neiBlock(0, iy) = neiBlock(1, iy);
473 neiDrag(0, iy) = neiDrag(1, iy);
474 neiBlock(xdim, iy) = neiBlock(cellDims.
x(), iy);
475 neiDrag(xdim, iy) = neiDrag(cellDims.
x(), iy);
482 const scalar cell_vol = pdrBlock.
V(ix,iy,iz);
484 const scalar surr_br = averageSurrounding(neiBlock, ix, iy);
485 const scalar surr_dr = averageSurrounding(neiDrag, ix, iy);
489 area_block_s(ix,iy,iz).z(),
490 area_block_r(ix,iy,iz).z(),
491 dirn_block(ix,iy,iz).z(),
493 &(drag_s(ix,iy,iz).zz()),
494 &(drag_r(ix,iy,iz).z()),
496 &(cbdi(ix,iy,iz).z()),
515 const scalar dx = pdrBlock.
dx(ix);
516 const scalar dy = pdrBlock.
dy(iy);
517 const scalar dz = pdrBlock.
dz(iz);
518 const scalar cell_vol = pdrBlock.
V(ix, iy, iz);
519 const scalar cell_size = pdrBlock.
width(ix, iy, iz);
529 if (cbdi(ix,iy,iz).
x() > maxCT ) { cbdi(ix,iy,iz).x() = maxCT; } ;
530 if (cbdi(ix,iy,iz).
y() > maxCT ) { cbdi(ix,iy,iz).y() = maxCT; } ;
531 if (cbdi(ix,iy,iz).z() > maxCT ) { cbdi(ix,iy,iz).z() = maxCT; } ;
533 surf(ix,iy,iz) /= cell_vol;
539 const scalar vb = v_block(ix,iy,iz);
546 && ((area_block_s(ix,iy,iz).z() + area_block_r(ix,iy,iz).z()) <
MIN_AB_FOR_SIZE)
550 || ( surf(ix,iy,iz) <= 0.0 )
560 double nn, lobs, lobsMax;
561 nn = obs_count(ix,iy,iz) - sub_count(ix,iy,iz).x() + grating_count(ix,iy,iz).x();
562 if ( nn < 1.0 ) { nn = 1.0; }
563 lobsMax = (area_block_s(ix,iy,iz).x() + area_block_r(ix,iy,iz).x()) / nn *
std::sqrt( dy * dz );
564 nn = obs_count(ix,iy,iz) - sub_count(ix,iy,iz).y() + grating_count(ix,iy,iz).y();
565 if ( nn < 1.0 ) { nn = 1.0; }
566 lobs = (area_block_s(ix,iy,iz).y() + area_block_r(ix,iy,iz).y()) / nn *
std::sqrt( dz * dx );
567 if ( lobs > lobsMax )
572 nn = obs_count(ix,iy,iz) - sub_count(ix,iy,iz).z() + grating_count(ix,iy,iz).z();
573 if ( nn < 1.0 ) { nn = 1.0; }
574 lobs = (area_block_s(ix,iy,iz).z() + area_block_r(ix,iy,iz).z()) / nn *
std::sqrt( dx * dy );
575 if ( lobs > lobsMax )
580 obs_size(ix,iy,iz) = lobsMax;
590 if (v_block(ix,iy,iz) < 0)
592 v_block(ix,iy,iz) = 0;
594 else if (v_block(ix,iy,iz) > 1)
596 v_block(ix,iy,iz) = 1;
607 if (sub_count(ix,iy,iz)[cmpt] < 0)
609 sub_count(ix,iy,iz)[cmpt] = 0;
613 v_block(ix,iy,iz) = 1.0 - v_block(ix,iy,iz);
632 write_blocked_face_list
635 obs_count, sub_count, n_blocked_faces,
639 write_blockedCellsSet
643 casepath,
"blockedCellsSet"
648 "betav", arr.
v_block, 1, {0, pars.cong_max_betav},
"zeroGradient",
659 const scalar cell_vol = pdrBlock.
V(ix, iy, iz);
668 scalar nmin =
cmptMin(sub_count(ix,iy,iz));
670 sub_count(ix,iy,iz).x() -= nmin;
671 sub_count(ix,iy,iz).y() -= nmin;
672 sub_count(ix,iy,iz).z() -= nmin;
674 obs_count(ix,iy,iz) -= nmin;
676 assert(obs_count(ix,iy,iz) > -1);
682 const scalar cell_23 =
::pow(cell_vol, 2.0/3.0);
683 obs_count(ix,iy,iz) /= cell_23;
684 sub_count(ix,iy,iz) /= cell_23;
692 Info<<
"Writing field files" <<
nl;
704 "Aw", arr.
surf, 0, {0, 1000},
"zeroGradient",
708 write_symmTensorField
713 write_symmTensorFieldV
715 "CT", cbdi,
Zero,
"zeroGradient",
724 "Nv", arr.
obs_count, 0, {0, 1000},
"zeroGradient",
728 write_symmTensorFieldV
739 "N", arr.
obs_count, 0, {0, 1000},
"zeroGradient",
743 write_symmTensorFieldV
764 + area_block_r(ix,iy,iz)
770 eff_block /= pdrBlock.
width(ix, iy, iz);
776 if (dirn_block(ix,iy,iz)[cmpt] || eff_block[cmpt] < 0)
784 drag_s(ix,iy,iz).xx() = eff_block.
x();
785 drag_s(ix,iy,iz).yy() = eff_block.
y();
786 drag_s(ix,iy,iz).zz() = eff_block.
z();
788 cbdi(ix,iy,iz).x() = 1.0 / (betai_inv1(ix,iy,iz).x() + 1.0);
789 cbdi(ix,iy,iz).y() = 1.0 / (betai_inv1(ix,iy,iz).y() + 1.0);
790 cbdi(ix,iy,iz).z() = 1.0 / (betai_inv1(ix,iy,iz).z() + 1.0);
792 if (cbdi(ix,iy,iz).z() < 0 || cbdi(ix,iy,iz).z() > 1.0)
795 <<
"beta_i problem. z-betai_inv1=" << betai_inv1(ix,iy,iz).z()
796 <<
" beta_i=" << cbdi(ix,iy,iz).z()
803 obs_size(ix,iy,iz) = 0.001 / obs_size(ix,iy,iz);
806 obs_count(ix,iy,iz) = 1.0;
814 write_symmTensorField
823 write_symmTensorField
832 write_symmTensorFieldV
840 write_symmTensorFieldV
856 "b", 1.0,
"zeroGradient",
876 "ft", 0,
"zeroGradient",
900 "Xi", 1,
"zeroGradient",
906 "Xp", 1,
"zeroGradient",
912 "GRxp", 0,
"zeroGradient",
918 "GRep", 0,
"zeroGradient",
924 "RPers", 0,
"zeroGradient",
928 write_pU_fields(meshIndexing,
patches, casepath);
949 "combustFlag", 1,
"zeroGradient",
967 "H2OPS", 0,
"zeroGradient",
973 "AIR", 0,
"zeroGradient",
979 "Ydefault", 0,
"zeroGradient",
985 "eRatio", 1,
"zeroGradient",
991 "sprayFlag", 1,
"zeroGradient",
1007 calculateAndWrite(*
this, meshIndexing, casepath,
patches);
1013 double brs,
double brr,
bool blocked,
1014 double surr_br,
double surr_dr,
1015 scalar* drags_p, scalar* dragr_p,
1022 scalar br = brr + brs;
1028 const scalar
alpha =
1031 ? (1.0 - 0.5 * br) / (1.0 - br) / (1.0 - br)
1039 const scalar
expon =
1042 ?
min(
max((surr_br / br - 0.25) * 4.0 / 3.0, scalar(0)), scalar(1))
1049 *dragr_p *= alpha_r;
1050 *drags_p *=
::pow(alpha_s, 1.09);
1052 if ( *cbdi_p < 0.0 ) { *cbdi_p = 0.0; }
1056 if ( *drags_p < 0.0 ) { *drags_p = 0.0; }
1060 if ( (surr_dr * 0.25) > *drags_p )
1062 *drags_p = surr_dr * 0.25;
1066 if ( blocked ) { *cbdi_p = 0.0; *drags_p = 0.0; *dragr_p = 0.0; }
1076 <<
"No blockage information - PDRblock is not set" <<
nl;
1083 scalar totCount = 0;
1084 scalar totVolBlock = 0;
1097 totVolBlock += v_block(ijk) * pdrBlock.
V(ijk);
1098 totArea += surf(ijk);
1100 totCount +=
max(0, obs_count(ijk));
1102 totDrag.x() +=
max(0, drag_s(ijk).xx());
1103 totDrag.y() +=
max(0, drag_s(ijk).yy());
1104 totDrag.z() +=
max(0, drag_s(ijk).zz());
1108 totBlock[cmpt] +=
max(0, area_block_s(ijk)[cmpt]);
1109 totBlock[cmpt] +=
max(0, area_block_r(ijk)[cmpt]);
1116 <<
"Volume blockage: " << totVolBlock <<
nl
1117 <<
"Total drag: " << totDrag <<
nl
1118 <<
"Total count: " << totCount <<
nl
1119 <<
"Total area blockage: " << totBlock <<
nl
1120 <<
"Total surface area: " << totArea <<
nl;
1127 template<
class Type>
1128 static void tail_field
1132 const char* wall_bc,
1140 putUniform(os,
"value", deflt);
1146 const word& patchName =
patches[patchi].patchName;
1157 putUniform(os,
"value", deflt);
1166 else if (
patches[patchi].patchType == 0)
1171 putUniform(os,
"value", deflt);
1179 putUniform(os,
"value", deflt);
1219 os.
writeEntry(
"neighbourPatch",
"inner_outer");
1224 os.
writeEntry(
"neighbourPatch",
"outer_inner");
1232 void write_scalarField
1235 const scalar& deflt,
const scalarMinMax& limits,
const char *wall_bc,
1245 make_header(os,
"", volScalarField::typeName, fieldName);
1251 <<
"nonuniform List<scalar>" <<
nl
1254 for (label celli=0; celli < meshIndexing.
nCells(); ++celli)
1277 putUniform(os,
"inletValue", deflt);
1278 putUniform(os,
"value", deflt);
1283 tail_field(os, deflt, wall_bc,
patches);
1293 void write_uniformField
1295 const word& fieldName,
const scalar& deflt,
const char *wall_bc,
1304 make_header(os,
"", volScalarField::typeName, fieldName);
1309 putUniform(os,
"internalField", deflt);
1317 if (fieldName ==
"alphat" || fieldName ==
"nut")
1325 putUniform(os,
"inletValue", deflt);
1328 putUniform(os,
"value", deflt);
1332 tail_field(os, deflt, wall_bc,
patches);
1342 void write_pU_fields
1354 make_header(os,
"", volVectorField::typeName,
"U");
1380 for (label patchi = 0; patchi < 3; ++patchi)
1388 for (label patchi = 3; patchi <
patches.size(); ++patchi)
1391 const word& patchName =
p.patchName;
1393 if (
p.patchType == 0)
1397 os.
writeEntry(
"type",
"timeVaryingMappedFixedValue");
1398 os.
writeEntry(
"fileName",
"<case>" / (patchName +
".dat"));
1406 os.
writeEntry(
"type",
"activePressureForceBaffleVelocity");
1411 os.
writeEntry(
"minThresholdValue",
p.blowoffPress);
1452 os.
writeEntry(
"neighbourPatch",
"inner_outer");
1457 os.
writeEntry(
"neighbourPatch",
"outer_inner");
1469 const char *wall_bc =
"zeroGradient;\n\trho\trho";
1474 make_header(os,
"", volScalarField::typeName,
"p");
1479 putUniform(os,
"internalField", deflt);
1491 putUniform(os,
"value", deflt);
1495 tail_field(os, deflt, wall_bc,
patches);
1506 void write_symmTensorField
1508 const word& fieldName,
1510 const symmTensor& deflt,
const char *wall_bc,
1519 make_header(os,
"", volSymmTensorField::typeName, fieldName);
1525 <<
"nonuniform List<symmTensor>" <<
nl
1528 for (label celli=0; celli < meshIndexing.
nCells(); ++celli)
1538 os <<
fld(cellIdx) <<
nl;
1550 putUniform(os,
"inletValue", deflt);
1551 putUniform(os,
"value", deflt);
1556 tail_field(os, deflt, wall_bc,
patches);
1566 void write_symmTensorFieldV
1568 const word& fieldName,
1570 const symmTensor& deflt,
const char *wall_bc,
1579 make_header(os,
"", volSymmTensorField::typeName, fieldName);
1585 <<
"nonuniform List<symmTensor>" <<
nl
1590 for (label celli=0; celli < meshIndexing.
nCells(); ++celli)
1618 putUniform(os,
"inletValue", deflt);
1619 putUniform(os,
"value", deflt);
1624 tail_field(os, deflt, wall_bc,
patches);
1634 void write_blocked_face_list
1642 double limit_par,
const fileName& casepath
1655 for (label facei=0; facei < meshIndexing.
nFaces(); ++facei)
1665 const label ix = faceIdx.
x();
1666 const label iy = faceIdx.
y();
1667 const label iz = faceIdx.
z();
1684 val = face_block(faceIdx).x();
1685 patchId = face_patch(faceIdx).x();
1699 ++n_blocked_faces(ix,iy,iz).x();
1700 sub_count(ix,iy,iz).x() = obs_count(ix,iy,iz);
1706 ++n_blocked_faces(ix-1,iy,iz).x();
1707 sub_count(ix-1,iy,iz).x() = obs_count(ix-1,iy,iz);
1715 val = face_block(faceIdx).y();
1716 patchId = face_patch(faceIdx).y();
1730 ++n_blocked_faces(ix,iy,iz).y();
1731 sub_count(ix,iy,iz).y() = obs_count(ix,iy,iz);
1737 ++n_blocked_faces(ix,iy-1,iz).y();
1738 sub_count(ix,iy-1,iz).y() = obs_count(ix,iy-1,iz);
1746 val = face_block(faceIdx).z();
1747 patchId = face_patch(faceIdx).z();
1761 ++n_blocked_faces(ix,iy,iz).z();
1762 sub_count(ix,iy,iz).z() = obs_count(ix,iy,iz);
1768 ++n_blocked_faces(ix,iy,iz-1).z();
1769 sub_count(ix,iy,iz-1).z() = obs_count(ix,iy,iz-1);
1779 usedFaces(
patchId).set(facei);
1781 else if (val > limit_par)
1799 if (!
isDir(setsDir))
1809 const word& patchName =
patches[patchi].patchName;
1811 OFstream os(setsDir / (patchName +
"Set"));
1813 make_header(os,
"polyMesh/sets",
"faceSet", patchName);
1816 const auto& fnd = usedFaces.cfind(patchi);
1818 if (fnd.good() && (*fnd).any())
1820 os <<
nl << (*fnd).toc() <<
nl;
1835 OFstream os(casepath /
"system/PDRMeshDict");
1837 make_header(os,
"system",
"dictionary",
"PDRMeshDict");
1839 os.
writeEntry(
"blockedCells",
"blockedCellsSet");
1844 const word& patchName =
p.patchName;
1845 const word setName = patchName +
"Set";
1847 if (
p.patchType == 0)
1854 else if (
p.patchType > 0)
1856 panelNames.
append(setName);
1865 const word& patchName =
p.patchName;
1866 const word setName = patchName +
"Set";
1868 if (
p.patchType > 0)
1872 os.
writeEntry(
"cyclicMasterPatch",
word(patchName +
"Cyclic_half0"));
1878 os.
writeEntry(
"defaultPatch",
"blockedFaces");
1889 void write_blockedCellsSet
1896 const word& listName
1899 if (listName.empty())
1922 for (label celli=0; celli < meshIndexing.
nCells(); ++celli)
1931 if (
fld(cellIdx) < limit_par)
1933 blockedCell.
set(celli);
1939 const label n_bfaces =
cmptSum(blocked);
1947 if (blocked[cmpt] > 1) ++n_bpairs;
1952 Info<<
"block " << celli <<
" from "
1953 << blocked <<
" -> ("
1954 << n_bfaces <<
' ' << n_bpairs
1965 blockedCell.
set(celli);
1971 make_header(os,
"constant/polyMesh/sets",
"cellSet", listName);
1973 if (blockedCell.
any())
1975 os << blockedCell.
toc();