diff --git a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C index a6a6545e9f..0af332a336 100644 --- a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C +++ b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C @@ -186,7 +186,16 @@ void Foam::dynamicRefineFvMesh::readDict() ).subDict(typeName + "Coeffs") ); - correctFluxes_ = List >(refineDict.lookup("correctFluxes")); + List > fluxVelocities = List > + ( + refineDict.lookup("correctFluxes") + ); + // Rework into hashtable. + correctFluxes_.resize(fluxVelocities.size()); + forAll(fluxVelocities, i) + { + correctFluxes_.insert(fluxVelocities[i][0], fluxVelocities[i][1]); + } dumpLevel_ = Switch(refineDict.lookup("dumpLevel")); } @@ -289,23 +298,46 @@ Foam::dynamicRefineFvMesh::refine << " split faces " << endl; } - forAll(correctFluxes_, i) + HashTable fluxes + ( + lookupClass() + ); + forAllConstIter(HashTable, fluxes, iter) { + if (!correctFluxes_.found(iter.key())) + { + WarningIn("dynamicRefineFvMesh::refine(const labelList&)") + << "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 " << correctFluxes_[i][0] - << " using interpolated flux " << correctFluxes_[i][1] + Info<< "Mapping flux " << iter.key() + << " using interpolated flux " << UName << endl; } - surfaceScalarField& phi = const_cast - ( - lookupObject(correctFluxes_[i][0]) - ); + + surfaceScalarField& phi = const_cast(*iter()); const surfaceScalarField phiU ( fvc::interpolate ( - lookupObject(correctFluxes_[i][1]) + lookupObject(UName) ) & Sf() ); @@ -482,27 +514,51 @@ Foam::dynamicRefineFvMesh::unrefine const labelList& reversePointMap = map().reversePointMap(); const labelList& reverseFaceMap = map().reverseFaceMap(); - forAll(correctFluxes_, i) + HashTable fluxes + ( + lookupClass() + ); + forAllConstIter(HashTable, fluxes, iter) { + if (!correctFluxes_.found(iter.key())) + { + WarningIn("dynamicRefineFvMesh::refine(const labelList&)") + << "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 " << correctFluxes_[i][0] - << " using interpolated flux " << correctFluxes_[i][1] + Info<< "Mapping flux " << iter.key() + << " using interpolated flux " << UName << endl; } - surfaceScalarField& phi = const_cast - ( - lookupObject(correctFluxes_[i][0]) - ); - surfaceScalarField phiU + + surfaceScalarField& phi = const_cast(*iter()); + const surfaceScalarField phiU ( fvc::interpolate ( - lookupObject(correctFluxes_[i][1]) + lookupObject(UName) ) & Sf() ); + forAllConstIter(Map