Commit d433ed35 authored by Kilian Lackhove's avatar Kilian Lackhove

Enable timedependent file function type.

This adds a TIMEDEPENDENT argument to Function type File and enables the use of
a time depenmdent file name for boundary conditions, auxiliary fields etc.

The implementation relies on boost::format, where the given filename is
used as format string and the step time as argument. The full boost::format
syntax is supported. An error is thown when the corresponding file is not
found, so in order to only supply a new file every Nth timespep, one might
use appropriately named symlinks.


The function
<FUNCTION NAME="Baseflow">
    <F VAR="U0" TIMEDEPENDENT="1" FILE="U0_%14.8R.fld"/>

will look for files named U0_basegrid_1.00000000E-05.fld,
U0_basegrid_2.00000000E-05.fld and so on.
parent b51a7a20
......@@ -214,7 +214,21 @@ the field data is specified. The expansion order used to generate the .rst file
must be the same as that for the simulation. The filename must be specified
relative to the location of the .xml file.
Other examples of this input features can be the insertion of a forcing term,
With the additional argument \inltt{TIMEDEPENDENT="1"}, different files can be
loaded for each timestep. The filenames are defined using
\href{}{boost::format syntax}
where the step time is used as variable. For example, the function
\inltt{Baseflow} would load the files \inltt{U0V0\_1.00000000E-05.fld},
\inltt{U0V0\_2.00000000E-05.fld} and so on.
<FUNCTION NAME="Baseflow">
<F VAR="U0,V0" TIMEDEPENDENT="1"FILE="U0V0_%14.8R.fld"/>
Other examples of this input feature can be the insertion of a forcing term,
......@@ -2278,7 +2278,15 @@ namespace Nektar
// Files are denoted by F
else if (conditionType == "F")
funcDef.m_type = eFunctionTypeFile;
if (variable->Attribute("TIMEDEPENDENT") &&
funcDef.m_type = eFunctionTypeTransientFile;
funcDef.m_type = eFunctionTypeFile;
// File must have a FILE.
......@@ -87,7 +87,8 @@ namespace Nektar
const char* const FunctionTypeMap[] =
......@@ -52,6 +52,8 @@
#include <SolverUtils/Advection/Advection.h>
#include <SolverUtils/Diffusion/Diffusion.h>
#include <boost/format.hpp>
#include <iostream>
#include <string>
......@@ -771,7 +773,7 @@ namespace Nektar
else if (vType == LibUtilities::eFunctionTypeFile)
else if (vType == LibUtilities::eFunctionTypeFile || vType == LibUtilities::eFunctionTypeTransientFile)
std::string filename
= m_session->GetFunctionFilename(pFunctionName, pFieldName,domain);
......@@ -790,6 +792,18 @@ namespace Nektar
ElementGIDs[i] = m_fields[0]->GetExp(i)->GetGeom()->GetGlobalID();
if (vType == LibUtilities::eFunctionTypeTransientFile)
filename = boost::str(boost::format(filename) % m_time);
catch (...)
ASSERTL0(false, "Invalid Filename in function \""
+ pFunctionName + "\", variable \"" + pFieldName + "\"")
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