45void Foam::faceReflecting::initialise(
const dictionary& coeffs)
48 forAll(qreflective_, bandI)
71 if (mesh_.nSolutionD() == 3)
73 nRay_ = 4*nPhi_*nTheta_;
74 refDiscAngles_.resize(nRay_);
75 const scalar deltaPhi =
pi/(2.0*nPhi_);
76 const scalar deltaTheta =
pi/nTheta_;
78 for (label
n = 1;
n <= nTheta_;
n++)
80 for (label m = 1; m <= 4*nPhi_; m++)
82 const scalar thetai = (2*
n - 1)*deltaTheta/2.0;
83 const scalar phii = (2*m - 1)*deltaPhi/2.0;
89 refDiscAngles_[rayI++] =
90 vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta);
96 else if (mesh_.nSolutionD() == 2)
99 refDiscAngles_.resize(nRay_);
102 const scalar deltaPhi =
pi/(2.0*nPhi_);
103 for (label m = 1; m <= 4*nPhi_; m++)
105 const scalar phii = (2*m - 1)*deltaPhi/2.0;
112 refDiscAngles_[rayI++] =
113 vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta);
119 <<
"The reflected rays are available in 2D or 3D "
123 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
125 const radiation::boundaryRadiationProperties& boundaryRadiation =
129 globalIndex globalNumbering(mesh_.nFaces());
134 DynamicList<point> dynCf;
135 DynamicList<vector> dynNf;
136 DynamicList<label> dynFacesI;
144 const tmp<scalarField> tt =
147 const tmp<scalarField>
tr =
150 const tmp<scalarField> ta =
170 dynFacesI.
append(faceI +
pp.start());
179 (r[faceI] > 0 && t[faceI] == 0) ||
180 (t[faceI] == 0 && a[faceI] > 0 && r[faceI] == 0)
183 includePatches_.insert(patchI);
201 treeBoundBox(mesh_.points()).extend(
rndGen, 1
e-3)
215 dict.add(
"mergeDistance", SMALL);
220 mesh_.boundaryMesh(),
227 new distributedTriSurfaceMesh
231 "reflectiveSurface.stl",
232 mesh_.time().constant(),
245 surfacesMesh_->searchableSurface::write();
250void Foam::faceReflecting::calculate()
261 label nBands = spectralDistribution_.
size();
265 const vector sunDir = directHitFaces_.direction();
266 const labelList& directHits = directHitFaces_.rayStartFaces();
287 label globalID = faceI +
pp.start();
289 if (r[faceI] > 0.0 && directHits.
found(globalID))
292 sunDir + 2.0*(-sunDir &
n[faceI]) *
n[faceI];
297 forAll(refDiscAngles_, iDisc)
299 scalar dotProd = refDir & refDiscAngles_[iDisc];
309 if (refDisDirsIndex[rayIndex] == -1)
311 refDisDirsIndex[rayIndex] = 1;
317 globalNumbering.toGlobal(globalID),
333 const scalar maxBounding =
348 for (; i < Cfs_->size(); i++)
350 const point& fc = Cfs_()[i];
352 const vector nf = Nfs_()[i];
354 const label myFaceId = shootFacesIds_()[i];
356 forAll(refDisDirsIndex, dirIndex)
358 if (refDisDirsIndex[dirIndex] > -1)
360 if ((nf & refDiscAngles_[dirIndex]) > 0)
366 startIndex.append(myFaceId);
367 dirStartIndex.append(dirIndex);
379 surfacesMesh_->findLine(start, end, hitInfo);
385 surfacesMesh_->localQueries
397 patchr.emplace_set(patchi, nBands);
398 patcha.emplace_set(patchi, nBands);
408 for (label bandI = 0; bandI < nBands; bandI++)
410 patchr[patchi][bandI] =
418 patcha[patchi][bandI] =
430 for (label bandI = 0; bandI < nBands; bandI++)
439 label trii = triangleIndex[i];
440 label facei = mapTriToGlobal_[trii];
443 label localFaceI =
pp.whichFace(facei);
446 if (refFacesDirIndex.
found(globalFace))
448 refDirIndex[i] = refFacesDirIndex.
find(globalFace)();
449 refIndex[i] = globalFace;
451 for (label bandI = 0; bandI < nBands; bandI++)
453 r[bandI][i] = patchr[patchI][bandI][localFaceI];
458 for (label bandI = 0; bandI < nBands; bandI++)
463 for (label bandI = 0; bandI < nBands; bandI++)
466 qreflective_[bandI].boundaryFieldRef();
470 const vector qPrim(solarCalc_.directSolarRad()*solarCalc_.direction());
476 if (hitInfo[rayI].hit())
480 dirStartIndex[rayI] == refDirIndex[rayI]
481 && refFacesDirIndex.
found(refIndex[rayI])
484 for (label bandI = 0; bandI < nBands; bandI++)
487 qreflective_[bandI].boundaryFieldRef();
489 label startFaceId = startIndex[rayI];
493 label localStartFaceI = ppStart.
whichFace(startFaceId);
495 scalar a = patcha[startPatchI][bandI][localStartFaceI];
499 vector rayIn = refDiscAngles_[dirStartIndex[rayI]];
503 qrefBf[startPatchI][localStartFaceI] +=
508 *spectralDistribution_[bandI]
512 & nStart[localStartFaceI]
522 dirStartIndex.clear();
528Foam::faceReflecting::faceReflecting
538 nTheta_(
dict.subDict(
"reflecting").getOrDefault<label>(
"nTheta", 10)),
539 nPhi_(
dict.subDict(
"reflecting").getOrDefault<label>(
"nPhi", 10)),
542 spectralDistribution_(spectralDistribution),
543 qreflective_(spectralDistribution_.size()),
544 directHitFaces_(directHiyFaces),
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
SubField< vector > subField
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
bool found(const Key &key) const
Same as contains().
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
@ REGISTER
Request registration (bool: true).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
A HashTable to objects of type <T> with a label key.
static FOAM_NO_DANGLING_REFERENCE const boundaryRadiationProperties & New(const fvMesh &mesh, Args &&... args)
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
static void mapCombineReduce(Container &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::mapReduce with an in-place cop.
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
UList< T > & reset(std::nullptr_t) noexcept
Reset to zero-sized and nullptr.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
bool found(const T &val, label pos=0) const
Same as contains().
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
label size() const noexcept
The number of entries in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static const Enum< distributionType > distributionTypeNames_
Calculates the reflecting faces from specular surfaces. It only takes into account the first reflecti...
void correct()
Correct reflected flux.
Helper class to calculate visible faces for global, sun-like illumination.
A fvBoundaryMesh is a fvPatch list with a reference to the associated fvMesh, with additional search ...
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
Class containing processor-to-processor mapping information.
void reverseDistribute(const label constructSize, List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
A patch is a list of labels that address the faces in the global face list.
label whichFace(const label facei) const noexcept
Return label of face in patch from global face label.
Boundary radiation properties holder.
tmp< scalarField > transmissivity(const label patchI, const label bandI=0, const vectorField *incomingDirection=nullptr, const scalarField *T=nullptr) const
Access boundary transmissivity on patch.
tmp< scalarField > absorptivity(const label patchI, const label bandI=0, const vectorField *incomingDirection=nullptr, const scalarField *T=nullptr) const
Access boundary absorptivity on patch.
tmp< scalarField > specReflectivity(const label patchI, const label bandI=0, const vectorField *incomingDirection=nullptr, const scalarField *T=nullptr) const
Access boundary specular reflectivity on patch.
A solar calculator model providing models for the solar direction and solar loads.
A class for managing temporary objects.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr scalar pi(M_PI)
constexpr scalar piByTwo(0.5 *M_PI)
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
List< label > labelList
A List of labels.
dimensionedScalar pow3(const dimensionedScalar &ds)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensionedScalar sin(const dimensionedScalar &ds)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
List< scalar > scalarList
List of scalar.
dimensionedScalar cos(const dimensionedScalar &ds)
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
const triSurface localSurface
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
#define forAll(list, i)
Loop across all elements in list.