45 void Foam::faceReflecting::initialise(
const dictionary& coeffs)
48 forAll(qreflective_, bandI)
58 mesh_.time().timeName(),
70 if (mesh_.nSolutionD() == 3)
72 nRay_ = 4*nPhi_*nTheta_;
73 refDiscAngles_.resize(nRay_);
74 const scalar deltaPhi =
pi/(2.0*nPhi_);
75 const scalar deltaTheta =
pi/nTheta_;
77 for (label
n = 1;
n <= nTheta_;
n++)
79 for (label m = 1; m <= 4*nPhi_; m++)
81 const scalar thetai = (2*
n - 1)*deltaTheta/2.0;
82 const scalar phii = (2*m - 1)*deltaPhi/2.0;
88 refDiscAngles_[rayI++] =
95 else if (mesh_.nSolutionD() == 2)
98 refDiscAngles_.resize(nRay_);
101 const scalar deltaPhi =
pi/(2.0*nPhi_);
102 for (label m = 1; m <= 4*nPhi_; m++)
104 const scalar phii = (2*m - 1)*deltaPhi/2.0;
111 refDiscAngles_[rayI++] =
118 <<
"The reflected rays are available in 2D or 3D "
122 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
124 const radiation::boundaryRadiationProperties& boundaryRadiation =
128 globalIndex globalNumbering(mesh_.nFaces());
133 DynamicList<point> dynCf;
134 DynamicList<vector> dynNf;
135 DynamicList<label> dynFacesI;
138 const polyPatch& pp =
patches[patchI];
141 if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
143 const tmp<scalarField> tt =
144 boundaryRadiation.transmissivity(patchI);
146 const tmp<scalarField>
tr =
147 boundaryRadiation.specReflectivity(patchI);
149 const tmp<scalarField> ta =
150 boundaryRadiation.absorptivity(patchI);
169 dynFacesI.append(faceI + pp.start());
170 dynCf.append(cf[faceI]);
171 dynNf.append(
n[faceI]);
178 (r[faceI] > 0 && t[faceI] == 0) ||
179 (t[faceI] == 0 && a[faceI] > 0 && r[faceI] == 0)
182 includePatches_.insert(patchI);
188 shootFacesIds_.reset(
new labelList(dynFacesI));
202 boundBox(mesh_.points(),
false)
217 dict.add(
"mergeDistance", SMALL);
222 mesh_.boundaryMesh(),
229 new distributedTriSurfaceMesh
233 "reflectiveSurface.stl",
234 mesh_.time().constant(),
247 surfacesMesh_->searchableSurface::write();
252 void Foam::faceReflecting::calculate()
254 const radiation::boundaryRadiationProperties& boundaryRadiation =
259 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
261 const fvBoundaryMesh& fvPatches = mesh_.boundary();
263 label nBands = spectralDistribution_.size();
267 const vector sunDir = directHitFaces_.direction();
268 const labelList& directHits = directHitFaces_.rayStartFaces();
270 globalIndex globalNumbering(mesh_.nFaces());
272 Map<label> refFacesDirIndex;
277 const polyPatch& pp =
patches[patchI];
279 if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
281 const tmp<scalarField>
tr =
282 boundaryRadiation.specReflectivity(patchI);
289 label globalID = faceI + pp.start();
291 if (r[faceI] > 0.0 && directHits.found(globalID))
294 sunDir + 2.0*(-sunDir &
n[faceI]) *
n[faceI];
299 forAll(refDiscAngles_, iDisc)
301 scalar dotProd = refDir & refDiscAngles_[iDisc];
311 if (refDisDirsIndex[rayIndex] == -1)
313 refDisDirsIndex[rayIndex] = 1;
317 refFacesDirIndex.insert
319 globalNumbering.toGlobal(globalID),
337 scalar maxBounding = 5.0*
mag(mesh_.bounds().max() - mesh_.bounds().min());
339 reduce(maxBounding, maxOp<scalar>());
345 DynamicField<point> start(nFaces);
346 DynamicField<point>
end(start.size());
347 DynamicList<label> startIndex(start.size());
348 DynamicField<label> dirStartIndex(start.size());
353 for (; i < Cfs_->size(); i++)
355 const point& fc = Cfs_()[i];
357 const vector nf = Nfs_()[i];
359 const label myFaceId = shootFacesIds_()[i];
361 forAll(refDisDirsIndex, dirIndex)
363 if (refDisDirsIndex[dirIndex] > -1)
365 if ((nf & refDiscAngles_[dirIndex]) > 0)
371 startIndex.append(myFaceId);
372 dirStartIndex.append(dirIndex);
382 List<pointIndexHit> hitInfo(startIndex.size());
384 surfacesMesh_->findLine(start,
end, hitInfo);
388 autoPtr<mapDistribute> mapPtr
390 surfacesMesh_->localQueries
396 const mapDistribute& map = mapPtr();
398 PtrList<List<scalarField>> patchr(
patches.size());
399 PtrList<List<scalarField>> patcha(
patches.size());
405 new List<scalarField>(nBands)
411 new List<scalarField>(nBands)
418 const polyPatch& pp =
patches[patchi];
420 if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
422 for (label bandI = 0; bandI < nBands; bandI++)
424 patchr[patchi][bandI] =
425 boundaryRadiation.specReflectivity
432 patcha[patchi][bandI] =
433 boundaryRadiation.absorptivity
443 List<scalarField> r(nBands);
444 for (label bandI = 0; bandI < nBands; bandI++)
446 r[bandI].setSize(triangleIndex.size());
448 labelList refDirIndex(triangleIndex.size());
449 labelList refIndex(triangleIndex.size());
453 label trii = triangleIndex[i];
454 label facei = mapTriToGlobal_[trii];
455 label patchI =
patches.whichPatch(facei);
456 const polyPatch& pp =
patches[patchI];
457 label localFaceI = pp.whichFace(facei);
460 if (refFacesDirIndex.found(globalFace))
462 refDirIndex[i] = refFacesDirIndex.find(globalFace)();
463 refIndex[i] = globalFace;
465 for (label bandI = 0; bandI < nBands; bandI++)
467 r[bandI][i] = patchr[patchI][bandI][localFaceI];
470 map.reverseDistribute(hitInfo.size(), refDirIndex);
471 map.reverseDistribute(hitInfo.size(), refIndex);
472 for (label bandI = 0; bandI < nBands; bandI++)
474 map.reverseDistribute(hitInfo.size(), r[bandI]);
477 for (label bandI = 0; bandI < nBands; bandI++)
480 qreflective_[bandI].boundaryFieldRef();
484 const vector qPrim(solarCalc_.directSolarRad()*solarCalc_.direction());
490 if (hitInfo[rayI].hit())
494 dirStartIndex[rayI] == refDirIndex[rayI]
495 && refFacesDirIndex.found(refIndex[rayI])
498 for (label bandI = 0; bandI < nBands; bandI++)
501 qreflective_[bandI].boundaryFieldRef();
503 label startFaceId = startIndex[rayI];
504 label startPatchI =
patches.whichPatch(startFaceId);
506 const polyPatch& ppStart =
patches[startPatchI];
507 label localStartFaceI = ppStart.whichFace(startFaceId);
509 scalar a = patcha[startPatchI][bandI][localStartFaceI];
513 vector rayIn = refDiscAngles_[dirStartIndex[rayI]];
517 qrefBf[startPatchI][localStartFaceI] +=
522 *spectralDistribution_[bandI]
526 & nStart[localStartFaceI]
536 dirStartIndex.clear();
542 Foam::faceReflecting::faceReflecting
552 nTheta_(
dict.subDict(
"reflecting").getOrDefault<label>(
"nTheta", 10)),
553 nPhi_(
dict.subDict(
"reflecting").getOrDefault<label>(
"nPhi", 10)),
556 spectralDistribution_(spectralDistribution),
557 qreflective_(spectralDistribution_.size()),
558 directHitFaces_(directHiyFaces),