mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Function object updates
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user