79 label localTriFacei = 0;
83 const label patchi = iter.key();
91 const face& f = patch[patchFacei];
101 const face& f = triFaces[triFacei];
107 triSurfaceToAgglom[localTriFacei++] = globalNumbering.
toGlobal 110 finalAgglom[patchi][patchFacei]
111 + coarsePatches[patchi].start()
119 triSurfaceToAgglom.
resize(localTriFacei);
129 rawSurface.localFaces(),
130 rawSurface.localPoints()
140 const label patchi = iter.key();
143 surface.patches()[newPatchi].index() =
patchi;
144 surface.patches()[newPatchi].name() = patch.
name();
145 surface.patches()[newPatchi].geometricType() = patch.type();
169 const labelList visFaces = visibleFaceFaces[facei];
170 forAll(visFaces, faceRemote)
172 label compactI = visFaces[faceRemote];
173 const point& remoteFc = compactCf[compactI];
179 str <<
"l " << vertI-1 <<
' ' << vertI <<
nl;
182 string cmd(
"objToVTK " + fName +
" " + fName.
lessExt() +
".vtk");
188 scalar calculateViewFactorFij
197 scalar rMag =
mag(r);
201 scalar dAiMag =
mag(dAi);
202 scalar dAjMag =
mag(dAj);
206 scalar cosThetaJ =
mag(nj & r)/rMag;
207 scalar cosThetaI =
mag(ni & r)/rMag;
211 (cosThetaI*cosThetaJ*dAjMag*dAiMag)
222 void insertMatrixElements
225 const label fromProci,
231 forAll(viewFactors, facei)
234 const labelList& globalFaces = globalFaceFaces[facei];
239 matrix[globalI][globalFaces[i]] = vf[i];
247 int main(
int argc,
char *argv[])
267 const bool writeViewFactors =
268 viewFactorDict.lookupOrDefault<
bool>(
"writeViewFactorMatrix",
false);
270 const bool dumpRays =
271 viewFactorDict.lookupOrDefault<
bool>(
"dumpRays",
false);
273 const label debug = viewFactorDict.lookupOrDefault<
label>(
"debug", 0);
307 Pout <<
"\nCreating single cell mesh..." <<
endl;
314 "coarse:" + mesh.
name(),
326 Pout <<
"\nCreated single cell mesh..." <<
endl;
333 label nCoarseFaces = 0;
334 label nFineFaces = 0;
341 const volScalarField::Boundary& qrb = qr.boundaryField();
349 if ((isA<fixedValueFvPatchScalarField>(qrpI)) && (pp.size() > 0))
351 viewFactorsPatches[count] = qrpI.
patch().
index();
358 viewFactorsPatches.resize(count);
361 label totalNCoarseFaces = nCoarseFaces;
367 Info <<
"\nTotal number of coarse faces: "<< totalNCoarseFaces <<
endl;
372 Pout <<
"\nView factor patches included in the calculation : " 373 << viewFactorsPatches <<
endl;
384 forAll(viewFactorsPatches, i)
386 const label patchID = viewFactorsPatches[i];
389 const labelList& agglom = finalAgglom[patchID];
392 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
394 const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchID];
395 const pointField& coarseSf = coarseMesh.Sf().boundaryField()[patchID];
398 includePatches.
insert(patchID);
402 point cf = coarseCf[facei];
404 const label coarseFacei = coarsePatchFace[facei];
405 const labelList& fineFaces = coarseToFine[coarseFacei];
406 const label agglomI =
407 agglom[fineFaces[0]] + coarsePatches[patchID].start();
419 upp.faceCentres().size()
420 + upp.localPoints().size()
426 upp.faceCentres().
size()
427 ) = upp.faceCentres();
432 upp.localPoints().size(),
433 upp.faceCentres().size()
434 ) = upp.localPoints();
438 forAll(availablePoints, iPoint)
440 point cfFine = availablePoints[iPoint];
441 if (
mag(cfFine-cfo) < dist)
443 dist =
mag(cfFine-cfo);
448 point sf = coarseSf[facei];
450 localCoarseSf.append(sf);
451 localAgg.append(agglomI);
495 labelList nVisibleFaceFaces(nCoarseFaces, 0);
499 nVisibleFaceFaces[rayStartFace[i]]++;
504 label nViewFactors = 0;
505 forAll(nVisibleFaceFaces, facei)
507 visibleFaceFaces[facei].
setSize(nVisibleFaceFaces[facei]);
508 nViewFactors += nVisibleFaceFaces[facei];
551 IOconstructMap.
write();
574 nVisibleFaceFaces = 0;
577 label facei = rayStartFace[i];
578 label compactI = rayEndFace[i];
579 visibleFaceFaces[facei][nVisibleFaceFaces[facei]++] = compactI;
600 forAll(viewFactorsPatches, i)
602 label patchID = viewFactorsPatches[i];
603 const labelList& agglom = finalAgglom[patchID];
606 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
608 forAll(coarseToFine, coarseI)
610 compactPatchId.append(patchID);
614 const label coarseFacei = coarsePatchFace[coarseI];
615 const labelList& fineFaces = coarseToFine[coarseFacei];
622 mesh.Cf().boundaryField()[patchID],
623 coarseToFine[coarseFacei]
627 mesh.Sf().boundaryField()[patchID],
628 coarseToFine[coarseFacei]
634 map.distribute(compactCoarseSf);
635 map.distribute(compactCoarseCf);
636 map.distribute(compactFineCf);
637 map.distribute(compactFineSf);
639 map.distribute(compactPatchId);
672 label totalPatches = coarsePatches.
size();
686 Info<<
"\nCalculating view factors..." <<
endl;
691 forAll(localCoarseSf, coarseFacei)
693 const List<point>& localFineSf = compactFineSf[coarseFacei];
695 const List<point>& localFineCf = compactFineCf[coarseFacei];
696 const label fromPatchId = compactPatchId[coarseFacei];
697 patchArea[fromPatchId] +=
mag(Ai);
699 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
701 forAll(visCoarseFaces, visCoarseFacei)
704 label compactJ = visCoarseFaces[visCoarseFacei];
705 const List<point>& remoteFineSj = compactFineSf[compactJ];
706 const List<point>& remoteFineCj = compactFineCf[compactJ];
708 const label toPatchId = compactPatchId[compactJ];
713 const vector& dAi = localFineSf[i];
714 const vector& dCi = localFineCf[i];
718 const vector& dAj = remoteFineSj[j];
719 const vector& dCj = remoteFineCj[j];
721 scalar dIntFij = calculateViewFactorFij
732 F[coarseFacei][visCoarseFacei] = Fij/
mag(Ai);
733 sumViewFactorPatch[fromPatchId][toPatchId] += Fij;
750 scalar wideBy2 = (box.
span() & emptyDir)*2.0;
752 forAll(localCoarseSf, coarseFacei)
754 const vector& Ai = localCoarseSf[coarseFacei];
755 const vector& Ci = localCoarseCf[coarseFacei];
757 vector R1i = Ci + (
mag(Ai)/wideBy2)*(Ain ^ emptyDir);
758 vector R2i = Ci - (
mag(Ai)/wideBy2)*(Ain ^ emptyDir) ;
760 const label fromPatchId = compactPatchId[coarseFacei];
761 patchArea[fromPatchId] +=
mag(Ai);
763 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
764 forAll(visCoarseFaces, visCoarseFacei)
767 label compactJ = visCoarseFaces[visCoarseFacei];
768 const vector& Aj = compactCoarseSf[compactJ];
769 const vector& Cj = compactCoarseCf[compactJ];
771 const label toPatchId = compactPatchId[compactJ];
774 vector R1j = Cj + (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
775 vector R2j = Cj - (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
777 scalar d1 =
mag(R1i - R2j);
778 scalar d2 =
mag(R2i - R1j);
779 scalar s1 =
mag(R1i - R1j);
780 scalar s2 =
mag(R2i - R2j);
782 scalar Fij =
mag((d1 + d2) - (s1 + s2))/(4.0*
mag(Ai)/wideBy2);
784 F[coarseFacei][visCoarseFacei] = Fij;
785 sumViewFactorPatch[fromPatchId][toPatchId] += Fij*
mag(Ai);
792 Info <<
"Writing view factor matrix..." <<
endl;
804 forAll(viewFactorsPatches, i)
806 label patchi = viewFactorsPatches[i];
807 forAll(viewFactorsPatches, i)
809 label patchJ = viewFactorsPatches[i];
810 Info <<
"F" << patchi << patchJ <<
": " 818 if (writeViewFactors)
834 volScalarField::Boundary& viewFactorFieldBf =
838 forAll(viewFactorsPatches, i)
840 label patchID = viewFactorsPatches[i];
841 const labelList& agglom = finalAgglom[patchID];
845 coarseMesh.patchFaceMap()[patchID];
847 forAll(coarseToFine, coarseI)
849 const scalar Fij =
sum(
F[compactI]);
850 const label coarseFaceID = coarsePatchFace[coarseI];
851 const labelList& fineFaces = coarseToFine[coarseFaceID];
854 const label faceID = fineFaces[fineId];
855 viewFactorFieldBf[patchID][faceID] = Fij;
860 viewFactorField.write();
867 labelList compactToGlobal(map.constructSize());
872 compactToGlobal[i] = globalNumbering.
toGlobal(i);
878 const Map<label>& localToCompactMap = compactMap[proci];
882 compactToGlobal[iter()] = globalNumbering.
toGlobal 899 forAll(globalFaceFaces, facei)
904 visibleFaceFaces[facei]
921 IOglobalFaceFaces.write();
926 forAll(globalFaceFaces, facei)
931 visibleFaceFaces[facei]
949 IOglobalFaceFaces.write();
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
virtual const fileName & name() const
Return the name of the stream.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
#define forAll(list, i)
Loop across all elements in list.
fvMesh as subset of other mesh. Consists of one cell and all original bounday faces. Useful when manipulating boundary data. Single internal cell only needed to be able to manipulate in a standard way.
fileName path() const
Return path.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
const word & name() const
Return name.
A class for handling file names.
const fileName & facesInstance() const
Return the current instance directory for faces.
A face is a list of labels corresponding to mesh vertices.
label index() const
Return the index of this patch in the fvBoundaryMesh.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
label nInternalFaces() const
dimensionedSymmTensor sqr(const dimensionedVector &dv)
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
A bounding box defined in terms of the points at its extremities.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
void resize(const label)
Alias for setSize(const label)
bool insert(const Key &key)
Insert a new entry.
label triangles(const pointField &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
virtual const pointField & points() const
Return raw points.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A list of faces which address into the list of points.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void append(const T &)
Append an element at the end of the list.
const word & constant() const
Return constant name.
const Field< PointType > & points() const
Return reference to global points.
const polyMesh & mesh() const
Return the mesh reference.
volVectorField F(fluid.F())
Triangle with additional region number.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
const fvPatch & patch() const
Return patch.
const Time & time() const
Return time.
labelHashSet includePatches
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
const geometricSurfacePatchList & patches() const
const boundBox & bounds() const
Return mesh bounding box.
label toGlobal(const label i) const
From local to global.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Class containing processor-to-processor mapping information.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
fileName lessExt() const
Return file name without extension (part before last .)
vector span() const
The bounding box span (from minimum to maximum)
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
label nTriangles() const
Number of triangles after splitting.
A patch is a list of labels that address the faces in the global face list.
label size() const
Return the number of elements in the UList.
virtual bool write(const bool valid=true) const
Write using setting from DB.
Triangulated surface description with patch information.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
int system(const std::string &command)
Execute the specified command.
label localSize() const
My local size.