ENH: DESModelRegions function object - store result on mesh database

This commit is contained in:
andy
2013-09-19 15:15:34 +01:00
parent 1083de70a6
commit ec66f480c7

View File

@ -81,6 +81,30 @@ Foam::DESModelRegions::DESModelRegions
<< endl; << endl;
} }
if (active_)
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField* DESModelRegionsPtr
(
new volScalarField
(
IOobject
(
type(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimless, 0.0)
)
);
mesh.objectRegistry::store(DESModelRegionsPtr);
}
read(dict); read(dict);
} }
@ -139,7 +163,12 @@ void Foam::DESModelRegions::write()
Info<< type() << " " << name_ << " output:" << nl; Info<< type() << " " << name_ << " output:" << nl;
} }
tmp<volScalarField> tresult; volScalarField& DESModelRegions =
const_cast<volScalarField&>
(
mesh.lookupObject<volScalarField>(type())
);
label DESpresent = false; label DESpresent = false;
if (mesh.foundObject<icoModel>("turbulenceModel")) if (mesh.foundObject<icoModel>("turbulenceModel"))
@ -151,7 +180,7 @@ void Foam::DESModelRegions::write()
{ {
const icoDESModel& des = const icoDESModel& des =
dynamic_cast<const icoDESModel&>(model); dynamic_cast<const icoDESModel&>(model);
tresult = des.LESRegion(); DESModelRegions == des.LESRegion();
DESpresent = true; DESpresent = true;
} }
} }
@ -164,17 +193,16 @@ void Foam::DESModelRegions::write()
{ {
const cmpDESModel& des = const cmpDESModel& des =
dynamic_cast<const cmpDESModel&>(model); dynamic_cast<const cmpDESModel&>(model);
tresult = des.LESRegion(); DESModelRegions == des.LESRegion();
DESpresent = true; DESpresent = true;
} }
} }
if (DESpresent) if (DESpresent)
{ {
const volScalarField& result = tresult();
scalar prc = scalar prc =
gSum(result.internalField()*mesh.V())/gSum(mesh.V())*100.0; gSum(DESModelRegions.internalField()*mesh.V())
/gSum(mesh.V())*100.0;
if (Pstream::master()) if (Pstream::master())
{ {
@ -186,11 +214,11 @@ void Foam::DESModelRegions::write()
{ {
Info<< " LES = " << prc << " % (volume)" << nl Info<< " LES = " << prc << " % (volume)" << nl
<< " RAS = " << 100.0 - prc << " % (volume)" << nl << " RAS = " << 100.0 - prc << " % (volume)" << nl
<< " writing field " << result.name() << nl << " writing field " << DESModelRegions.name() << nl
<< endl; << endl;
} }
result.write(); DESModelRegions.write();
} }
else else
{ {