在src\overset\cellCellStencil\cellCellStencil.C中
Foam::autoPtr<Foam::cellCellStencil> Foam::cellCellStencil::New
(
const fvMesh& mesh,
const dictionary& dict,
const bool update
)
{
DebugInFunction << "Constructing cellCellStencil" << endl;
const word stencilType(dict.get<word>("method"));
auto cstrIter = meshConstructorTablePtr_->cfind(stencilType);
if (!cstrIter.found())
{
FatalIOErrorInLookup
(
dict,
"cellCellStencil",
stencilType,
*meshConstructorTablePtr_
) << exit(FatalIOError);
}
return autoPtr<cellCellStencil>(cstrIter()(mesh, dict, update));
}
这段代码读取了fvSchemes里oversetInterpolation里的method信息并且在最后构造了cellCellStencil对象。
在oversetSrc\cellCellStencil\inverseDistance.C中
Foam::cellCellStencils::inverseDistance::inverseDistance
(
const fvMesh& mesh,
const dictionary& dict,
const bool doUpdate
)
:
cellCellStencil(mesh),
dict_(dict),
smallVec_(Zero),
cellTypes_(labelList(mesh.nCells(), CALCULATED)),
interpolationCells_(0),
cellInterpolationMap_(),
cellStencil_(0),
cellInterpolationWeights_(0),
cellInterpolationWeight_
(
IOobject
(
"cellInterpolationWeight",
mesh_.facesInstance(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar(dimless, Zero),
zeroGradientFvPatchScalarField::typeName
)
{
// Protect local fields from interpolation
nonInterpolatedFields_.insert("cellInterpolationWeight");
nonInterpolatedFields_.insert("cellTypes");
nonInterpolatedFields_.insert("maxMagWeight");
// For convenience also suppress frequently used displacement field
nonInterpolatedFields_.insert("cellDisplacement");
nonInterpolatedFields_.insert("grad(cellDisplacement)");
const word w("snGradCorr(cellDisplacement)");
const word d("((viscosity*faceDiffusivity)*magSf)");
nonInterpolatedFields_.insert("surfaceIntegrate(("+d+"*"+w+"))");
// Read zoneID
this->zoneID();
// Read old-time cellTypes
IOobject io
(
"cellTypes",
mesh_.time().timeName(),
mesh_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
);
if (io.typeHeaderOk<volScalarField>(true))
{
if (debug)
{
Pout<< "Reading cellTypes from time " << mesh_.time().timeName()
<< endl;
}
const volScalarField volCellTypes(io, mesh_);
forAll(volCellTypes, celli)
{
// Round to integer
cellTypes_[celli] = volCellTypes[celli];
}
}
if (doUpdate)
{
update();
}
}
实现了inverseDistance这一子类的构造,并调用了update()
在oversetSrc\cellCellStencil\cellCellStencil\cellCellStencilObject.H中
// Constructors
//- Construct with mesh
explicit cellCellStencilObject
(
const fvMesh& mesh,
const bool update = true
)
:
MeshObject
<
fvMesh,
Foam::MoveableMeshObject,
cellCellStencilObject
>(mesh),
cellCellStencil(mesh),
stencilPtr_
(
cellCellStencil::New
(
mesh,
mesh.schemesDict().subDict
(
"oversetInterpolation"
),
update
)
)
{}
调用了cellCellStencil的New并指定了oversetInterpolation为dict
在oversetSrc\dynamicOversetFvMesh.C中
bool Foam::dynamicOversetFvMesh::update()
{
//if (dynamicMotionSolverFvMesh::update())
if (dynamicMotionSolverListFvMesh::update())
{
// Calculate the local extra faces for the interpolation. Note: could
// let demand-driven lduAddr() trigger it but just to make sure.
updateAddressing();
// Addressing and/or weights have changed. Make interpolated cells
// up to date with donors
interpolateFields();
return true;
}
return false;
}
以及
bool Foam::dynamicOversetFvMesh::updateAddressing() const
{
const cellCellStencilObject& overlap = Stencil::New(*this);
...
}
bool Foam::dynamicOversetFvMesh::interpolateFields()
{
// Add the stencil suppression list
wordHashSet suppressed(Stencil::New(*this).nonInterpolatedFields());
// Use whatever the solver has set up as suppression list
const dictionary* dictPtr
(
this->schemesDict().findDict("oversetInterpolationSuppressed")
);
if (dictPtr)
{
suppressed.insert(dictPtr->toc());
}
interpolate<volScalarField>(suppressed);
interpolate<volVectorField>(suppressed);
interpolate<volSphericalTensorField>(suppressed);
interpolate<volSymmTensorField>(suppressed);
interpolate<volTensorField>(suppressed);
return true;
}
在oversetSrc\cellCellStencil\inverseDistance\inverseDistanceCellCellStencil.C中transfer
// Check which acceptor has won and transfer
forAll(interpolationCells_, i)
{
if (!doneAcceptor[i])
{
label cellI = interpolationCells_[i];
const labelList& slots = cellStencil_[cellI];
if (slots.size() != 1)
{
FatalErrorInFunction << "Problem:" << slots
<< abort(FatalError);
}
label slotI = slots[0];
// Important: check if the stencil is actually for this cell
if (samples[slotI] == mesh_.cellCentres()[cellI])
{
cellStencil_[cellI].transfer(donorCellCells[slotI]);
cellInterpolationWeights_[cellI].transfer
(
donorWeights[slotI]
);
// Mark cell as being done so it does not get sent over
// again.
doneAcceptor.set(i);
}
}
}