81 label localTriFacei = 0;
87 const label patchi = iter.key();
93 const face& f = patch[patchFacei];
108 triSurfaceToAgglom[localTriFacei++] = globalNumbering.
toGlobal 111 finalAgglom[patchi][patchFacei]
112 + coarsePatches[patchi].start()
120 triSurfaceToAgglom.
resize(localTriFacei);
130 rawSurface.localFaces(),
131 rawSurface.localPoints()
141 const label patchi = iter.key();
144 surface.patches()[newPatchi].index() =
patchi;
145 surface.patches()[newPatchi].name() = patch.
name();
146 surface.patches()[newPatchi].geometricType() = patch.type();
165 allPoints.
append(compactCf);
170 const labelList visFaces = visibleFaceFaces[facei];
171 forAll(visFaces, faceRemote)
180 Pout<<
"\nDumping rays to " << fName +
".vtk" <<
endl;
195 scalar calculateViewFactorFij
204 scalar rMag =
mag(r);
208 scalar dAiMag =
mag(dAi);
209 scalar dAjMag =
mag(dAj);
213 scalar cosThetaJ =
mag(nj & r)/rMag;
214 scalar cosThetaI =
mag(ni & r)/rMag;
218 (cosThetaI*cosThetaJ*dAjMag*dAiMag)
229 void insertMatrixElements
232 const label fromProci,
238 forAll(viewFactors, facei)
241 const labelList& globalFaces = globalFaceFaces[facei];
246 matrix[globalI][globalFaces[i]] = vf[i];
254 int main(
int argc,
char *argv[])
268 isA<cyclicTransform>(pp)
269 || isA<symmetryPolyPatch>(pp)
270 || isA<symmetryPlanePolyPatch>(pp)
271 || isA<wedgePolyPatch>(pp)
275 <<
" does not currently support transforming patches: " 276 "cyclic, symmetry and wedge." 294 const bool writeViewFactors =
295 viewFactorDict.lookupOrDefault<
bool>(
"writeViewFactorMatrix",
false);
297 const bool dumpRays =
298 viewFactorDict.lookupOrDefault<
bool>(
"dumpRays",
false);
300 const label debug = viewFactorDict.lookupOrDefault<
label>(
"debug", 0);
334 Pout <<
"\nCreating single cell mesh..." <<
endl;
341 "coarse:" + mesh.
name(),
353 Pout <<
"\nCreated single cell mesh..." <<
endl;
360 label nCoarseFaces = 0;
361 label nFineFaces = 0;
375 if ((isA<fixedValueFvPatchScalarField>(qrpI)) && (pp.size() > 0))
384 viewFactorsPatches.resize(count);
387 label totalNCoarseFaces = nCoarseFaces;
393 Info <<
"\nTotal number of coarse faces: "<< totalNCoarseFaces <<
endl;
398 Pout <<
"\nView factor patches included in the calculation : " 399 << viewFactorsPatches <<
endl;
410 forAll(viewFactorsPatches, i)
412 const label patchID = viewFactorsPatches[i];
415 const labelList& agglom = finalAgglom[patchID];
418 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
420 const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchID];
421 const pointField& coarseSf = coarseMesh.Sf().boundaryField()[patchID];
424 includePatches.
insert(patchID);
428 point cf = coarseCf[facei];
430 const label coarseFacei = coarsePatchFace[facei];
431 const labelList& fineFaces = coarseToFine[coarseFacei];
432 const label agglomI =
433 agglom[fineFaces[0]] + coarsePatches[patchID].start();
445 upp.faceCentres().size()
446 + upp.localPoints().size()
452 upp.faceCentres().
size()
453 ) = upp.faceCentres();
458 upp.localPoints().size(),
459 upp.faceCentres().size()
460 ) = upp.localPoints();
464 forAll(availablePoints, iPoint)
466 point cfFine = availablePoints[iPoint];
467 if (
mag(cfFine-cfo) < dist)
469 dist =
mag(cfFine-cfo);
474 point sf = coarseSf[facei];
476 localCoarseSf.append(sf);
477 localAgg.append(agglomI);
521 labelList nVisibleFaceFaces(nCoarseFaces, 0);
525 nVisibleFaceFaces[rayStartFace[i]]++;
530 label nViewFactors = 0;
531 forAll(nVisibleFaceFaces, facei)
533 visibleFaceFaces[facei].
setSize(nVisibleFaceFaces[facei]);
534 nViewFactors += nVisibleFaceFaces[facei];
577 IOconstructMap.
write();
600 nVisibleFaceFaces = 0;
603 label facei = rayStartFace[i];
604 label compactI = rayEndFace[i];
605 visibleFaceFaces[facei][nVisibleFaceFaces[facei]++] = compactI;
626 forAll(viewFactorsPatches, i)
628 label patchID = viewFactorsPatches[i];
629 const labelList& agglom = finalAgglom[patchID];
632 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
634 forAll(coarseToFine, coarseI)
636 compactPatchId.append(patchID);
640 const label coarseFacei = coarsePatchFace[coarseI];
641 const labelList& fineFaces = coarseToFine[coarseFacei];
648 mesh.Cf().boundaryField()[patchID],
649 coarseToFine[coarseFacei]
653 mesh.Sf().boundaryField()[patchID],
654 coarseToFine[coarseFacei]
660 map.distribute(compactCoarseSf);
661 map.distribute(compactCoarseCf);
662 map.distribute(compactFineCf);
663 map.distribute(compactFineSf);
665 map.distribute(compactPatchId);
673 runTime.path()/
"allVisibleFaces",
698 label totalPatches = coarsePatches.
size();
712 Info<<
"\nCalculating view factors..." <<
endl;
717 forAll(localCoarseSf, coarseFacei)
719 const List<point>& localFineSf = compactFineSf[coarseFacei];
721 const List<point>& localFineCf = compactFineCf[coarseFacei];
722 const label fromPatchId = compactPatchId[coarseFacei];
723 patchArea[fromPatchId] +=
mag(Ai);
725 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
727 forAll(visCoarseFaces, visCoarseFacei)
729 F[coarseFacei].setSize(visCoarseFaces.
size());
730 label compactJ = visCoarseFaces[visCoarseFacei];
731 const List<point>& remoteFineSj = compactFineSf[compactJ];
732 const List<point>& remoteFineCj = compactFineCf[compactJ];
734 const label toPatchId = compactPatchId[compactJ];
739 const vector& dAi = localFineSf[i];
740 const vector& dCi = localFineCf[i];
744 const vector& dAj = remoteFineSj[j];
745 const vector& dCj = remoteFineCj[j];
747 scalar dIntFij = calculateViewFactorFij
758 F[coarseFacei][visCoarseFacei] = Fij/
mag(Ai);
759 sumViewFactorPatch[fromPatchId][toPatchId] += Fij;
776 scalar wideBy2 = (box.
span() & emptyDir)*2.0;
778 forAll(localCoarseSf, coarseFacei)
780 const vector& Ai = localCoarseSf[coarseFacei];
781 const vector& Ci = localCoarseCf[coarseFacei];
783 vector R1i = Ci + (
mag(Ai)/wideBy2)*(Ain ^ emptyDir);
784 vector R2i = Ci - (
mag(Ai)/wideBy2)*(Ain ^ emptyDir) ;
786 const label fromPatchId = compactPatchId[coarseFacei];
787 patchArea[fromPatchId] +=
mag(Ai);
789 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
790 forAll(visCoarseFaces, visCoarseFacei)
792 F[coarseFacei].setSize(visCoarseFaces.
size());
793 label compactJ = visCoarseFaces[visCoarseFacei];
794 const vector& Aj = compactCoarseSf[compactJ];
795 const vector& Cj = compactCoarseCf[compactJ];
797 const label toPatchId = compactPatchId[compactJ];
800 vector R1j = Cj + (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
801 vector R2j = Cj - (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
803 scalar d1 =
mag(R1i - R2j);
804 scalar d2 =
mag(R2i - R1j);
805 scalar s1 =
mag(R1i - R1j);
806 scalar s2 =
mag(R2i - R2j);
808 scalar Fij =
mag((d1 + d2) - (s1 + s2))/(4.0*
mag(Ai)/wideBy2);
810 F[coarseFacei][visCoarseFacei] = Fij;
811 sumViewFactorPatch[fromPatchId][toPatchId] += Fij*
mag(Ai);
818 Info <<
"Writing view factor matrix..." <<
endl;
830 forAll(viewFactorsPatches, i)
832 label patchi = viewFactorsPatches[i];
833 forAll(viewFactorsPatches, i)
835 label patchJ = viewFactorsPatches[i];
836 Info <<
"F" << patchi << patchJ <<
": " 844 if (writeViewFactors)
861 viewFactorField.boundaryFieldRef();
864 forAll(viewFactorsPatches, i)
866 label patchID = viewFactorsPatches[i];
867 const labelList& agglom = finalAgglom[patchID];
871 coarseMesh.patchFaceMap()[patchID];
873 forAll(coarseToFine, coarseI)
875 const scalar Fij =
sum(
F[compactI]);
876 const label coarseFaceID = coarsePatchFace[coarseI];
877 const labelList& fineFaces = coarseToFine[coarseFaceID];
880 const label faceID = fineFaces[fineId];
881 viewFactorFieldBf[patchID][faceID] = Fij;
886 viewFactorField.write();
893 labelList compactToGlobal(map.constructSize());
898 compactToGlobal[i] = globalNumbering.
toGlobal(i);
904 const Map<label>& localToCompactMap = compactMap[proci];
908 compactToGlobal[iter()] = globalNumbering.
toGlobal 925 forAll(globalFaceFaces, facei)
930 visibleFaceFaces[facei]
947 IOglobalFaceFaces.write();
952 forAll(globalFaceFaces, facei)
957 visibleFaceFaces[facei]
975 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.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
const word & executable() const
Name of executable without the path.
#define forAll(list, i)
Loop across all elements in list.
fvMesh as subset of other mesh. Consists of one cell and all original boundary faces. Useful when manipulating boundary data. Single internal cell only needed to be able to manipulate in a standard way.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const word & name() const
Return name.
const word & name() const
Return name.
A class for handling file names.
const dimensionedScalar F
Faraday constant: default SI units: [C/mol].
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of 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.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
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.
const dimensionSet dimless
void resize(const label)
Alias for setSize(const label)
bool insert(const Key &key)
Insert a new entry.
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 List obtained as a section of another List.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
void append(const T &)
Append an element at the end of the list.
word name() const
Return file name (part beyond last /)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
const Field< PointType > & points() const
Return reference to global points.
const polyMesh & mesh() const
Return the mesh reference.
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
Triangle with additional region number.
const fvPatch & patch() const
Return patch.
const Time & time() const
Return time.
void write(const fileName &file, const word &title, const bool binary, const PointField &points, const VertexList &vertices, const LineList &lines, const FaceList &faces, const wordList &fieldNames, const boolList &fieldIsPointValues, const UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesConstArg(Type, nullArg))
Write VTK polygonal data to a file. Takes a PtrList of fields of labels and.
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.
Class containing processor-to-processor mapping information.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Triangulation of three-dimensional polygons.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
vector span() const
The bounding box span (from minimum to maximum)
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
virtual bool write(const bool write=true) const
Write using setting from DB.
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.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
const UList< triFace > & triPoints() const
Get the triangles' points.
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.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
label localSize() const
My local size.