diff --git a/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C b/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C index 47dfb38935..462b59c955 100644 --- a/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C +++ b/src/fvMeshTopoChangers/refiner/fvMeshTopoChangersRefiner.C @@ -257,11 +257,11 @@ Foam::fvMeshTopoChangers::refiner::refine } // Update fields - mesh().updateMesh(map); + mesh().updateMesh(map()); - // Correct the flux for modified/added faces. All the faces which only - // have been renumbered will already have been handled by the mapping. { + // Correct the flux for modified/added faces. All the faces which only + // have been renumbered will already have been handled by the mapping. const labelList& faceMap = map().faceMap(); const labelList& reverseFaceMap = map().reverseFaceMap(); @@ -296,141 +296,12 @@ Foam::fvMeshTopoChangers::refiner::refine Pout<< "Found " << masterFaces.size() << " split faces " << endl; } - HashTable fluxes - ( - mesh().lookupClass() - ); - forAllIter(HashTable, fluxes, iter) - { - if (!correctFluxes_.found(iter.key())) - { - WarningInFunction - << "Cannot find surfaceScalarField " << iter.key() - << " in user-provided flux mapping table " - << correctFluxes_ << endl - << " The flux mapping table is used to recreate the" - << " flux on newly created faces." << endl - << " Either add the entry if it is a flux or use (" - << iter.key() << " none) to suppress this warning." - << endl; - continue; - } - - const word& UName = correctFluxes_[iter.key()]; - - if (UName == "none") - { - continue; - } - - if (UName == "NaN") - { - Pout<< "Setting surfaceScalarField " << iter.key() - << " to NaN" << endl; - - surfaceScalarField& phi = *iter(); - - sigFpe::fillNan(phi.primitiveFieldRef()); - - continue; - } - - if (debug) - { - Pout<< "Mapping flux " << iter.key() - << " using interpolated flux " << UName - << endl; - } - - surfaceScalarField& phi = *iter(); - const surfaceScalarField phiU - ( - fvc::interpolate - ( - mesh().lookupObject(UName) - ) - & mesh().Sf() - ); - - // Recalculate new internal faces. - for (label facei = 0; facei < mesh().nInternalFaces(); facei++) - { - const label oldFacei = faceMap[facei]; - - if (oldFacei == -1) - { - // Inflated/appended - phi[facei] = phiU[facei]; - } - else if (reverseFaceMap[oldFacei] != facei) - { - // face-from-masterface - phi[facei] = phiU[facei]; - } - } - - // Recalculate new boundary faces. - surfaceScalarField::Boundary& phiBf = phi.boundaryFieldRef(); - - forAll(phiBf, patchi) - { - fvsPatchScalarField& patchPhi = phiBf[patchi]; - - const fvsPatchScalarField& patchPhiU = - phiU.boundaryField()[patchi]; - - label facei = patchPhi.patch().start(); - - forAll(patchPhi, i) - { - const label oldFacei = faceMap[facei]; - - if (oldFacei == -1) - { - // Inflated/appended - patchPhi[i] = patchPhiU[i]; - } - else if (reverseFaceMap[oldFacei] != facei) - { - // face-from-masterface - patchPhi[i] = patchPhiU[i]; - } - - facei++; - } - } - - // Update master faces - forAllConstIter(labelHashSet, masterFaces, iter) - { - const label facei = iter.key(); - - if (mesh().isInternalFace(facei)) - { - phi[facei] = phiU[facei]; - } - else - { - const label patchi = - mesh().boundaryMesh().whichPatch(facei); - - const label i = - facei - mesh().boundaryMesh()[patchi].start(); - - const fvsPatchScalarField& patchPhiU = - phiU.boundaryField()[patchi]; - - fvsPatchScalarField& patchPhi = phiBf[patchi]; - - patchPhi[i] = patchPhiU[i]; - } - } - } + refineFluxes(masterFaces, map()); + refineUfs(masterFaces, map()); } - // Update numbering of cells/vertices. - meshCutter_.updateMesh(map); + meshCutter_.updateMesh(map()); // Update numbering of protectedCells_ if (protectedCells_.size()) @@ -439,7 +310,7 @@ Foam::fvMeshTopoChangers::refiner::refine forAll(newProtectedCell, celli) { - label oldCelli = map().cellMap()[celli]; + const label oldCelli = map().cellMap()[celli]; newProtectedCell.set(celli, protectedCells_.get(oldCelli)); } protectedCells_.transfer(newProtectedCell); @@ -506,95 +377,11 @@ Foam::fvMeshTopoChangers::refiner::unrefine // Update fields mesh().updateMesh(map); - // Correct the flux for modified faces. - { - const labelList& reversePointMap = map().reversePointMap(); - const labelList& reverseFaceMap = map().reverseFaceMap(); - - HashTable fluxes - ( - mesh().lookupClass() - ); - forAllIter(HashTable, fluxes, iter) - { - if (!correctFluxes_.found(iter.key())) - { - WarningInFunction - << "Cannot find surfaceScalarField " << iter.key() - << " in user-provided flux mapping table " - << correctFluxes_ << endl - << " The flux mapping table is used to recreate the" - << " flux on newly created faces." << endl - << " Either add the entry if it is a flux or use (" - << iter.key() << " none) to suppress this warning." - << endl; - continue; - } - - const word& UName = correctFluxes_[iter.key()]; - - if (UName == "none") - { - continue; - } - - if (debug) - { - Info<< "Mapping flux " << iter.key() - << " using interpolated flux " << UName - << endl; - } - - surfaceScalarField& phi = *iter(); - surfaceScalarField::Boundary& phiBf = - phi.boundaryFieldRef(); - - const surfaceScalarField phiU - ( - fvc::interpolate - ( - mesh().lookupObject(UName) - ) - & mesh().Sf() - ); - - - forAllConstIter(Map