Time and functionObject updated for end()

- added end() method to functionObject, functionObjectList & associated classes
- moved outputFilters from src/sampling -> src/OpenFOAM/db/functionObjects
This commit is contained in:
Mark Olesen
2009-02-17 12:48:10 +01:00
parent c2256e51f3
commit fee6e312b9
35 changed files with 255 additions and 114 deletions

View File

@ -255,6 +255,15 @@ void Foam::fieldAverage::execute()
}
void Foam::fieldAverage::end()
{
if (active_)
{
calcAverages();
}
}
void Foam::fieldAverage::write()
{
if (active_)

View File

@ -41,7 +41,7 @@ Description
// averaging info if available
cleanRestart true;
// Fields to be probed. runTime modifiable!
// Fields to be averaged. runTime modifiable!
fields
(
U
@ -281,6 +281,9 @@ public:
//- Execute the averaging
virtual void execute();
//- Execute the averaging at the final time-loop
virtual void end();
//- Calculate the field average data and write
virtual void write();
};

View File

@ -76,14 +76,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem)
"(Foam::Ostream&, const Foam::fieldAverageItem&)"
);
os<< faItem.fieldName_ << nl;
os<< token::BEGIN_BLOCK << nl;
os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl;
os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl;
os.writeKeyword("prime2Mean") << faItem.mean_
<< token::END_STATEMENT << nl;
os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_]
<< token::END_STATEMENT << nl;
os<< token::END_BLOCK << nl;
<< token::END_STATEMENT << nl << token::END_BLOCK << nl;
os.check
(

View File

@ -163,6 +163,13 @@ void Foam::fieldMinMax::execute()
// Do nothing - only valid on write
}
void Foam::fieldMinMax::end()
{
// Do nothing - only valid on write
}
void Foam::fieldMinMax::write()
{
if (active_)

View File

@ -80,8 +80,8 @@ protected:
// Protected data
//- Name of this set of forces,
// Also used as the name of the probes directory.
//- Name of this set of field min/max.
// Also used as the name of the output directory.
word name_;
const objectRegistry& obr_;
@ -108,7 +108,7 @@ protected:
// Private Member Functions
//- If the forces file has not been created create it
//- If the output file has not been created create it
void makeFile();
//- Disallow default bitwise copy construct
@ -147,18 +147,21 @@ public:
// Member Functions
//- Return name of the set of forces
//- Return name of the set of field min/max
virtual const word& name() const
{
return name_;
}
//- Read the forces data
//- Read the field min/max data
virtual void read(const dictionary&);
//- Execute
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Calculate the field min/max
template<class Type>
void calcMinMaxFields(const word& fieldName);

View File

@ -104,6 +104,12 @@ void Foam::forceCoeffs::execute()
}
void Foam::forceCoeffs::end()
{
// Do nothing - only valid on write
}
void Foam::forceCoeffs::write()
{
if (active_)

View File

@ -126,9 +126,12 @@ public:
//- Read the forces data
virtual void read(const dictionary&);
//- Execute
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Write the forces
virtual void write();
};

View File

@ -273,6 +273,13 @@ void Foam::forces::execute()
// Do nothing - only valid on write
}
void Foam::forces::end()
{
// Do nothing - only valid on write
}
void Foam::forces::write()
{
if (active_)

View File

@ -200,9 +200,12 @@ public:
//- Read the forces data
virtual void read(const dictionary&);
//- Execute
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Write the forces
virtual void write();

View File

@ -41,15 +41,14 @@ namespace Foam
Foam::systemCall::systemCall
(
const word& name,
const objectRegistry& obr,
const objectRegistry&,
const dictionary& dict,
const bool loadFromFiles
const bool
)
:
name_(name),
obr_(obr),
active_(true),
executeCalls_(),
endCalls_(),
writeCalls_()
{
read(dict);
@ -66,8 +65,16 @@ Foam::systemCall::~systemCall()
void Foam::systemCall::read(const dictionary& dict)
{
dict.lookup("executeCalls") >> executeCalls_;
dict.lookup("writeCalls") >> writeCalls_;
dict.readIfPresent("executeCalls", executeCalls_);
dict.readIfPresent("endCalls", endCalls_);
dict.readIfPresent("writeCalls", writeCalls_);
if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
{
WarningIn("Foam::system::read(const dictionary&)")
<< "no executeCalls, endCalls or writeCalls defined."
<< endl;
}
}
@ -79,6 +86,16 @@ void Foam::systemCall::execute()
}
}
void Foam::systemCall::end()
{
forAll(endCalls_, callI)
{
::system(endCalls_[callI].c_str());
}
}
void Foam::systemCall::write()
{
forAll(writeCalls_, callI)

View File

@ -63,14 +63,12 @@ protected:
//- Name of this set of system calls
word name_;
const objectRegistry& obr_;
//- on/off switch
bool active_;
//- List of calls to execute - every step
stringList executeCalls_;
//- List of calls to execute when exiting the time-loop
stringList endCalls_;
//- List of calls to execute - write steps
stringList writeCalls_;
@ -97,9 +95,9 @@ public:
systemCall
(
const word& name,
const objectRegistry&,
const objectRegistry& unused,
const dictionary&,
const bool loadFromFiles = false
const bool loadFromFilesUnused = false
);
@ -119,10 +117,13 @@ public:
//- Read the system calls
virtual void read(const dictionary&);
//- Execute
//- Execute the "executeCalls" at each time-step
virtual void execute();
//- Write
//- Execute the "endCalls" at the final time-loop
virtual void end();
//- Write, execute the "writeCalls"
virtual void write();
//- Update for changes of mesh

View File

@ -58,7 +58,7 @@ Foam::dynamicPressure::dynamicPressure
name_(name),
obr_(obr),
active_(true),
pName_(dict.lookup("p")),
pName_(dict.lookupOrDefault<word>("p", "p")),
rho_(readScalar(dict.lookup("rho")))
{
// Check if the available mesh is an fvMesh, otherwise deactivate
@ -68,7 +68,7 @@ Foam::dynamicPressure::dynamicPressure
WarningIn
(
"dynamicPressure::dynamicPressure"
"(const objectRegistry& obr, const dictionary& dict)"
"(const objectRegistry&, const dictionary&)"
) << "No fvMesh available, deactivating." << nl
<< endl;
}
@ -81,7 +81,7 @@ Foam::dynamicPressure::dynamicPressure
WarningIn
(
"dynamicPressure::dynamicPressure"
"(const objectRegistry& obr, const dictionary& dict)"
"(const objectRegistry&, const dictionary&)"
) << "Pressure is not kinematic pressure, deactivating." << nl
<< endl;
}
@ -103,7 +103,7 @@ void Foam::dynamicPressure::read(const dictionary& dict)
{
if (active_)
{
dict.lookup("p") >> pName_;
dict.readIfPresent("p", pName_);
dict.lookup("rho") >> rho_;
}
}
@ -115,6 +115,12 @@ void Foam::dynamicPressure::execute()
}
void Foam::dynamicPressure::end()
{
// Do nothing - only valid on write
}
void Foam::dynamicPressure::write()
{
if (active_)

View File

@ -66,10 +66,10 @@ class dynamicPressure
//- on/off switch
bool active_;
//- Name of pressure field
//- Name of pressure field, default is "p"
word pName_;
//- Density
//- Density value
scalar rho_;
@ -120,9 +120,12 @@ public:
//- Read the dynamicPressure data
virtual void read(const dictionary&);
//- Execute
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Calculate the dynamicPressure and write
virtual void write();