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();
205 SubList<point>(allPoints,
nPoints, nFaces) = cf.localPoints();
208 const label pti = closestPointIndex(coarseCf[facei], allPoints);
212 localCf.push_back(allPoints[pti]);
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)
364 mathematical::pi*(1 +
Foam::sqrt(5.0))*(pointi + 0.5);
375 else if (mesh_.nSolutionD() == 2)
381 const scalar theta = mathematical::pi*(pointi+0.5)/
nPoints;
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;
476 for (
const label facei : rayStartFace)
478 ++nVisibleFaceFaces[facei];
481 check(nVisibleFaceFaces);
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
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)
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];
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];
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]});
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
void push_back(const T &val)
Copy append an element to the end of this list.
void setCapacity(const label len)
Alter the size of the underlying storage.
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void push_back(const T &val)
Append an element at the end of the list.
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.
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.
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.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
@ broadcast
broadcast [MPI]
label size() const noexcept
The number of entries in the list.
Base class for ray search engines.
void createGeometry()
Create patch geometry based on the original mesh.
static const label maxDynListLength
label nParticipatingFaces() const
Number of participating faces.
virtual void shootRays(labelList &rayStartFaceOut, labelList &rayEndFaceOut) const =0
Shoot rays; returns lists of ray start and end faces.
static label closestPointIndex(const point &p0, const List< point > &pts)
void createParallelAddressing(labelList &rayEndFace) const
Create parallel addressing - map, compact-to-global.
coordSystem::cartesian createCoordSystem(const point &origin, const vector &dir) const
Create Cartesian co-ordinate system.
void createAgglomeration(const IOobject &io)
Create patch geometry based on the agglomerated mesh.
virtual void correct(labelListList &visibleFaceFaces) const
Correct.
static void check(const labelList &nVisibleFaceFaces)
tmp< pointField > createHemiPoints(const label nRayPerFace) const
Create a set of points describing a hemisphere.
raySearchEngine(const raySearchEngine &)=delete
No copy construct.
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.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
label constructSize() const noexcept
Constructed data size.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute List data using default commsType, default flip/negate operator.
const faceList::subList faces() const
Return mesh faces for the entire boundary.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const volScalarField & p0
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
A namespace for various viewFactor model implementations.
Different types of constants.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
dimensionedScalar sin(const dimensionedScalar &ds)
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
IOList< labelList > labelListIOList
IO for a List of labelList.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vectorField pointField
pointField is a vectorField.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a).
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.