Commit cafcc06b authored by bonnell's avatar bonnell

Add support for time-series solution files to PLOT3D Reader. Resolves #2257 and #1954

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@26725 18c085ea-50e0-402c-830e-de6fd14e8384
parent bf548d90
......@@ -36,6 +36,7 @@
*
*****************************************************************************/
#include <FileFunctions.h>
#include <Utility.h>
#include <visitstream.h>
#include <vectortypes.h>
......@@ -1113,3 +1114,46 @@ FileFunctions::ComposeDatabaseName(const std::string &host,
return h + ":" + db;
}
// ****************************************************************************
// Method: FileMatchesPatternCB
//
// Purpose:
// This function is a callback to the method ReadAndProcessDirectory,
// located in Utility.h. It is called for each file in a given directory.
// Once it receives a file, it feeds that file to caller which then
// determines if the filename matches the requested pattern.
//
// Programmer: Kathleen Biagas
// Creation: Jun 26, 2013
//
// Modifications:
// Kathleen Biagas, Fri Jun 26 12:13:39 PDT 2015
// Moved from NetworkManager, and added the 'returnFullpath' callback data
// item.
//
// ****************************************************************************
void
FileFunctions::FileMatchesPatternCB(void *cbdata, const std::string &filename, bool isDir, bool canAccess, long size)
{
if (!isDir)
{
void **arr = (void **)cbdata;
std::vector< std::string > *fl = (std::vector< std::string > *)arr[0];
std::string *pattern = (std::string*)arr[1];
int *returnFullPath = (int*)arr[2];
std::string name(filename);
size_t index = filename.rfind(VISIT_SLASH_CHAR);
if(index != std::string::npos)
name = name.substr(index+1);
if (WildcardStringMatch(*pattern, name))
{
if (*returnFullPath)
fl->push_back(filename);
else
fl->push_back(name);
}
}
}
......@@ -44,6 +44,14 @@
#include <sys/types.h>
#include <sys/stat.h>
// ****************************************************************************
// Modifications:
// Kathleen Biagas, Fri Jun 26 12:10:08 PDT 2015
// Added FileMatchesPatternCB, a callback that can be used with
// ReadAndProcessDirectory. (Moved from NetworkManager).
//
// ****************************************************************************
namespace FileFunctions
{
//
......@@ -111,6 +119,8 @@ void MISC_API SplitHostDatabase(const std::string &hostDB,
std::string &host, std::string &db);
std::string MISC_API ComposeDatabaseName(const std::string &host,
const std::string &db);
void MISC_API FileMatchesPatternCB(void *, const std::string &, bool, bool, long);
};
#endif
<?xml version="1.0"?>
<Plugin name="PLOT3D" type="database" label="PLOT3D" version="1.0" enabled="true" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" dbtype="STMD" haswriter="false" hasoptions="true" filePatternsStrict="false" opensWholeDirectory="false">
<Plugin name="PLOT3D" type="database" label="PLOT3D" version="1.0" enabled="true" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" dbtype="MTMD" haswriter="false" hasoptions="true" filePatternsStrict="false" opensWholeDirectory="false">
<FilePatterns>
*.q
*.x
......
......@@ -38,7 +38,7 @@
#include <PLOT3DPluginInfo.h>
#include <avtPLOT3DFileFormat.h>
#include <avtSTMDFileFormatInterface.h>
#include <avtMTMDFileFormatInterface.h>
#include <avtGenericDatabase.h>
#include <avtPLOT3DOptions.h>
......@@ -55,7 +55,7 @@
DatabaseType
PLOT3DCommonPluginInfo::GetDatabaseType()
{
return DB_TYPE_STMD;
return DB_TYPE_MTMD;
}
// ****************************************************************************
......@@ -79,13 +79,15 @@ avtDatabase *
PLOT3DCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
{
avtSTMDFileFormat **ffl = new avtSTMDFileFormat*[nList];
for (int i = 0 ; i < nList ; i++)
// ignore any nBlocks past 1
int nTimestepGroups = nList / nBlock;
avtMTMDFileFormat **ffl = new avtMTMDFileFormat*[nTimestepGroups];
for (int i = 0 ; i < nTimestepGroups ; i++)
{
ffl[i] = new avtPLOT3DFileFormat(list[i], readOptions);
ffl[i] = new avtPLOT3DFileFormat(list[i*nBlock], readOptions);
}
avtSTMDFileFormatInterface *inter
= new avtSTMDFileFormatInterface(ffl, nList);
avtMTMDFileFormatInterface *inter
= new avtMTMDFileFormatInterface(ffl, nTimestepGroups);
return new avtGenericDatabase(inter);
}
......
This diff is collapsed.
......@@ -43,7 +43,7 @@
#ifndef AVT_PLOT3D_FILE_FORMAT_H
#define AVT_PLOT3D_FILE_FORMAT_H
#include <avtSTMDFileFormat.h>
#include <avtMTMDFileFormat.h>
#include <vector>
#include <string>
......@@ -66,27 +66,48 @@ class vtkPLOT3DReader;
// Kathleen Biagas, Thu Apr 23 10:36:09 PDT 2015
// Added 'haveSolutionFile' flag.
//
// Kathleen Biagas, Fri Jun 26 10:24:26 PDT 2015
// Change this from type STMD to MTMD.
// Add solutionFiles, times, haveReadMetaFile, haveProcessedQ, previousTS.
//
// ****************************************************************************
class avtPLOT3DFileFormat : public avtSTMDFileFormat
class avtPLOT3DFileFormat : public avtMTMDFileFormat
{
public:
avtPLOT3DFileFormat(const char *, DBOptionsAttributes *);
virtual ~avtPLOT3DFileFormat();
virtual void GetTimes(std::vector<double> &);
virtual int GetNTimesteps(void);
virtual const char *GetType(void) { return "PLOT3D File Format"; };
virtual vtkDataSet *GetMesh(int, const char *);
virtual vtkDataArray *GetVar(int, const char *);
virtual vtkDataArray *GetVectorVar(int, const char *);
virtual void FreeUpResources(void);
virtual void PopulateDatabaseMetaData(avtDatabaseMetaData *);
virtual vtkDataSet *GetMesh(int, int, const char *);
virtual vtkDataArray *GetVar(int, int, const char *);
virtual vtkDataArray *GetVectorVar(int, int, const char *);
virtual void ActivateTimestep(int ts);
protected:
vtkPLOT3DReader *reader;
std::string visitMetaFile;
bool ReadVisItMetaFile(void);
std::string xFileName;
std::string qFileName;
std::string solutionRoot;
std::vector<std::string> solutionFiles;
std::vector<double> times;
bool haveSolutionFile;
bool haveReadMetaFile;
bool haveProcessedQ;
int previousTS;
virtual void PopulateDatabaseMetaData(avtDatabaseMetaData *, int);
private:
bool ReadVisItMetaFile(void);
bool ProcessQForTimeSeries(void);
void SetTimeStep(int timeState);
};
......
......@@ -48,6 +48,8 @@ vtkPLOT3DReader::vtkPLOT3DReader()
this->SolutionOffsets = NULL;
// parent class sets up scalar function 100 and vector 202 ALWAYS, but
// we only want what user requests, so remove what parent set up.
this->SetScalarFunctionNumber(-1);
this->SetVectorFunctionNumber(-1);
this->RemoveAllFunctions();
}
......@@ -295,6 +297,7 @@ int vtkPLOT3DReader::RequestInformation(
fclose(qFp);
return 0;
}
fclose(qFp);
}
return 1;
}
......@@ -346,7 +349,7 @@ int vtkPLOT3DReader::RequestData(
{
return 0;
}
if ( this->ReadQHeader(qFp) != VTK_OK )
{
fclose(qFp);
......@@ -449,7 +452,7 @@ int vtkPLOT3DReader::RequestData(
{
output->GetPointData()->GetArray("StagnationEnergy")->SetName("InternalEnergy");
}
if (removeMomentum)
output->GetPointData()->RemoveArray("Momentum");
}
......@@ -496,7 +499,7 @@ vtkPLOT3DReader::ReadGrid(FILE *xyzFp, vtkStructuredGrid *output)
fseek(xyzFp, offset, SEEK_SET);
this->SkipByteCount(xyzFp);
int d = this->TwoDimensionalGeometry ? 2 : 3;
int d = this->Internal->NumberOfDimensions;
if (this->ReadVector(xyzFp, this->NumberOfPoints, d, pointArray) == 0)
{
vtkErrorMacro("Encountered premature end-of-file while reading "
......@@ -531,8 +534,8 @@ vtkPLOT3DReader::ComputeGridOffset(FILE *xyzFp)
;
}
long nd = this->TwoDimensionalGeometry ? 2 : 3;
long bc = this->HasByteCount ? sizeof(int) : 0;
long nd = this->Internal->NumberOfDimensions;
long bc = this->Internal->HasByteCount ? sizeof(int) : 0;
for (int j = i+1; j <= this->GridNumber; j++)
{
......@@ -597,9 +600,11 @@ vtkPLOT3DReader::ReadSolutionProperties(FILE *qFp)
return VTK_ERROR;
}
this->SkipByteCount(qFp);
this->Properties = newProp;
this->Properties->Register(this);
//if (this->GridNumber == 0)
{
this->Properties = newProp;
this->Properties->Register(this);
}
newProp->Delete();
return VTK_OK;
}
......@@ -690,23 +695,15 @@ vtkPLOT3DReader::ComputeSolutionOffset(FILE *qFp)
{
// Number of scalars to be read: 1 for density, 1 for energy and
// NumDims for Momentum
int ns = 1 + 1 + (this->TwoDimensionalGeometry ? 2 : 3);
int ns = 1 + 1 + this->Internal->NumberOfDimensions;
if (this->Internal->BinaryFile)
{
long bc = this->HasByteCount ? sizeof(int) : 0;
if (this->DoublePrecision)
{
this->SolutionOffsets[j] = this->SolutionOffsets[0] +
4 * sizeof(double) + 2*bc +
ns * this->GridSizes[j-1]*sizeof(double) + 2*bc;
}
else
{
this->SolutionOffsets[j] = this->SolutionOffsets[0] +
4 * sizeof(float) + 2*bc +
ns * this->GridSizes[j-1]*sizeof(float) + 2*bc;
}
int n = 4;
long bc = this->Internal->HasByteCount ? sizeof(int) : 0;
int mult = this->Internal->Precision;
this->SolutionOffsets[j] = this->SolutionOffsets[j-1] +
n * mult + 2*bc +
ns * this->GridSizes[j-1]*mult + 2*bc;
}
else
{
......
......@@ -125,7 +125,6 @@
#include <PlotPluginInfo.h>
#include <StackTimer.h>
#include <FileFunctions.h> // for ReadAndProcessDirectory
#include <Utility.h> // for WildcardStringMatch
#include <vtkImageData.h>
......@@ -178,7 +177,6 @@ static void BroadcastImage(avtImage_p &, bool, int);
static bool IsBlankImage(avtImage_p img);
static std::vector<int> BuildBlankImageVector(avtImage_p img);
#endif
static void FileMatchesPatternCB(void *, const std::string &, bool, bool, long);
//
// Static data members of the NetworkManager class.
......@@ -703,6 +701,9 @@ NetworkManager::GetOpenDatabases() const
// Kathleen Biagas, Thu June 27 10:38:54 MST 2013
// If passed a virtual Database, expand it to the actual files.
//
// Kathleen Biagas, Fri Jun 26 12:14:51 PDT 2015
// Moved FileMatchesPatternCB to FileFunctions.
//
// ****************************************************************************
NetnodeDB *
......@@ -820,10 +821,14 @@ NetworkManager::GetDBFromCache(const std::string &filename, int time,
}
// look for files that match pattern
std::vector< std::string > fileNames;
void *cb_data[2];
int returnFullPath = 1;
void *cb_data[3];
cb_data[0] = (void *)&fileNames;
cb_data[1] = (void *)&pattern;
FileFunctions::ReadAndProcessDirectory(path, FileMatchesPatternCB, (void*) cb_data, false);
cb_data[2] = (void *)&returnFullPath;
FileFunctions::ReadAndProcessDirectory(path,
FileFunctions::FileMatchesPatternCB, (void*) cb_data,
false);
char **names = new char *[fileNames.size()];
for (size_t i = 0; i < fileNames.size(); ++i)
{
......@@ -7049,35 +7054,3 @@ NetworkManager::GetQueryParameters(const std::string &qName)
return avtQueryFactory::Instance()->GetDefaultInputParams(qName);
}
// ****************************************************************************
// Method: FileMatchesPatternCB
//
// Purpose:
// This function is a callback to the method ReadAndProcessDirectory,
// located in Utility.h. It is called for each file in a give directory.
// Once it receives a file, it feeds that file to NetworkManager which then
// determines if the filename matches the requested pattern.
//
// Programmer: Kathleen Biagas
// Creation: Jun 26, 2013
//
// Modifications:
//
// ****************************************************************************
static void
FileMatchesPatternCB(void *cbdata, const std::string &filename, bool isDir, bool canAccess, long size)
{
if (!isDir)
{
void **arr = (void **)cbdata;
std::vector< std::string > *fl = (std::vector< std::string > *)arr[0];
std::string *pattern = (std::string*)arr[1];
std::string name(filename);
size_t index = filename.rfind(VISIT_SLASH_CHAR);
if(index != std::string::npos)
name = name.substr(index+1);
if (WildcardStringMatch(*pattern, name))
fl->push_back(filename);
}
}
......@@ -59,7 +59,7 @@ enhancements and bug-fixes that were added to this release.</p>
<p><b><font size="4">File format reader changes in version 2.10</font></b></p>
<ul>
<li>The PLOT3D reader has been enhanced to <i>auto-detect</i> the format options normally specified by the <i>.vp3d meta file</i> or via <i>Read options.</i>Auto-detection works for most binary files, but not for ascii. It is always on, and if successful, will override the values specified in the <i>.vp3d meta file</i> or <i>Read options.</i> If not successful, the reader will fallback to use the other settings.</li>
<li></li>
<li>The PLOT3D reader now supports time-series solution files, specified in the form 'somefile*.q', (where '*' matches a number specifing the timestate) or 'somefile??3?.q'. Use the '?' form to sub-select from the time series. The q filename in this form can be used in the <i>.vp3d meta file</i>, or via <i>Read Options.</i> The '.q' extension is the default.</li>
<li></li>
<li></li>
</ul>
......
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