Commit 5177a15a authored by js9's avatar js9
Browse files

allowing MTMD files to be grouped into longer sequences



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@9706 18c085ea-50e0-402c-830e-de6fd14e8384
parent 29febcc0
......@@ -66,11 +66,17 @@ using std::vector;
// Programmer: Hank Childs
// Creation: April 4, 2003
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
avtMTMDFileFormatInterface::avtMTMDFileFormatInterface(avtMTMDFileFormat *f)
avtMTMDFileFormatInterface::avtMTMDFileFormatInterface(avtMTMDFileFormat **lst,
int ntsgroups)
{
format = f;
chunks = lst;
nTimestepGroups = ntsgroups;
}
......@@ -80,13 +86,25 @@ avtMTMDFileFormatInterface::avtMTMDFileFormatInterface(avtMTMDFileFormat *f)
// Programmer: Hank Childs
// Creation: April 4, 2003
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
avtMTMDFileFormatInterface::~avtMTMDFileFormatInterface()
{
if (format != NULL)
if (chunks != NULL)
{
delete format;
for (int i=0; i<nTimestepGroups; i++)
{
if (chunks[i] != NULL)
{
delete chunks[i];
chunks[i] = NULL;
}
}
delete[] chunks;
}
}
......@@ -107,12 +125,18 @@ avtMTMDFileFormatInterface::~avtMTMDFileFormatInterface()
// Progrmamer: Hank Childs
// Creation: April 4, 2003
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
vtkDataSet *
avtMTMDFileFormatInterface::GetMesh(int ts, int dom, const char *mesh)
{
return format->GetMesh(ts, dom, mesh);
int tsGroup = GetTimestepGroupForTimestep(ts);
int localTS = GetTimestepWithinGroup(ts);
return chunks[tsGroup]->GetMesh(localTS, dom, mesh);
}
......@@ -132,12 +156,18 @@ avtMTMDFileFormatInterface::GetMesh(int ts, int dom, const char *mesh)
// Progrmamer: Hank Childs
// Creation: April 4, 2003
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
vtkDataArray *
avtMTMDFileFormatInterface::GetVar(int ts, int dom, const char *var)
{
return format->GetVar(ts, dom, var);
int tsGroup = GetTimestepGroupForTimestep(ts);
int localTS = GetTimestepWithinGroup(ts);
return chunks[tsGroup]->GetVar(localTS, dom, var);
}
......@@ -157,12 +187,18 @@ avtMTMDFileFormatInterface::GetVar(int ts, int dom, const char *var)
// Progrmamer: Hank Childs
// Creation: April 4, 2003
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
vtkDataArray *
avtMTMDFileFormatInterface::GetVectorVar(int ts, int dom, const char *var)
{
return format->GetVectorVar(ts, dom, var);
int tsGroup = GetTimestepGroupForTimestep(ts);
int localTS = GetTimestepWithinGroup(ts);
return chunks[tsGroup]->GetVectorVar(localTS, dom, var);
}
......@@ -189,13 +225,18 @@ avtMTMDFileFormatInterface::GetVectorVar(int ts, int dom, const char *var)
// Dave Bremer, Wed Apr 23 14:55:31 PDT 2008
// Allow metadata requests for information about all domains to go through.
//
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
void *
avtMTMDFileFormatInterface::GetAuxiliaryData(const char *var, int ts, int dom,
const char *type, void *args, DestructorFunction &df)
{
return format->GetAuxiliaryData(var, ts, dom, type, args, df);
int tsGroup = GetTimestepGroupForTimestep(ts);
int localTS = GetTimestepWithinGroup(ts);
return chunks[tsGroup]->GetAuxiliaryData(var, localTS, dom, type, args, df);
}
......@@ -206,17 +247,22 @@ avtMTMDFileFormatInterface::GetAuxiliaryData(const char *var, int ts, int dom,
// Gets the name of the file we are using.
//
// Arguments:
// <unused> The timestep (does not really apply to this interface).
// ts The timestep
//
// Programmer: Hank Childs
// Creation: March 12, 2002
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
const char *
avtMTMDFileFormatInterface::GetFilename(int)
avtMTMDFileFormatInterface::GetFilename(int ts)
{
return format->GetFilename();
int tsGroup = GetTimestepGroupForTimestep(ts);
return chunks[tsGroup]->GetFilename();
}
......@@ -245,6 +291,9 @@ avtMTMDFileFormatInterface::GetFilename(int)
// Mark C. Miller, Tue May 31 20:12:42 PDT 2005
// Replaced -INT_MAX & -DBL_MAX with INVALID_CYCLE and INVALID_TIME
//
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
void
......@@ -253,35 +302,43 @@ avtMTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
{
int i, j;
GenerateTimestepCounts();
//
// Throw an exception if an invalid time state was requested.
//
int nTimesteps = format->GetNTimesteps();
if (timeState < 0 || timeState >= nTimesteps)
if (timeState < 0 || timeState >= nTotalTimesteps)
{
EXCEPTION2(BadIndexException, timeState, nTimesteps);
EXCEPTION2(BadIndexException, timeState, nTotalTimesteps);
}
//
// We know for sure that the number of states is the number of timesteps.
//
md->SetNumStates(nTimesteps);
md->SetNumStates(nTotalTimesteps);
//
// Let the format plugin populate as much of database metadata as it can,
// first. It migth actually set cycles/times too.
//
format->SetDatabaseMetaData(md, timeState);
int tsGroup = GetTimestepGroupForTimestep(timeState);
int localTS = GetTimestepWithinGroup(timeState);
chunks[tsGroup]->SetDatabaseMetaData(md, localTS);
if (md->AreAllCyclesAccurateAndValid(nTimesteps) != true)
//
// Note: In an MTXX format, a single file has multiple time steps in it
// So, we don't have the same kinds of semantics we do with STXX databases
// in, for example, trying to guess cycle numbers from file names
//
if (md->AreAllCyclesAccurateAndValid(nTotalTimesteps) != true)
{
//
// Note: In an MTXX format, a single file has multiple time steps in it
// So, we don't have the same kinds of semantics we do with STXX databases
// in, for example, trying to guess cycle numbers from file names
//
vector<int> cycles;
format->FormatGetCycles(cycles);
for (i=0; i<nTimestepGroups; i++)
{
vector<int> tmp;
chunks[i]->FormatGetCycles(tmp);
cycles.insert(cycles.end(),tmp.begin(),tmp.end());
}
bool cyclesLookGood = true;
for (i = 0; i < cycles.size(); i++)
{
......@@ -291,14 +348,16 @@ avtMTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
break;
}
}
if (cycles.size() != nTimesteps)
if (cycles.size() != nTotalTimesteps)
cyclesLookGood = false;
if (cyclesLookGood == false)
{
cycles.clear();
for (i = 0; i < nTimesteps; i++)
for (i = 0; i < nTotalTimesteps; i++)
{
int c = format->FormatGetCycle(i);
int tsg = GetTimestepGroupForTimestep(i);
int lts = GetTimestepWithinGroup(i);
int c = chunks[tsg]->FormatGetCycle(lts);
cycles.push_back(c);
......@@ -322,7 +381,7 @@ avtMTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
else
{
cycles.clear();
for (j = 0 ; j < nTimesteps ; j++)
for (j = 0 ; j < nTotalTimesteps ; j++)
{
cycles.push_back(j);
}
......@@ -331,11 +390,16 @@ avtMTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
}
}
if (md->AreAllTimesAccurateAndValid(nTimesteps) != true)
if (md->AreAllTimesAccurateAndValid(nTotalTimesteps) != true)
{
// Set the times in the metadata.
vector<double> times;
format->FormatGetTimes(times);
for (i=0; i<nTimestepGroups; i++)
{
vector<double> tmp;
chunks[i]->FormatGetTimes(tmp);
times.insert(times.end(),tmp.begin(),tmp.end());
}
bool timesLookGood = true;
for (i = 0; i < times.size(); i++)
{
......@@ -345,19 +409,21 @@ avtMTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
break;
}
}
if (times.size() != nTimesteps)
if (times.size() != nTotalTimesteps)
timesLookGood = false;
if (timesLookGood == false)
{
times.clear();
for (i = 0; i < nTimesteps; i++)
for (i = 0; i < nTotalTimesteps; i++)
{
double t = format->FormatGetTime(i);
int tsg = GetTimestepGroupForTimestep(i);
int lts = GetTimestepWithinGroup(i);
double t = chunks[tsg]->FormatGetTime(lts);
times.push_back(t);
if ((t == avtFileFormat::INVALID_TIME) ||
((i != 0) && (times[i] <= times[i-1])))
((i != 0) && (times[i] <= times[i-1])))
{
timesLookGood = false;
break;
......@@ -377,7 +443,7 @@ avtMTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
else
{
times.clear();
for (j = 0 ; j < nTimesteps ; j++)
for (j = 0 ; j < nTotalTimesteps ; j++)
{
times.push_back((double)j);
}
......@@ -397,27 +463,35 @@ avtMTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
// Programmer: Mark C. Miller
// Creation: May 31, 2005
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
void
avtMTMDFileFormatInterface::SetCycleTimeInDatabaseMetaData(
avtDatabaseMetaData *md, int timeState)
{
int i;
GenerateTimestepCounts();
//
// Throw an exception if an invalid time state was requested.
//
int nTimesteps = format->GetNTimesteps();
if (timeState < 0 || timeState >= nTimesteps)
if (timeState < 0 || timeState >= nTotalTimesteps)
{
EXCEPTION2(BadIndexException, timeState, nTimesteps);
EXCEPTION2(BadIndexException, timeState, nTotalTimesteps);
}
vector<int> cycles;
format->FormatGetCycles(cycles);
for (int i=0; i<nTimestepGroups; i++)
{
vector<int> tmp;
chunks[i]->FormatGetCycles(tmp);
cycles.insert(cycles.end(),tmp.begin(),tmp.end());
}
bool cyclesLookGood = true;
for (i = 0; i < cycles.size(); i++)
for (int i = 0; i < cycles.size(); i++)
{
if ((i != 0) && (cycles[i] <= cycles[i-1]))
{
......@@ -425,11 +499,13 @@ avtMTMDFileFormatInterface::SetCycleTimeInDatabaseMetaData(
break;
}
}
if (cycles.size() != nTimesteps)
if (cycles.size() != nTotalTimesteps)
cyclesLookGood = false;
if (cyclesLookGood == false)
{
int c = format->FormatGetCycle(timeState);
int tsg = GetTimestepGroupForTimestep(timeState);
int lts = GetTimestepWithinGroup(timeState);
int c = chunks[tsg]->FormatGetCycle(lts);
if (c != avtFileFormat::INVALID_CYCLE)
{
md->SetCycle(timeState, c);
......@@ -443,9 +519,14 @@ avtMTMDFileFormatInterface::SetCycleTimeInDatabaseMetaData(
}
vector<double> times;
format->FormatGetTimes(times);
for (int i=0; i<nTimestepGroups; i++)
{
vector<double> tmp;
chunks[i]->FormatGetTimes(tmp);
times.insert(times.end(),tmp.begin(),tmp.end());
}
bool timesLookGood = true;
for (i = 0; i < times.size(); i++)
for (int i = 0; i < times.size(); i++)
{
if ((i != 0) && (times[i] <= times[i-1]))
{
......@@ -453,11 +534,13 @@ avtMTMDFileFormatInterface::SetCycleTimeInDatabaseMetaData(
break;
}
}
if (times.size() != nTimesteps)
if (times.size() != nTotalTimesteps)
timesLookGood = false;
if (timesLookGood == false)
{
double t = format->FormatGetTime(timeState);
int tsg = GetTimestepGroupForTimestep(timeState);
int lts = GetTimestepWithinGroup(timeState);
double t = chunks[tsg]->FormatGetTime(lts);
if (t != avtFileFormat::INVALID_TIME)
{
md->SetTime(timeState, t);
......@@ -481,12 +564,19 @@ avtMTMDFileFormatInterface::SetCycleTimeInDatabaseMetaData(
// Programmer: Hank Childs
// Creation: April 4, 2003
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
void
avtMTMDFileFormatInterface::FreeUpResources(int, int)
{
format->FreeUpResources();
for (int i = 0 ; i < nTimestepGroups ; i++)
{
chunks[i]->FreeUpResources();
}
}
// ****************************************************************************
......@@ -499,12 +589,20 @@ avtMTMDFileFormatInterface::FreeUpResources(int, int)
// Programmer: Mark C. Miller
// Creation: February 23, 2004
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
void
avtMTMDFileFormatInterface::ActivateTimestep(int ts)
{
format->ActivateTimestep(ts);
GenerateTimestepCounts();
int tsGroup = GetTimestepGroupForTimestep(ts);
int localTS = GetTimestepWithinGroup(ts);
chunks[tsGroup]->ActivateTimestep(localTS);
}
// ****************************************************************************
......@@ -515,10 +613,101 @@ avtMTMDFileFormatInterface::ActivateTimestep(int ts)
// Programmer: Mark C. Miller
// Creation: March 16, 2004
//
// Modifications:
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
void
avtMTMDFileFormatInterface::PopulateIOInformation(int ts, avtIOInformation& ioInfo)
{
format->PopulateIOInformation(ts, ioInfo);
int tsGroup = GetTimestepGroupForTimestep(ts);
int localTS = GetTimestepWithinGroup(ts);
chunks[tsGroup]->PopulateIOInformation(localTS, ioInfo);
}
// ****************************************************************************
// Method: avtMTMDFileFormatInterface::GetTimestepGroupForTimestep
//
// Purpose:
// Find the timestep group containing the given timestep.
//
// Arguments:
// ts the timestep
//
// Programmer: Jeremy Meredith
// Creation: January 28, 2010
//
// ****************************************************************************
int
avtMTMDFileFormatInterface::GetTimestepGroupForTimestep(int ts)
{
int group = 0;
while (group < tsPerGroup.size() &&
tsPerGroup[group] <= ts)
{
ts -= tsPerGroup[group];
++group;
}
if (group >= tsPerGroup.size())
{
EXCEPTION2(BadIndexException, group, tsPerGroup.size());
}
return group;
}
// ****************************************************************************
// Method: avtMTMDFileFormatInterface::GetTimestepWithinGroup
//
// Purpose:
// Find the "local timestep", i.e. the index within the timestep-group
// containing the given timestep.
//
// Arguments:
// ts the timestep
//
// Programmer: Jeremy Meredith
// Creation: January 28, 2010
//
// ****************************************************************************
int
avtMTMDFileFormatInterface::GetTimestepWithinGroup(int ts)
{
int group = GetTimestepGroupForTimestep(ts);
int base = 0;
for (int i=0; i<group; i++)
base += tsPerGroup[i];
return ts - base;
}
// ****************************************************************************
// Method: avtMTMDFileFormatInterface::GenerateTimestepCounts
//
// Purpose:
// Generate the local information used to map local<->global time steps.
//
// Arguments:
// none
//
// Programmer: Jeremy Meredith
// Creation: January 28, 2010
//
// ****************************************************************************
void
avtMTMDFileFormatInterface::GenerateTimestepCounts()
{
//
// Count up the time steps from each timestep group
//
tsPerGroup.clear();
nTotalTimesteps = 0;
for (int i=0; i<nTimestepGroups; i++)
{
int n = chunks[i]->GetNTimesteps();
tsPerGroup.push_back(n);
nTotalTimesteps += n;
}
}
......@@ -75,12 +75,17 @@ class avtIOInformation;
//
// Mark C. Miller, Tue May 31 20:12:42 PDT 2005
// Added method SetCycleTimeInDatabaseMetaData
//
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010
// MTMD files can now be grouped into longer sequences.
//
// ****************************************************************************
class DATABASE_API avtMTMDFileFormatInterface : public avtFileFormatInterface
{
public:
avtMTMDFileFormatInterface(avtMTMDFileFormat *);
avtMTMDFileFormatInterface(avtMTMDFileFormat **,
int ntsgroups);
virtual ~avtMTMDFileFormatInterface();
virtual vtkDataSet *GetMesh(int, int, const char *);
......@@ -103,11 +108,18 @@ class DATABASE_API avtMTMDFileFormatInterface : public avtFileFormatInterface
virtual void PopulateIOInformation(int ts, avtIOInformation& ioInfo);
protected:
avtMTMDFileFormat *format;
int nTimestepGroups;
std::vector<int> tsPerGroup;
int nTotalTimesteps;
avtMTMDFileFormat **chunks;
virtual int GetNumberOfFileFormats(void)
{ return 1; };
virtual avtFileFormat *GetFormat(int n) const { return format; };
{ return nTimestepGroups; };
virtual avtFileFormat *GetFormat(int n) const { return chunks[n]; };
void GenerateTimestepCounts();
int GetTimestepGroupForTimestep(int ts);
int GetTimestepWithinGroup(int ts);
};
......
......@@ -354,7 +354,7 @@ avtMTSDFileFormatInterface::GetAuxiliaryData(const char *var, int ts, int dom,
// Gets the name of the file we are using.
//
// Arguments:
// <unused> The timestep (does not really apply to this interface).
// ts The timestep
//
// Programmer: Hank Childs
// Creation: March 12, 2002
......
......@@ -78,7 +78,14 @@ avtDatabase *
ADIOSCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
{
return new avtGenericDatabase(
new avtMTMDFileFormatInterface(
new avtADIOSFileFormat(list[0])));
// ignore any nBlocks past 1
int nTimestepGroups = nList / nBlock;
avtMTMDFileFormat **ffl = new avtMTMDFileFormat*[nTimestepGroups];
for (int i = 0 ; i < nTimestepGroups ; i++)
{
ffl[i] = new avtADIOSFileFormat(list[i*nBlock]);
}
avtMTMDFileFormatInterface *inter
= new avtMTMDFileFormatInterface(ffl, nTimestepGroups);
return new avtGenericDatabase(inter);
}
......@@ -23,13 +23,23 @@ Definition:
// Pass the common info to the file format constructor since we're using
// the common info to pass the pointer to the plugin manager.
//
// Jeremy Meredith, Thu Jan 28 15:49:05 EST 2010