56 void Foam::radiation::solarLoad::updateReflectedRays
61 if (!reflectedFaces_ && hitFaces_)
70 spectralDistribution_,
76 reflectedFaces_->correct();
78 volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
80 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
86 for (label bandI = 0; bandI < nBands_; bandI++)
89 reflectedFaces_->qreflective(bandI).boundaryField()[
patchID];
97 for (label bandI = 0; bandI < nBands_; bandI++)
101 const label cellI = cellIs[i];
105 reflectedFaces_->qreflective(bandI).
106 boundaryField()[
patchID][i] * sf[i]
118 bool Foam::radiation::solarLoad::updateHitFaces()
122 hitFaces_.reset(
new faceShading(mesh_, solarCalc_.direction()));
127 switch (solarCalc_.sunDirectionModel())
136 label updateIndex = label
138 mesh_.time().value()/solarCalc_.sunTrackingUpdateInterval()
141 if (updateIndex > updateTimeIndex_)
143 Info <<
"Updating Sun position..." <<
endl;
144 updateTimeIndex_ = updateIndex;
145 solarCalc_.correctSunDirection();
146 hitFaces_->direction() = solarCalc_.direction();
147 hitFaces_->correct();
159 void Foam::radiation::solarLoad::updateAbsorptivity
164 const boundaryRadiationProperties& boundaryRadiation =
167 for (
const label
patchID : includePatches)
169 absorptivity_[
patchID].setSize(nBands_);
170 for (label bandI = 0; bandI < nBands_; bandI++)
172 absorptivity_[
patchID][bandI] =
173 boundaryRadiation.absorptivity(
patchID, bandI);
179 void Foam::radiation::solarLoad::updateDirectHitRadiation
185 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
187 volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
192 for (label bandI = 0; bandI < nBands_; bandI++)
194 volScalarField::Boundary& qprimaryBf =
195 qprimaryRad_[bandI].boundaryFieldRef();
201 const label faceI = hitFacesId[i];
204 const label localFaceI = faceI - pp.start();
206 solarCalc_.directSolarRad()*solarCalc_.direction();
211 qprimaryBf[
patchID][localFaceI] +=
212 (qPrim &
n[localFaceI])
213 * spectralDistribution_[bandI]
214 * absorptivity_[
patchID][bandI]()[localFaceI];
217 if (includeMappedPatchBasePatches[
patchID])
224 const label cellI = pp.faceCells()[localFaceI];
227 (qPrim & sf[localFaceI])
228 * spectralDistribution_[bandI]
229 * absorptivity_[
patchID][bandI]()[localFaceI]
237 void Foam::radiation::solarLoad::updateSkyDiffusiveRadiation
243 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
245 volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
247 switch(solarCalc_.sunLoadModel())
252 for (
const label
patchID : includePatches)
258 const labelList& cellIds = pp.faceCells();
262 const scalar cosEpsilon(verticalDir_ & -
n[faceI]);
266 const scalar cosTheta(solarCalc_.direction() & -
n[faceI]);
270 if (cosEpsilon == 0.0)
277 Y = 0.55+0.437*cosTheta + 0.313*
sqr(cosTheta);
284 Ed = solarCalc_.C()*
Y*solarCalc_.directSolarRad();
291 * solarCalc_.directSolarRad()
292 * (1.0 + cosEpsilon)/2.0;
297 solarCalc_.directSolarRad()
298 * (solarCalc_.C() +
Foam::sin(solarCalc_.beta()))
299 * solarCalc_.groundReflectivity()
300 * (1.0 - cosEpsilon)/2.0;
303 const label cellI = cellIds[faceI];
304 if (includeMappedPatchBasePatches[
patchID])
306 for (label bandI = 0; bandI < nBands_; bandI++)
310 * spectralDistribution_[bandI]
311 * absorptivity_[
patchID][bandI]()[faceI];
316 for (label bandI = 0; bandI < nBands_; bandI++)
320 * spectralDistribution_[bandI]
321 * absorptivity_[
patchID][bandI]()[faceI]
322 * sf[faceI]/V[cellI];
332 for (
const label
patchID : includePatches)
337 const labelList& cellIds = pp.faceCells();
340 const label cellI = cellIds[faceI];
341 if (includeMappedPatchBasePatches[
patchID])
343 for (label bandI = 0; bandI < nBands_; bandI++)
346 solarCalc_.diffuseSolarRad()
347 * spectralDistribution_[bandI]
348 * absorptivity_[
patchID][bandI]()[faceI];
353 for (label bandI = 0; bandI < nBands_; bandI++)
357 spectralDistribution_[bandI]
358 * absorptivity_[
patchID][bandI]()[faceI]
359 * solarCalc_.diffuseSolarRad()
360 )*sf[faceI]/V[cellI];
371 void Foam::radiation::solarLoad::initialise(
const dictionary& coeffs)
373 coeffs.readEntry(
"spectralDistribution", spectralDistribution_);
375 nBands_ = spectralDistribution_.size();
377 qprimaryRad_.setSize(nBands_);
379 if (coeffs.readIfPresent(
"gridUp", verticalDir_))
381 verticalDir_.normalise();
387 verticalDir_ = (-
g/
mag(
g)).value();
390 coeffs.readEntry(
"useReflectedRays", useReflectedRays_);
392 spectralDistribution_ =
393 spectralDistribution_/
sum(spectralDistribution_);
395 forAll(qprimaryRad_, bandI)
405 mesh_.time().timeName(),
416 coeffs.readIfPresent(
"solidCoupled", solidCoupled_);
417 coeffs.readIfPresent(
"wallCoupled", wallCoupled_);
418 coeffs.readIfPresent(
"updateAbsorptivity", updateAbsorptivity_);
753 solarCalc_(coeffs_, mesh_),
755 useReflectedRays_(false),
756 spectralDistribution_(),
761 updateAbsorptivity_(false),
769 Foam::radiation::solarLoad::solarLoad
782 mesh_.time().timeName(),
797 mesh_.time().timeName(),
805 solarCalc_(
dict, mesh_),
807 useReflectedRays_(
false),
808 spectralDistribution_(),
813 absorptivity_(mesh_.boundaryMesh().size()),
814 updateAbsorptivity_(
false),
848 if (!pp.
coupled() && !isA<cyclicAMIPolyPatch>(pp))
850 includePatches.
insert(patchI);
860 (isA<mappedPatchBase>(pp) && solidCoupled_)
861 || (isA<wallPolyPatch>(pp) && wallCoupled_)
864 includeMappedPatchBasePatches.
insert(patchI);
868 if (updateAbsorptivity_ || firstIter_)
870 updateAbsorptivity(includePatches);
873 bool facesChanged = updateHitFaces();
881 const labelList& hitFacesId = hitFaces_->rayStartFaces();
882 updateDirectHitRadiation(hitFacesId, includeMappedPatchBasePatches);
885 updateSkyDiffusiveRadiation
888 includeMappedPatchBasePatches
892 if (useReflectedRays_)
894 updateReflectedRays(includeMappedPatchBasePatches);
902 if (mesh_.time().writeTime())
917 mesh_.time().timeName(),