solarHeatLoad.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "solarHeatLoad.H"
27 #include "surfaceFields.H"
28 #include "vectorList.H"
32 #include "cyclicAMIPolyPatch.H"
33 #include "mappedPatchBase.H"
34 #include "wallPolyPatch.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  namespace radiation
41  {
42  defineTypeNameAndDebug(solarHeatLoad, 1);
44  }
45 }
46 
48  = "viewFactorWall";
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
53 {
54  if (hitFaces_.empty())
55  {
57  return true;
58  }
59  else
60  {
61  switch (solarCalc_.sunDirectionModel())
62  {
64  {
65  return false;
66  break;
67  }
69  {
70  label updateIndex = label
71  (
73  );
74 
75  if (updateIndex > updateTimeIndex_)
76  {
77  Info << "Updating Sun position..." << endl;
78  updateTimeIndex_ = updateIndex;
80  hitFaces_->direction() = solarCalc_.direction();
81  hitFaces_->correct();
82 //Info << "now the sun direction is : " << solarCalc_.direction();
83 //add write for debug
84 // if (debug)
85 // {
86 // hitFaces_->write();
87 // }
88  return true;
89  break;
90  }
91  }
92  }
93  }
94 
95  return false;
96 }
97 
98 
100 (
101  const labelHashSet& includePatches
102 )
103 {
104  const boundaryRadiationProperties& boundaryRadiation =
106 
107  forAllConstIter(labelHashSet, includePatches, iter)
108  {
109  const label patchID = iter.key();
110  absorptivity_[patchID].setSize(nBands_);
111  for (label bandI = 0; bandI < nBands_; bandI++)
112  {
113  absorptivity_[patchID][bandI] =
114  boundaryRadiation.absorptivity(patchID, bandI);
115  }
116  }
117 }
118 
119 
121 (
122  const labelList& hitFacesId,
123  const labelHashSet& includeMappedPatchBasePatches
124 )
125 {
126  const polyBoundaryMesh& patches = mesh_.boundaryMesh();
127  const scalarField& V = mesh_.V();
128 
129  forAll (hitFacesId, i)
130  {
131  const label faceI = hitFacesId[i];
132  label patchID = patches.whichPatch(faceI);
133  const polyPatch& pp = patches[patchID];
134  const label localFaceI = faceI - pp.start();
135  const vector qPrim =
136  solarCalc_.directSolarRad()
137  * solarCalc_.direction();
138 //Info << "cell hit face " << i << " from solar direction is " << solarCalc_.direction()<< endl;
139 //Info << "cell hit face " << i << " 's solar load is " << solarCalc_.directSolarRad()<< endl;
140 //Info << "cell hit face " << i <<" heat from sun is " << qPrim<< endl<< endl;
141 
142 // if (includeMappedPatchBasePatches[patchID])
143  {
144  const vectorField n = pp.faceNormals();
145 
146  for (label bandI = 0; bandI < nBands_; bandI++)
147  {
148 
149 //Info <<endl<< "for patch name " << pp.name() << endl;
150 //Info << "cell hit face [" << i <<"] spectralDistribution is " << spectralDistribution_[bandI]<< endl;
151 //Info << "cell hit face [" << i <<"] absorptivity is " <<absorptivity_[patchID][bandI]()[localFaceI]<< endl;
152 //Info << "For Qr, face normals is " << n[localFaceI] << endl;
153 //Info << "For Qr, qPrm & face normals == " << (qPrim & n[localFaceI]) << endl<<endl;
154  Qr_.boundaryField()[patchID][localFaceI] +=
155  (qPrim & n[localFaceI])
156  * spectralDistribution_[bandI]
157  * absorptivity_[patchID][bandI]()[localFaceI];
158  }
159  }
160  // else
161  {
162  const vectorField& sf = mesh_.Sf().boundaryField()[patchID];
163  const label cellI = pp.faceCells()[localFaceI];
164 
165  for (label bandI = 0; bandI < nBands_; bandI++)
166  {
167 //Info<<endl << "face normals is " << sf[localFaceI] << endl;
168 //Info << "qPrm & face normals == is " << (qPrim & sf[localFaceI]) << endl<<endl;
169  Ru_[cellI] +=
170  (qPrim & sf[localFaceI])
171  * spectralDistribution_[bandI]
172  * absorptivity_[patchID][bandI]()[localFaceI]
173  / V[cellI];
174 
175  //Ru_[cellI]=0;
176  }
177  }
178  }
179 // Info << "All direct radiation heat flux is " << Qr_ << endl;
180 }
181 
183 (
184  const labelHashSet& includePatches,
185  const labelHashSet& includeMappedPatchBasePatches
186 )
187 {
188  const polyBoundaryMesh& patches = mesh_.boundaryMesh();
189  const scalarField& V = mesh_.V();
190 
191  switch(solarCalc_.sunLoadModel())
192  {
195  {
196  forAllConstIter(labelHashSet, includePatches, iter)
197  {
198  const label patchID = iter.key();
199  const polyPatch& pp = patches[patchID];
200  const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
201 
202  const vectorField n = pp.faceNormals();
203  const labelList& cellIds = pp.faceCells();
204 
205  forAll (n, faceI)
206  {
207  const scalar cosEpsilon(verticalDir_ & -n[faceI]);
208 
209  scalar Ed(0.0);
210  scalar Er(0.0);
211  const scalar cosTheta(solarCalc_.direction() & -n[faceI]);
212 
213  {
214  // Above the horizon
215  if (cosEpsilon == 0.0)
216  {
217  // Vertical walls
218  scalar Y(0);
219 
220  if (cosTheta > -0.2)
221  {
222  Y = 0.55+0.437*cosTheta + 0.313*sqr(cosTheta);
223  }
224  else
225  {
226  Y = 0.45;
227  }
228 
229  Ed = solarCalc_.C()*Y*solarCalc_.directSolarRad();
230  }
231  else
232  {
233  //Other than vertical walls
234  Ed =
235  solarCalc_.C()
236  * solarCalc_.directSolarRad()
237  * (1.0 + cosEpsilon)/2.0;
238  }
239 
240  // Ground reflected
241  Er =
242  solarCalc_.directSolarRad()
243  * (solarCalc_.C() + Foam::sin(solarCalc_.beta()))
244  * solarCalc_.groundReflectivity()
245  * (1.0 - cosEpsilon)/2.0;
246  }
247 
248  const label cellI = cellIds[faceI];
249  // if (includeMappedPatchBasePatches[patchID])
250 //本来这部分includeMappedPatchBasePatches判断内部的计算的Q辐射量是为了耦合边界使用的
251  {
252  for (label bandI = 0; bandI < nBands_; bandI++)
253  {
254  // 这个是计算所有的天空漫反射,Qr_是包含天空漫反射和地面反射的辐射量
255  QdiffRad_.boundaryField()[patchID][faceI] +=
256  (Ed + Er)
257  * spectralDistribution_[bandI]
258  * absorptivity_[patchID][bandI]()[faceI];
259  }
260  }
261 
262 
263  // else
264  //这里是方程计算会用到的Ru
265  {
266  for (label bandI = 0; bandI < nBands_; bandI++)
267  {
268  Ru_[cellI] +=
269  (Ed + Er)
270  * spectralDistribution_[bandI]
271  * absorptivity_[patchID][bandI]()[faceI]
272  * sf[faceI]/V[cellI];
273 
274  //Ru_[cellI]=0;
275  }
276  }
277  }
278  }
279 // Info << "theor max Sky reflective radiation heat flux is " << QdiffRad_ << endl;
280  }
281  break;
282 
284  {
285  forAllConstIter(labelHashSet, includePatches, iter)
286  {
287  const label patchID = iter.key();
288  const polyPatch& pp = patches[patchID];
289  const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
290 
291  const labelList& cellIds = pp.faceCells();
292  forAll (pp, faceI)
293  {
294  const label cellI = cellIds[faceI];
295  //if (includeMappedPatchBasePatches[patchID])
296  {
297  for (label bandI = 0; bandI < nBands_; bandI++)
298  {
299 
300  QdiffRad_.boundaryField()[patchID][faceI] +=
301  solarCalc_.diffuseSolarRad()
302  * spectralDistribution_[bandI]
303  * absorptivity_[patchID][bandI]()[faceI];
304  }
305  }
306  //else
307  {
308  for (label bandI = 0; bandI < nBands_; bandI++)
309  {
310  Ru_[cellI] +=
311  (
312  spectralDistribution_[bandI]
313  * absorptivity_[patchID][bandI]()[faceI]
314  * solarCalc_.diffuseSolarRad()
315  )*sf[faceI]/V[cellI];
316 
317  // Ru_[cellI]=0;
318  }
319  }
320  }
321  }
322 // Info << "constant model, Sky reflective radiation heat flux is " << QdiffRad_ << endl;
323  break;
324  }
325  }
326 }
327 
328 
330 {
331 
332  if (coeffs.found("gridUp"))
333  {
334  coeffs.lookup("gridUp") >> verticalDir_;
335  verticalDir_ /= mag(verticalDir_);
336  }
337  else if (mesh_.foundObject<uniformDimensionedVectorField>("g"))
338  {
340  mesh_.lookupObject<uniformDimensionedVectorField>("g");
341  verticalDir_ = (-g/mag(g)).value();
342  }
343 
344  includePatches_ = mesh_.boundaryMesh().findIndices(viewFactorWalls);
345 
346  coeffs.lookup("useVFbeamToDiffuse") >> useVFbeamToDiffuse_;
347 
348  coeffs.lookup("spectralDistribution") >> spectralDistribution_;
349  spectralDistribution_ =
350  spectralDistribution_/sum(spectralDistribution_);
351 
352  nBands_ = spectralDistribution_.size();
353 
354  if (useVFbeamToDiffuse_)
355  {
356  map_.reset
357  (
358  new IOmapDistribute
359  (
360  IOobject
361  (
362  "mapDist",
363  mesh_.facesInstance(),
364  mesh_,
367  )
368  )
369  );
370  }
371 
372  if (coeffs.found("solidCoupled"))
373  {
374  coeffs.lookup("solidCoupled") >> solidCoupled_;
375  }
376 
377  if (coeffs.found("wallCoupled"))
378  {
379  coeffs.lookup("wallCoupled") >> wallCoupled_;
380  }
381 
382  if (coeffs.found("updateAbsorptivity"))
383  {
384  coeffs.lookup("updateAbsorptivity") >> updateAbsorptivity_;
385  }
386 }
387 
388 
390 (
391  const labelHashSet& includePatches,
392  const labelHashSet& includeMappedPatchBasePatches
393 )
394 {
395 
396  scalarListIOList FmyProc
397  (
398  IOobject
399  (
400  "F",
401  mesh_.facesInstance(),
402  mesh_,
405  false
406  )
407  );
408 
409 
410  if (finalAgglom_.size() > 0 && coarseMesh_.empty())
411  {
412  coarseMesh_.reset
413  (
414  new singleCellFvMesh
415  (
416  IOobject
417  (
418  "coarse." + mesh_.name(),
419  mesh_.polyMesh::instance(),
420  mesh_.time(),
423  ),
424  mesh_,
425  finalAgglom_
426  )
427  );
428  }
429 
430  label nLocalVFCoarseFaces = 0;
431  forAll(includePatches_, i)
432  {
433  const label patchI = includePatches_[i];
434  nLocalVFCoarseFaces +=
435  coarseMesh_->boundaryMesh()[patchI].size();
436  }
437 
438  label totalFVNCoarseFaces = nLocalVFCoarseFaces;
439  reduce(totalFVNCoarseFaces, sumOp<label>());
440 
441  // Calculate weighted absorptivity on coarse patches
442  List<scalar> localCoarseRave(nLocalVFCoarseFaces);
443  List<scalar> localCoarsePartialArea(nLocalVFCoarseFaces);
444  List<vector> localCoarseNorm(nLocalVFCoarseFaces);
445 
446  scalarField compactCoarseRave(map_->constructSize(), 0.0);
447  scalarField compactCoarsePartialArea(map_->constructSize(), 0.0);
448  vectorList compactCoarseNorm(map_->constructSize(), vector::zero);
449 
450  const boundaryRadiationProperties& boundaryRadiation =
452 
453  coarseToFine_.setSize(includePatches_.size());
454 
455  const labelList& hitFacesId = hitFaces_->rayStartFaces();
456 
457  label startI = 0;
458  label compactI = 0;
459  forAll (includePatches_, i)
460  {
461  const label patchID = includePatches_[i];
462  const polyPatch& pp = mesh_.boundaryMesh()[patchID];
463 
464  const polyPatch& cpp = coarseMesh_->boundaryMesh()[patchID];
465 
466  const labelList& agglom = finalAgglom_[patchID];
467  //if (pp.size() > 0)
468  if (agglom.size() > 0)
469  {
470  label nAgglom = max(agglom) + 1;
471  coarseToFine_[i] = invertOneToMany(nAgglom, agglom);
472  }
473 
474  scalarField r(pp.size(), 0.0);
475  for (label bandI = 0; bandI < nBands_; bandI++)
476  {
477  const tmp<scalarField> tr =
478  spectralDistribution_[bandI]
479  *boundaryRadiation.reflectivity(patchID, bandI);
480  r += tr();
481  }
482 
483  scalarList Rave(cpp.size(), 0.0);
484  scalarList area(cpp.size(), 0.0);
485 
486  const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
487 
488  const labelList& coarsePatchFace =
489  coarseMesh_->patchFaceMap()[patchID];
490 
491  forAll (cpp, coarseI)
492  {
493  const label coarseFaceID = coarsePatchFace[coarseI];
494  const labelList& fineFaces =
495  coarseToFine_[i][coarseFaceID];
496 
497  UIndirectList<scalar> fineSf
498  (
499  sf,
500  fineFaces
501  );
502  scalar fineArea = sum(fineSf());
503 
504  scalar fullArea = 0.0;
505  forAll(fineFaces, j)
506  {
507  label faceI = fineFaces[j];
508  label globalFaceI = faceI + pp.start();
509 
510  if (findIndex(hitFacesId, globalFaceI) != -1)
511  {
512  fullArea += sf[faceI];
513  }
514  Rave[coarseI] += (r[faceI]*sf[faceI])/fineArea;
515  }
516  localCoarsePartialArea[compactI++] = fullArea/fineArea;
517  }
518 
520  (
521  localCoarseRave,
522  Rave.size(),
523  startI
524  ).assign(Rave);
525 
526 
527  const vectorList coarseNSf = cpp.faceNormals();
529  (
530  localCoarseNorm,
531  cpp.size(),
532  startI
533  ).assign(coarseNSf);
534  startI += cpp.size();
535  }
536 
537 
538  SubList<scalar>(compactCoarsePartialArea, nLocalVFCoarseFaces).assign
539  (
540  localCoarsePartialArea
541  );
542 
543  SubList<scalar>(compactCoarseRave, nLocalVFCoarseFaces).assign
544  (
545  localCoarseRave
546  );
547 
548  SubList<vector>(compactCoarseNorm, nLocalVFCoarseFaces).assign
549  (
550  localCoarseNorm
551  );
552 
553  map_->distribute(compactCoarsePartialArea);
554  map_->distribute(compactCoarseRave);
555  map_->distribute(compactCoarseNorm);
556 
557 
558  // Calculate coarse hitFaces and Sun direct hit heat fluxes
559  scalarList localqDiffusive(nLocalVFCoarseFaces, 0.0);
560 
561  label locaFaceI = 0;
562  forAll (includePatches_, i)
563  {
564  const label patchID = includePatches_[i];
565  const polyPatch& pp = coarseMesh_->boundaryMesh()[patchID];
566  const polyPatch& ppf = mesh_.boundaryMesh()[patchID];
567 
568  const labelList& coarsePatchFace =
569  coarseMesh_->patchFaceMap()[patchID];
570  const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
571 
572  scalarField a(ppf.size(), 0.0);
573  for (label bandI = 0; bandI < nBands_; bandI++)
574  {
575  const tmp<scalarField> ta =
576  spectralDistribution_[bandI]
577  * absorptivity_[patchID][bandI]();
578  a += ta();
579  }
580 
581  forAll (pp, coarseI)
582  {
583  const label coarseFaceID = coarsePatchFace[coarseI];
584  const labelList& fineFaces = coarseToFine_[i][coarseFaceID];
585  UIndirectList<scalar> fineSf
586  (
587  sf,
588  fineFaces
589  );
590  scalar fineArea = sum(fineSf());
591 
592  scalar aAve = 0.0;
593  forAll(fineFaces, j)
594  {
595  label faceI = fineFaces[j];
596  aAve += (a[faceI]*sf[faceI])/fineArea;
597  }
598 
599  const scalarList& vf = FmyProc[locaFaceI];
600 
601  const labelList& compactFaces = visibleFaceFaces_[locaFaceI];
602 
603 
604  forAll (compactFaces, j)
605  {
606  label compactI = compactFaces[j];
607 
608  localqDiffusive[locaFaceI] +=
609  compactCoarsePartialArea[compactI]
610  * aAve
611  * (solarCalc_.directSolarRad()*solarCalc_.direction())
612  & compactCoarseNorm[compactI]
613  * vf[j]
614  * compactCoarseRave[compactI];
615 
616  }
617  locaFaceI++;
618  }
619  }
620 
621  // Fill QsecondRad_
622  label compactId = 0;
623  forAll (includePatches_, i)
624  {
625  const label patchID = includePatches_[i];
626  const polyPatch& pp = coarseMesh_->boundaryMesh()[patchID];
627 
628  if (pp.size() > 0)
629  {
630  scalarField& Qrp = QrefecFormOtherWallRad_.boundaryField()[patchID];
631 
632  const labelList& coarsePatchFace =
633  coarseMesh_->patchFaceMap()[patchID];
634 
635  forAll(pp, coarseI)
636  {
637  const label coarseFaceID = coarsePatchFace[coarseI];
638  const labelList& fineFaces = coarseToFine_[i][coarseFaceID];
639  forAll(fineFaces, k)
640  {
641  label faceI = fineFaces[k];
642  Qrp[faceI] = localqDiffusive[compactId];
643  }
644  compactId ++;
645  }
646  }
647  }
648 
649  const scalarField& V = mesh_.V();
650  const polyBoundaryMesh& patches = mesh_.boundaryMesh();
651 
652  forAllConstIter(labelHashSet, includePatches, iter)
653  {
654  const label patchID = iter.key();
655  const scalarField& qSecond = QrefecFormOtherWallRad_.boundaryField()[patchID];
656 //Info << "other wall reflective radiation heat flux is " << QrefecFormOtherWallRad_ << endl;
657  //if (includeMappedPatchBasePatches[patchID])
658  {
659  QdiffRad_.boundaryField()[patchID] += qSecond;//add the groundReflectivity radiation to the toatal reflective radiation
660  }
661  //else
662  {
663  const polyPatch& pp = patches[patchID];
664  const labelList& cellIds = pp.faceCells();
665  const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
666  forAll (pp, faceI)
667  {
668  const label cellI = cellIds[faceI];
669  Ru_[cellI] += qSecond[faceI]*sf[faceI]/V[cellI];
670 
671  //Ru_[cellI]=0;
672  }
673  }
674  }
675 // Info << "add other wall reflective heat, total diffuse Solar radiation heat flux is " << QdiffRad_ << endl;
676 }
677 
678 
679 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
680 
682 :
683  radiationModel(typeName, T),
684  finalAgglom_
685  (
686  IOobject
687  (
688  "finalAgglom",
689  mesh_.facesInstance(),
690  mesh_,
691  IOobject::READ_IF_PRESENT,
692  IOobject::NO_WRITE,
693  false
694  )
695  ),
696  coarseMesh_(),
697  Qr_
698  (
699  IOobject
700  (
701  "Qr",
702  mesh_.time().timeName(),
703  mesh_,
704  IOobject::READ_IF_PRESENT,
705  IOobject::AUTO_WRITE
706  ),
707  mesh_,
709  ),
710  QrefecFormOtherWallRad_
711  (
712  IOobject
713  (
714  "Qrefec",
715  mesh_.time().timeName(),
716  mesh_,
717  IOobject::READ_IF_PRESENT,
718  IOobject::NO_WRITE
719  ),
720  mesh_,
721  dimensionedScalar("Qrefec", dimMass/pow3(dimTime), 0.0)
722  ),
723  QdiffRad_
724  (
725  IOobject
726  (
727  "QdiffRad",
728  mesh_.time().timeName(),
729  mesh_,
730  IOobject::NO_READ,
731  IOobject::AUTO_WRITE
732  ),
733  mesh_,
734  dimensionedScalar("QdiffRad", dimMass/pow3(dimTime), 0.0)
735  ),
736  QtotalRad_
737  (
738  IOobject
739  (
740  "QtotalRad_",
741  mesh_.time().timeName(),
742  mesh_,
743  IOobject::READ_IF_PRESENT,
744  IOobject::AUTO_WRITE
745  ),
746  mesh_,
747  dimensionedScalar("QtotalRad_", dimMass/pow3(dimTime), 0.0)
748  ),
749  hitFaces_(),
750  Ru_
751  (
752  IOobject
753  (
754  "Ru",
755  mesh_.time().timeName(),
756  mesh_,
757  IOobject::NO_READ,
758  IOobject::AUTO_WRITE
759  ),
760  mesh_,
762  ),
763  solarCalc_(this->subDict(typeName + "Coeffs"), mesh_),
764  verticalDir_(vector::zero),
765  useVFbeamToDiffuse_(false),
766  includePatches_(mesh_.boundary().size(), -1),
767  coarseToFine_(),
768  nBands_(1),
769  spectralDistribution_(nBands_),
770  map_(),
771  visibleFaceFaces_
772  (
773  IOobject
774  (
775  "visibleFaceFaces",
776  mesh_.facesInstance(),
777  mesh_,
778  IOobject::READ_IF_PRESENT,
779  IOobject::NO_WRITE,
780  false
781  )
782  ),
783  solidCoupled_(true),
784  absorptivity_(mesh_.boundaryMesh().size()),
785  updateAbsorptivity_(false),
786  firstIter_(true),
787  updateTimeIndex_(0)
788 {
790 }
791 
792 
794 (
795  const dictionary& dict,
796  const volScalarField& T
797 )
798 :
799  radiationModel(typeName, dict, T),
800  finalAgglom_
801  (
802  IOobject
803  (
804  "finalAgglom",
805  mesh_.facesInstance(),
806  mesh_,
809  false
810  )
811  ),
812  coarseMesh_(),
813  Qr_
814  (
815  IOobject
816  (
817  "Qr",
818  mesh_.time().timeName(),
819  mesh_,
822  ),
823  mesh_,
825  ),
826  QrefecFormOtherWallRad_
827  (
828  IOobject
829  (
830  "Qrefec",
831  mesh_.time().timeName(),
832  mesh_,
835  ),
836  mesh_,
837  dimensionedScalar("Qrefec", dimMass/pow3(dimTime), 0.0)
838  ),
839  QdiffRad_
840  (
841  IOobject
842  (
843  "QdiffRad",
844  mesh_.time().timeName(),
845  mesh_,
848  ),
849  mesh_,
850  dimensionedScalar("QdiffRad", dimMass/pow3(dimTime), 0.0)
851  ),
852  QtotalRad_
853  (
854  IOobject
855  (
856  "QtotalRad_",
857  mesh_.time().timeName(),
858  mesh_,
861  ),
862  mesh_,
863  dimensionedScalar("QtotalRad_", dimMass/pow3(dimTime), 0.0)
864  ),
865  hitFaces_(),
866  Ru_
867  (
868  IOobject
869  (
870  "Ru",
871  mesh_.time().timeName(),
872  mesh_,
875  ),
876  mesh_,
878  ),
879  solarCalc_(coeffs_, mesh_),
880  verticalDir_(vector::zero),
881  useVFbeamToDiffuse_(false),
882  includePatches_(mesh_.boundary().size(), -1),
883  coarseToFine_(),
884  nBands_(1),
885  spectralDistribution_(nBands_),
886  map_(),
887  visibleFaceFaces_
888  (
889  IOobject
890  (
891  "visibleFaceFaces",
892  mesh_.facesInstance(),
893  mesh_,
896  false
897  )
898  ),
899  solidCoupled_(true),
900  wallCoupled_(false),
901  absorptivity_(mesh_.boundaryMesh().size()),
902  updateAbsorptivity_(false),
903  firstIter_(true),
904  updateTimeIndex_(0)
905 {
906  initialise(coeffs_);
907 }
908 
909 
911 (
912  const dictionary& dict,
913  const volScalarField& T,
914  const word radWallFieldName
915 )
916 :
917  radiationModel("none", T),
918  finalAgglom_
919  (
920  IOobject
921  (
922  "finalAgglom",
923  mesh_.facesInstance(),
924  mesh_,
927  false
928  )
929  ),
930  coarseMesh_(),
931  Qr_
932  (
933  IOobject
934  (
935  radWallFieldName,
936  mesh_.time().timeName(),
937  mesh_,
940  ),
941  mesh_,
943  ),
944  QrefecFormOtherWallRad_
945  (
946  IOobject
947  (
948  "Qrefec",
949  mesh_.time().timeName(),
950  mesh_,
953  ),
954  mesh_,
955  dimensionedScalar("Qrefec", dimMass/pow3(dimTime), 0.0)
956  ),
957  QdiffRad_
958  (
959  IOobject
960  (
961  "QdiffRad",
962  mesh_.time().timeName(),
963  mesh_,
966  ),
967  mesh_,
968  dimensionedScalar("QdiffRad", dimMass/pow3(dimTime), 0.0)
969  ),
970  QtotalRad_
971  (
972  IOobject
973  (
974  "QtotalRad_",
975  mesh_.time().timeName(),
976  mesh_,
979  ),
980  mesh_,
981  dimensionedScalar("QtotalRad_", dimMass/pow3(dimTime), 0.0)
982  ),
983  hitFaces_(),
984  Ru_
985  (
986  IOobject
987  (
988  "Ru",
989  mesh_.time().timeName(),
990  mesh_,
993  ),
994  mesh_,
996  ),
997  solarCalc_(dict, mesh_),
998  verticalDir_(vector::zero),
999  useVFbeamToDiffuse_(false),
1000  includePatches_(mesh_.boundary().size(), -1),
1001  coarseToFine_(),
1002  nBands_(1),
1003  spectralDistribution_(nBands_),
1004  map_(),
1005  visibleFaceFaces_
1006  (
1007  IOobject
1008  (
1009  "visibleFaceFaces",
1010  mesh_.facesInstance(),
1011  mesh_,
1014  false
1015  )
1016  ),
1017  solidCoupled_(true),
1018  wallCoupled_(false),
1019  absorptivity_(mesh_.boundaryMesh().size()),
1020  updateAbsorptivity_(false),
1021  firstIter_(true)
1022 {
1023  initialise(dict);
1024 }
1025 
1026 
1027 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
1028 
1030 {}
1031 
1032 
1033 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1034 
1036 {
1037  return nBands_;
1038 }
1039 
1040 
1042 {
1043  if (radiationModel::read())
1044  {
1045  return true;
1046  }
1047  else
1048  {
1049  return false;
1050  }
1051 }
1052 
1053 
1055 {
1056  const polyBoundaryMesh& patches = mesh_.boundaryMesh();
1057  labelHashSet includePatches;
1058  forAll(patches, patchI)
1059  {
1060  const polyPatch& pp = patches[patchI];
1061  if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
1062  {
1063  includePatches.insert(patchI);
1064  }
1065  }
1066  //Info << "all IncludePatches the number is " << includePatches.size() << endl;
1067 
1068  labelHashSet includeWallGetRadiationPatches;
1069  forAll(patches, patchI)
1070  {
1071  const polyPatch& pp = patches[patchI];
1072  // Info << "boundary type is " << pp.type() << endl;
1073  if (isA<wallPolyPatch>(pp))
1074  {
1075  includeWallGetRadiationPatches.insert(patchI);
1076  }
1077  }
1078 
1079 // Info << "includeWallGetRadiationPatches the number is " <<includeWallGetRadiationPatches.size() << endl;
1080 
1081  if (updateAbsorptivity_ || firstIter_)
1082  {
1083  updateAbsorptivity(includePatches);
1084  }
1085 
1086  bool facesChanged = updateHitFaces();
1087 
1088 // Info << "faceChanged is = " << facesChanged <<endl;
1089 
1090  if (facesChanged)
1091  {
1092  // Reset Ru and Qr
1093  Ru_ = dimensionedScalar("Ru", dimMass/dimLength/pow3(dimTime), 0.0);
1094  Qr_.boundaryField() = 0.0;
1095  QdiffRad_.boundaryField() = 0.0;
1096 
1097  // Add direct hit radation
1098  const labelList& hitFacesId = hitFaces_->rayStartFaces();
1099  updateDirectHitRadiation(hitFacesId,includeWallGetRadiationPatches);
1100 
1101  // Add sky diffusive radiation
1102  updateSkyDiffusiveRadiation
1103  (
1104  includePatches,
1105  includeWallGetRadiationPatches
1106  );
1107 
1108  // Add indirect diffusive radiation
1109  if (useVFbeamToDiffuse_)
1110  {
1111  calculateQdiff(includePatches,includeWallGetRadiationPatches);
1112  }
1113 
1114  firstIter_ = false;
1115 
1116 //Info << "direct Qr is = " << Qr_ <<endl;
1117  QtotalRad_ = Qr_ + QdiffRad_;
1118 
1119  }
1120 
1121  if (debug)
1122  {
1123  if (mesh_.time().outputTime())
1124  {
1125  Ru_.write();
1126  }
1127  }
1128 }
1129 
1130 
1132 {
1133  return tmp<volScalarField>
1134  (
1135  new volScalarField
1136  (
1137  IOobject
1138  (
1139  "Rp",
1140  mesh_.time().timeName(),
1141  mesh_,
1144  false
1145  ),
1146  mesh_,
1148  (
1149  "zero",
1151  0.0
1152  )
1153  )
1154  );
1155 }
1156 
1157 
1160 {
1161  return Ru_;
1162 }
1163 
1164 // ************************************************************************* //
Foam::radiation::solarHeatLoad::calculate
void calculate()
Solve.
Definition: solarHeatLoad.C:1054
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::solarCalculator::direction
const vector direction() const
const acess to direction
Definition: solarCalculator.H:231
Foam::radiation::boundaryRadiationProperties::absorptivity
tmp< scalarField > absorptivity(const label patchId, const label bandI=0) const
Access boundary absorptivity on patch.
Definition: boundaryRadiationProperties.C:133
Foam::radiation::solarHeatLoad::updateDirectHitRadiation
void updateDirectHitRadiation(const labelList &, const labelHashSet &)
Update direct hit faces radiation.
Definition: solarHeatLoad.C:121
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
Foam::solarCalculator::sunTrackingUpdateInterval
scalar sunTrackingUpdateInterval()
Return sunTrackingUpdateInterval.
Definition: solarCalculator.H:297
vectorList.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::solarCalculator::mSunDirTraking
@ mSunDirTraking
Definition: solarCalculator.H:111
Foam::radiation::radiationModel::coeffs_
dictionary coeffs_
Radiation model dictionary.
Definition: radiationModel.H:103
Foam::IOobject::AUTO_WRITE
@ AUTO_WRITE
Definition: IOobject.H:117
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::findIndex
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
Foam::invertOneToMany
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
Definition: ListOps.C:67
Foam::IOmapDistribute
IOmapDistribute is derived from mapDistribute and IOobject to give the mapDistribute automatic IO fun...
Definition: IOmapDistribute.H:51
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:255
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
solarHeatLoad.H
Foam::polyPatch::coupled
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:322
Foam::radiation::solarHeatLoad::solarCalc_
solarCalculator solarCalc_
Solar calculator.
Definition: solarHeatLoad.H:121
boundary
faceListList boundary(nPatches)
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
wallPolyPatch.H
Foam::radiation::solarHeatLoad::Rp
virtual tmp< volScalarField > Rp() const
Source term component (for power of T^4)
Definition: solarHeatLoad.C:1131
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::solarCalculator::mSunLoadFairWeatherConditions
@ mSunLoadFairWeatherConditions
Definition: solarCalculator.H:118
g
const dimensionedVector & g
Definition: setRegionFluidFields.H:33
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
surfaceFields.H
Foam::surfaceFields.
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:261
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::HashSet< label, Hash< label > >
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::MeshObject< fvMesh, Foam::GeometricMeshObject, boundaryRadiationProperties >::New
static const boundaryRadiationProperties & New(const fvMesh &mesh)
Definition: MeshObject.C:44
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::faceHeatShading
faceHeatShading uses the transmissivity value in the boundaryRadiationProperties in order to evaluate...
Definition: faceHeatShading.H:58
Foam::radiation::solarHeatLoad::updateSkyDiffusiveRadiation
void updateSkyDiffusiveRadiation(const labelHashSet &, const labelHashSet &)
Update Sky diffusive radiation.
Definition: solarHeatLoad.C:183
Foam::radiation::boundaryRadiationProperties::reflectivity
tmp< scalarField > reflectivity(const label patchId, const label bandI=0) const
Access boundary reflectivity on patch.
Definition: boundaryRadiationProperties.C:179
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::singleCellFvMesh
fvMesh as subset of other mesh. Consists of one cell and all original bounday faces....
Definition: singleCellFvMesh.H:53
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
Foam::radiation::solarHeatLoad::~solarHeatLoad
virtual ~solarHeatLoad()
Destructor.
Definition: solarHeatLoad.C:1029
Foam::pow4
dimensionedScalar pow4(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:98
Foam::radiation::radiationModel::read
virtual bool read()=0
Read radiationProperties dictionary.
Definition: radiationModel.C:197
Foam::UniformDimensionedField< vector >
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::radiation::solarHeatLoad::Ru
virtual tmp< DimensionedField< scalar, volMesh > > Ru() const
Source term component (constant)
Definition: solarHeatLoad.C:1159
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:302
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:87
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::Info
messageStream Info
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::radiation::solarHeatLoad::nBands
label nBands() const
Number of bands.
Definition: solarHeatLoad.C:1035
Foam::UList::assign
void assign(const UList< T > &)
Assign elements to those from UList.
Definition: UList.C:37
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
Foam::solarCalculator::sunDirectionModel
sunDirModel sunDirectionModel() const
Return Sun direction model.
Definition: solarCalculator.H:273
radiation
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
Foam::radiation::boundaryRadiationProperties
Definition: boundaryRadiationProperties.H:56
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::radiation::solarHeatLoad::updateAbsorptivity
void updateAbsorptivity(const labelHashSet &includePatches)
Update absorptivity.
Definition: solarHeatLoad.C:100
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::radiation::solarHeatLoad::viewFactorWalls
static const word viewFactorWalls
Static name for view factor walls.
Definition: solarHeatLoad.H:89
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::radiation::solarHeatLoad::updateHitFaces
bool updateHitFaces()
Update hit faces.
Definition: solarHeatLoad.C:52
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
Foam::solarCalculator::mSunDirConstant
@ mSunDirConstant
Definition: solarCalculator.H:110
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:340
sf
volScalarField sf(fieldObject, mesh)
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::radiation::radiationModel::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: radiationModel.H:91
cyclicAMIPolyPatch.H
Foam::radiation::defineTypeNameAndDebug
defineTypeNameAndDebug(cloudAbsorptionEmission, 0)
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
uniformDimensionedFields.H
Foam::radiation::addToRadiationRunTimeSelectionTables
addToRadiationRunTimeSelectionTables(fvDOM)
Foam::solarCalculator::correctSunDirection
void correctSunDirection()
Recalculate.
Definition: solarCalculator.C:298
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::sumOp
Definition: ops.H:162
Foam::PrimitivePatch::faceNormals
const Field< PointType > & faceNormals() const
Return face normals for patch.
Definition: PrimitivePatchTemplate.C:520
Foam::solarCalculator::mSunLoadTheoreticalMaximum
@ mSunLoadTheoreticalMaximum
Definition: solarCalculator.H:119
Foam::radiation::solarHeatLoad::solarHeatLoad
solarHeatLoad(const solarHeatLoad &)
Disallow default bitwise copy construct.
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::radiation::radiationModel
Top level model for radiation modelling.
Definition: radiationModel.H:73
Foam::radiation::radiationModel::initialise
void initialise()
Initialise.
Definition: radiationModel.C:77
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::IOList
A List of objects of type <T> with automated input and output.
Definition: IOList.H:50
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry.
Definition: HashSet.H:116
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:333
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::dimTemperature
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:106
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:59
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::tr
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:49
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::radiation::solarHeatLoad::hitFaces_
autoPtr< faceHeatShading > hitFaces_
Direct hit faces Ids.
Definition: solarHeatLoad.H:115
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:110
Foam::radiation::solarHeatLoad::read
bool read()
Read radiation properties dictionary.
Definition: solarHeatLoad.C:1041
Foam::radiation::solarHeatLoad::updateTimeIndex_
label updateTimeIndex_
Update Sun position index.
Definition: solarHeatLoad.H:163
Foam::radiation::solarHeatLoad::calculateQdiff
void calculateQdiff(const labelHashSet &, const labelHashSet &)
Calculate diffusive heat flux.
Definition: solarHeatLoad.C:390
boundaryRadiationProperties.H
Y
PtrList< volScalarField > & Y
Definition: createFields.H:36
Foam::zero
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:47
mappedPatchBase.H
Foam::solarCalculator::mSunLoadConstant
@ mSunLoadConstant
Definition: solarCalculator.H:117