58 for (
const label
n : nVisibleFaceFaces)
60 nFaceMin =
min(nFaceMin,
n);
61 nFaceMax =
max(nFaceMax,
n);
65 const label nFace = nVisibleFaceFaces.size();
66 const label nGlobalRays =
returnReduce(nRay, sumOp<label>());
71 <<
"No rays identified - view factors will not be calculated" 75 const label globalNFacesMin =
returnReduce(nFaceMin, minOp<label>());
76 const label globalNFacesMax =
returnReduce(nFaceMax, maxOp<label>());
77 const label nGlobalFaces =
returnReduce(nFace, sumOp<label>());
78 const scalar avgFaces = nGlobalRays/scalar(nGlobalFaces);
80 Info<<
"\nRay summary:" <<
nl 81 <<
" Number of rays: " << nGlobalRays <<
nl 82 <<
" Number of rays-per-face (min, max, average): (" 83 << globalNFacesMin <<
", " 84 << globalNFacesMax <<
", " 85 << avgFaces <<
")" <<
endl;
92 const List<point>&
pts 97 scalar distSqr = GREAT;
114 Info<<
"\nFace agglomeration: active" <<
nl 115 <<
" Reading file " <<
io.name() <<
endl;
120 Info<<
" Creating coarse mesh" <<
nl;
129 mesh_.time().timeName(),
139 const auto& coarseMesh = agglomMeshPtr_();
147 const polyBoundaryMesh& finePatches = mesh_.boundaryMesh();
148 const polyBoundaryMesh& coarsePatches = coarseMesh.boundaryMesh();
150 for (
const label patchi : patchIDs_)
152 nCoarseFace_ += coarsePatches[patchi].size();
153 nFace_ += finePatches[patchi].size();
156 Info<<
"\nTotal number of coarse faces: " 160 Info<<
"\nTotal number of fine faces: " 167 DynamicList<point> localCf(nCoarseFace_);
168 DynamicList<vector> localSf(nCoarseFace_);
169 DynamicList<label> localAgg(nCoarseFace_);
171 for (
const label patchi : patchIDs_)
173 const labelList& agglom = finalAgglom[patchi];
175 if (agglom.empty())
continue;
177 label nAgglom =
max(agglom) + 1;
179 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchi];
181 const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchi];
182 const vectorField& coarseSf = coarseMesh.Sf().boundaryField()[patchi];
184 const polyPatch&
pp = finePatches[patchi];
185 patchAreas_[patchi] +=
sum(coarseMesh.magSf().boundaryField()[patchi]);
189 const label coarseFacei = coarsePatchFace[facei];
190 const label agglomi = coarseFacei + coarsePatches[patchi].start();
193 const labelList& fineFaces = coarseToFine[coarseFacei];
196 UIndirectList<face>(
pp, fineFaces),
201 const label nFaces = cf.faceCentres().size();
202 const label
nPoints = cf.localPoints().size();
204 SubList<point>(
allPoints, nFaces) = cf.faceCentres();
208 const label pti = closestPointIndex(coarseCf[facei],
allPoints);
213 localSf.push_back(coarseSf[facei]);
214 localAgg.push_back(agglomi);
219 Info<<
"\nAssembled coarse patch data" <<
endl;
235 globalNumbering_ = globalIndex(nCoarseFace_);
241 DynamicList<point> localCf(mesh_.nBoundaryFaces());
242 DynamicList<vector> localSf(mesh_.nBoundaryFaces());
244 const auto&
pbm = mesh_.boundaryMesh();
246 for (
const label patchi : patchIDs_)
248 localCf.push_back(
pbm[patchi].faceCentres());
249 localSf.push_back(
pbm[patchi].faceAreas());
251 patchAreas_[patchi] +=
sum(mesh_.magSf().boundaryField()[patchi]);
254 Info<<
"\nAssembled patch data" <<
endl;
256 nFace_ = localCf.size();
268 globalNumbering_ = globalIndex(nFace_);
286 mapPtr_.reset(
new mapDistribute(globalNumbering_, rayEndFace, compactMap));
288 DebugInfo <<
"\nCreating compact-to-global addressing" <<
endl;
292 compactToGlobal_.resize_nocopy(mapPtr_->constructSize());
296 for (label i = 0; i < globalNumbering_.localSize(); ++i)
298 compactToGlobal_[i] = globalNumbering_.toGlobal(i);
303 const Map<label>& localToCompactMap = compactMap[proci];
307 compactToGlobal_[*iter] =
308 globalNumbering_.toGlobal(proci, iter.key());
327 if (mesh_.nSolutionD() == 2)
339 return coordSystem::cartesian(origin, dir, axis);
345 const label nRayPerFace
349 auto& hemiPts = themiPts.ref();
351 const label
nPoints = hemiPts.size();
353 if (mesh_.nSolutionD() == 3)
372 else if (mesh_.nSolutionD() == 2)
392 const dictionary&
dict 399 patchGroup_(
dict.getOrDefault<word>(
"patchGroup",
"viewFactorWall")),
400 patchIDs_(mesh_.boundaryMesh().indices(patchGroup_)),
401 patchAreas_(mesh_.boundaryMesh().nNonProcessor(),
Zero),
402 agglomerate_(
dict.
get<bool>(
"agglomerate")),
403 agglomMeshPtr_(nullptr),
406 allCf_(UPstream::nProcs()),
407 allSf_(UPstream::nProcs()),
408 allAgg_(UPstream::nProcs())
410 Info<<
"\nParticipating patches:" <<
endl;
414 const label patchi = patchIDs_[i];
415 Info<<
" " << i <<
": " << mesh_.boundaryMesh()[patchi].name()
419 const word agglomName(
dict.getOrDefault<word>(
"agglom",
"finalAgglom"));
424 mesh_.facesInstance(),
434 createAgglomeration(agglomIO);
443 <<
"Found agglomeration file: " << agglomIO.objectPath() <<
nl 444 <<
" This is inconsistent with the view factor calculation " 445 <<
"and should be removed" <<
nl <<
endl;
454 nCoarseFace_ == -1 ? globalIndex(nFace_) : globalIndex(nCoarseFace_);
473 for (
const label facei : rayStartFace)
475 ++nVisibleFaceFaces[facei];
478 check(nVisibleFaceFaces);
488 visibleFaceFaces.resize_nocopy(nFace);
489 forAll(nVisibleFaceFaces, facei)
491 visibleFaceFaces[facei].resize_nocopy(nVisibleFaceFaces[facei]);
494 nVisibleFaceFaces = 0;
497 const label facei = rayStartFace[i];
498 const label sloti = rayEndFace[i];
499 visibleFaceFaces[facei][nVisibleFaceFaces[facei]++] = sloti;
506 const mapDistribute& map,
509 List<List<vector>>& compactFineSf,
510 List<List<point>>& compactFineCf,
511 DynamicList<List<point>>& compactPoints,
512 DynamicList<label>& compactPatchId
515 compactCf.resize_nocopy(map.constructSize());
516 compactSf.resize_nocopy(map.constructSize());
517 compactFineSf.resize_nocopy(map.constructSize());
518 compactFineCf.resize_nocopy(map.constructSize());
519 compactPoints.setCapacity(map.constructSize());
520 compactPatchId.setCapacity(map.constructSize());
528 const auto& coarseMesh = agglomMeshPtr_();
529 const auto& coarsePatches = coarseMesh.boundaryMesh();
530 const auto& coarseFaces = coarseMesh.faces();
531 const auto& coarsePoints = coarseMesh.points();
533 const auto& finalAgglom = coarseMesh.patchFaceAgglomeration();
537 for (
const label patchi : patchIDs_)
539 const auto& fineCfp = mesh_.Cf().boundaryField()[patchi];
540 const auto& fineSfp = mesh_.Sf().boundaryField()[patchi];
541 const labelList& agglom = finalAgglom[patchi];
543 if (agglom.empty())
continue;
545 const label nAgglom =
max(agglom) + 1;
548 coarseMesh.patchFaceMap()[patchi];
550 const label coarseStart = coarsePatches[patchi].start();
552 forAll(coarseToFine, coarsei)
554 compactPatchId.push_back(patchi);
559 coarseFaces[coarseStart + coarsei]
561 compactPoints.push_back(localPoints);
563 const label coarseFacei = coarsePatchFace[coarsei];
564 const labelList& fineFaces = coarseToFine[coarseFacei];
566 List<point>& fineCf = compactFineCf[sloti];
568 fineCf = UIndirectList<point>(fineCfp, fineFaces);
570 List<vector>& fineSf = compactFineSf[sloti];
571 fineSf.resize_nocopy(fineFaces.size());
572 fineSf = UIndirectList<vector>(fineSfp, fineFaces);
583 const auto&
patches = mesh_.boundaryMesh();
584 const faceList& faces = mesh_.faces();
588 for (
const label patchi : patchIDs_)
590 const auto& Sfp = mesh_.Sf().boundaryField()[patchi];
591 const auto& Cfp = mesh_.Cf().boundaryField()[patchi];
597 compactPatchId.push_back(patchi);
599 const auto& fpts = faces[facei +
pp.start()];
600 compactPoints.push_back(List<point>(mesh_.points(), fpts));
602 compactFineCf[sloti] = List<point>({Cfp[facei]});
603 compactFineSf[sloti] = List<vector>({Sfp[facei]});
611 map.distribute(compactSf);
612 map.distribute(compactCf);
613 map.distribute(compactFineCf);
614 map.distribute(compactFineSf);
615 map.distribute(compactPoints);
616 map.distribute(compactPatchId);
Different types of constants.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
static void listCombineGather(UList< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combines List elements.
static label closestPointIndex(const point &p0, const List< point > &pts)
coordSystem::cartesian createCoordSystem(const point &origin, const vector &dir) const
Create Cartesian co-ordinate system.
const polyBoundaryMesh & pbm
dimensionedScalar acos(const dimensionedScalar &ds)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
const label maxDynListLength(viewFactorDict.getOrDefault< label >("maxDynListLength", 1000000))
errorManipArg< error, int > exit(error &err, const int errNo=1)
void createGeometry()
Create patch geometry based on the original mesh.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Ignore writing from objectRegistry::writeObject()
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
void compactAddressing(const mapDistribute &map, pointField &compactCf, vectorField &compactSf, List< List< vector >> &compactFineSf, List< List< point >> &compactFineCf, DynamicList< List< point >> &compactPoints, DynamicList< label > &compactPatchId) const
Create compact addressing.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
#define forAll(list, i)
Loop across all elements in list.
void createAgglomeration(const IOobject &io)
Create patch geometry based on the agglomerated mesh.
A Cartesian coordinate system.
List< face > faceList
List of faces.
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
dimensionedScalar cos(const dimensionedScalar &ds)
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
static const Identity< scalar > I
tmp< pointField > createHemiPoints(const label nRayPerFace) const
Create a set of points describing a hemisphere.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
constexpr scalar pi(M_PI)
static void check(const labelList &nVisibleFaceFaces)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
#define DebugInfo
Report an information message using Foam::Info.
dimensionedScalar sin(const dimensionedScalar &ds)
virtual void correct(labelListList &visibleFaceFaces) const
Correct.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual linear/tree communicat...
label nParticipatingFaces() const
Number of participating faces.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
raySearchEngine(const raySearchEngine &)=delete
No copy construct.
const polyBoundaryMesh & patches
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
const volScalarField & p0
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
virtual void shootRays(labelList &rayStartFaceOut, labelList &rayEndFaceOut) const =0
Shoot rays; returns lists of ray start and end faces.
void createParallelAddressing(labelList &rayEndFace) const
Create parallel addressing - map, compact-to-global.
static constexpr const zero Zero
Global zero (0)
IOList< labelList > labelListIOList
IO for a List of labelList.