mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: check of valid Ptr before using it
This commit is contained in:
@ -137,100 +137,103 @@ void Foam::interRegionHeatTransferModel::addSup
|
|||||||
const label fieldI
|
const label fieldI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (firstIter_)
|
if (secondaryToPrimaryInterpPtr_.valid())
|
||||||
{
|
{
|
||||||
check();
|
if (firstIter_)
|
||||||
firstIter_ = false;
|
{
|
||||||
}
|
check();
|
||||||
|
firstIter_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
const volScalarField& h = eEqn.psi();
|
const volScalarField& h = eEqn.psi();
|
||||||
|
|
||||||
tmp<volScalarField> tTmapped
|
tmp<volScalarField> tTmapped
|
||||||
(
|
|
||||||
new volScalarField
|
|
||||||
(
|
(
|
||||||
IOobject
|
new volScalarField
|
||||||
(
|
(
|
||||||
"Tmapped" + mesh_.name(),
|
IOobject
|
||||||
mesh_.time().timeName(),
|
(
|
||||||
|
"Tmapped" + mesh_.name(),
|
||||||
|
mesh_.time().timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
dimensionedScalar("T", dimTemperature, 0.0)
|
||||||
IOobject::NO_WRITE
|
)
|
||||||
),
|
);
|
||||||
mesh_,
|
|
||||||
dimensionedScalar("T", dimTemperature, 0.0)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
volScalarField& Tmapped = tTmapped();
|
volScalarField& Tmapped = tTmapped();
|
||||||
|
|
||||||
const fvMesh& secondaryMesh =
|
const fvMesh& secondaryMesh =
|
||||||
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
|
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
|
||||||
|
|
||||||
const volScalarField& Tsecondary =
|
const volScalarField& Tsecondary =
|
||||||
secondaryMesh.lookupObject<volScalarField>("T");
|
secondaryMesh.lookupObject<volScalarField>("T");
|
||||||
|
|
||||||
secondaryToPrimaryInterpPtr_->interpolateInternalField
|
|
||||||
(
|
|
||||||
Tmapped,
|
|
||||||
Tsecondary,
|
|
||||||
meshToMesh::MAP,
|
|
||||||
eqOp<scalar>()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!master_)
|
|
||||||
{
|
|
||||||
secondaryToPrimaryInterpPtr_->interpolateInternalField
|
secondaryToPrimaryInterpPtr_->interpolateInternalField
|
||||||
(
|
(
|
||||||
htc_,
|
Tmapped,
|
||||||
secIrht_->calculateHtc(),
|
Tsecondary,
|
||||||
meshToMesh::CELL_VOLUME_WEIGHT,
|
meshToMesh::MAP,
|
||||||
eqOp<scalar>()
|
eqOp<scalar>()
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (debug)
|
if (!master_)
|
||||||
{
|
{
|
||||||
Info<< " Volumetric integral of htc : "
|
secondaryToPrimaryInterpPtr_->interpolateInternalField
|
||||||
<< fvc::domainIntegrate(htc_).value()
|
(
|
||||||
<< endl;
|
htc_,
|
||||||
}
|
secIrht_->calculateHtc(),
|
||||||
|
meshToMesh::CELL_VOLUME_WEIGHT,
|
||||||
//SAF: temporarily output
|
eqOp<scalar>()
|
||||||
if (mesh_.time().outputTime())
|
);
|
||||||
{
|
}
|
||||||
Tmapped.write();
|
|
||||||
htc_.write();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (h.dimensions() == dimEnergy/dimMass)
|
|
||||||
{
|
|
||||||
const basicThermo& primaryThermo =
|
|
||||||
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
|
||||||
|
|
||||||
eEqn += htc_*Tmapped - fvm::Sp(htc_/primaryThermo.Cp(), h);
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< " Energy exchange from region " << secondaryMesh.name()
|
Info<< " Volumetric integral of htc : "
|
||||||
<< " To " << mesh_.name() << " : "
|
<< fvc::domainIntegrate(htc_).value()
|
||||||
<< fvc::domainIntegrate
|
|
||||||
(
|
|
||||||
htc_*(h/primaryThermo.Cp() - Tmapped)
|
|
||||||
).value()
|
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if(h.dimensions() == dimTemperature)
|
|
||||||
{
|
|
||||||
eEqn += htc_*Tmapped - fvm::Sp(htc_, h);
|
|
||||||
|
|
||||||
if (debug)
|
//SAF: temporarily output
|
||||||
|
if (mesh_.time().outputTime())
|
||||||
{
|
{
|
||||||
Info<< " Enegy exchange from region " << secondaryMesh.name()
|
Tmapped.write();
|
||||||
<< " To " << mesh_.name() << " : "
|
htc_.write();
|
||||||
<< fvc::domainIntegrate(htc_*(h - Tmapped)).value()
|
}
|
||||||
<< endl;
|
|
||||||
|
if (h.dimensions() == dimEnergy/dimMass)
|
||||||
|
{
|
||||||
|
const basicThermo& primaryThermo =
|
||||||
|
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
|
||||||
|
|
||||||
|
eEqn += htc_*Tmapped - fvm::Sp(htc_/primaryThermo.Cp(), h);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " Energy exchange from region " << secondaryMesh.name()
|
||||||
|
<< " To " << mesh_.name() << " : "
|
||||||
|
<< fvc::domainIntegrate
|
||||||
|
(
|
||||||
|
htc_*(h/primaryThermo.Cp() - Tmapped)
|
||||||
|
).value()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(h.dimensions() == dimTemperature)
|
||||||
|
{
|
||||||
|
eEqn += htc_*Tmapped - fvm::Sp(htc_, h);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " Enegy exchange from region " << secondaryMesh.name()
|
||||||
|
<< " To " << mesh_.name() << " : "
|
||||||
|
<< fvc::domainIntegrate(htc_*(h - Tmapped)).value()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user