Commit 9893e623 authored by sergio's avatar sergio Committed by Andrew Heather
Browse files

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.
parent 36112db1
......@@ -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<labelledTri> triangles(mesh.nBoundaryFaces());
List<labelledTri> 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());
......
......@@ -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
);
......
......@@ -3794,7 +3794,7 @@ void Foam::distributedTriSurfaceMesh::getRegion
labelList triangleIndex(info.size());
autoPtr<mapDistribute> mapPtr
(
calcLocalQueries
localQueries
(
info,
triangleIndex
......@@ -3859,7 +3859,7 @@ void Foam::distributedTriSurfaceMesh::getNormal
labelList triangleIndex(info.size());
autoPtr<mapDistribute> mapPtr
(
calcLocalQueries
localQueries
(
info,
triangleIndex
......@@ -4261,7 +4261,7 @@ void Foam::distributedTriSurfaceMesh::getField
labelList triangleIndex(info.size());
autoPtr<mapDistribute> 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::mapDistribute>
Foam::distributedTriSurfaceMesh::localQueries
(
const List<pointIndexHit>& 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<mapDistribute> 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<treeBoundBox>& bbs,
......
......@@ -202,6 +202,7 @@ private:
// Triangle index
//- Helper: convert local triangle indices to global ones
void convertTriIndices(List<pointIndexHit>& 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<mapDistribute> localQueries
(
const List<pointIndexHit>&,
labelList& triangleIndex
) const;
//- Print some stats. Parallel aware version of
// triSurface::writeStats.
void writeStats(Ostream& os) const;
......
......@@ -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
......
......@@ -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<word>("T", "T")),
solarLoad_(dict.lookupOrDefault("solarLoad", false))
TName_(dict.lookupOrDefault<word>("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<volScalarField,scalar>
(
dom.externalRadHeatFieldName_
dom.primaryFluxName_ + "_0"
);
word qSecName = dom.relfectedFluxName_ + "_0";
if (this->db().foundObject<volScalarField>(qSecName))
{
const volScalarField& qSec =
this->db().lookupObject<volScalarField>(qSecName);
Ir += qSec.boundaryField()[patch().index()];
}
}
forAll(Iw, faceI)
......@@ -248,7 +254,6 @@ void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
{
mixedFvPatchScalarField::write(os);
os.writeEntryIfDifferent<word>("T", "T", TName_);
os.writeEntry("solarLoad", solarLoad_);
}
......
......@@ -86,10 +86,6 @@ class greyDiffusiveRadiationMixedFvPatchScalarField
//- Name of temperature field
word TName_;
//- Activate solar load
bool solarLoad_;
public:
//- Runtime type information
......
......@@ -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::scalarField> Foam::radiation::
greyDiffusiveViewFactorFixedValueFvPatchScalarField::qro() const
greyDiffusiveViewFactorFixedValueFvPatchScalarField::qro(label bandI) const
{
tmp<scalarField> tqrt(new scalarField(qro_));
if (solarLoad_)
{
const radiationModel& radiation =
db().lookupObject<radiationModel>("radiationProperties");
const viewFactor& radiation =
db().lookupObject<viewFactor>("radiationProperties");
if (radiation.useSolarLoad())
{
tqrt.ref() += patch().lookupPatchField<volScalarField, scalar>
(
radiation.externalRadHeatFieldName_
radiation.primaryFluxName_ + "_" + name(bandI)
);
word qSecName = radiation.relfectedFluxName_ + "_" + name(bandI);
if (this->db().foundObject<volScalarField>(qSecName))
{
const volScalarField& qSec =
this->db().lookupObject<volScalarField>(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_);
}
......
......@@ -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<scalarField> qro() const;
tmp<scalarField> qro(label bandI = 0) const;
// Evaluation functions
......
......@@ -213,6 +213,25 @@ updateCoeffs()
}
}
if (dom.useSolarLoad())
{
// Looking for primary heat flux single band
Ir += patch().lookupPatchField<volScalarField,scalar>
(
dom.primaryFluxName_ + "_" + name(lambdaId - 1)
);
word qSecName = dom.relfectedFluxName_ + "_" + name(lambdaId - 1);
if (this->db().foundObject<volScalarField>(qSecName))
{
const volScalarField& qSec =
this->db().lookupObject<volScalarField>(qSecName);
Ir += qSec.boundaryField()[patch().index()];
}
}
forAll(Iw, facei)
{
const vector& d = dom.IRay(rayId).d();
......
......@@ -292,4 +292,9 @@ Foam::radiation::P1::Ru() const
}