80 label localTriFacei = 0;
92 const face&
f = patch[patchFacei];
110 finalAgglom[
patchi][patchFacei]
111 + coarsePatches[
patchi].start()
129 rawSurface.localFaces(),
130 rawSurface.localPoints()
134 surface.patches().setSize(newPatchi);
143 surface.patches()[newPatchi].index() =
patchi;
144 surface.patches()[newPatchi].name() = patch.
name();
145 surface.patches()[newPatchi].geometricType() = patch.type();
164 allPoints.
append(compactCf);
169 const labelList visFaces = visibleFaceFaces[facei];
170 forAll(visFaces, faceRemote)
179 Pout<<
"\nDumping rays to " << fName +
".vtk" <<
endl;
194 scalar calculateViewFactorFij
203 scalar rMag =
mag(r);
207 scalar dAiMag =
mag(dAi);
208 scalar dAjMag =
mag(dAj);
212 scalar cosThetaJ =
mag(nj & r)/rMag;
213 scalar cosThetaI =
mag(ni & r)/rMag;
217 (cosThetaI*cosThetaJ*dAjMag*dAiMag)
228 void insertMatrixElements
231 const label fromProci,
237 forAll(viewFactors, facei)
240 const labelList& globalFaces = globalFaceFaces[facei];
245 matrix[globalI][globalFaces[i]] = vf[i];
253 int main(
int argc,
char *argv[])
267 isA<cyclicTransform>(pp)
268 || isA<symmetryPolyPatch>(pp)
269 || isA<symmetryPlanePolyPatch>(pp)
270 || isA<wedgePolyPatch>(pp)
274 <<
" does not currently support transforming patches: "
275 "cyclic, symmetry and wedge."
293 const bool writeViewFactors =
294 viewFactorDict.lookupOrDefault<
bool>(
"writeViewFactorMatrix",
false);
296 const bool dumpRays =
297 viewFactorDict.lookupOrDefault<
bool>(
"dumpRays",
false);
299 const label debug = viewFactorDict.lookupOrDefault<
label>(
"debug", 0);
333 Pout <<
"\nCreating single cell mesh..." <<
endl;
340 "coarse:" + mesh.
name(),
352 Pout <<
"\nCreated single cell mesh..." <<
endl;
359 label nCoarseFaces = 0;
360 label nFineFaces = 0;
374 if ((isA<fixedValueFvPatchScalarField>(qrpI)) && (pp.size() > 0))
383 viewFactorsPatches.resize(
count);
386 label totalNCoarseFaces = nCoarseFaces;
392 Info <<
"\nTotal number of coarse faces: "<< totalNCoarseFaces <<
endl;
397 Pout <<
"\nView factor patches included in the calculation : "
398 << viewFactorsPatches <<
endl;
409 forAll(viewFactorsPatches, i)
411 const label patchID = viewFactorsPatches[i];
414 const labelList& agglom = finalAgglom[patchID];
417 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
419 const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchID];
420 const pointField& coarseSf = coarseMesh.Sf().boundaryField()[patchID];
427 point cf = coarseCf[facei];
429 const label coarseFacei = coarsePatchFace[facei];
430 const labelList& fineFaces = coarseToFine[coarseFacei];
431 const label agglomI =
432 agglom[fineFaces[0]] + coarsePatches[patchID].start();
444 upp.faceCentres().size()
445 + upp.localPoints().size()
451 upp.faceCentres().size()
452 ) = upp.faceCentres();
457 upp.localPoints().size(),
458 upp.faceCentres().size()
459 ) = upp.localPoints();
463 forAll(availablePoints, iPoint)
465 point cfFine = availablePoints[iPoint];
466 if (
mag(cfFine-cfo) < dist)
468 dist =
mag(cfFine-cfo);
475 localCoarseSf.append(
sf);
476 localAgg.append(agglomI);
520 labelList nVisibleFaceFaces(nCoarseFaces, 0);
524 nVisibleFaceFaces[rayStartFace[i]]++;
529 forAll(nVisibleFaceFaces, facei)
531 visibleFaceFaces[facei].
setSize(nVisibleFaceFaces[facei]);
574 IOconstructMap.write();
597 nVisibleFaceFaces = 0;
600 label facei = rayStartFace[i];
601 label compactI = rayEndFace[i];
602 visibleFaceFaces[facei][nVisibleFaceFaces[facei]++] = compactI;
623 forAll(viewFactorsPatches, i)
625 label patchID = viewFactorsPatches[i];
626 const labelList& agglom = finalAgglom[patchID];
629 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
631 forAll(coarseToFine, coarseI)
633 compactPatchId.append(patchID);
637 const label coarseFacei = coarsePatchFace[coarseI];
638 const labelList& fineFaces = coarseToFine[coarseFacei];
645 mesh.Cf().boundaryField()[patchID],
646 coarseToFine[coarseFacei]
650 mesh.Sf().boundaryField()[patchID],
651 coarseToFine[coarseFacei]
657 map.distribute(compactCoarseSf);
658 map.distribute(compactCoarseCf);
659 map.distribute(compactFineCf);
660 map.distribute(compactFineSf);
662 map.distribute(compactPatchId);
670 runTime.path()/
"allVisibleFaces",
695 label totalPatches = coarsePatches.
size();
709 Info<<
"\nCalculating view factors..." <<
endl;
714 forAll(localCoarseSf, coarseFacei)
716 const List<point>& localFineSf = compactFineSf[coarseFacei];
718 const List<point>& localFineCf = compactFineCf[coarseFacei];
719 const label fromPatchId = compactPatchId[coarseFacei];
720 patchArea[fromPatchId] +=
mag(Ai);
722 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
724 forAll(visCoarseFaces, visCoarseFacei)
726 F[coarseFacei].setSize(visCoarseFaces.
size());
727 label compactJ = visCoarseFaces[visCoarseFacei];
728 const List<point>& remoteFineSj = compactFineSf[compactJ];
729 const List<point>& remoteFineCj = compactFineCf[compactJ];
731 const label toPatchId = compactPatchId[compactJ];
736 const vector& dAi = localFineSf[i];
737 const vector& dCi = localFineCf[i];
741 const vector& dAj = remoteFineSj[j];
742 const vector& dCj = remoteFineCj[j];
744 scalar dIntFij = calculateViewFactorFij
755 F[coarseFacei][visCoarseFacei] = Fij/
mag(Ai);
756 sumViewFactorPatch[fromPatchId][toPatchId] += Fij;
773 scalar wideBy2 = (box.
span() & emptyDir)*2.0;
775 forAll(localCoarseSf, coarseFacei)
777 const vector& Ai = localCoarseSf[coarseFacei];
778 const vector& Ci = localCoarseCf[coarseFacei];
780 vector R1i = Ci + (
mag(Ai)/wideBy2)*(Ain ^ emptyDir);
781 vector R2i = Ci - (
mag(Ai)/wideBy2)*(Ain ^ emptyDir) ;
783 const label fromPatchId = compactPatchId[coarseFacei];
784 patchArea[fromPatchId] +=
mag(Ai);
786 const labelList& visCoarseFaces = visibleFaceFaces[coarseFacei];
787 forAll(visCoarseFaces, visCoarseFacei)
789 F[coarseFacei].setSize(visCoarseFaces.
size());
790 label compactJ = visCoarseFaces[visCoarseFacei];
791 const vector& Aj = compactCoarseSf[compactJ];
792 const vector& Cj = compactCoarseCf[compactJ];
794 const label toPatchId = compactPatchId[compactJ];
797 vector R1j = Cj + (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
798 vector R2j = Cj - (
mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
800 scalar d1 =
mag(R1i - R2j);
801 scalar d2 =
mag(R2i - R1j);
802 scalar s1 =
mag(R1i - R1j);
803 scalar s2 =
mag(R2i - R2j);
805 scalar Fij =
mag((d1 + d2) - (s1 + s2))/(4.0*
mag(Ai)/wideBy2);
807 F[coarseFacei][visCoarseFacei] = Fij;
808 sumViewFactorPatch[fromPatchId][toPatchId] += Fij*
mag(Ai);
815 Info <<
"Writing view factor matrix..." <<
endl;
827 forAll(viewFactorsPatches, i)
830 forAll(viewFactorsPatches, i)
832 label patchJ = viewFactorsPatches[i];
841 if (writeViewFactors)
858 viewFactorField.boundaryFieldRef();
861 forAll(viewFactorsPatches, i)
863 label patchID = viewFactorsPatches[i];
864 const labelList& agglom = finalAgglom[patchID];
868 coarseMesh.patchFaceMap()[patchID];
870 forAll(coarseToFine, coarseI)
872 const scalar Fij =
sum(
F[compactI]);
873 const label coarseFaceID = coarsePatchFace[coarseI];
874 const labelList& fineFaces = coarseToFine[coarseFaceID];
877 const label faceID = fineFaces[fineId];
878 viewFactorFieldBf[patchID][faceID] = Fij;
883 viewFactorField.write();
890 labelList compactToGlobal(map.constructSize());
895 compactToGlobal[i] = globalNumbering.
toGlobal(i);
901 const Map<label>& localToCompactMap = compactMap[proci];
905 compactToGlobal[iter()] = globalNumbering.
toGlobal
922 forAll(globalFaceFaces, facei)
927 visibleFaceFaces[facei]
944 IOglobalFaceFaces.write();
949 forAll(globalFaceFaces, facei)
954 visibleFaceFaces[facei]
972 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.
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/mol].
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)