mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: dynamicRefineFvMesh: check all fluxes for interpolation
This commit is contained in:
@ -186,7 +186,16 @@ void Foam::dynamicRefineFvMesh::readDict()
|
|||||||
).subDict(typeName + "Coeffs")
|
).subDict(typeName + "Coeffs")
|
||||||
);
|
);
|
||||||
|
|
||||||
correctFluxes_ = List<Pair<word> >(refineDict.lookup("correctFluxes"));
|
List<Pair<word> > fluxVelocities = List<Pair<word> >
|
||||||
|
(
|
||||||
|
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"));
|
dumpLevel_ = Switch(refineDict.lookup("dumpLevel"));
|
||||||
}
|
}
|
||||||
@ -289,23 +298,46 @@ Foam::dynamicRefineFvMesh::refine
|
|||||||
<< " split faces " << endl;
|
<< " split faces " << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(correctFluxes_, i)
|
HashTable<const surfaceScalarField*> fluxes
|
||||||
|
(
|
||||||
|
lookupClass<surfaceScalarField>()
|
||||||
|
);
|
||||||
|
forAllConstIter(HashTable<const surfaceScalarField*>, 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)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Mapping flux " << correctFluxes_[i][0]
|
Info<< "Mapping flux " << iter.key()
|
||||||
<< " using interpolated flux " << correctFluxes_[i][1]
|
<< " using interpolated flux " << UName
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
surfaceScalarField& phi = const_cast<surfaceScalarField&>
|
|
||||||
(
|
surfaceScalarField& phi = const_cast<surfaceScalarField&>(*iter());
|
||||||
lookupObject<surfaceScalarField>(correctFluxes_[i][0])
|
|
||||||
);
|
|
||||||
const surfaceScalarField phiU
|
const surfaceScalarField phiU
|
||||||
(
|
(
|
||||||
fvc::interpolate
|
fvc::interpolate
|
||||||
(
|
(
|
||||||
lookupObject<volVectorField>(correctFluxes_[i][1])
|
lookupObject<volVectorField>(UName)
|
||||||
)
|
)
|
||||||
& Sf()
|
& Sf()
|
||||||
);
|
);
|
||||||
@ -482,27 +514,51 @@ Foam::dynamicRefineFvMesh::unrefine
|
|||||||
const labelList& reversePointMap = map().reversePointMap();
|
const labelList& reversePointMap = map().reversePointMap();
|
||||||
const labelList& reverseFaceMap = map().reverseFaceMap();
|
const labelList& reverseFaceMap = map().reverseFaceMap();
|
||||||
|
|
||||||
forAll(correctFluxes_, i)
|
HashTable<const surfaceScalarField*> fluxes
|
||||||
|
(
|
||||||
|
lookupClass<surfaceScalarField>()
|
||||||
|
);
|
||||||
|
forAllConstIter(HashTable<const surfaceScalarField*>, 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)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Mapping flux " << correctFluxes_[i][0]
|
Info<< "Mapping flux " << iter.key()
|
||||||
<< " using interpolated flux " << correctFluxes_[i][1]
|
<< " using interpolated flux " << UName
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
surfaceScalarField& phi = const_cast<surfaceScalarField&>
|
|
||||||
(
|
surfaceScalarField& phi = const_cast<surfaceScalarField&>(*iter());
|
||||||
lookupObject<surfaceScalarField>(correctFluxes_[i][0])
|
const surfaceScalarField phiU
|
||||||
);
|
|
||||||
surfaceScalarField phiU
|
|
||||||
(
|
(
|
||||||
fvc::interpolate
|
fvc::interpolate
|
||||||
(
|
(
|
||||||
lookupObject<volVectorField>(correctFluxes_[i][1])
|
lookupObject<volVectorField>(UName)
|
||||||
)
|
)
|
||||||
& Sf()
|
& Sf()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
forAllConstIter(Map<label>, faceToSplitPoint, iter)
|
forAllConstIter(Map<label>, faceToSplitPoint, iter)
|
||||||
{
|
{
|
||||||
label oldFaceI = iter.key();
|
label oldFaceI = iter.key();
|
||||||
|
|||||||
@ -64,7 +64,7 @@ protected:
|
|||||||
Switch dumpLevel_;
|
Switch dumpLevel_;
|
||||||
|
|
||||||
//- Fluxes to map
|
//- Fluxes to map
|
||||||
List<Pair<word> > correctFluxes_;
|
HashTable<word> correctFluxes_;
|
||||||
|
|
||||||
//- Number of refinement/unrefinement steps done so far.
|
//- Number of refinement/unrefinement steps done so far.
|
||||||
label nRefinementIterations_;
|
label nRefinementIterations_;
|
||||||
|
|||||||
@ -35,13 +35,14 @@ dynamicRefineFvMeshCoeffs
|
|||||||
// Stop refinement if maxCells reached
|
// Stop refinement if maxCells reached
|
||||||
maxCells 200000;
|
maxCells 200000;
|
||||||
// Flux field and corresponding velocity field. Fluxes on changed
|
// Flux field and corresponding velocity field. Fluxes on changed
|
||||||
// faces get recalculated by interpolating the velocity.
|
// faces get recalculated by interpolating the velocity. Use 'none'
|
||||||
|
// on surfaceScalarFields that do not need to be reinterpolated.
|
||||||
correctFluxes
|
correctFluxes
|
||||||
(
|
(
|
||||||
(
|
(phi U)
|
||||||
phi
|
(nHatf none)
|
||||||
U
|
(rho*phi none)
|
||||||
)
|
(ghf none)
|
||||||
);
|
);
|
||||||
// Write the refinement level as a volScalarField
|
// Write the refinement level as a volScalarField
|
||||||
dumpLevel true;
|
dumpLevel true;
|
||||||
|
|||||||
Reference in New Issue
Block a user