mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Adding solar radiation modelling and tutorial changes
This commit is contained in:
@ -23,21 +23,6 @@ dict.add
|
||||
);
|
||||
dict.add("mergeDistance", SMALL);
|
||||
|
||||
labelHashSet includePatches;
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
const polyPatch& pp = patches[patchI];
|
||||
if
|
||||
(
|
||||
!pp.coupled()
|
||||
&& !isA<cyclicAMIPolyPatch>(pp)
|
||||
&& !isA<emptyPolyPatch>(pp)
|
||||
)
|
||||
{
|
||||
includePatches.insert(patchI);
|
||||
}
|
||||
}
|
||||
|
||||
labelList triSurfaceToAgglom(5*nFineFaces);
|
||||
|
||||
const triSurface localSurface = triangulate
|
||||
@ -69,6 +54,4 @@ distributedTriSurfaceMesh surfacesMesh
|
||||
|
||||
triSurfaceToAgglom.resize(surfacesMesh.size());
|
||||
|
||||
//surfacesMesh.searchableSurface::write();
|
||||
|
||||
surfacesMesh.setField(triSurfaceToAgglom);
|
||||
|
||||
@ -89,7 +89,7 @@ for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||
|
||||
DynamicList<label> dRayIs;
|
||||
|
||||
// Collect the rays which has not abstacle in bettween in rayStartFace
|
||||
// Collect the rays which has not obstacle in bettween in rayStartFace
|
||||
// and rayEndFace. If the ray hit itself get stored in dRayIs
|
||||
forAll(hitInfo, rayI)
|
||||
{
|
||||
|
||||
@ -29,33 +29,42 @@ Description
|
||||
(finalAgglom generated by faceAgglomerate utility).
|
||||
|
||||
Each view factor between the agglomerated faces i and j (Fij) is calculated
|
||||
using a double integral of the sub-areas composing the agglomaration.
|
||||
using a double integral of the sub-areas composing the agglomeration.
|
||||
|
||||
The patches involved in the view factor calculation are taken from the Qr
|
||||
volScalarField (radiative flux) when is greyDiffusiveRadiationViewFactor
|
||||
otherwise they are not included.
|
||||
The patches involved in the view factor calculation are taken from the
|
||||
boundary file and should be part on the group viewFactorWall. ie.:
|
||||
|
||||
floor
|
||||
{
|
||||
type wall;
|
||||
inGroups 2(wall viewFactorWall);
|
||||
nFaces 100;
|
||||
startFace 3100;
|
||||
}
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
#include "singleCellFvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "distributedTriSurfaceMesh.H"
|
||||
#include "cyclicAMIPolyPatch.H"
|
||||
#include "mapDistribute.H"
|
||||
#include "meshTools.H"
|
||||
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
#include "DynamicField.H"
|
||||
#include "unitConversion.H"
|
||||
|
||||
#include "scalarMatrices.H"
|
||||
#include "labelListIOList.H"
|
||||
#include "scalarListIOList.H"
|
||||
|
||||
#include "singleCellFvMesh.H"
|
||||
|
||||
#include "IOmapDistribute.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
triSurface triangulate
|
||||
(
|
||||
@ -116,7 +125,7 @@ triSurface triangulate
|
||||
newPatchI++;
|
||||
}
|
||||
|
||||
triSurfaceToAgglom.resize(localTriFaceI);
|
||||
//striSurfaceToAgglom.resize(localTriFaceI-1);
|
||||
|
||||
triangles.shrink();
|
||||
|
||||
@ -209,7 +218,7 @@ scalar calculateViewFactorFij
|
||||
return
|
||||
(
|
||||
(cosThetaI*cosThetaJ*dAjMag*dAiMag)
|
||||
/(sqr(rMag)*constant::mathematical::pi)
|
||||
/(sqr(rMag)*constant::mathematical::pi)
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -264,6 +273,8 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
const word viewFactorWall("viewFactorWall");
|
||||
|
||||
const bool writeViewFactors =
|
||||
viewFactorDict.lookupOrDefault<bool>("writeViewFactorMatrix", false);
|
||||
|
||||
@ -272,19 +283,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
const label debug = viewFactorDict.lookupOrDefault<label>("debug", 0);
|
||||
|
||||
volScalarField Qr
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Qr",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
// Read agglomeration map
|
||||
labelListIOList finalAgglom
|
||||
(
|
||||
@ -336,27 +334,14 @@ int main(int argc, char *argv[])
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
const polyBoundaryMesh& coarsePatches = coarseMesh.boundaryMesh();
|
||||
|
||||
labelList viewFactorsPatches(patches.size());
|
||||
|
||||
const volScalarField::GeometricBoundaryField& Qrb = Qr.boundaryField();
|
||||
|
||||
label count = 0;
|
||||
forAll(Qrb, patchI)
|
||||
labelList viewFactorsPatches(patches.findIndices(viewFactorWall));
|
||||
forAll (viewFactorsPatches, i)
|
||||
{
|
||||
const polyPatch& pp = patches[patchI];
|
||||
const fvPatchScalarField& QrpI = Qrb[patchI];
|
||||
|
||||
if ((isA<fixedValueFvPatchScalarField>(QrpI)) && (pp.size() > 0))
|
||||
{
|
||||
viewFactorsPatches[count] = QrpI.patch().index();
|
||||
nCoarseFaces += coarsePatches[patchI].size();
|
||||
nFineFaces += patches[patchI].size();
|
||||
count ++;
|
||||
}
|
||||
label patchI = viewFactorsPatches[i];
|
||||
nCoarseFaces += coarsePatches[patchI].size();
|
||||
nFineFaces += patches[patchI].size();
|
||||
}
|
||||
|
||||
viewFactorsPatches.resize(count);
|
||||
|
||||
// total number of coarse faces
|
||||
label totalNCoarseFaces = nCoarseFaces;
|
||||
|
||||
@ -381,78 +366,85 @@ int main(int argc, char *argv[])
|
||||
|
||||
DynamicList<label> localAgg(nCoarseFaces);
|
||||
|
||||
forAll (viewFactorsPatches, i)
|
||||
labelHashSet includePatches;
|
||||
forAll(viewFactorsPatches, i)
|
||||
{
|
||||
const label patchID = viewFactorsPatches[i];
|
||||
|
||||
const polyPatch& pp = patches[patchID];
|
||||
const labelList& agglom = finalAgglom[patchID];
|
||||
label nAgglom = max(agglom)+1;
|
||||
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
|
||||
const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
|
||||
|
||||
const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchID];
|
||||
const pointField& coarseSf = coarseMesh.Sf().boundaryField()[patchID];
|
||||
|
||||
labelHashSet includePatches;
|
||||
includePatches.insert(patchID);
|
||||
|
||||
forAll(coarseCf, faceI)
|
||||
if (agglom.size() > 0)
|
||||
{
|
||||
point cf = coarseCf[faceI];
|
||||
label nAgglom = max(agglom)+1;
|
||||
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
|
||||
const labelList& coarsePatchFace =
|
||||
coarseMesh.patchFaceMap()[patchID];
|
||||
|
||||
const label coarseFaceI = coarsePatchFace[faceI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceI];
|
||||
const label agglomI =
|
||||
agglom[fineFaces[0]] + coarsePatches[patchID].start();
|
||||
const pointField& coarseCf =
|
||||
coarseMesh.Cf().boundaryField()[patchID];
|
||||
const pointField& coarseSf =
|
||||
coarseMesh.Sf().boundaryField()[patchID];
|
||||
|
||||
// Construct single face
|
||||
uindirectPrimitivePatch upp
|
||||
(
|
||||
UIndirectList<face>(pp, fineFaces),
|
||||
pp.points()
|
||||
);
|
||||
|
||||
|
||||
List<point> availablePoints
|
||||
(
|
||||
upp.faceCentres().size()
|
||||
+ upp.localPoints().size()
|
||||
);
|
||||
|
||||
SubList<point>
|
||||
(
|
||||
availablePoints,
|
||||
upp.faceCentres().size()
|
||||
).assign(upp.faceCentres());
|
||||
|
||||
SubList<point>
|
||||
(
|
||||
availablePoints,
|
||||
upp.localPoints().size(),
|
||||
upp.faceCentres().size()
|
||||
).assign(upp.localPoints());
|
||||
|
||||
point cfo = cf;
|
||||
scalar dist = GREAT;
|
||||
forAll(availablePoints, iPoint)
|
||||
forAll(coarseCf, faceI)
|
||||
{
|
||||
point cfFine = availablePoints[iPoint];
|
||||
if (mag(cfFine-cfo) < dist)
|
||||
{
|
||||
dist = mag(cfFine-cfo);
|
||||
cf = cfFine;
|
||||
}
|
||||
}
|
||||
point cf = coarseCf[faceI];
|
||||
|
||||
point sf = coarseSf[faceI];
|
||||
localCoarseCf.append(cf);
|
||||
localCoarseSf.append(sf);
|
||||
localAgg.append(agglomI);
|
||||
const label coarseFaceI = coarsePatchFace[faceI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceI];
|
||||
const label agglomI =
|
||||
agglom[fineFaces[0]] + coarsePatches[patchID].start();
|
||||
|
||||
// Construct single face
|
||||
uindirectPrimitivePatch upp
|
||||
(
|
||||
UIndirectList<face>(pp, fineFaces),
|
||||
pp.points()
|
||||
);
|
||||
|
||||
|
||||
List<point> availablePoints
|
||||
(
|
||||
upp.faceCentres().size()
|
||||
+ upp.localPoints().size()
|
||||
);
|
||||
|
||||
SubList<point>
|
||||
(
|
||||
availablePoints,
|
||||
upp.faceCentres().size()
|
||||
).assign(upp.faceCentres());
|
||||
|
||||
SubList<point>
|
||||
(
|
||||
availablePoints,
|
||||
upp.localPoints().size(),
|
||||
upp.faceCentres().size()
|
||||
).assign(upp.localPoints());
|
||||
|
||||
point cfo = cf;
|
||||
scalar dist = GREAT;
|
||||
forAll(availablePoints, iPoint)
|
||||
{
|
||||
point cfFine = availablePoints[iPoint];
|
||||
if (mag(cfFine-cfo) < dist)
|
||||
{
|
||||
dist = mag(cfFine-cfo);
|
||||
cf = cfFine;
|
||||
}
|
||||
}
|
||||
|
||||
point sf = coarseSf[faceI];
|
||||
localCoarseCf.append(cf);
|
||||
localCoarseSf.append(sf);
|
||||
localAgg.append(agglomI);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Distribute local coarse Cf and Sf for shooting rays
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -478,7 +470,6 @@ int main(int argc, char *argv[])
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#include "searchingEngine.H"
|
||||
|
||||
|
||||
// Determine rays between coarse face centres
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
DynamicList<label> rayStartFace(nCoarseFaces + 0.01*nCoarseFaces);
|
||||
@ -486,8 +477,8 @@ int main(int argc, char *argv[])
|
||||
DynamicList<label> rayEndFace(rayStartFace.size());
|
||||
|
||||
|
||||
// Return rayStartFace in local index andrayEndFace in global index
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Return rayStartFace in local index and rayEndFace in global index
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
#include "shootRays.H"
|
||||
|
||||
@ -508,7 +499,6 @@ int main(int argc, char *argv[])
|
||||
nViewFactors += nVisibleFaceFaces[faceI];
|
||||
}
|
||||
|
||||
|
||||
// - Construct compact numbering
|
||||
// - return map from remote to compact indices
|
||||
// (per processor (!= myProcNo) a map from remote index to compact index)
|
||||
@ -519,54 +509,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
mapDistribute map(globalNumbering, rayEndFace, compactMap);
|
||||
|
||||
labelListIOList IOsubMap
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"subMap",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
map.subMap()
|
||||
);
|
||||
IOsubMap.write();
|
||||
|
||||
|
||||
labelListIOList IOconstructMap
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"constructMap",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
map.constructMap()
|
||||
);
|
||||
IOconstructMap.write();
|
||||
|
||||
|
||||
IOList<label> consMapDim
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"constructMapDim",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
List<label>(1, map.constructSize())
|
||||
);
|
||||
consMapDim.write();
|
||||
|
||||
|
||||
// visibleFaceFaces has:
|
||||
// (local face, local viewed face) = compact viewed face
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -600,33 +542,38 @@ int main(int argc, char *argv[])
|
||||
forAll(viewFactorsPatches, i)
|
||||
{
|
||||
label patchID = viewFactorsPatches[i];
|
||||
|
||||
const labelList& agglom = finalAgglom[patchID];
|
||||
label nAgglom = max(agglom)+1;
|
||||
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
|
||||
const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
|
||||
|
||||
forAll(coarseToFine, coarseI)
|
||||
if (agglom.size() > 0)
|
||||
{
|
||||
compactPatchId.append(patchID);
|
||||
List<point>& fineCf = compactFineCf[compactI];
|
||||
List<point>& fineSf = compactFineSf[compactI++];
|
||||
label nAgglom = max(agglom)+1;
|
||||
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
|
||||
const labelList& coarsePatchFace =
|
||||
coarseMesh.patchFaceMap()[patchID];
|
||||
|
||||
const label coarseFaceI = coarsePatchFace[coarseI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceI];
|
||||
forAll(coarseToFine, coarseI)
|
||||
{
|
||||
compactPatchId.append(patchID);
|
||||
List<point>& fineCf = compactFineCf[compactI];
|
||||
List<point>& fineSf = compactFineSf[compactI++];
|
||||
|
||||
fineCf.setSize(fineFaces.size());
|
||||
fineSf.setSize(fineFaces.size());
|
||||
const label coarseFaceI = coarsePatchFace[coarseI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceI];
|
||||
|
||||
fineCf = UIndirectList<point>
|
||||
(
|
||||
mesh.Cf().boundaryField()[patchID],
|
||||
coarseToFine[coarseFaceI]
|
||||
);
|
||||
fineSf = UIndirectList<point>
|
||||
(
|
||||
mesh.Sf().boundaryField()[patchID],
|
||||
coarseToFine[coarseFaceI]
|
||||
);
|
||||
fineCf.setSize(fineFaces.size());
|
||||
fineSf.setSize(fineFaces.size());
|
||||
|
||||
fineCf = UIndirectList<point>
|
||||
(
|
||||
mesh.Cf().boundaryField()[patchID],
|
||||
coarseToFine[coarseFaceI]
|
||||
);
|
||||
fineSf = UIndirectList<point>
|
||||
(
|
||||
mesh.Sf().boundaryField()[patchID],
|
||||
coarseToFine[coarseFaceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -837,22 +784,25 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
label patchID = viewFactorsPatches[i];
|
||||
const labelList& agglom = finalAgglom[patchID];
|
||||
label nAgglom = max(agglom)+1;
|
||||
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
|
||||
const labelList& coarsePatchFace =
|
||||
coarseMesh.patchFaceMap()[patchID];
|
||||
|
||||
forAll(coarseToFine, coarseI)
|
||||
if (agglom.size() > 0)
|
||||
{
|
||||
const scalar Fij = sum(F[compactI]);
|
||||
const label coarseFaceID = coarsePatchFace[coarseI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceID];
|
||||
forAll (fineFaces, fineId)
|
||||
label nAgglom = max(agglom)+1;
|
||||
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
|
||||
const labelList& coarsePatchFace =
|
||||
coarseMesh.patchFaceMap()[patchID];
|
||||
|
||||
forAll(coarseToFine, coarseI)
|
||||
{
|
||||
const label faceID = fineFaces[fineId];
|
||||
viewFactorField.boundaryField()[patchID][faceID] = Fij;
|
||||
const scalar Fij = sum(F[compactI]);
|
||||
const label coarseFaceID = coarsePatchFace[coarseI];
|
||||
const labelList& fineFaces = coarseToFine[coarseFaceID];
|
||||
forAll (fineFaces, fineId)
|
||||
{
|
||||
const label faceID = fineFaces[fineId];
|
||||
viewFactorField.boundaryField()[patchID][faceID] = Fij;
|
||||
}
|
||||
compactI++;
|
||||
}
|
||||
compactI++;
|
||||
}
|
||||
}
|
||||
viewFactorField.write();
|
||||
@ -886,66 +836,64 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
if (Pstream::master())
|
||||
labelListList globalFaceFaces(visibleFaceFaces.size());
|
||||
|
||||
// Create globalFaceFaces needed to insert view factors
|
||||
// in F to the global matrix Fmatrix
|
||||
forAll(globalFaceFaces, faceI)
|
||||
{
|
||||
scalarSquareMatrix Fmatrix(totalNCoarseFaces, totalNCoarseFaces, 0.0);
|
||||
|
||||
labelListList globalFaceFaces(visibleFaceFaces.size());
|
||||
|
||||
// Create globalFaceFaces needed to insert view factors
|
||||
// in F to the global matrix Fmatrix
|
||||
forAll(globalFaceFaces, faceI)
|
||||
{
|
||||
globalFaceFaces[faceI] = renumber
|
||||
(
|
||||
compactToGlobal,
|
||||
visibleFaceFaces[faceI]
|
||||
);
|
||||
}
|
||||
|
||||
labelListIOList IOglobalFaceFaces
|
||||
globalFaceFaces[faceI] = renumber
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"globalFaceFaces",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
globalFaceFaces
|
||||
compactToGlobal,
|
||||
visibleFaceFaces[faceI]
|
||||
);
|
||||
IOglobalFaceFaces.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
labelListList globalFaceFaces(visibleFaceFaces.size());
|
||||
forAll(globalFaceFaces, faceI)
|
||||
{
|
||||
globalFaceFaces[faceI] = renumber
|
||||
(
|
||||
compactToGlobal,
|
||||
visibleFaceFaces[faceI]
|
||||
);
|
||||
}
|
||||
|
||||
labelListIOList IOglobalFaceFaces
|
||||
labelListIOList IOglobalFaceFaces
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"globalFaceFaces",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
globalFaceFaces
|
||||
);
|
||||
"globalFaceFaces",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
globalFaceFaces
|
||||
);
|
||||
IOglobalFaceFaces.write();
|
||||
|
||||
IOglobalFaceFaces.write();
|
||||
}
|
||||
|
||||
labelListIOList IOvisibleFaceFaces
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"visibleFaceFaces",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
visibleFaceFaces
|
||||
);
|
||||
IOvisibleFaceFaces.write();
|
||||
|
||||
IOmapDistribute IOmapDist
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"mapDist",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
map.xfer()
|
||||
);
|
||||
|
||||
IOmapDist.write();
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user