ENH: Function object updates

This commit is contained in:
andy
2013-11-29 09:25:09 +00:00
parent d24bc269f2
commit 5126a6a49a
20 changed files with 415 additions and 322 deletions

View File

@ -335,7 +335,6 @@ void Foam::fieldAverage::write()
{
if (active_)
{
calcAverages();
writeAverages();
writeAveragingProperties();

View File

@ -96,7 +96,20 @@ void Foam::fieldCoordinateSystemTransform::read(const dictionary& dict)
void Foam::fieldCoordinateSystemTransform::execute()
{
// Do nothing
if (active_)
{
Info<< type() << " " << name_ << " output:" << nl;
forAll(fieldSet_, fieldI)
{
// If necessary load field
transform<scalar>(fieldSet_[fieldI]);
transform<vector>(fieldSet_[fieldI]);
transform<sphericalTensor>(fieldSet_[fieldI]);
transform<symmTensor>(fieldSet_[fieldI]);
transform<tensor>(fieldSet_[fieldI]);
}
}
}
@ -114,16 +127,23 @@ void Foam::fieldCoordinateSystemTransform::timeSet()
void Foam::fieldCoordinateSystemTransform::write()
{
if (active_)
{
Info<< type() << " " << name_ << " output:" << nl;
forAll(fieldSet_, fieldI)
{
// If necessary load field
transform<scalar>(fieldSet_[fieldI]);
transform<vector>(fieldSet_[fieldI]);
transform<sphericalTensor>(fieldSet_[fieldI]);
transform<symmTensor>(fieldSet_[fieldI]);
transform<tensor>(fieldSet_[fieldI]);
const word fieldName = fieldSet_[fieldI] + ":Transformed";
const regIOobject& field =
obr_.lookupObject<regIOobject>(fieldName);
Info<< " writing field " << field.name() << nl;
field.write();
}
Info<< endl;
}
}

View File

@ -37,7 +37,7 @@ void Foam::fieldCoordinateSystemTransform::transformField
const Type& field
) const
{
const word& fieldName = field.name() + "Transformed";
const word& fieldName = field.name() + ":Transformed";
if (!obr_.foundObject<Type>(fieldName))
{

View File

@ -328,32 +328,8 @@ void Foam::nearWallFields::execute()
{
Info<< "nearWallFields:execute()" << endl;
}
}
void Foam::nearWallFields::end()
{
if (debug)
{
Info<< "nearWallFields:end()" << endl;
}
}
void Foam::nearWallFields::timeSet()
{
// Do nothing
}
void Foam::nearWallFields::write()
{
if (debug)
{
Info<< "nearWallFields:write()" << endl;
}
// Do nothing
if (active_)
{
if
@ -380,7 +356,7 @@ void Foam::nearWallFields::write()
Info<< type() << " " << name_ << " output:" << nl;
Info<< " Writing sampled fields to " << obr_.time().timeName()
Info<< " Sampling fields fields to " << obr_.time().timeName()
<< endl;
sampleFields(vsf_);
@ -388,8 +364,37 @@ void Foam::nearWallFields::write()
sampleFields(vSpheretf_);
sampleFields(vSymmtf_);
sampleFields(vtf_);
}
}
void Foam::nearWallFields::end()
{
if (debug)
{
Info<< "nearWallFields:end()" << endl;
}
}
void Foam::nearWallFields::timeSet()
{
// Do nothing
}
void Foam::nearWallFields::write()
{
if (debug)
{
Info<< "nearWallFields:write()" << endl;
}
if (active_)
{
Info<< " Writing sampled fields to " << obr_.time().timeName()
<< endl;
// Write fields
forAll(vsf_, i)
{
vsf_[i].write();

View File

@ -53,6 +53,27 @@ Foam::processorField::processorField
if (isA<fvMesh>(obr_))
{
read(dict);
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField* procFieldPtr
(
new volScalarField
(
IOobject
(
"processorID",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimless, 0.0)
)
);
mesh.objectRegistry::store(procFieldPtr);
}
else
{
@ -88,7 +109,14 @@ void Foam::processorField::read(const dictionary& dict)
void Foam::processorField::execute()
{
// Do nothing
if (active_)
{
const volScalarField& procField =
obr_.lookupObject<volScalarField>("processorID");
const_cast<volScalarField&>(procField) ==
dimensionedScalar("procI", dimless, Pstream::myProcNo());
}
}
@ -108,20 +136,8 @@ void Foam::processorField::write()
{
if (active_)
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField procField
(
IOobject
(
"processorID",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("procI", dimless, Pstream::myProcNo())
);
const volScalarField& procField =
obr_.lookupObject<volScalarField>("processorID");
procField.write();
}

View File

@ -125,29 +125,16 @@ void Foam::calcFvcDiv::read(const dictionary& dict)
{
dict.lookup("fieldName") >> fieldName_;
dict.lookup("resultName") >> resultName_;
if (resultName_ == "none")
{
resultName_ = "fvc::div(" + fieldName_ + ")";
}
}
}
void Foam::calcFvcDiv::execute()
{
// Do nothing - only valid on write
}
void Foam::calcFvcDiv::end()
{
// Do nothing - only valid on write
}
void Foam::calcFvcDiv::timeSet()
{
// Do nothing - only valid on write
}
void Foam::calcFvcDiv::write()
{
if (active_)
{
@ -165,4 +152,34 @@ void Foam::calcFvcDiv::write()
}
void Foam::calcFvcDiv::end()
{
// Do nothing
}
void Foam::calcFvcDiv::timeSet()
{
// Do nothing
}
void Foam::calcFvcDiv::write()
{
if (active_)
{
if (obr_.foundObject<regIOobject>(resultName_))
{
const regIOobject& field =
obr_.lookupObject<regIOobject>(resultName_);
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << field.name() << nl << endl;
field.write();
}
}
}
// ************************************************************************* //

View File

@ -38,25 +38,14 @@ void Foam::calcFvcDiv::calcDiv
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
word divName = resultName;
if (divName == "none")
{
divName = "fvc::div(" + fieldName + ")";
}
if (mesh.foundObject<FieldType>(fieldName))
{
const FieldType& vf = mesh.lookupObject<FieldType>(fieldName);
volScalarField& field = divField(divName, vf.dimensions());
volScalarField& field = divField(resultName, vf.dimensions());
field = fvc::div(vf);
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << field.name() << nl << endl;
field.write();
processed = true;
}
}

View File

@ -87,29 +87,16 @@ void Foam::calcFvcGrad::read(const dictionary& dict)
{
dict.lookup("fieldName") >> fieldName_;
dict.lookup("resultName") >> resultName_;
if (resultName_ == "none")
{
resultName_ = "fvc::grad(" + fieldName_ + ")";
}
}
}
void Foam::calcFvcGrad::execute()
{
// Do nothing - only valid on write
}
void Foam::calcFvcGrad::end()
{
// Do nothing - only valid on write
}
void Foam::calcFvcGrad::timeSet()
{
// Do nothing - only valid on write
}
void Foam::calcFvcGrad::write()
{
if (active_)
{
@ -127,4 +114,34 @@ void Foam::calcFvcGrad::write()
}
void Foam::calcFvcGrad::end()
{
// Do nothing
}
void Foam::calcFvcGrad::timeSet()
{
// Do nothing
}
void Foam::calcFvcGrad::write()
{
if (active_)
{
if (obr_.foundObject<regIOobject>(resultName_))
{
const regIOobject& field =
obr_.lookupObject<regIOobject>(resultName_);
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << field.name() << nl << endl;
field.write();
}
}
}
// ************************************************************************* //

View File

@ -91,40 +91,25 @@ void Foam::calcFvcGrad::calcGrad
const fvMesh& mesh = refCast<const fvMesh>(obr_);
word gradName = resultName;
if (gradName == "none")
{
gradName = "fvc::grad(" + fieldName + ")";
}
if (mesh.foundObject<vfType>(fieldName))
{
const vfType& vf = mesh.lookupObject<vfType>(fieldName);
vfGradType& field = gradField<Type>(gradName, vf.dimensions());
vfGradType& field = gradField<Type>(resultName, vf.dimensions());
field = fvc::grad(vf);
Info<< type() << " output:" << nl
<< " writing " << field.name() << " field" << nl << endl;
field.write();
processed = true;
}
else if (mesh.foundObject<sfType>(fieldName))
{
const sfType& sf = mesh.lookupObject<sfType>(fieldName);
vfGradType& field = gradField<Type>(gradName, sf.dimensions());
vfGradType& field = gradField<Type>(resultName, sf.dimensions());
field = fvc::grad(sf);
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << field.name() << nl << endl;
field.write();
processed = true;
}
}

View File

@ -87,29 +87,16 @@ void Foam::calcMag::read(const dictionary& dict)
{
dict.lookup("fieldName") >> fieldName_;
dict.lookup("resultName") >> resultName_;
if (resultName_ == "none")
{
resultName_ = "mag(" + fieldName_ + ")";
}
}
}
void Foam::calcMag::execute()
{
// Do nothing - only valid on write
}
void Foam::calcMag::end()
{
// Do nothing - only valid on write
}
void Foam::calcMag::timeSet()
{
// Do nothing - only valid on write
}
void Foam::calcMag::write()
{
if (active_)
{
@ -130,4 +117,34 @@ void Foam::calcMag::write()
}
void Foam::calcMag::end()
{
// Do nothing
}
void Foam::calcMag::timeSet()
{
// Do nothing
}
void Foam::calcMag::write()
{
if (active_)
{
if (obr_.foundObject<regIOobject>(resultName_))
{
const regIOobject& field =
obr_.lookupObject<regIOobject>(resultName_);
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << field.name() << nl << endl;
field.write();
}
}
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -80,26 +80,15 @@ void Foam::calcMag::calc
const fvMesh& mesh = refCast<const fvMesh>(obr_);
word magName = resultName;
if (magName == "none")
{
magName = "mag(" + fieldName + ")";
}
if (mesh.foundObject<vfType>(fieldName))
{
const vfType& vf = mesh.lookupObject<vfType>(fieldName);
volScalarField& field =
magField<volScalarField>(magName, vf.dimensions());
magField<volScalarField>(resultName_, vf.dimensions());
field = mag(vf);
Info<< type() << " output:" << nl
<< " writing " << field.name() << " field" << nl << endl;
field.write();
processed = true;
}
else if (mesh.foundObject<sfType>(fieldName))
@ -107,15 +96,10 @@ void Foam::calcMag::calc
const sfType& sf = mesh.lookupObject<sfType>(fieldName);
surfaceScalarField& field =
magField<surfaceScalarField>(magName, sf.dimensions());
magField<surfaceScalarField>(resultName_, sf.dimensions());
field = mag(sf);
Info<< type() << " output:" << nl
<< " writing " << field.name() << " field" << nl << endl;
field.write();
processed = true;
}
}

View File

@ -154,24 +154,6 @@ void Foam::CourantNo::read(const dictionary& dict)
void Foam::CourantNo::execute()
{
// Do nothing - only valid on write
}
void Foam::CourantNo::end()
{
// Do nothing - only valid on write
}
void Foam::CourantNo::timeSet()
{
// Do nothing - only valid on write
}
void Foam::CourantNo::write()
{
if (active_)
{
@ -197,6 +179,28 @@ void Foam::CourantNo::write()
iField = 0.5*sumPhi/mesh.V().field()*mesh.time().deltaTValue();
CourantNo.correctBoundaryConditions();
}
}
void Foam::CourantNo::end()
{
// Do nothing
}
void Foam::CourantNo::timeSet()
{
// Do nothing
}
void Foam::CourantNo::write()
{
if (active_)
{
const volScalarField& CourantNo =
obr_.lookupObject<volScalarField>(type());
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << CourantNo.name() << nl

View File

@ -129,24 +129,6 @@ void Foam::DESModelRegions::read(const dictionary& dict)
void Foam::DESModelRegions::execute()
{
// Do nothing - only valid on write
}
void Foam::DESModelRegions::end()
{
// Do nothing - only valid on write
}
void Foam::DESModelRegions::timeSet()
{
// Do nothing - only valid on write
}
void Foam::DESModelRegions::write()
{
typedef incompressible::turbulenceModel icoModel;
typedef incompressible::DESModel icoDESModel;
@ -217,12 +199,8 @@ void Foam::DESModelRegions::write()
if (log_)
{
Info<< " LES = " << prc << " % (volume)" << nl
<< " RAS = " << 100.0 - prc << " % (volume)" << nl
<< " writing field " << DESModelRegions.name() << nl
<< endl;
<< " RAS = " << 100.0 - prc << " % (volume)" << endl;
}
DESModelRegions.write();
}
else
{
@ -236,4 +214,33 @@ void Foam::DESModelRegions::write()
}
void Foam::DESModelRegions::end()
{
// Do nothing
}
void Foam::DESModelRegions::timeSet()
{
// Do nothing
}
void Foam::DESModelRegions::write()
{
if (log_)
{
const volScalarField& DESModelRegions =
obr_.lookupObject<volScalarField>(type());
Info<< type() << " " << name_ << " output:" << nl;
<< " writing field " << DESModelRegions.name() << nl
<< endl;
DESModelRegions.write();
}
}
// ************************************************************************* //

View File

@ -115,24 +115,6 @@ void Foam::Lambda2::read(const dictionary& dict)
void Foam::Lambda2::execute()
{
// Do nothing - only valid on write
}
void Foam::Lambda2::end()
{
// Do nothing - only valid on write
}
void Foam::Lambda2::timeSet()
{
// Do nothing - only valid on write
}
void Foam::Lambda2::write()
{
if (active_)
{
@ -156,6 +138,28 @@ void Foam::Lambda2::write()
);
Lambda2 = -eigenValues(SSplusWW)().component(vector::Y);
}
}
void Foam::Lambda2::end()
{
// Do nothing
}
void Foam::Lambda2::timeSet()
{
// Do nothing
}
void Foam::Lambda2::write()
{
if (active_)
{
const volScalarField& Lambda2 =
obr_.lookupObject<volScalarField>(type())
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << Lambda2.name() << nl

View File

@ -119,23 +119,6 @@ void Foam::Peclet::read(const dictionary& dict)
void Foam::Peclet::execute()
{
// Do nothing - only valid on write
}
void Foam::Peclet::end()
{
// Do nothing - only valid on write
}
void Foam::Peclet::timeSet()
{
// Do nothing - only valid on write
}
void Foam::Peclet::write()
{
typedef compressible::turbulenceModel cmpTurbModel;
typedef incompressible::turbulenceModel icoTurbModel;
@ -208,6 +191,27 @@ void Foam::Peclet::write()
*mesh.surfaceInterpolation::deltaCoeffs()
*fvc::interpolate(nuEff)
);
}
}
void Foam::Peclet::end()
{
// Do nothing - only valid on write
}
void Foam::Peclet::timeSet()
{
// Do nothing - only valid on write
}
void Foam::Peclet::write()
{
if (active_)
{
const surfaceScalarField& Peclet =
mesh.lookupObject<surfaceScalarField>(type());
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << Peclet.name() << nl

View File

@ -114,24 +114,6 @@ void Foam::Q::read(const dictionary& dict)
void Foam::Q::execute()
{
// Do nothing - only valid on write
}
void Foam::Q::end()
{
// Do nothing - only valid on write
}
void Foam::Q::timeSet()
{
// Do nothing - only valid on write
}
void Foam::Q::write()
{
if (active_)
{
@ -149,6 +131,28 @@ void Foam::Q::write()
);
Q = 0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU))));
}
}
void Foam::Q::end()
{
// Do nothing
}
void Foam::Q::timeSet()
{
// Do nothing
}
void Foam::Q::write()
{
if (active_)
{
const volScalarField& Q =
mesh.lookupObject<volScalarField>(type())
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << Q.name() << nl

View File

@ -291,24 +291,6 @@ void Foam::pressureTools::read(const dictionary& dict)
void Foam::pressureTools::execute()
{
// Do nothing - only valid on write
}
void Foam::pressureTools::end()
{
// Do nothing - only valid on write
}
void Foam::pressureTools::timeSet()
{
// Do nothing - only valid on write
}
void Foam::pressureTools::write()
{
if (active_)
{
@ -321,6 +303,28 @@ void Foam::pressureTools::write()
);
pResult == convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef());
}
}
void Foam::pressureTools::end()
{
// Do nothing
}
void Foam::pressureTools::timeSet()
{
// Do nothing
}
void Foam::pressureTools::write()
{
if (active_)
{
const volScalarField& pResult =
obr_.lookupObject<volScalarField>(pName())
Info<< type() << " " << name_ << " output:" << nl
<< " writing field " << pResult.name() << nl

View File

@ -224,24 +224,6 @@ void Foam::wallShearStress::read(const dictionary& dict)
void Foam::wallShearStress::execute()
{
// Do nothing - only valid on write
}
void Foam::wallShearStress::end()
{
// Do nothing - only valid on write
}
void Foam::wallShearStress::timeSet()
{
// Do nothing - only valid on write
}
void Foam::wallShearStress::write()
{
typedef compressible::turbulenceModel cmpModel;
typedef incompressible::turbulenceModel icoModel;
@ -286,8 +268,31 @@ void Foam::wallShearStress::write()
<< "database" << exit(FatalError);
}
calcShearStress(mesh, Reff(), wallShearStress);
}
}
void Foam::wallShearStress::end()
{
// Do nothing
}
void Foam::wallShearStress::timeSet()
{
// Do nothing
}
void Foam::wallShearStress::write()
{
if (active_)
{
functionObjectFile::write();
const volVectorField& wallShearStress =
obr_.lookupObject<volVectorField>(type());
if (log_)
{

View File

@ -268,24 +268,6 @@ void Foam::yPlusLES::read(const dictionary& dict)
void Foam::yPlusLES::execute()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::end()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::timeSet()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::write()
{
if (active_)
{
@ -317,6 +299,30 @@ void Foam::yPlusLES::write()
{
calcIncompressibleYPlus(mesh, U, yPlusLES);
}
}
}
void Foam::yPlusLES::end()
{
// Do nothing
}
void Foam::yPlusLES::timeSet()
{
// Do nothing
}
void Foam::yPlusLES::write()
{
if (active_)
{
functionObjectFile::write();
const volScalarField& yPlusLES =
obr_.lookupObject<volScalarField>(type())
if (log_)
{

View File

@ -255,24 +255,6 @@ void Foam::yPlusRAS::read(const dictionary& dict)
void Foam::yPlusRAS::execute()
{
// Do nothing - only valid on write
}
void Foam::yPlusRAS::end()
{
// Do nothing - only valid on write
}
void Foam::yPlusRAS::timeSet()
{
// Do nothing - only valid on write
}
void Foam::yPlusRAS::write()
{
if (active_)
{
@ -302,6 +284,30 @@ void Foam::yPlusRAS::write()
{
calcIncompressibleYPlus(mesh, yPlusRAS);
}
}
}
void Foam::yPlusRAS::end()
{
// Do nothing
}
void Foam::yPlusRAS::timeSet()
{
// Do nothing
}
void Foam::yPlusRAS::write()
{
if (active_)
{
functionObjectFile::write();
const volScalarField& yPlusRAS =
mesh.lookupObject<volScalarField>(type())
if (log_)
{