Commit 7abd5470 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: improve robustness of outputFilterOutputControl

parent db07daf6
......@@ -33,25 +33,25 @@ Foam::NamedEnum<Enum, nEnum>::NamedEnum()
:
HashTable<int>(2*nEnum)
{
for (int i=0; i<nEnum; i++)
for (int enumI = 0; enumI < nEnum; ++enumI)
{
if (!names[i] || names[i][0] == '\0')
if (!names[enumI] || names[enumI][0] == '\0')
{
stringList goodNames(i);
stringList goodNames(enumI);
for (int j = 0; j < i; j++)
for (int i = 0; i < enumI; ++i)
{
goodNames[j] = names[j];
goodNames[i] = names[i];
}
FatalErrorIn("NamedEnum<Enum, nEnum>::NamedEnum()")
<< "Illegal enumeration name at position " << i << endl
<< "Illegal enumeration name at position " << enumI << endl
<< "after entries " << goodNames << ".\n"
<< "Possibly your NamedEnum<Enum, nEnum>::names array"
<< " is not of size " << nEnum << endl
<< abort(FatalError);
}
insert(names[i], i);
insert(names[enumI], enumI);
}
}
......@@ -61,7 +61,7 @@ Foam::NamedEnum<Enum, nEnum>::NamedEnum()
template<class Enum, int nEnum>
Enum Foam::NamedEnum<Enum, nEnum>::read(Istream& is) const
{
word name(is);
const word name(is);
HashTable<int>::const_iterator iter = find(name);
......@@ -71,7 +71,7 @@ Enum Foam::NamedEnum<Enum, nEnum>::read(Istream& is) const
(
"NamedEnum<Enum, nEnum>::read(Istream&) const", is
) << name << " is not in enumeration: "
<< toc() << exit(FatalIOError);
<< sortedToc() << exit(FatalIOError);
}
return Enum(iter());
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -68,17 +68,27 @@ Foam::outputFilterOutputControl::~outputFilterOutputControl()
void Foam::outputFilterOutputControl::read(const dictionary& dict)
{
outputControl_ = outputControlNames_.read(dict.lookup("outputControl"));
if (dict.found("outputControl"))
{
outputControl_ = outputControlNames_.read(dict.lookup("outputControl"));
}
else
{
outputControl_ = ocTimeStep;
}
switch (outputControl_)
{
case ocTimeStep:
{
dict.lookup("outputInterval") >> outputInterval_;
outputInterval_ = dict.lookupOrDefault<label>("outputInterval", 0);
break;
}
default:
{
// do nothing
break;
}
}
}
......@@ -97,17 +107,21 @@ bool Foam::outputFilterOutputControl::output() const
);
break;
}
case ocOutputTime:
{
return time_.outputTime();
break;
}
default:
{
// this error should not actually be possible
FatalErrorIn("bool Foam::outputFilterOutputControl::output()")
<< "Unknown output control: "
<< "Undefined output control: "
<< outputControlNames_[outputControl_] << nl
<< abort(FatalError);
break;
}
}
......
......@@ -25,6 +25,8 @@ Class
Foam::outputFilterOutputControl
Description
An output control for function objects.
The default is time-step execution at every interval.
SourceFiles
outputFilterOutputControl.C
......@@ -51,10 +53,11 @@ class outputFilterOutputControl
{
public:
//- The output control options
enum outputControls
{
ocTimeStep,
ocOutputTime
ocTimeStep, /*!< execution is coupled to the time-step */
ocOutputTime /*!< execution is coupled to the output-time */
};
......@@ -71,7 +74,7 @@ private:
//- Type of output
outputControls outputControl_;
//- The execution interval (in time steps) when using TIMESTEP mode
//- The execution interval (in time steps) when using @c timeStep mode,
// a value <= 1 means execute at every time step
label outputInterval_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment