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();
271 globalNumbering_ = globalIndex(nFace_);
289 mapPtr_.reset(
new mapDistribute(globalNumbering_, rayEndFace, compactMap));
291 DebugInfo <<
"\nCreating compact-to-global addressing" <<
endl;
295 compactToGlobal_.resize_nocopy(mapPtr_->constructSize());
299 for (label i = 0; i < globalNumbering_.localSize(); ++i)
301 compactToGlobal_[i] = globalNumbering_.toGlobal(i);
306 const Map<label>& localToCompactMap = compactMap[proci];
310 compactToGlobal_[*iter] =
311 globalNumbering_.toGlobal(proci, iter.key());
330 if (mesh_.nSolutionD() == 2)
342 return coordSystem::cartesian(origin, dir, axis);
348 const label nRayPerFace
352 auto& hemiPts = themiPts.ref();
354 const label
nPoints = hemiPts.size();
356 if (mesh_.nSolutionD() == 3)
375 else if (mesh_.nSolutionD() == 2)
395 const dictionary&
dict 402 patchGroup_(
dict.getOrDefault<word>(
"patchGroup",
"viewFactorWall")),
403 patchIDs_(mesh_.boundaryMesh().indices(patchGroup_)),
404 patchAreas_(mesh_.boundaryMesh().nNonProcessor(),
Zero),
405 agglomerate_(
dict.
get<bool>(
"agglomerate")),
406 agglomMeshPtr_(nullptr),
409 allCf_(UPstream::nProcs()),
410 allSf_(UPstream::nProcs()),
411 allAgg_(UPstream::nProcs())
413 Info<<
"\nParticipating patches:" <<
endl;
417 const label patchi = patchIDs_[i];
418 Info<<
" " << i <<
": " << mesh_.boundaryMesh()[patchi].name()
422 const word agglomName(
dict.getOrDefault<word>(
"agglom",
"finalAgglom"));
427 mesh_.facesInstance(),
437 createAgglomeration(agglomIO);
446 <<
"Found agglomeration file: " << agglomIO.objectPath() <<
nl 447 <<
" This is inconsistent with the view factor calculation " 448 <<
"and should be removed" <<
nl <<
endl;
457 nCoarseFace_ == -1 ? globalIndex(nFace_) : globalIndex(nCoarseFace_);
476 for (
const label facei : rayStartFace)
478 ++nVisibleFaceFaces[facei];
481 check(nVisibleFaceFaces);
491 visibleFaceFaces.resize_nocopy(nFace);
492 forAll(nVisibleFaceFaces, facei)
494 visibleFaceFaces[facei].resize_nocopy(nVisibleFaceFaces[facei]);
497 nVisibleFaceFaces = 0;
500 const label facei = rayStartFace[i];
501 const label sloti = rayEndFace[i];
502 visibleFaceFaces[facei][nVisibleFaceFaces[facei]++] = sloti;
509 const mapDistribute& map,
512 List<List<vector>>& compactFineSf,
513 List<List<point>>& compactFineCf,
514 DynamicList<List<point>>& compactPoints,
515 DynamicList<label>& compactPatchId
518 compactCf.resize_nocopy(map.constructSize());
519 compactSf.resize_nocopy(map.constructSize());
520 compactFineSf.resize_nocopy(map.constructSize());
521 compactFineCf.resize_nocopy(map.constructSize());
522 compactPoints.setCapacity(map.constructSize());
523 compactPatchId.setCapacity(map.constructSize());
531 const auto& coarseMesh = agglomMeshPtr_();
532 const auto& coarsePatches = coarseMesh.boundaryMesh();
533 const auto& coarseFaces = coarseMesh.faces();
534 const auto& coarsePoints = coarseMesh.points();
536 const auto& finalAgglom = coarseMesh.patchFaceAgglomeration();
540 for (
const label patchi : patchIDs_)
542 const auto& fineCfp = mesh_.Cf().boundaryField()[patchi];
543 const auto& fineSfp = mesh_.Sf().boundaryField()[patchi];
544 const labelList& agglom = finalAgglom[patchi];
546 if (agglom.empty())
continue;
548 const label nAgglom =
max(agglom) + 1;
551 coarseMesh.patchFaceMap()[patchi];
553 const label coarseStart = coarsePatches[patchi].start();
555 forAll(coarseToFine, coarsei)
557 compactPatchId.push_back(patchi);
562 coarseFaces[coarseStart + coarsei]
564 compactPoints.push_back(localPoints);
566 const label coarseFacei = coarsePatchFace[coarsei];
567 const labelList& fineFaces = coarseToFine[coarseFacei];
569 List<point>& fineCf = compactFineCf[sloti];
571 fineCf = UIndirectList<point>(fineCfp, fineFaces);
573 List<vector>& fineSf = compactFineSf[sloti];
574 fineSf.resize_nocopy(fineFaces.size());
575 fineSf = UIndirectList<vector>(fineSfp, fineFaces);
586 const auto&
patches = mesh_.boundaryMesh();
587 const faceList& faces = mesh_.faces();
591 for (
const label patchi : patchIDs_)
593 const auto& Sfp = mesh_.Sf().boundaryField()[patchi];
594 const auto& Cfp = mesh_.Cf().boundaryField()[patchi];
600 compactPatchId.push_back(patchi);
602 const auto& fpts = faces[facei +
pp.start()];
603 compactPoints.push_back(List<point>(mesh_.points(), fpts));
605 compactFineCf[sloti] = List<point>({Cfp[facei]});
606 compactFineSf[sloti] = List<vector>({Sfp[facei]});
614 map.distribute(compactSf);
615 map.distribute(compactCf);
616 map.distribute(compactFineCf);
617 map.distribute(compactFineSf);
618 map.distribute(compactPoints);
619 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 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)
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.
static void broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
Ignore writing from objectRegistry::writeObject()
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
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.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
#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.
static void listGather(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather (reduce) list elements, applying bop to each list element.
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)
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
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 int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
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.
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element...
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.