From 70ed6ba9677091df89a0b68b66088f1aa4a27b3d Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Tue, 19 Feb 2019 11:06:50 +0100 Subject: [PATCH 1/5] BUGFIX: View factor smoothing now takes into account reciprocity condition --- .../radiationModel/viewFactor/viewFactor.C | 247 +++++++++++++++++- 1 file changed, 239 insertions(+), 8 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModel/viewFactor/viewFactor.C b/src/thermophysicalModels/radiation/radiationModel/viewFactor/viewFactor.C index 60a8ba652..3c81fc7c1 100644 --- a/src/thermophysicalModels/radiation/radiationModel/viewFactor/viewFactor.C +++ b/src/thermophysicalModels/radiation/radiationModel/viewFactor/viewFactor.C @@ -64,7 +64,7 @@ void Foam::radiation::viewFactor::initialise() } } - selectedPatches_.resize(count--); + selectedPatches_.resize(count); if (debug) { @@ -173,6 +173,82 @@ void Foam::radiation::viewFactor::initialise() globalIndex globalNumbering(nLocalCoarseFaces_); + // Calculate global face areas + scalarField compactCoarseMagSf(map_->constructSize(), 0.0); + DynamicList localCoarseMagSf(nLocalCoarseFaces_); + + forAll (selectedPatches_, i) + { + label patchID = selectedPatches_[i]; + + const scalarField& sf = mesh_.magSf().boundaryField()[patchID]; + + const polyPatch& pp = coarseMesh_.boundaryMesh()[patchID]; + const labelList& coarsePatchFace = coarseMesh_.patchFaceMap()[patchID]; + + scalarList magSf(pp.size(), 0.0); + + if (pp.size() > 0) + { + const labelList& agglom = finalAgglom_[patchID]; + label nAgglom = max(agglom) + 1; + + labelListList coarseToFine(invertOneToMany(nAgglom, agglom)); + + forAll (coarseToFine, coarseI) + { + const label coarseFaceID = coarsePatchFace[coarseI]; + const labelList& fineFaces = coarseToFine[coarseFaceID]; + UIndirectList fineSf + ( + sf, + fineFaces + ); + magSf[coarseI] = sum(fineSf()); + } + } + + localCoarseMagSf.append(magSf); + } + + // Fill the local values to distribute + SubList(compactCoarseMagSf, nLocalCoarseFaces_).assign(localCoarseMagSf); + + // Distribute data + map_->distribute(compactCoarseMagSf); + + // Distribute local global ID + labelList compactGlobalIds(map_->constructSize(), 0.0); + + labelList localGlobalIds(nLocalCoarseFaces_); + + for(label k = 0; k < nLocalCoarseFaces_; k++) + { + localGlobalIds[k] = globalNumbering.toGlobal(Pstream::myProcNo(), k); + } + + SubList