Commit a4cfc67f authored by mattijs's avatar mattijs
Browse files

allow on-the-fly construction for e.g. having hundreds of cutting planes

parent 79ffe067
......@@ -37,8 +37,43 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
dict_.readIfPresent("region", regionName_);
dict_.readIfPresent("dictionary", dictName_);
dict_.readIfPresent("enabled", enabled_);
dict_.readIfPresent("storeFilter", storeFilter_);
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
{
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::destroyFilter()
{
ptr_.reset();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -56,6 +91,7 @@ Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
regionName_(polyMesh::defaultRegion),
dictName_(),
enabled_(true),
storeFilter_(true),
outputControl_(t, dict)
{
readDict();
......@@ -83,32 +119,9 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::start()
{
readDict();
if (enabled_)
if (enabled_&&storeFilter_)
{
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
allocateFilter();
}
return true;
......@@ -120,12 +133,22 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::execute()
{
if (enabled_)
{
if (!storeFilter_)
{
allocateFilter();
}
ptr_->execute();
if (enabled_ && outputControl_.output())
{
ptr_->write();
}
if (!storeFilter_)
{
destroyFilter();
}
}
return true;
......@@ -137,12 +160,22 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::end()
{
if (enabled_)
{
if (!storeFilter_)
{
allocateFilter();
}
ptr_->end();
if (enabled_ && outputControl_.output())
{
ptr_->write();
}
if (!storeFilter_)
{
destroyFilter();
}
}
return true;
......
......@@ -78,6 +78,10 @@ class OutputFilterFunctionObject
//- Switch for the execution of the functionObject
bool enabled_;
//- Switch to store filter in between writes or use on-the-fly
// construction
bool storeFilter_;
//- Output controls
outputFilterOutputControl outputControl_;
......@@ -89,6 +93,12 @@ class OutputFilterFunctionObject
//- Read relevant dictionary entries
void readDict();
//- Creates most of the data associated with this object.
void allocateFilter();
//- Destroys most of the data associated with this object.
void destroyFilter();
//- Disallow default bitwise copy construct
OutputFilterFunctionObject(const OutputFilterFunctionObject&);
......
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