From af7923d749978d0987f39ab9768cf187e1c9f705 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 3 Dec 2018 13:51:40 -0800 Subject: [PATCH 1/3] ENH: Adding reflecting fluxes to Solar load radiation model. Adding functionality to the boundary radiation models and new place holder for basic wall types such as transparent, opaqueDiffusive, opaqueReflective,etc. Changing radiation wall models to run time selectable. Adding multi-band capabilities to VF model and improving the set up for using solar loads in VF and fvDOM radiation models. --- .../triSurfaceTools/triSurfaceTools.C | 30 +- .../triSurfaceTools/triSurfaceTools.H | 2 + .../distributedTriSurfaceMesh.C | 128 ++++- .../distributedTriSurfaceMesh.H | 12 + src/thermophysicalModels/radiation/Make/files | 26 +- ...iffusiveRadiationMixedFvPatchScalarField.C | 31 +- ...iffusiveRadiationMixedFvPatchScalarField.H | 4 - ...veViewFactorFixedValueFvPatchScalarField.C | 39 +- ...veViewFactorFixedValueFvPatchScalarField.H | 8 +- ...iffusiveRadiationMixedFvPatchScalarField.C | 19 + .../radiation/radiationModels/P1/P1.C | 5 + .../radiation/radiationModels/P1/P1.H | 3 + .../radiationModels/fvDOM/fvDOM/fvDOM.C | 5 +- .../radiationModels/fvDOM/fvDOM/fvDOM.H | 6 + .../radiationModels/fvDOM/fvDOM/fvDOMI.H | 10 + .../radiationModels/noRadiation/noRadiation.H | 6 + .../radiationModels/opaqueSolid/opaqueSolid.C | 5 + .../radiationModels/opaqueSolid/opaqueSolid.H | 3 + .../radiationModel/radiationModel.C | 21 +- .../radiationModel/radiationModel.H | 18 +- .../solarLoad/faceReflecting/faceReflecting.C | 536 ++++++++++++++++++ .../solarLoad/faceReflecting/faceReflecting.H | 166 ++++++ .../solarLoad/faceShading/faceShading.H | 2 +- .../radiationModels/solarLoad/solarLoad.C | 419 ++++++-------- .../radiationModels/solarLoad/solarLoad.H | 90 ++- .../radiationModels/viewFactor/viewFactor.C | 357 +++++++----- .../radiationModels/viewFactor/viewFactor.H | 11 +- .../radiationModels/viewFactor/viewFactorI.H | 13 +- .../boundaryRadiationProperties.C | 252 +++++++- .../boundaryRadiationProperties.H | 86 ++- .../boundaryRadiationPropertiesPatch.C | 393 ++----------- .../boundaryRadiationPropertiesPatch.H | 190 +++++-- .../lookup/lookup.C | 208 +++++++ .../lookup/lookup.H | 209 +++++++ .../opaqueDiffusive/opaqueDiffusive.C | 203 +++++++ .../opaqueDiffusive/opaqueDiffusive.H | 206 +++++++ .../opaqueReflective/opaqueReflective.C | 205 +++++++ .../opaqueReflective/opaqueReflective.H | 217 +++++++ .../transparent/transparent.C | 204 +++++++ .../transparent/transparent.H | 206 +++++++ .../solarCalculator/solarCalculator.H | 14 +- .../constantAbsorption/constantAbsorption.C | 115 ++++ .../constantAbsorption/constantAbsorption.H} | 76 ++- .../multiBandAbsorption/multiBandAbsorption.C | 121 ++++ .../multiBandAbsorption/multiBandAbsorption.H | 177 ++++++ .../solidAbsorption/solidAbsorption.C | 215 +++++++ .../solidAbsorption/solidAbsorption.H | 151 +++++ .../wallAbsorptionEmissionModel.C} | 52 +- .../wallAbsorptionEmissionModel.H | 160 ++++++ .../wallAbsorptionEmissionModelNew.C} | 22 +- .../constantTransmissivity.C | 50 +- .../constantTransmissivity.H | 29 +- .../multiBandTransmissivity.C} | 62 +- .../multiBandTransmissivity.H} | 61 +- .../wallTransmissivityModel.C} | 14 +- .../wallTransmissivityModel.H} | 58 +- .../wallTransmissivityModelNew.C | 56 ++ tutorials/basic/potentialFoam/cylinder/0/U | 55 ++ tutorials/basic/potentialFoam/cylinder/0/p | 55 ++ .../constant/boundaryRadiationProperties | 8 +- .../constant/panelRegion/radiationProperties | 2 - .../constant/radiationProperties | 2 - .../constant/boundaryRadiationProperties | 8 +- .../pyrolysisRegion/radiationProperties | 1 - .../constant/radiationProperties | 2 - .../constant/boundaryRadiationProperties | 10 +- .../constant/panelRegion/radiationProperties | 2 - .../constant/radiationProperties | 2 - .../constant/boundaryRadiationProperties | 2 +- .../constant/panelRegion/radiationProperties | 1 - .../constant/radiationProperties | 1 - .../constant/boundaryRadiationProperties | 8 +- .../constant/radiationProperties | 2 - .../constant/boundaryRadiationProperties | 3 +- .../constant/radiationProperties | 2 - .../constant/boundaryRadiationProperties | 2 +- .../constant/radiationProperties | 2 - .../constant/boundaryRadiationProperties | 2 +- .../constant/radiationProperties | 2 - .../constant/boundaryRadiationProperties | 2 +- .../constant/radiationProperties | 1 - .../externalSolarLoad/0.orig/air/T | 6 +- .../externalSolarLoad/0.orig/air/qr | 6 +- .../externalSolarLoad/0.orig/solid/T | 4 +- .../externalSolarLoad/Allclean | 2 + .../constant/air/boundaryRadiationProperties | 33 +- .../constant/air/radiationProperties | 38 +- .../constant/floor/radiationProperties | 11 +- .../constant/solid/radiationProperties | 11 +- .../bottomAir/boundaryRadiationProperties | 9 +- .../constant/bottomAir/radiationProperties | 3 - .../constant/heater/radiationProperties | 2 +- .../topAir/boundaryRadiationProperties | 8 +- 93 files changed, 5068 insertions(+), 1229 deletions(-) create mode 100644 src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C create mode 100644 src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.H create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/lookup/lookup.C create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/lookup/lookup.H create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/opaqueDiffusive/opaqueDiffusive.C create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/opaqueDiffusive/opaqueDiffusive.H create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/opaqueReflective/opaqueReflective.C create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/opaqueReflective/opaqueReflective.H create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/transparent/transparent.C create mode 100644 src/thermophysicalModels/radiation/submodels/boundaryRadiationProperties/transparent/transparent.H create mode 100644 src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/constantAbsorption/constantAbsorption.C rename src/thermophysicalModels/radiation/submodels/{transmissivityModel/noTransmissivity/noTransmissivity.H => wallAbsorptionEmissionModel/constantAbsorption/constantAbsorption.H} (55%) create mode 100644 src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/multiBandAbsorption/multiBandAbsorption.C create mode 100644 src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/multiBandAbsorption/multiBandAbsorption.H create mode 100644 src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/solidAbsorption/solidAbsorption.C create mode 100644 src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/solidAbsorption/solidAbsorption.H rename src/thermophysicalModels/radiation/submodels/{transmissivityModel/noTransmissivity/noTransmissivity.C => wallAbsorptionEmissionModel/wallAbsorptionEmissionModel/wallAbsorptionEmissionModel.C} (57%) create mode 100644 src/thermophysicalModels/radiation/submodels/wallAbsorptionEmissionModel/wallAbsorptionEmissionModel/wallAbsorptionEmissionModel.H rename src/thermophysicalModels/radiation/submodels/{transmissivityModel/transmissivityModel/transmissivityModelNew.C => wallAbsorptionEmissionModel/wallAbsorptionEmissionModel/wallAbsorptionEmissionModelNew.C} (71%) rename src/thermophysicalModels/radiation/submodels/{transmissivityModel => wallTransmissivityModel}/constantTransmissivity/constantTransmissivity.C (73%) rename src/thermophysicalModels/radiation/submodels/{transmissivityModel => wallTransmissivityModel}/constantTransmissivity/constantTransmissivity.H (78%) rename src/thermophysicalModels/radiation/submodels/{transmissivityModel/multiBandSolidTransmissivity/multiBandSolidTransmissivity.C => wallTransmissivityModel/multiBandTransmissivity/multiBandTransmissivity.C} (64%) rename src/thermophysicalModels/radiation/submodels/{transmissivityModel/multiBandSolidTransmissivity/multiBandSolidTransmissivity.H => wallTransmissivityModel/multiBandTransmissivity/multiBandTransmissivity.H} (66%) rename src/thermophysicalModels/radiation/submodels/{transmissivityModel/transmissivityModel/transmissivityModel.C => wallTransmissivityModel/wallTransmissivityModel/wallTransmissivityModel.C} (82%) rename src/thermophysicalModels/radiation/submodels/{transmissivityModel/transmissivityModel/transmissivityModel.H => wallTransmissivityModel/wallTransmissivityModel/wallTransmissivityModel.H} (65%) create mode 100644 src/thermophysicalModels/radiation/submodels/wallTransmissivityModel/wallTransmissivityModel/wallTransmissivityModelNew.C create mode 100644 tutorials/basic/potentialFoam/cylinder/0/U create mode 100644 tutorials/basic/potentialFoam/cylinder/0/p diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C index 2dd7c980ae..e20c1cf778 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C @@ -2191,16 +2191,36 @@ Foam::triSurface Foam::triSurfaceTools::triangulate ( const polyBoundaryMesh& bMesh, const labelHashSet& includePatches, + labelList& faceMap, const bool verbose ) { const polyMesh& mesh = bMesh.mesh(); // Storage for surfaceMesh. Size estimate. - DynamicList triangles(mesh.nBoundaryFaces()); + List triangles; + // Calculate number of faces and triangles + label nFaces = 0; + label nTris = 0; + + for (const label patchi : includePatches) + { + const polyPatch& patch = bMesh[patchi]; + const pointField& points = patch.points(); + nFaces += patch.size(); + for (const face& f : patch) + { + faceList triFaces(f.nTriangles(points)); + nTris += triFaces.size(); + } + } + + triangles.setSize(nTris); + faceMap.setSize(nTris); label newPatchi = 0; + nTris = 0; for (const label patchi : includePatches) { const polyPatch& patch = bMesh[patchi]; @@ -2208,6 +2228,7 @@ Foam::triSurface Foam::triSurfaceTools::triangulate label nTriTotal = 0; + label faceI = 0; for (const face& f : patch) { faceList triFaces(f.nTriangles(points)); @@ -2218,10 +2239,13 @@ Foam::triSurface Foam::triSurfaceTools::triangulate for (const face& f : triFaces) { - triangles.append(labelledTri(f[0], f[1], f[2], newPatchi)); + faceMap[nTris] = patch.start() + faceI; + triangles[nTris++] = labelledTri(f[0], f[1], f[2], newPatchi); ++nTriTotal; } + + faceI++; } if (verbose) @@ -2233,7 +2257,7 @@ Foam::triSurface Foam::triSurfaceTools::triangulate newPatchi++; } - triangles.shrink(); + //triangles.shrink(); // Create globally numbered tri surface triSurface rawSurface(triangles, mesh.points()); diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H index 5451007193..6a286ade0a 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H @@ -479,10 +479,12 @@ public: //- Simple triangulation of (selected patches of) boundaryMesh. Needs // polyMesh (or polyBoundaryMesh) since only at this level are the // triangles on neighbouring patches connected. + // Return faceMap from triI to faceI static triSurface triangulate ( const polyBoundaryMesh& mBesh, const labelHashSet& includePatches, + labelList& faceMap, const bool verbose = false ); diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 9bf3f12ab6..7623480695 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -3794,7 +3794,7 @@ void Foam::distributedTriSurfaceMesh::getRegion labelList triangleIndex(info.size()); autoPtr mapPtr ( - calcLocalQueries + localQueries ( info, triangleIndex @@ -3859,7 +3859,7 @@ void Foam::distributedTriSurfaceMesh::getNormal labelList triangleIndex(info.size()); autoPtr mapPtr ( - calcLocalQueries + localQueries ( info, triangleIndex @@ -4261,7 +4261,7 @@ void Foam::distributedTriSurfaceMesh::getField labelList triangleIndex(info.size()); autoPtr mapPtr ( - calcLocalQueries + localQueries ( info, triangleIndex @@ -4352,6 +4352,128 @@ Foam::triSurface Foam::distributedTriSurfaceMesh::overlappingSurface } +// Exchanges indices to the processor they come from. +// - calculates exchange map +// - uses map to calculate local triangle index +Foam::autoPtr +Foam::distributedTriSurfaceMesh::localQueries +( + const List& info, + labelList& triangleIndex +) const +{ + triangleIndex.setSize(info.size()); + + const globalIndex& triIndexer = globalTris(); + + + // Determine send map + // ~~~~~~~~~~~~~~~~~~ + + // Since determining which processor the query should go to is + // cheap we do a multi-pass algorithm to save some memory temporarily. + + // 1. Count + labelList nSend(Pstream::nProcs(), 0); + + forAll(info, i) + { + if (info[i].hit()) + { + label proci = triIndexer.whichProcID(info[i].index()); + nSend[proci]++; + } + } + + // 2. Size sendMap + labelListList sendMap(Pstream::nProcs()); + forAll(nSend, proci) + { + sendMap[proci].setSize(nSend[proci]); + nSend[proci] = 0; + } + + // 3. Fill sendMap + forAll(info, i) + { + if (info[i].hit()) + { + label proci = triIndexer.whichProcID(info[i].index()); + triangleIndex[i] = triIndexer.toLocal(proci, info[i].index()); + sendMap[proci][nSend[proci]++] = i; + } + else + { + triangleIndex[i] = -1; + } + } + + + // Send over how many i need to receive + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + labelListList sendSizes(Pstream::nProcs()); + sendSizes[Pstream::myProcNo()].setSize(Pstream::nProcs()); + forAll(sendMap, proci) + { + sendSizes[Pstream::myProcNo()][proci] = sendMap[proci].size(); + } + Pstream::gatherList(sendSizes); + Pstream::scatterList(sendSizes); + + + // Determine receive map + // ~~~~~~~~~~~~~~~~~~~~~ + + labelListList constructMap(Pstream::nProcs()); + + // My local segments first + constructMap[Pstream::myProcNo()] = identity + ( + sendMap[Pstream::myProcNo()].size() + ); + + label segmenti = constructMap[Pstream::myProcNo()].size(); + forAll(constructMap, proci) + { + if (proci != Pstream::myProcNo()) + { + // What i need to receive is what other processor is sending to me. + label nRecv = sendSizes[proci][Pstream::myProcNo()]; + constructMap[proci].setSize(nRecv); + + for (label i = 0; i < nRecv; i++) + { + constructMap[proci][i] = segmenti++; + } + } + } + + + // Pack into distribution map + // ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + autoPtr mapPtr + ( + new mapDistribute + ( + segmenti, // size after construction + std::move(sendMap), + std::move(constructMap) + ) + ); + const mapDistribute& map = mapPtr(); + + + // Send over queries + // ~~~~~~~~~~~~~~~~~ + + map.distribute(triangleIndex); + + return mapPtr; +} + + void Foam::distributedTriSurfaceMesh::distribute ( const List& bbs, diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.H b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.H index c2b6caf40b..a585a0b408 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.H +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.H @@ -202,6 +202,7 @@ private: // Triangle index + //- Helper: convert local triangle indices to global ones void convertTriIndices(List& info) const; @@ -559,6 +560,17 @@ public: labelList& subFaceMap ); + + //- Obtains global indices from pointIndexHit and swaps them back + // to their original processor. Used to calculate local region + // and normal. + virtual autoPtr localQueries + ( + const List&, + labelList& triangleIndex + ) const; + + //- Print some stats. Parallel aware version of // triSurface::writeStats. void writeStats(Ostream& os) const; diff --git a/src/thermophysicalModels/radiation/Make/files b/src/thermophysicalModels/radiation/Make/files index bd4e985783..ef657f1c13 100644 --- a/src/thermophysicalModels/radiation/Make/files +++ b/src/thermophysicalModels/radiation/Make/files @@ -11,6 +11,7 @@ radiationModels/viewFactor/viewFactor.C radiationModels/opaqueSolid/opaqueSolid.C radiationModels/solarLoad/solarLoad.C radiationModels/solarLoad/faceShading/faceShading.C +radiationModels/solarLoad/faceReflecting/faceReflecting.C /* Scatter model */ submodels/scatterModel/scatterModel/scatterModel.C @@ -18,6 +19,18 @@ submodels/scatterModel/scatterModel/scatterModelNew.C submodels/scatterModel/noScatter/noScatter.C submodels/scatterModel/constantScatter/constantScatter.C +/* Wall sub-models */ +submodels/wallTransmissivityModel/wallTransmissivityModel/wallTransmissivityModel.C +submodels/wallTransmissivityModel/wallTransmissivityModel/wallTransmissivityModelNew.C +submodels/wallTransmissivityModel/constantTransmissivity/constantTransmissivity.C +submodels/wallTransmissivityModel/multiBandTransmissivity/multiBandTransmissivity.C + +submodels/wallAbsorptionEmissionModel/wallAbsorptionEmissionModel/wallAbsorptionEmissionModel.C +submodels/wallAbsorptionEmissionModel/wallAbsorptionEmissionModel/wallAbsorptionEmissionModelNew.C +submodels/wallAbsorptionEmissionModel/multiBandAbsorption/multiBandAbsorption.C +submodels/wallAbsorptionEmissionModel/constantAbsorption/constantAbsorption.C +submodels/wallAbsorptionEmissionModel/solidAbsorption/solidAbsorption.C + /* Absorption/Emission model */ submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModel.C submodels/absorptionEmissionModel/absorptionEmissionModel/absorptionEmissionModelNew.C @@ -31,18 +44,19 @@ submodels/absorptionEmissionModel/multiBandSolidAbsorptionEmission/multiBandSoli submodels/boundaryRadiationProperties/boundaryRadiationProperties.C submodels/boundaryRadiationProperties/boundaryRadiationPropertiesPatch.C +/* Types of radiative walls */ +submodels/boundaryRadiationProperties/transparent/transparent.C +submodels/boundaryRadiationProperties/lookup/lookup.C +submodels/boundaryRadiationProperties/opaqueDiffusive/opaqueDiffusive.C +submodels/boundaryRadiationProperties/opaqueReflective/opaqueReflective.C + /* Soot model */ submodels/sootModel/sootModel/sootModel.C submodels/sootModel/sootModel/sootModelNew.C submodels/sootModel/mixtureFractionSoot/mixtureFractionSoots.C submodels/sootModel/noSoot/noSoot.C -/* Transmissivity model */ -submodels/transmissivityModel/transmissivityModel/transmissivityModel.C -submodels/transmissivityModel/transmissivityModel/transmissivityModelNew.C -submodels/transmissivityModel/noTransmissivity/noTransmissivity.C -submodels/transmissivityModel/constantTransmissivity/constantTransmissivity.C -submodels/transmissivityModel/multiBandSolidTransmissivity/multiBandSolidTransmissivity.C + /* Solar calculator model */ submodels/solarCalculator/solarCalculator.C diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C index 6de2b03ae2..7a6de7e82c 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -47,8 +47,7 @@ greyDiffusiveRadiationMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - TName_("T"), - solarLoad_(false) + TName_("T") { refValue() = 0.0; refGrad() = 0.0; @@ -66,8 +65,7 @@ greyDiffusiveRadiationMixedFvPatchScalarField ) : mixedFvPatchScalarField(ptf, p, iF, mapper), - TName_(ptf.TName_), - solarLoad_(ptf.solarLoad_) + TName_(ptf.TName_) {} @@ -80,8 +78,7 @@ greyDiffusiveRadiationMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - TName_(dict.lookupOrDefault("T", "T")), - solarLoad_(dict.lookupOrDefault("solarLoad", false)) + TName_(dict.lookupOrDefault("T", "T")) { if (dict.found("refValue")) { @@ -111,8 +108,7 @@ greyDiffusiveRadiationMixedFvPatchScalarField ) : mixedFvPatchScalarField(ptf), - TName_(ptf.TName_), - solarLoad_(ptf.solarLoad_) + TName_(ptf.TName_) {} @@ -124,8 +120,7 @@ greyDiffusiveRadiationMixedFvPatchScalarField ) : mixedFvPatchScalarField(ptf, iF), - TName_(ptf.TName_), - solarLoad_(ptf.solarLoad_) + TName_(ptf.TName_) {} @@ -197,12 +192,23 @@ updateCoeffs() Ir += dom.IRay(rayI).qin().boundaryField()[patchi]; } - if (solarLoad_) + if (dom.useSolarLoad()) { + // Looking for primary heat flux single band Ir += patch().lookupPatchField ( - dom.externalRadHeatFieldName_ + dom.primaryFluxName_ + "_0" ); + + word qSecName = dom.relfectedFluxName_ + "_0"; + + if (this->db().foundObject(qSecName)) + { + const volScalarField& qSec = + this->db().lookupObject(qSecName); + + Ir += qSec.boundaryField()[patch().index()]; + } } forAll(Iw, faceI) @@ -248,7 +254,6 @@ void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write { mixedFvPatchScalarField::write(os); os.writeEntryIfDifferent("T", "T", TName_); - os.writeEntry("solarLoad", solarLoad_); } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H index 6a0bb491f3..53a61156f7 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H @@ -86,10 +86,6 @@ class greyDiffusiveRadiationMixedFvPatchScalarField //- Name of temperature field word TName_; - //- Activate solar load - bool solarLoad_; - - public: //- Runtime type information diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C index 200916dd93..97181ef2c0 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C @@ -30,6 +30,7 @@ License #include "fvPatchFieldMapper.H" #include "volFields.H" #include "radiationModel.H" +#include "viewFactor.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -41,8 +42,7 @@ greyDiffusiveViewFactorFixedValueFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - qro_(), - solarLoad_(false) + qro_() {} @@ -56,8 +56,7 @@ greyDiffusiveViewFactorFixedValueFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper), - qro_(ptf.qro_, mapper), - solarLoad_(ptf.solarLoad_) + qro_(ptf.qro_, mapper) {} @@ -70,8 +69,7 @@ greyDiffusiveViewFactorFixedValueFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF, dict, false), - qro_("qro", dict, p.size()), - solarLoad_(dict.lookupOrDefault("solarLoad", false)) + qro_("qro", dict, p.size()) { if (dict.found("value")) { @@ -95,8 +93,7 @@ greyDiffusiveViewFactorFixedValueFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf), - qro_(ptf.qro_), - solarLoad_(ptf.solarLoad_) + qro_(ptf.qro_) {} @@ -108,8 +105,7 @@ greyDiffusiveViewFactorFixedValueFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, iF), - qro_(ptf.qro_), - solarLoad_(ptf.solarLoad_) + qro_(ptf.qro_) {} @@ -167,19 +163,29 @@ updateCoeffs() Foam::tmp Foam::radiation:: -greyDiffusiveViewFactorFixedValueFvPatchScalarField::qro() const +greyDiffusiveViewFactorFixedValueFvPatchScalarField::qro(label bandI) const { tmp tqrt(new scalarField(qro_)); - if (solarLoad_) - { - const radiationModel& radiation = - db().lookupObject("radiationProperties"); + const viewFactor& radiation = + db().lookupObject("radiationProperties"); + if (radiation.useSolarLoad()) + { tqrt.ref() += patch().lookupPatchField ( - radiation.externalRadHeatFieldName_ + radiation.primaryFluxName_ + "_" + name(bandI) ); + + word qSecName = radiation.relfectedFluxName_ + "_" + name(bandI); + + if (this->db().foundObject(qSecName)) + { + const volScalarField& qSec = + this->db().lookupObject(qSecName); + + tqrt.ref() += qSec.boundaryField()[patch().index()]; + } } return tqrt; @@ -194,7 +200,6 @@ write { fixedValueFvPatchScalarField::write(os); qro_.writeEntry("qro", os); - os.writeEntry("solarLoad", solarLoad_); } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H index 7738874578..5f3f87efdd 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H @@ -37,7 +37,6 @@ Usage \table Property | Description | Required | Default value qro | external radiative heat flux | yes | - emissivityMode | emissivity mode: solidRadiation or lookup | yes | \endtable Example of the boundary condition specification: @@ -46,8 +45,6 @@ Usage { type greyDiffusiveRadiationViewFactor; qro uniform 0; - emissivityMode solidRadiation; - value uniform 0; } \endverbatim @@ -87,9 +84,6 @@ class greyDiffusiveViewFactorFixedValueFvPatchScalarField //- External radiative heat flux scalarField qro_; - //- Activate solar load - bool solarLoad_; - public: @@ -168,7 +162,7 @@ public: // Access //- Return external + solar load radiative heat flux - tmp qro() const; + tmp qro(label bandI = 0) const; // Evaluation functions diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C index d6dffe1440..b123f30e08 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C @@ -213,6 +213,25 @@ updateCoeffs() } } + if (dom.useSolarLoad()) + { + // Looking for primary heat flux single band + Ir += patch().lookupPatchField + ( + dom.primaryFluxName_ + "_" + name(lambdaId - 1) + ); + + word qSecName = dom.relfectedFluxName_ + "_" + name(lambdaId - 1); + + if (this->db().foundObject(qSecName)) + { + const volScalarField& qSec = + this->db().lookupObject(qSecName); + + Ir += qSec.boundaryField()[patch().index()]; + } + } + forAll(Iw, facei) { const vector& d = dom.IRay(rayId).d(); diff --git a/src/thermophysicalModels/radiation/radiationModels/P1/P1.C b/src/thermophysicalModels/radiation/radiationModels/P1/P1.C index a8ef86c266..d2a8d690ab 100644 --- a/src/thermophysicalModels/radiation/radiationModels/P1/P1.C +++ b/src/thermophysicalModels/radiation/radiationModels/P1/P1.C @@ -292,4 +292,9 @@ Foam::radiation::P1::Ru() const } +Foam::label Foam::radiation::P1::nBands() const +{ + return absorptionEmission_->nBands(); +} + // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H index e52db15437..bf9b398807 100644 --- a/src/thermophysicalModels/radiation/radiationModels/P1/P1.H +++ b/src/thermophysicalModels/radiation/radiationModels/P1/P1.H @@ -128,6 +128,9 @@ public: //- Source term component (constant) virtual tmp Ru() const; + + //- Number of bands + label nBands() const; }; diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C index a84d2c3b14..16c0db32b0 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C @@ -193,10 +193,7 @@ void Foam::radiation::fvDOM::initialise() if (useSolarLoad_) { const dictionary& solarDict = this->subDict("solarLoarCoeffs"); - solarLoad_.reset - ( - new solarLoad(solarDict, T_, externalRadHeatFieldName_) - ); + solarLoad_.reset(new solarLoad(solarDict, T_)); if (solarLoad_->nBands() > 1) { diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H index fb2df4df4c..da4bd9c9f5 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.H @@ -244,6 +244,9 @@ public: //- Number of wavelengths inline label nLambda() const; + //- Number of bands + inline label nBands() const; + //- Const access to total absorption coefficient inline const volScalarField& a() const; @@ -270,6 +273,9 @@ public: //- Return meshOrientation inline vector meshOrientation() const; + + //- Use solar load + inline bool useSolarLoad() const; }; diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOMI.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOMI.H index 1cbf2a6e0a..69d2783652 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOMI.H +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOMI.H @@ -67,6 +67,11 @@ inline Foam::label Foam::radiation::fvDOM::nLambda() const } +inline Foam::label Foam::radiation::fvDOM::nBands() const +{ + return nLambda_; +} + inline const Foam::volScalarField& Foam::radiation::fvDOM::a() const { return a_; @@ -124,4 +129,9 @@ inline Foam::vector Foam::radiation::fvDOM::meshOrientation() const } +inline bool Foam::radiation::fvDOM::useSolarLoad() const +{ + return useSolarLoad_; +} + // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.H b/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.H index c16b1243a4..3107d656ee 100644 --- a/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.H +++ b/src/thermophysicalModels/radiation/radiationModels/noRadiation/noRadiation.H @@ -101,6 +101,12 @@ public: //- Source term component (constant) tmp Ru() const; + + //- Number of bands + label nBands() const + { + return 0; + } }; diff --git a/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C b/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C index 0b40a454ae..b2128c122a 100644 --- a/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C +++ b/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.C @@ -121,4 +121,9 @@ Foam::radiation::opaqueSolid::Ru() const } +Foam::label Foam::radiation::opaqueSolid::nBands() const +{ + return absorptionEmission_->nBands(); +} + // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.H b/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.H index 231cfc5078..5230b906fd 100644 --- a/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.H +++ b/src/thermophysicalModels/radiation/radiationModels/opaqueSolid/opaqueSolid.H @@ -102,6 +102,9 @@ public: //- Source term component (constant) tmp Ru() const; + + //- Number of bands + label nBands() const; }; diff --git a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C index 3e70332e8b..4ba2e2fe64 100644 --- a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C +++ b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.C @@ -47,6 +47,12 @@ namespace Foam const Foam::word Foam::radiation::radiationModel::externalRadHeatFieldName_ = "qrExt"; +const Foam::word Foam::radiation::radiationModel::primaryFluxName_ = + "qprimaryRad"; + + const Foam::word Foam::radiation::radiationModel::relfectedFluxName_ = + "qreflective"; + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::IOobject Foam::radiation::radiationModel::createIOobject @@ -90,8 +96,6 @@ void Foam::radiation::radiationModel::initialise() scatter_.reset(scatterModel::New(*this, mesh_).ptr()); soot_.reset(sootModel::New(*this, mesh_).ptr()); - - transmissivity_.reset(transmissivityModel::New(*this, mesh_).ptr()); } } @@ -120,8 +124,7 @@ Foam::radiation::radiationModel::radiationModel(const volScalarField& T) firstIter_(true), absorptionEmission_(nullptr), scatter_(nullptr), - soot_(nullptr), - transmissivity_(nullptr) + soot_(nullptr) {} @@ -141,8 +144,7 @@ Foam::radiation::radiationModel::radiationModel firstIter_(true), absorptionEmission_(nullptr), scatter_(nullptr), - soot_(nullptr), - transmissivity_(nullptr) + soot_(nullptr) { if (readOpt() == IOobject::NO_READ) { @@ -181,8 +183,7 @@ Foam::radiation::radiationModel::radiationModel firstIter_(true), absorptionEmission_(nullptr), scatter_(nullptr), - soot_(nullptr), - transmissivity_(nullptr) + soot_(nullptr) { initialise(); } @@ -319,7 +320,7 @@ Foam::radiation::radiationModel::soot() const return *soot_; } - +/* const Foam::radiation::transmissivityModel& Foam::radiation::radiationModel::transmissivity() const { @@ -332,6 +333,6 @@ Foam::radiation::radiationModel::transmissivity() const return *transmissivity_; } - +*/ // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.H b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.H index 8a416b6b2d..1de41e8a48 100644 --- a/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.H +++ b/src/thermophysicalModels/radiation/radiationModels/radiationModel/radiationModel.H @@ -50,7 +50,7 @@ SourceFiles #include "volFields.H" #include "fvMatricesFwd.H" #include "Switch.H" -#include "transmissivityModel.H" +#include "absorptionEmissionModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -64,7 +64,7 @@ namespace radiation { // Forward declaration of classes -class absorptionEmissionModel; +//class absorptionEmissionModel; class scatterModel; class sootModel; @@ -83,6 +83,13 @@ public: //- Static name external radiative fluxes static const word externalRadHeatFieldName_; + //- Static name for primary solar fluxes + static const word primaryFluxName_; + + //- Static name for reflected solar fluxes + static const word relfectedFluxName_; + + protected: @@ -124,7 +131,7 @@ protected: autoPtr soot_; //- Transmissivity model - autoPtr transmissivity_; + //autoPtr transmissivity_; private: @@ -265,12 +272,11 @@ public: volScalarField& T ) const; + virtual label nBands() const = 0; + //- Access to absorptionEmission model const absorptionEmissionModel& absorptionEmission() const; - //- Access to transmissivity Model - const transmissivityModel& transmissivity() const; - //- Access to soot Model const sootModel& soot() const; diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C new file mode 100644 index 0000000000..0337ed9f60 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceReflecting/faceReflecting.C @@ -0,0 +1,536 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "faceReflecting.H" +#include "boundaryRadiationProperties.H" +#include "cyclicAMIPolyPatch.H" +#include "volFields.H" + + +using namespace Foam::constant::mathematical; + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(faceReflecting, 0); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::faceReflecting::initialise(const dictionary& coeffs) +{ + + forAll(qreflective_, bandI) + { + qreflective_.set + ( + bandI, + new volScalarField + ( + IOobject + ( + "qreflective_" + Foam::name(bandI) , + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar(dimMass/pow3(dimTime), Zero) + ) + ); + } + + label rayI = 0; + if (mesh_.nSolutionD() == 3) + { + nRay_ = 4*nPhi_*nTheta_; + refDiscAngles_.resize(nRay_); + const scalar deltaPhi = pi/(2.0*nPhi_); + const scalar deltaTheta = pi/nTheta_; + + for (label n = 1; n <= nTheta_; n++) + { + for (label m = 1; m <= 4*nPhi_; m++) + { + const scalar thetai = (2*n - 1)*deltaTheta/2.0; + const scalar phii = (2*m - 1)*deltaPhi/2.0; + + scalar sinTheta = Foam::sin(thetai); + scalar cosTheta = Foam::cos(thetai); + scalar sinPhi = Foam::sin(phii); + scalar cosPhi = Foam::cos(phii); + refDiscAngles_[rayI++] = + vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta); + + } + } + + } + else if (mesh_.nSolutionD() == 2) + { + nRay_ = 4*nPhi_; + refDiscAngles_.resize(nRay_); + const scalar thetai = piByTwo; + //const scalar deltaTheta = pi; + const scalar deltaPhi = pi/(2.0*nPhi_); + for (label m = 1; m <= 4*nPhi_; m++) + { + const scalar phii = (2*m - 1)*deltaPhi/2.0; + + scalar sinTheta = Foam::sin(thetai); + scalar cosTheta = Foam::cos(thetai); + scalar sinPhi = Foam::sin(phii); + scalar cosPhi = Foam::cos(phii); + + refDiscAngles_[rayI++] = + vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta); + } + } + else + { + FatalErrorInFunction + << "The reflected rays are available in 2D or 3D " + << abort(FatalError); + } + + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + + const radiation::boundaryRadiationProperties& boundaryRadiation = + radiation::boundaryRadiationProperties::New(mesh_); + + // global face index + globalIndex globalNumbering(mesh_.nFaces()); + + // Collect faces with t = 0, r = 0 and a > 0 to shoot rays + // and patches to construct the triSurface + DynamicList dynCf; + DynamicList