82 label localTriFacei = 0;
94 const face&
f = patch[patchFacei];
112 finalAgglom[
patchi][patchFacei]
113 + coarsePatches[
patchi].start()
131 rawSurface.localFaces(),
132 rawSurface.localPoints()
136 surface.patches().setSize(newPatchi);
145 surface.patches()[newPatchi].index() =
patchi;
146 surface.patches()[newPatchi].name() = patch.
name();
147 surface.patches()[newPatchi].geometricType() = patch.type();
166 allPoints.
append(compactCf);
171 const labelList visFaces = visibleFaceFaces[facei];
172 forAll(visFaces, faceRemote)
181 Pout<<
"\nDumping rays to " << fName +
".vtk" <<
endl;
196 scalar calculateViewFactorFij
205 scalar rMag =
mag(r);
209 scalar dAiMag =
mag(dAi);
210 scalar dAjMag =
mag(dAj);
214 scalar cosThetaJ =
mag(nj & r)/rMag;
215 scalar cosThetaI =
mag(ni & r)/rMag;
219 (cosThetaI*cosThetaJ*dAjMag*dAiMag)
230 void insertMatrixElements
233 const label fromProci,
239 forAll(viewFactors, facei)
242 const labelList& globalFaces = globalFaceFaces[facei];
247 matrix[globalI][globalFaces[i]] = vf[i];
255 int main(
int argc,
char *argv[])
269 isA<cyclicTransform>(pp)
270 || isA<symmetryPolyPatch>(pp)
271 || isA<symmetryPlanePolyPatch>(pp)
272 || isA<wedgePolyPatch>(pp)
276 <<
" does not currently support transforming patches: "
277 "cyclic, symmetry and wedge."
295 const bool writeViewFactors =
296 viewFactorDict.lookupOrDefault<
bool>(
"writeViewFactorMatrix",
false);
298 const bool dumpRays =
299 viewFactorDict.lookupOrDefault<
bool>(
"dumpRays",
false);
301 const label debug = viewFactorDict.lookupOrDefault<
label>(
"debug", 0);
335 Pout <<
"\nCreating single cell mesh..." <<
endl;
342 "coarse:" + mesh.
name(),
354 Pout <<
"\nCreated single cell mesh..." <<
endl;
361 label nCoarseFaces = 0;
362 label nFineFaces = 0;
376 if ((isA<fixedValueFvPatchScalarField>(qrpI)) && (pp.
size() > 0))
385 viewFactorsPatches.resize(
count);
388 label totalNCoarseFaces = nCoarseFaces;
394 Info <<
"\nTotal number of coarse faces: "<< totalNCoarseFaces <<
endl;
399 Pout <<
"\nView factor patches included in the calculation : "
400 << viewFactorsPatches <<
endl;
411 forAll(viewFactorsPatches, i)
413 const label patchID = viewFactorsPatches[i];
416 const labelList& agglom = finalAgglom[patchID];
419 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
421 const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchID];
422 const pointField& coarseSf = coarseMesh.Sf().boundaryField()[patchID];
429 point cf = coarseCf[facei];
431 const label coarseFacei = coarsePatchFace[facei];
432 const labelList& fineFaces = coarseToFine[coarseFacei];
433 const label agglomI =
434 agglom[fineFaces[0]] + coarsePatches[patchID].start();
446 upp.faceCentres().size()
447 + upp.localPoints().size()
453 upp.faceCentres().size()
454 ) = upp.faceCentres();
459 upp.localPoints().size(),
460 upp.faceCentres().size()
461 ) = upp.localPoints();
465 forAll(availablePoints, iPoint)
467 point cfFine = availablePoints[iPoint];
468 if (
mag(cfFine-cfo) < dist)
470 dist =
mag(cfFine-cfo);
477 localCoarseSf.append(
sf);
478 localAgg.append(agglomI);
522 labelList nVisibleFaceFaces(nCoarseFaces, 0);
526 nVisibleFaceFaces[rayStartFace[i]]++;
531 forAll(nVisibleFaceFaces, facei)
533 visibleFaceFaces[facei].
setSize(nVisibleFaceFaces[facei]);
576 IOconstructMap.write();
599 nVisibleFaceFaces = 0;
602 label facei = rayStartFace[i];
603 label compactI = rayEndFace[i];
604 visibleFaceFaces[facei][nVisibleFaceFaces[facei]++] = compactI;
625 forAll(viewFactorsPatches, i)
627 label patchID = viewFactorsPatches[i];
628 const labelList& agglom = finalAgglom[patchID];
631 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
633 forAll(coarseToFine, coarseI)
635 compactPatchId.append(patchID);
639 const label coarseFacei = coarsePatchFace[coarseI];
640 const labelList& fineFaces = coarseToFine[coarseFacei];
647 mesh.Cf().boundaryField()[patchID],
648 coarseToFine[coarseFacei]
652 mesh.Sf().boundaryField()[patchID],
653 coarseToFine[coarseFacei]
659 map.distribute(compactCoarseSf);
660 map.distribute(compactCoarseCf);
661 map.distribute(compactFineCf);
662 map.distribute(compactFineSf);
664 map.distribute(compactPatchId);
672 runTime.path()/
"allVisibleFaces",
697 label totalPatches = coarsePatches.
size();
711 Info<<
"\nCalculating view factors..." <<
endl;
716 forAll(localCoarseSf, coarseFacei)
718 const List<point>& localFineSf = compactFineSf[coarseFacei];
720 const List<point>& localFineCf = compactFineCf[coarseFacei];
721 const label fromPatchId = compactPatchId[coarseFacei];
722 patchArea[fromPatchId] +=
mag(Ai);
724 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
726 forAll(visCoarseFaces, visCoarseFacei)
728 F[coarseFacei].setSize(visCoarseFaces.
size());
729 label compactJ = visCoarseFaces[visCoarseFacei];
730 const List<point>& remoteFineSj = compactFineSf[compactJ];
731 const List<point>& remoteFineCj = compactFineCf[compactJ];
733 const label toPatchId = compactPatchId[compactJ];
738 const vector& dAi = localFineSf[i];
739 const vector& dCi = localFineCf[i];
743 const vector& dAj = remoteFineSj[j];
744 const vector& dCj = remoteFineCj[j];
746 scalar dIntFij = calculateViewFactorFij
757 F[coarseFacei][visCoarseFacei] = Fij/
mag(Ai);
758 sumViewFactorPatch[fromPatchId][toPatchId] += Fij;
775 scalar wideBy2 = (box.
span() & emptyDir)*2.0;
777 forAll(localCoarseSf, coarseFacei)
779 const vector& Ai = localCoarseSf[coarseFacei];
780 const vector& Ci = localCoarseCf[coarseFacei];
782 vector R1i = Ci + (
mag(Ai)/wideBy2)*(Ain ^ emptyDir);
783 vector R2i = Ci - (
mag(Ai)/wideBy2)*(Ain ^ emptyDir) ;
785 const label fromPatchId = compactPatchId[coarseFacei];
786 patchArea[fromPatchId] +=
mag(Ai);
788 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
789 forAll(visCoarseFaces, visCoarseFacei)
791 F[coarseFacei].setSize(visCoarseFaces.
size());
792 label compactJ = visCoarseFaces[visCoarseFacei];
793 const vector& Aj = compactCoarseSf[compactJ];
794 const vector& Cj = compactCoarseCf[compactJ];
796 const label toPatchId = compactPatchId[compactJ];
799 vector R1j = Cj + (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
800 vector R2j = Cj - (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
802 scalar d1 =
mag(R1i - R2j);
803 scalar d2 =
mag(R2i - R1j);
804 scalar s1 =
mag(R1i - R1j);
805 scalar s2 =
mag(R2i - R2j);
807 scalar Fij =
mag((d1 + d2) - (s1 + s2))/(4.0*
mag(Ai)/wideBy2);
809 F[coarseFacei][visCoarseFacei] = Fij;
810 sumViewFactorPatch[fromPatchId][toPatchId] += Fij*
mag(Ai);
817 Info <<
"Writing view factor matrix..." <<
endl;
829 forAll(viewFactorsPatches, i)
832 forAll(viewFactorsPatches, i)
834 label patchJ = viewFactorsPatches[i];
843 if (writeViewFactors)
860 viewFactorField.boundaryFieldRef();
863 forAll(viewFactorsPatches, i)
865 label patchID = viewFactorsPatches[i];
866 const labelList& agglom = finalAgglom[patchID];
870 coarseMesh.patchFaceMap()[patchID];
872 forAll(coarseToFine, coarseI)
874 const scalar Fij =
sum(
F[compactI]);
875 const label coarseFaceID = coarsePatchFace[coarseI];
876 const labelList& fineFaces = coarseToFine[coarseFaceID];
879 const label faceID = fineFaces[fineId];
880 viewFactorFieldBf[patchID][faceID] = Fij;
885 viewFactorField.write();
892 labelList compactToGlobal(map.constructSize());
897 compactToGlobal[i] = globalNumbering.
toGlobal(i);
903 const Map<label>& localToCompactMap = compactMap[proci];
907 compactToGlobal[iter()] = globalNumbering.
toGlobal
924 forAll(globalFaceFaces, facei)
929 visibleFaceFaces[facei]
946 IOglobalFaceFaces.write();
951 forAll(globalFaceFaces, facei)
956 visibleFaceFaces[facei]
974 IOglobalFaceFaces.write();
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Generic GeometricBoundaryField class.
Generic GeometricField class.
bool insert(const Key &key)
Insert a new entry.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const word & name() const
Return name.
void append(const T &)
Append an element at the end of the list.
void resize(const label)
Alias for setSize(const label)
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
A list of faces which address into the list of points.
const Field< PointType > & points() const
Return reference to global points.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
A List obtained as a section of another List.
A List with indirect addressing.
label size() const
Return the number of elements in the UList.
static bool master(const label communicator=0)
Am I the master process.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
label size() const
Return the number of elements in the UPtrList.
const word & executable() const
Name of executable without the path.
A bounding box defined in terms of the points at its extremities.
vector span() const
The bounding box span (from minimum to maximum)
const word & name() const
Return const reference to name.
Class containing processor-to-processor mapping information.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
word name() const
Return file name (part beyond last /)
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
const fvPatch & patch() const
Return patch.
label index() const
Return the index of this patch in the fvBoundaryMesh.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label localSize() const
My local size.
label toGlobal(const label i) const
From local to global.
Triangle with additional region number.
const Time & time() const
Return time.
const word & name() const
Return name.
const polyMesh & mesh() const
Return the mesh reference.
Mesh consisting of general polyhedral cells.
const fileName & facesInstance() const
Return the current instance directory for faces.
label nSolutionD() const
Return the number of valid solved-for dimensions in the mesh.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
const boundBox & bounds() const
Return mesh bounding box.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
A patch is a list of labels that address the faces in the global face list.
Triangulation of three-dimensional polygons.
const UList< triFace > & triPoints() const
Get the triangles' points.
label nInternalFaces() const
fvMesh as subset of other mesh. Consists of one cell and all original boundary faces....
Triangulated surface description with patch information.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
const polyBoundaryMesh & bMesh
volScalarField sf(fieldObject, mesh)
const fvPatchList & patches
const dimensionedScalar F
Faraday constant: default SI units: [C/kmol].
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pair< label > labelPair
Label pair.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const dimensionSet dimless
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
labelHashSet includePatches
labelList triSurfaceToAgglom(5 *nFineFaces)
Foam::argList args(argc, argv)