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[])
270 isA<cyclicTransform>(pp)
271 || isA<symmetryPolyPatch>(pp)
272 || isA<symmetryPlanePolyPatch>(pp)
273 || isA<wedgePolyPatch>(pp)
277 <<
" does not currently support transforming patches: "
278 "cyclic, symmetry and wedge."
296 const bool writeViewFactors =
297 viewFactorDict.lookupOrDefault<
bool>(
"writeViewFactorMatrix",
false);
299 const bool dumpRays =
300 viewFactorDict.lookupOrDefault<
bool>(
"dumpRays",
false);
302 const label debug = viewFactorDict.lookupOrDefault<
label>(
"debug", 0);
336 Pout <<
"\nCreating single cell mesh..." <<
endl;
355 Pout <<
"\nCreated single cell mesh..." <<
endl;
362 label nCoarseFaces = 0;
363 label nFineFaces = 0;
377 if ((isA<fixedValueFvPatchScalarField>(qrpI)) && (pp.
size() > 0))
386 viewFactorsPatches.resize(
count);
389 label totalNCoarseFaces = nCoarseFaces;
395 Info <<
"\nTotal number of coarse faces: "<< totalNCoarseFaces <<
endl;
400 Pout <<
"\nView factor patches included in the calculation : "
401 << viewFactorsPatches <<
endl;
412 forAll(viewFactorsPatches, i)
414 const label patchID = viewFactorsPatches[i];
417 const labelList& agglom = finalAgglom[patchID];
420 const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
422 const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchID];
423 const pointField& coarseSf = coarseMesh.Sf().boundaryField()[patchID];
430 point cf = coarseCf[facei];
432 const label coarseFacei = coarsePatchFace[facei];
433 const labelList& fineFaces = coarseToFine[coarseFacei];
434 const label agglomI =
435 agglom[fineFaces[0]] + coarsePatches[patchID].start();
447 upp.faceCentres().size()
448 + upp.localPoints().size()
454 upp.faceCentres().size()
455 ) = upp.faceCentres();
460 upp.localPoints().size(),
461 upp.faceCentres().size()
462 ) = upp.localPoints();
466 forAll(availablePoints, iPoint)
468 point cfFine = availablePoints[iPoint];
469 if (
mag(cfFine-cfo) < dist)
471 dist =
mag(cfFine-cfo);
478 localCoarseSf.append(
sf);
479 localAgg.append(agglomI);
523 labelList nVisibleFaceFaces(nCoarseFaces, 0);
527 nVisibleFaceFaces[rayStartFace[i]]++;
532 forAll(nVisibleFaceFaces, facei)
534 visibleFaceFaces[facei].
setSize(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];
649 coarseToFine[coarseFacei]
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)
833 forAll(viewFactorsPatches, i)
835 label patchJ = viewFactorsPatches[i];
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();
#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.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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...
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 /)
const Time & time() const
Return the top-level database.
const surfaceVectorField & Cf() const
Return face centres.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const word & name() const
Return reference to name.
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 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.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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 mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
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)