55 void Foam::radiation::solarLoad::updateReflectedRays
60 if (!reflectedFaces_ && hitFaces_)
69 spectralDistribution_,
75 reflectedFaces_->correct();
77 volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
79 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
85 for (label bandI = 0; bandI < nBands_; ++bandI)
88 reflectedFaces_->qreflective(bandI).boundaryField()[
patchID];
96 for (label bandI = 0; bandI < nBands_; ++bandI)
100 const label cellI = cellIs[i];
104 reflectedFaces_->qreflective(bandI).
105 boundaryField()[
patchID][i] * sf[i]
114 bool Foam::radiation::solarLoad::updateHitFaces()
118 hitFaces_.reset(
new faceShading(mesh_, solarCalc_.direction()));
123 switch (solarCalc_.sunDirectionModel())
132 const label updateIndex = label
134 mesh_.time().value()/solarCalc_.sunTrackingUpdateInterval()
137 if (updateIndex > updateTimeIndex_)
139 Info <<
"Updating Sun position..." <<
endl;
140 updateTimeIndex_ = updateIndex;
141 solarCalc_.correctSunDirection();
142 hitFaces_->direction() = solarCalc_.direction();
143 hitFaces_->correct();
155 void Foam::radiation::solarLoad::updateAbsorptivity
160 const boundaryRadiationProperties& boundaryRadiation =
163 for (
const label
patchID : includePatches)
165 absorptivity_[
patchID].setSize(nBands_);
166 for (label bandI = 0; bandI < nBands_; ++bandI)
168 absorptivity_[
patchID][bandI] =
169 boundaryRadiation.absorptivity(
patchID, bandI);
175 void Foam::radiation::solarLoad::updateDirectHitRadiation
181 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
183 volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
188 for (label bandI = 0; bandI < nBands_; ++bandI)
190 volScalarField::Boundary& qprimaryBf =
191 qprimaryRad_[bandI].boundaryFieldRef();
197 const label faceI = hitFacesId[i];
200 const label localFaceI = faceI - pp.start();
202 solarCalc_.directSolarRad()*solarCalc_.direction();
207 qprimaryBf[
patchID][localFaceI] +=
208 (qPrim &
n[localFaceI])
209 * spectralDistribution_[bandI]
210 * absorptivity_[
patchID][bandI]()[localFaceI];
213 if (includeMappedPatchBasePatches[
patchID])
220 const label cellI = pp.faceCells()[localFaceI];
223 (qPrim & sf[localFaceI])
224 * spectralDistribution_[bandI]
225 * absorptivity_[
patchID][bandI]()[localFaceI]
233 void Foam::radiation::solarLoad::updateSkyDiffusiveRadiation
239 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
241 volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
243 switch(solarCalc_.sunLoadModel())
248 for (
const label
patchID : includePatches)
254 const labelList& cellIds = pp.faceCells();
258 const scalar cosEpsilon(verticalDir_ & -
n[faceI]);
262 const scalar cosTheta(solarCalc_.direction() & -
n[faceI]);
266 if (cosEpsilon == 0.0)
273 Y = 0.55+0.437*cosTheta + 0.313*
sqr(cosTheta);
280 Ed = solarCalc_.C()*
Y*solarCalc_.directSolarRad();
287 * solarCalc_.directSolarRad()
288 * (1.0 + cosEpsilon)/2.0;
293 solarCalc_.directSolarRad()
294 * (solarCalc_.C() +
Foam::sin(solarCalc_.beta()))
295 * solarCalc_.groundReflectivity()
296 * (1.0 - cosEpsilon)/2.0;
299 const label cellI = cellIds[faceI];
300 if (includeMappedPatchBasePatches[
patchID])
302 for (label bandI = 0; bandI < nBands_; ++bandI)
306 * spectralDistribution_[bandI]
307 * absorptivity_[
patchID][bandI]()[faceI];
312 for (label bandI = 0; bandI < nBands_; ++bandI)
316 * spectralDistribution_[bandI]
317 * absorptivity_[
patchID][bandI]()[faceI]
318 * sf[faceI]/V[cellI];
329 for (
const label
patchID : includePatches)
334 const labelList& cellIds = pp.faceCells();
337 const label cellI = cellIds[faceI];
338 if (includeMappedPatchBasePatches[
patchID])
340 for (label bandI = 0; bandI < nBands_; ++bandI)
343 solarCalc_.diffuseSolarRad()
344 * spectralDistribution_[bandI]
345 * absorptivity_[
patchID][bandI]()[faceI];
350 for (label bandI = 0; bandI < nBands_; ++bandI)
354 spectralDistribution_[bandI]
355 * absorptivity_[
patchID][bandI]()[faceI]
356 * solarCalc_.diffuseSolarRad()
357 )*sf[faceI]/V[cellI];
368 void Foam::radiation::solarLoad::initialise(
const dictionary& coeffs)
370 spectralDistributions_.reset
372 Function1<scalarField>::New
374 "spectralDistribution",
380 spectralDistribution_ =
381 spectralDistributions_->value(mesh_.time().timeOutputValue());
383 nBands_ = spectralDistribution_.size();
385 spectralDistribution_ =
386 spectralDistribution_/
sum(spectralDistribution_);
388 qprimaryRad_.setSize(nBands_);
390 forAll(qprimaryRad_, bandI)
400 mesh_.time().timeName(),
411 if (coeffs.readIfPresent(
"gridUp", verticalDir_))
413 verticalDir_.normalise();
419 verticalDir_ = (-
g/
mag(
g)).value();
423 coeffs.readIfPresent(
"wallCoupled", wallCoupled_);
424 coeffs.readIfPresent(
"updateAbsorptivity", updateAbsorptivity_);
425 coeffs.readEntry(
"useReflectedRays", useReflectedRays_);
731 solarCalc_(coeffs_, mesh_),
762 spectralDistribution_(),
763 spectralDistributions_(),
770 updateAbsorptivity_(false),
771 useReflectedRays_(false),
778 Foam::radiation::solarLoad::solarLoad
785 solarCalc_(
dict, mesh_),
792 mesh_.time().timeName(),
807 mesh_.time().timeName(),
815 absorptivity_(mesh_.boundaryMesh().size()),
816 spectralDistribution_(),
817 spectralDistributions_(),
824 updateAbsorptivity_(
false),
825 useReflectedRays_(
false),
852 if (!pp.
coupled() && !isA<cyclicAMIPolyPatch>(pp))
854 includePatches.
insert(patchI);
864 (isA<mappedPatchBase>(pp) && solidCoupled_)
865 || (isA<wallPolyPatch>(pp) && wallCoupled_)
868 includeMappedPatchBasePatches.
insert(patchI);
872 if (updateAbsorptivity_ || firstIter_)
874 updateAbsorptivity(includePatches);
877 const bool facesChanged = updateHitFaces();
879 const bool timeDependentLoad =
882 if (facesChanged || timeDependentLoad)
887 solarCalc_.correctDirectSolarRad();
888 solarCalc_.correctDiffuseSolarRad();
890 spectralDistribution_ =
891 spectralDistributions_->value(mesh_.time().value());
893 spectralDistribution_ =
894 spectralDistribution_/
sum(spectralDistribution_);
897 const labelList& hitFacesId = hitFaces_->rayStartFaces();
898 updateDirectHitRadiation(hitFacesId, includeMappedPatchBasePatches);
901 updateSkyDiffusiveRadiation
904 includeMappedPatchBasePatches
908 if (useReflectedRays_)
910 updateReflectedRays(includeMappedPatchBasePatches);
918 if (mesh_.time().writeTime())
933 mesh_.time().timeName(),