Commit c6e0cff4 authored by hrchilds's avatar hrchilds
Browse files

Update from July 22, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@285 18c085ea-50e0-402c-830e-de6fd14e8384
parent 188ba770
......@@ -81,6 +81,8 @@ ExodusCommonPluginInfo::GetDefaultExtensions()
// Hank Childs, Tue Feb 25 13:56:42 PST 2003
// Account for .EXODUS, .nemesis, and .NEMESIS.
//
// Hank Childs, Thu Jul 22 11:29:31 PDT 2004
// Register the file list
// ****************************************************************************
avtDatabase *
ExodusCommonPluginInfo::SetupDatabase(const char *const *list,
......@@ -124,10 +126,25 @@ ExodusCommonPluginInfo::SetupDatabase(const char *const *list,
return rv;
}
//
// We don't want to register the file list with every Exodus file format,
// because that list can get big. Instead, register a list statically
// with the format. It will return an index and then tell each new
// instance that it should use this index.
//
int fileListId = -1;
if (!containsManyFiles)
{
fileListId = avtExodusFileFormat::RegisterFileList(list, nList);
}
avtMTSDFileFormat **ffl = new avtMTSDFileFormat*[nList];
for (int i = 0 ; i < nList ; i++)
{
ffl[i] = new avtExodusFileFormat(list[i]);
avtExodusFileFormat *exo = new avtExodusFileFormat(list[i]);
if (!containsManyFiles)
exo->SetFileList(fileListId);
ffl[i] = exo;
}
avtMTSDFileFormatInterface *inter
= new avtMTSDFileFormatInterface(ffl, nList);
......
......@@ -12,6 +12,7 @@
#include <vtkPointData.h>
#include <avtDatabaseMetaData.h>
#include <avtMaterial.h>
#include <avtVariableCache.h>
#include <BadIndexException.h>
......@@ -24,6 +25,9 @@ using std::vector;
using std::sort;
vector< vector<string> > *avtExodusFileFormat::globalFileLists = NULL;
// ****************************************************************************
// Method: avtExodusFileFormat constructor
//
......@@ -38,6 +42,9 @@ using std::sort;
// Hank Childs, Tue Apr 8 10:58:18 PDT 2003
// Defer reading in the file.
//
// Hank Childs, Thu Jul 22 14:28:10 PDT 2004
// Add support for registering file lists.
//
// ****************************************************************************
avtExodusFileFormat::avtExodusFileFormat(const char *name)
......@@ -46,6 +53,37 @@ avtExodusFileFormat::avtExodusFileFormat(const char *name)
reader = NULL;
cache = NULL;
readInFile = false;
fileList = -1;
}
// ****************************************************************************
// Method: avtExodusFileFormat::RegisterFileList
//
// Purpose:
// Registers a file list with this format. The file list is the "real"
// list of file names in the Nemesis file.
//
// Programmer: Hank Childs
// Creation: July 22, 2004
//
// ****************************************************************************
int
avtExodusFileFormat::RegisterFileList(const char *const *list, int nlist)
{
if (globalFileLists == NULL)
{
globalFileLists = new vector< vector<string> >;
}
vector<string> thisList(nlist);
for (int i = 0 ; i < nlist ; i++)
thisList[i] = list[i];
globalFileLists->push_back(thisList);
return globalFileLists->size()-1;
}
......@@ -171,6 +209,9 @@ avtExodusFileFormat::FreeUpResources(void)
// Hank Childs, Sun Jun 27 10:31:18 PDT 2004
// Tell the reader that it should always generate the global node id numbers
//
// Hank Childs, Thu Jul 22 10:43:36 PDT 2004
// Tell the reader to generate block ids.
//
// ****************************************************************************
vtkExodusReader *
......@@ -184,6 +225,7 @@ avtExodusFileFormat::GetReader(void)
reader = vtkExodusReader::New();
reader->SetFileName(filenames[0]);
reader->SetGenerateNodeGlobalIdArray(1);
reader->SetGenerateBlockIdCellArray(1);
//
// Everything we want will assume that at least the information has been
......@@ -310,6 +352,9 @@ avtExodusFileFormat::GetNTimesteps(void)
// Hank Childs, Sun Jun 27 13:20:51 PDT 2004
// Indicate that we have global node ids.
//
// Hank Childs, Thu Jul 22 14:41:51 PDT 2004
// Use the real filenames when creating the SIL.
//
// ****************************************************************************
void
......@@ -337,8 +382,13 @@ avtExodusFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
mesh->blockOrigin = 0;
mesh->spatialDimension = spatialDimension;
mesh->topologicalDimension = spatialDimension;
mesh->blockTitle = "file";
mesh->blockPieceName = "file";
mesh->blockTitle = "File";
if (globalFileLists != NULL && fileList >= 0 &&
(fileList < globalFileLists->size()))
{
mesh->blockNames = (*globalFileLists)[fileList];
}
mesh->blockPieceName = "File";
mesh->containsGlobalNodeIds = true;
md->Add(mesh);
......@@ -448,15 +498,7 @@ avtExodusFileFormat::GetMesh(int ts, const char *mesh)
//
// See if we have this cached.
//
const char *matname = NULL;
if (doMaterialSelection)
{
matname = materialName;
}
else
{
matname = "_all";
}
const char *matname = "_all";
int fts = 0;
int dom = 0;
vtkDataSet *cmesh = (vtkDataSet *) cache->GetVTKObject(mesh,
......@@ -559,6 +601,7 @@ avtExodusFileFormat::GetVar(int ts, const char *var)
}
// ****************************************************************************
// Method: avtExodusFileFormat::GetVectorVar
//
......@@ -628,75 +671,91 @@ avtExodusFileFormat::GetVectorVar(int ts, const char *var)
// ****************************************************************************
// Method: avtExodusFileFormat::SetTimestep
// Method: avtExodusFileFormat::GetAuxiliaryData
//
// Purpose:
// Sets the timestep of the Exodus file.
// Gets the auxiliary data specified.
//
// Arguments:
// var The variable of interest.
// ts The timestep of interest.
// type The type of auxiliary data.
// <unnamed> The arguments for that type -- not used.
// df Destructor function.
//
// Returns: The auxiliary data.
//
// Programmer: Hank Childs
// Creation: October 9, 2001
// Creation: July 22, 2004
//
// ****************************************************************************
void
avtExodusFileFormat::SetTimestep(int ts)
void *
avtExodusFileFormat::GetAuxiliaryData(const char *var, int ts,
const char * type, void *,
DestructorFunction &df)
{
int nTimesteps = GetNTimesteps();
if (ts < 0 || ts >= nTimesteps)
int i;
if (strcmp(type, AUXILIARY_DATA_MATERIAL) != 0)
return NULL;
if (strstr(var, "ElementBlock") != var)
EXCEPTION1(InvalidVariableException, var);
vtkDataSet *ds = ForceRead("_none");
if (ds == NULL)
return NULL;
vtkDataArray *arr = ds->GetCellData()->GetArray("BlockId");
if (arr == NULL)
return NULL;
int nzones = ds->GetNumberOfCells();
vector<int> sortedBlockIds = blockId;
sort(sortedBlockIds.begin(), sortedBlockIds.end());
std::vector<std::string> mats(numBlocks);
for (i = 0 ; i < numBlocks ; i++)
{
EXCEPTION2(BadIndexException, ts, nTimesteps);
char num[1024];
sprintf(num, "%d", sortedBlockIds[i]);
mats[i] = num;
}
vtkExodusReader *rdr = GetReader();
rdr->SetTimeStep(ts+1);
int *mat_0 = new int[nzones];
int *ptr = (int *) arr->GetVoidPointer(0);
for (i = 0 ; i < nzones ; i++)
mat_0[i] = ptr[i]-1;
avtMaterial *mat = new avtMaterial(numBlocks, mats, nzones, mat_0,
0, NULL, NULL, NULL, NULL);
delete [] mat_0;
df = avtMaterial::Destruct;
return (void*) mat;
}
// ****************************************************************************
// Method: avtExodusFileFormat::GetBlockInformation
// Method: avtExodusFileFormat::SetTimestep
//
// Purpose:
// Determine which block we should read in.
//
// Arguments:
// bIdx A location to place a block index.
//
// Returns: True if we should read in only one block, false otherwise.
// Sets the timestep of the Exodus file.
//
// Programmer: Hank Childs
// Creation: October 9, 2001
//
// ****************************************************************************
bool
avtExodusFileFormat::GetBlockInformation(int &bIdx)
void
avtExodusFileFormat::SetTimestep(int ts)
{
if (!doMaterialSelection)
{
return false;
}
bool gotBlock = false;
for (int i = 0 ; i < numBlocks ; i++)
{
char name[1024];
sprintf(name, "%d", blockId[i]);
if (strcmp(name, materialName) == 0)
{
bIdx = i;
gotBlock = true;
break;
}
}
if (!gotBlock)
int nTimesteps = GetNTimesteps();
if (ts < 0 || ts >= nTimesteps)
{
debug1 << "Exodus file format could not find block "
<< materialName << endl;
return false;
EXCEPTION2(BadIndexException, ts, nTimesteps);
}
return true;
vtkExodusReader *rdr = GetReader();
rdr->SetTimeStep(ts+1);
}
......@@ -788,42 +847,9 @@ avtExodusFileFormat::ForceRead(const char *var)
{
vtkExodusReader *rdr = GetReader();
//
// Determine which block we should read in.
//
int bId;
bool useBlockIds = GetBlockInformation(bId);
//
// It might be a block that is not valid for this domain (this frequently
// happens with Exodus files). If so, just return a dummy.
//
if (useBlockIds)
{
if (!validBlock[bId])
{
debug5 << "Asked Exodus file for a block that it does not have, "
<< "returning NULL." << endl;
return NULL;
}
}
//
// We can use the "pieces" mechanism to only read in part of the Exodus
// file. We can bypass it if we want to read in the whole thing -- the
// else case.
//
vtkDataSet *ds = rdr->GetOutput();
if (useBlockIds)
{
ds->SetUpdatePiece(bId);
ds->SetUpdateNumberOfPieces(numBlocks);
}
else
{
ds->SetUpdatePiece(0);
ds->SetUpdateNumberOfPieces(1);
}
ds->SetUpdatePiece(0);
ds->SetUpdateNumberOfPieces(1);
//
// Use a helper function to set up the reader to only read in the variable
......
......@@ -7,6 +7,9 @@
#include <avtMTSDFileFormat.h>
#include <vector>
#include <string>
class vtkExodusReader;
......@@ -30,6 +33,10 @@ class avtVariableCache;
// Hank Childs, Sat Apr 17 07:42:40 PDT 2004
// Added support for times.
//
// Hank Childs, Thu Jul 22 11:29:31 PDT 2004
// Make materials go throw the standard generic database path. Also add
// support for registering file lists.
//
// ****************************************************************************
class avtExodusFileFormat : public avtMTSDFileFormat
......@@ -37,6 +44,9 @@ class avtExodusFileFormat : public avtMTSDFileFormat
public:
avtExodusFileFormat(const char *);
virtual ~avtExodusFileFormat();
static int RegisterFileList(const char *const *, int);
void SetFileList(int fl) { fileList = fl; };
virtual void FreeUpResources(void);
const char *GetType(void) { return "Exodus File Format"; };
......@@ -50,7 +60,10 @@ class avtExodusFileFormat : public avtMTSDFileFormat
virtual vtkDataArray *GetVectorVar(int, const char *);
virtual void PopulateDatabaseMetaData(avtDatabaseMetaData*);
virtual bool PerformsMaterialSelection(void) {return true;};
virtual void *GetAuxiliaryData(const char *var, int,
const char *type, void *args,
DestructorFunction &);
protected:
vtkExodusReader *reader;
......@@ -61,9 +74,13 @@ class avtExodusFileFormat : public avtMTSDFileFormat
std::vector<std::string> cellVars;
avtVariableCache *cache;
bool readInFile;
int fileList;
// Note: this needs to be a pointer because there are issues with
// constructors being called in shared libraries for static objects.
static std::vector< std::vector<std::string> > *globalFileLists;
vtkExodusReader *GetReader(void);
bool GetBlockInformation(int &);
void SetTimestep(int);
void LoadVariable(vtkExodusReader *, const char *);
vtkDataSet *ForceRead(const char *);
......
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