Commit 62c71f39 authored by hrchilds's avatar hrchilds

Add time periodicity to the Nek reader.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@19941 18c085ea-50e0-402c-830e-de6fd14e8384
parent c0f03983
......@@ -271,6 +271,9 @@ using std::vector;
// Hank Childs, Sun Oct 28 17:56:17 PDT 2012
// Add database options.
//
// Hank Childs, Fri Jan 4 14:33:11 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
avtNek5000FileFormat::avtNek5000FileFormat(const char *filename,
......@@ -287,6 +290,8 @@ avtNek5000FileFormat::avtNek5000FileFormat(const char *filename,
iNumOutputDirs = 0;
bParFormat = false;
curTimestep = 0;
numberOfTimePeriods = 1;
gapBetweenTimePeriods = 0.0;
readOptionToGetAllTimes = atts->GetBool("Read all times and cycles");
......@@ -358,6 +363,9 @@ avtNek5000FileFormat::avtNek5000FileFormat(const char *filename,
// Fix problem with uninitialized variable in the case where the path is
// fully specified.
//
// Hank Childs, Fri Jan 4 14:33:11 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
void
......@@ -451,6 +459,14 @@ avtNek5000FileFormat::ParseMetaDataFile(const char *filename)
if (iNumOutputDirs > 1)
bParFormat = true;
}
else if (STREQUAL("timeperiods:", tag.c_str())==0)
{
f >> numberOfTimePeriods;
}
else if (STREQUAL("gapBetweenTimePeriods:", tag.c_str())==0)
{
f >> gapBetweenTimePeriods;
}
else if (STREQUAL("NEK3D", tag.c_str()) != 0)
{
//This is an obsolete tag, ignore it.
......@@ -469,6 +485,17 @@ avtNek5000FileFormat::ParseMetaDataFile(const char *filename)
}
}
if (numberOfTimePeriods < 1)
{
EXCEPTION2(NonCompliantFileException, "Nek",
"The number of time periods must be 1 or more.");
}
if (numberOfTimePeriods > 1 && gapBetweenTimePeriods <= 0.0)
{
EXCEPTION2(NonCompliantFileException, "Nek",
"The gap between time periods must be non-zero.");
}
//Do a little consistency checking before moving on
if (fileTemplate == "")
{
......@@ -1046,11 +1073,19 @@ avtNek5000FileFormat::~avtNek5000FileFormat()
// Programmer: dbremer -- generated by xml2avt
// Creation: Fri May 18 16:07:09 PST 2007
//
// Modifications:
//
// Hank Childs, Fri Jan 4 15:14:04 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
int
avtNek5000FileFormat::GetNTimesteps(void)
{
if (numberOfTimePeriods > 1)
return iNumTimesteps*numberOfTimePeriods;
return iNumTimesteps;
}
......@@ -1566,11 +1601,19 @@ avtNek5000FileFormat::ReadPoints(int element, int timestep)
// Hank Childs, Thu Jan 8 10:58:15 CST 2009
// Fix a memory leak of non-cachable elements.
//
// Hank Childs, Fri Jan 4 15:34:47 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
vtkDataArray *
avtNek5000FileFormat::GetVar(int timestep, int domain, const char *varname)
{
if (numberOfTimePeriods > 1)
{
timestep = timestep % iNumTimesteps;
}
int t1 = visitTimer->StartTimer();
const int num_elements = myElementList.size();
......@@ -1806,11 +1849,19 @@ avtNek5000FileFormat::ReadVar(int timestate, int element, const char *varname)
// Hank Childs, Tue Jan 13 17:58:15 CST 2009
// Fix serious problems with this routine (must have been untested before).
//
// Hank Childs, Fri Jan 4 15:34:47 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
vtkDataArray *
avtNek5000FileFormat::GetVectorVar(int timestep, int domain, const char *varname)
{
if (numberOfTimePeriods > 1)
{
timestep = timestep % iNumTimesteps;
}
if (strcmp(varname, "velocity") != 0)
EXCEPTION1(InvalidVariableException, varname);
......@@ -2077,13 +2128,38 @@ avtNek5000FileFormat::GetCycles(vector<int> &outCycles)
// Programmer: Dave Bremer
// Creation: May 21, 2007
//
// Modifications:
//
// Hank Childs, Fri Jan 4 15:29:57 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
void
avtNek5000FileFormat::GetTimes(vector<double> &outTimes)
{
UpdateCyclesAndTimes();
outTimes = aTimes;
if (numberOfTimePeriods > 1)
{
int nTimes = aTimes.size();
outTimes.resize(nTimes*numberOfTimePeriods);
for (int i = 0 ; i < numberOfTimePeriods ; i++)
for (int j = 0 ; j < nTimes ; j++)
{
int index = i*nTimes+j;
if (i == 0)
outTimes[index] = aTimes[j];
else
{
if (j == 0)
outTimes[index] = outTimes[index-1] + gapBetweenTimePeriods;
else
outTimes[index] = outTimes[index-1] + (aTimes[j]-aTimes[j-1]);
}
}
}
else
outTimes = aTimes;
}
......@@ -2512,6 +2588,11 @@ avtNek5000FileFormat::FindAsciiDataStart(FILE *fd, int &outDataStart, int &outLi
// Programmer: Hank Childs
// Creation: January 5, 2009
//
// Modifications:
//
// Hank Childs, Fri Jan 4 15:34:47 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
void *
......@@ -2519,6 +2600,11 @@ avtNek5000FileFormat::GetAuxiliaryData(const char *var, int timestep,
int /*domain*/, const char *type, void *,
DestructorFunction &df)
{
if (numberOfTimePeriods > 1)
{
timestep = timestep % iNumTimesteps;
}
void *rv = NULL;
if (strcmp(type, AUXILIARY_DATA_SPATIAL_EXTENTS) == 0)
......@@ -3279,11 +3365,19 @@ avtNek5000FileFormat::CombineElementLists(
// Hank Childs, Thu Mar 1 08:18:55 PST 2012
// Fix memory leak with time varying meshes.
//
// Hank Childs, Fri Jan 4 15:34:47 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
void
avtNek5000FileFormat::ActivateTimestep(int ts)
{
if (numberOfTimePeriods > 1)
{
ts = ts % iNumTimesteps;
}
map<PointerKey, float *, KeyCompare>::iterator it;
map<PointerKey, float *, KeyCompare> new_cachedData;
for (it = cachedData.begin() ; it != cachedData.end() ; it++)
......
......@@ -133,6 +133,9 @@ class KeyCompare {
// Hank Childs, Sun Oct 28 17:56:17 PDT 2012
// Add attributes for reading all times, cycles.
//
// Hank Childs, Fri Jan 4 14:33:11 PST 2013
// Add support for time periodicity.
//
// ****************************************************************************
class avtNek5000FileFormat : public avtMTMDFileFormat
......@@ -178,6 +181,9 @@ class avtNek5000FileFormat : public avtMTMDFileFormat
int iNumOutputDirs; //used in parallel format
bool bParFormat;
int numberOfTimePeriods;
double gapBetweenTimePeriods;
// This info is embedded in, or derived from, the file header
bool bSwapEndian;
int iNumBlocks;
......
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