diff --git a/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C b/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C index 6dade9e19..b982884a3 100644 --- a/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C +++ b/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C @@ -100,12 +100,14 @@ Foam::coupledFvMatrix::solve(const dictionary& solverControls) fvMatrix& curMatrix = static_cast& >(matrices[rowI]); + // HR 12.03.19: Complete assembly before making copies. + curMatrix.completeAssembly(); + saveDiag.set(rowI, new scalarField(curMatrix.diag())); psiCmpt.set(rowI, new scalarField(curMatrix.psi().size())); source.set(rowI, new Field(curMatrix.source())); sourceCmpt.set(rowI, new scalarField(curMatrix.psi().size())); - curMatrix.completeAssembly(); curMatrix.addBoundarySource(source[rowI]); interfaces[rowI] = curMatrix.psi().boundaryField().interfaces(); 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