Commit af04477b authored by allens's avatar allens

for each FileFormat added NonCompliantException to most of the error...

for each FileFormat added NonCompliantException to most of the error messagingto gives users more information, minor clean up of other files.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12839 18c085ea-50e0-402c-830e-de6fd14e8384
parent bac1fbd0
......@@ -49,10 +49,11 @@
#include <vtkFloatArray.h>
#include <vtkUnstructuredGrid.h>
#include <avtDatabaseMetaData.h>
#include <InvalidDBTypeException.h>
#include <InvalidDBTypeException.h>
#include <InvalidVariableException.h>
#include <InvalidFilesException.h>
#include <NonCompliantException.h>
// Define this symbol BEFORE including hdf5.h to indicate the HDF5 code
// in this file uses version 1.6 of the HDF5 API. This is harmless for
......@@ -149,6 +150,9 @@ avtGTCFileFormat::Initialize()
if(initialized)
return true;
if( H5Fis_hdf5( GetFilename() ) < 0 )
EXCEPTION1( InvalidFilesException, GetFilename() );
// Turn off error message printing.
H5Eset_auto(0,0);
debug4 << mName << "Opening " << GetFilename() << endl;
......@@ -157,8 +161,10 @@ avtGTCFileFormat::Initialize()
if (fileHandle < 0)
{
debug4 << mName << "Could not open " << GetFilename() << endl;
EXCEPTION1(InvalidDBTypeException, "Cannot be a GTC file since it is not even an HDF5 file.");
debug4 << mName << "Could not open " << GetFilename() << endl;
EXCEPTION2( NonCompliantException, "GTC File Open",
"File '" + string(GetFilename()) + "' can not be opened" );
}
particleHandle = H5Dopen(fileHandle, "particle_data");
......@@ -166,8 +172,8 @@ avtGTCFileFormat::Initialize()
{
debug4 << mName << "Could not open particle_data" << endl;
H5Fclose(fileHandle);
EXCEPTION1(InvalidDBTypeException, "Cannot be a GTC file, "
"since it is does not contain the dataset \"particle_data\"");
EXCEPTION2( NonCompliantException, "GTC Dataset Open",
"Dataset 'particle_data' can not be opened" );
}
//Check variable's size.
......@@ -181,7 +187,8 @@ avtGTCFileFormat::Initialize()
H5Sclose(sid);
H5Dclose(particleHandle);
H5Fclose(fileHandle);
EXCEPTION1(InvalidDBTypeException, "The GTC file has an invalid number of dimensions");
EXCEPTION2( NonCompliantException, "GTC Dataset Extents",
"Dataset 'particle_data' has an invalid extents");
}
debug4 << mName << "Determining variable size" << endl;
......@@ -193,7 +200,8 @@ avtGTCFileFormat::Initialize()
H5Sclose(sid);
H5Dclose(particleHandle);
H5Fclose(fileHandle);
EXCEPTION1(InvalidDBTypeException, "The GTC file has an insufficient number of variables");
EXCEPTION2( NonCompliantException, "GTC Dataset Extents",
"Dataset 'particle_data' has an insufficient number of variables");
}
H5Sclose(dataspace);
......@@ -902,6 +910,3 @@ parallelBuffer::AddElement( float *data )
}
#endif
......@@ -51,10 +51,8 @@
#include <avtDatabaseMetaData.h>
#include <Expression.h>
#include <BadIndexException.h>
#include <NonCompliantException.h>
#include <InvalidFilesException.h>
#include <InvalidVariableException.h>
#include <UnexpectedValueException.h>
#include <vtkStructuredGrid.h>
#include <vtkPoints.h>
#include <vtkCellType.h>
......@@ -128,22 +126,36 @@ static void dbg_string_attrib(hid_t id, const std::string &str)
avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
avtMTSDFileFormat (&filename, 1)
{
if( H5Fis_hdf5( filename ) < 0 )
EXCEPTION1( InvalidFilesException, filename );
// INITIALIZE DATA MEMBERS
fname = filename;
hid_t file;
hid_t root_id, group_id;
char *string_attrib;
float time;
file = H5Fopen (filename, H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, filename);
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + string(filename) + "' can not be opened" );
}
hsize_t i, npoints;
// Read attributes
root_id = H5Gopen (file, "/");
if ( root_id < 0 )
{
H5Fclose(file);
EXCEPTION2( NonCompliantException, "H5NIMROD Group Open",
"The root group '/' was not found" );
}
dbg_string_attrib(root_id, "Description");
dbg_string_attrib(root_id, "Source");
......@@ -151,7 +163,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(root_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'time' was not found or was the wrong type." );
}
debug5 << "time: " << time << std::endl;
......@@ -160,7 +173,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(root_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Group Open",
"The group '/GRID' was not found" );
}
string_attrib = NULL;
......@@ -174,8 +188,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose(file);
EXCEPTION2(UnexpectedValueException, "Cartesian - XYZ",
string_attrib);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Cartesian - XYZ' was not found or was the wrong type." );
}
free(string_attrib);
}
......@@ -194,8 +208,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose (file);
EXCEPTION2 (UnexpectedValueException, "Structured",
string_attrib ? string_attrib : "NULL");
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Topology' was not found or not 'Structured'" );
}
if(string_attrib)
{
......@@ -211,7 +225,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
H5Gclose(root_id);
H5Gclose(grid_id);
H5Fclose (file);
EXCEPTION2 (UnexpectedValueException, 3, ndims);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Dimensions",
"Grid dataset 'X' does not have three dimensions" );
}
// points
for (i = 0, npoints = 1; i < ndims; i++)
......@@ -253,7 +268,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(group_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'Step number' was not found or wrong type" );
}
cycles.push_back( atoi(stepnumber) );
......@@ -264,7 +280,8 @@ avtH5NimrodFileFormat::avtH5NimrodFileFormat (const char *filename):
{
H5Gclose(group_id);
H5Fclose(file);
EXCEPTION1 (InvalidFilesException, filename);
EXCEPTION2( NonCompliantException, "H5NIMROD Read Attribute",
"Attribute 'time' was not found or wrong type" );
}
times.push_back( time );
......@@ -448,7 +465,10 @@ avtH5NimrodFileFormat::GetMesh (int timestate, const char *meshname)
hid_t file;
file = H5Fopen (fname.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, fname.c_str ());
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + fname + "' can not be opened" );
}
hid_t grid_id = H5Gopen (file, "/GRID");
vtkpoints->SetNumberOfPoints (npoints);
......@@ -513,7 +533,10 @@ avtH5NimrodFileFormat::GetVar (int timestate, const char *varname)
file = H5Fopen (fname.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, fname.c_str ());
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + fname + "' can not be opened" );
}
hid_t root_id, group_id;
root_id = H5Gopen (file, "/");
......@@ -570,7 +593,10 @@ avtH5NimrodFileFormat::GetVectorVar (int timestate, const char *varname)
file = H5Fopen (fname.c_str (), H5F_ACC_RDONLY, H5P_DEFAULT);
if (file < 0)
EXCEPTION1 (InvalidFilesException, fname.c_str ());
{
EXCEPTION2( NonCompliantException, "H5NIMROD File Open",
"File '" + fname + "' can not be opened" );
}
hid_t root_id, group_id;
root_id = H5Gopen (file, "/");
......@@ -652,14 +678,9 @@ avtH5NimrodFileFormat::GetVectorVar (int timestate, const char *varname)
void avtH5NimrodFileFormat::GetCycles(std::vector<int> &c)
{
c = cycles;
metadata->SetCyclesAreAccurate(true);
metadata->SetCycles( cycles );
metadata->SetTimesAreAccurate(true);
metadata->SetTimes( times );
}
// ****************************************************************************
// Method: avtH5NimrodFileFormat::GetTimes
//
......@@ -677,10 +698,4 @@ void avtH5NimrodFileFormat::GetCycles(std::vector<int> &c)
void avtH5NimrodFileFormat::GetTimes(std::vector<double> &t)
{
t = times;
metadata->SetCyclesAreAccurate(true);
metadata->SetCycles( cycles );
metadata->SetTimesAreAccurate(true);
metadata->SetTimes( times );
}
......@@ -1170,6 +1170,7 @@ avtH5PartFileFormat::GetFieldMesh(int timestate, const char *meshname)
coords[2]->Delete();
visitTimer->StopTimer(t1, "H5PartFileFormat::GetFieldMesh()");
return rgrid;
}
......
......@@ -93,7 +93,7 @@ avtM3DC1Field::~avtM3DC1Field()
// ****************************************************************************
// Method: findElementNeighbors
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -192,7 +192,7 @@ void avtM3DC1Field::findElementNeighbors()
// ****************************************************************************
// Method: register_vert
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -221,7 +221,7 @@ void avtM3DC1Field::register_vert(v_entry *vlist, int *len,
// ****************************************************************************
// Method: add_edge
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -254,7 +254,7 @@ void avtM3DC1Field::add_edge(edge *list, int *tri,
// ****************************************************************************
// Method: get_tri_coords2D
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -282,7 +282,7 @@ int avtM3DC1Field::get_tri_coords2D(double *xin, int el, double *xout)
// ****************************************************************************
// Method: get_tri_coords2D
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -367,7 +367,7 @@ int avtM3DC1Field::get_tri_coords2D(double *xin, double *xout)
// ****************************************************************************
// Method: interp basic interpolation
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -386,7 +386,7 @@ float avtM3DC1Field::interp(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdR interpolation in dR
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -411,7 +411,7 @@ float avtM3DC1Field::interpdR(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdz interpolation in dz
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -437,7 +437,7 @@ float avtM3DC1Field::interpdz(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdR2 interpolation in dR2
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -467,7 +467,7 @@ float avtM3DC1Field::interpdR2(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdz2 interpolation in dz2
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -497,7 +497,7 @@ float avtM3DC1Field::interpdz2(float *var, int el, double *lcoords)
// ****************************************************************************
// Method: interpdR interpolation in dR
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......@@ -528,9 +528,10 @@ float avtM3DC1Field::interpdRdz(float *var, int el, double *lcoords)
// Method: interpBcomps
//
// Simultaneously interpolate all three cylindrical components of
// magnetic field
// magnetic field - should not be used for calculating integral
// curves.
//
// Creationist: Allen Sanderson
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
......
This diff is collapsed.
......@@ -123,7 +123,7 @@ class avtM3DC1FileFormat : public avtMTSDFileFormat
std::vector<int> m_cycles;
std::vector<double> m_times;
public:
public:
std::vector<std::string> m_scalarVarNames;
std::vector<std::string> m_fieldVarNames;
......
......@@ -15,8 +15,8 @@ MDSplusMDServerPluginInfo.C
${COMMON_SOURCES}
avtMDSplusFileFormat.C
avtMDSplusOptions.C
mdsPlusAPI.C
#mdsPlusReader.cc
mdsPlusAPI.c
)
SET(LIBE_SOURCES
......@@ -24,8 +24,8 @@ MDSplusEnginePluginInfo.C
${COMMON_SOURCES}
avtMDSplusFileFormat.C
avtMDSplusOptions.C
mdsPlusAPI.C
#mdsPlusReader.cc
mdsPlusAPI.c
)
INCLUDE_DIRECTORIES(
......
......@@ -47,7 +47,7 @@
#include <vtkCellTypes.h>
#include <vtkFloatArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <vtkLine.h>
#include <vtkUnstructuredGrid.h>
#include <avtDatabaseMetaData.h>
......@@ -55,9 +55,7 @@
#include <DBOptionsAttributes.h>
#include <Expression.h>
#include <InvalidVariableException.h>
#include <InvalidFilesException.h>
#include <UnexpectedValueException.h>
#include <NonCompliantException.h>
#include <DebugStream.h>
#include "mdsPlusAPI.h"
......@@ -149,7 +147,7 @@ void
avtMDSplusFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int timeState)
{
avtMeshMetaData *mmd;
avtMeshType mt = AVT_RECTILINEAR_MESH;
avtMeshType mt = AVT_UNSTRUCTURED_MESH;
int nblocks = 1;
int block_origin = 0;
int cell_origin = 0;
......@@ -163,20 +161,28 @@ avtMDSplusFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int time
// mt, extents, nblocks, block_origin,
// spatial_dimension, topological_dimension );
mmd = new avtMeshMetaData(string("LinearGrid"),
mmd = new avtMeshMetaData(string("Signal"),
nblocks, block_origin,
cell_origin, group_origin,
spatial_dimension, topological_dimension, mt);
mmd->hideFromGUI = true;
md->Add(mmd);
mmd = new avtMeshMetaData(string("Experiment"),
nblocks, block_origin,
cell_origin, group_origin,
spatial_dimension, topological_dimension, mt);
mmd->hideFromGUI = true;
md->Add(mmd);
// Populate the scalar field vars that will be interpolate onto a
// refined mesh.
for ( int i = 0; i < m_fieldVarNames.size(); ++i )
{
string varname = m_fieldVarNames[i];
string meshname("LinearGrid");
AddScalarVarToMetaData( md, varname, meshname, AVT_NODECENT );
AddScalarVarToMetaData( md, "Signals/"+varname, "Signal", AVT_NODECENT );
AddScalarVarToMetaData( md, "Experiment/"+varname, "Experiment", AVT_NODECENT );
}
}
......@@ -203,15 +209,15 @@ avtMDSplusFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int time
vtkDataSet *
avtMDSplusFileFormat::GetMesh(int timestate, const char *meshname)
{
debug1 << "Attempting to connect to mdsplus host: " << m_host << endl;
cerr << "Attempting to connect to mdsplus host: " << m_host << endl;
debug1 << "Connecting to mdsplus host: " << m_host << endl;
if( (m_socket = MDS_Connect( m_host.c_str() )) < 0 )
EXCEPTION1( InvalidFilesException, m_host.c_str() );
{
EXCEPTION1( NonCompliantException, "MDSplus server connection",
"Unable to connect to MDS server " + m_host );
}
debug1 << "Attempting to connect to mdsplus tree: " << m_tree
<< " and shot: " << m_shot << endl;
cerr << "Attempting to connect to mdsplus tree: " << m_tree
debug1 << "Connecting to mdsplus tree: " << m_tree
<< " and shot: " << m_shot << endl;
if( MDS_Open( m_tree.c_str(), m_shot ) < 0 )
......@@ -219,20 +225,18 @@ avtMDSplusFileFormat::GetMesh(int timestate, const char *meshname)
char shotstr[16];
sprintf( shotstr, "%d", m_shot );
EXCEPTION2( UnexpectedValueException,
m_tree + string(" or ") + shotstr, "NOT FOUND" );
EXCEPTION2( NonCompliantException, "MDSplus open",
m_tree + string(" or ") + shotstr + " was not found." );
}
bool valid = is_valid( m_signal.c_str() );
debug1 << "Attempting to find : '" << m_signal << "' "
debug1 << "Retrieving mesh : '" << m_signal << "' "
<< (valid ? "success" : "failed") << endl;
cerr << "Attempting to find : '" << m_signal << "' "
<< (valid ? "success" : "failed") << endl;
if( !valid )
EXCEPTION2( UnexpectedValueException, m_signal, "NOT FOUND" );
EXCEPTION2( NonCompliantException, "MDSplus signal validation",
"The signal " + m_signal + " was not found." );
int type = get_type( m_signal.c_str() );
int rank = get_rank( m_signal.c_str() );
......@@ -242,15 +246,17 @@ avtMDSplusFileFormat::GetMesh(int timestate, const char *meshname)
rank = get_dims( m_signal.c_str(), &dims );
cerr << "type " << type << " "
<< "size " << size << " "
<< "rank " << rank << " "
<< "dims ";
void *values = 0;
for( unsigned int i=0; i<rank; ++i )
cerr << dims[i] << " ";
cerr << endl;
// Get the true values via mdsplus
double origin[3] = {0,0,0};
double spacing[3] = {1,1,1};
if( strcmp(meshname, "Signal" ) == 0 )
values = get_values( m_signal.c_str(), type );
else //if( strcmp(meshname, "Experiment" ) == 0 )
{
}
MDS_Disconnect();
......@@ -262,41 +268,36 @@ avtMDSplusFileFormat::GetMesh(int timestate, const char *meshname)
dims[i] = 1;
}
// Get the true values via mdsplus
double origin[3] = {0,0,0};
double spacing[3] = {1,1,1};
vtkFloatArray *coords[3] = {0, 0, 0};
for( unsigned int i=0; i<3; ++i )
{
// set each coordinate
coords[i] = vtkFloatArray::New();
coords[i]->SetNumberOfTuples(dims[i]);
float *coordsPtr = (float *) coords[i]->GetVoidPointer(0);
///////////////////
// // Create A VTK rectilinear mesh grid for the mesh.
// vtkFloatArray *coords[3] = {0, 0, 0};
for (int j=0; j<dims[i]; j++)
coordsPtr[j] = origin[i] + j * spacing[i];
}
// create vtkRectilinearGrid objects + set dims and coords
vtkRectilinearGrid *grid = vtkRectilinearGrid::New();
grid->SetDimensions( coords[0]->GetNumberOfTuples(),
coords[1]->GetNumberOfTuples(),
coords[2]->GetNumberOfTuples() );
// for( unsigned int i=0; i<3; ++i )
// {
// // set each coordinate
// coords[i] = vtkFloatArray::New();
// coords[i]->SetNumberOfTuples(dims[i]);
// float *coordsPtr = (float *) coords[i]->GetVoidPointer(0);
grid->SetXCoordinates(coords[0]);
grid->SetYCoordinates(coords[1]);
grid->SetZCoordinates(coords[2]);
// for (int j=0; j<dims[i]; j++)
// coordsPtr[j] = origin[i] + j * spacing[i];
// }
for( unsigned int i=0; i<3; ++i )
coords[i]->Delete();
// // create vtkRectilinearGrid objects + set dims and coords
// vtkRectilinearGrid *grid = vtkRectilinearGrid::New();
// grid->SetDimensions( coords[0]->GetNumberOfTuples(),
// coords[1]->GetNumberOfTuples(),
// coords[2]->GetNumberOfTuples() );
free( dims );
// grid->SetXCoordinates(coords[0]);
// grid->SetYCoordinates(coords[1]);
// grid->SetZCoordinates(coords[2]);
return grid;
// for( unsigned int i=0; i<3; ++i )
// coords[i]->Delete();
// // Create a VTK grid for the mesh.
///////////////////
// // Create A VTK point mesh grid for the mesh.
// vtkUnstructuredGrid *grid = vtkUnstructuredGrid::New();
// vtkPoints *vtkpoints = vtkPoints::New();
......@@ -313,6 +314,10 @@ avtMDSplusFileFormat::GetMesh(int timestate, const char *meshname)
// vtkpoints->InsertPoint(i, pt);
// }
// grid->SetPoints(vtkpoints);
// vtkpoints->Delete();
// grid->Allocate(size);
// for( unsigned int i=0; i<size; ++i )
......@@ -321,13 +326,55 @@ avtMDSplusFileFormat::GetMesh(int timestate, const char *meshname)
// grid->InsertNextCell(VTK_VERTEX, 1, &vertex);
// }
// grid->SetPoints(vtkpoints);
// return grid;
// vtkpoints->Delete();
// cerr << "dome with mesh creation" << endl;
// // Create a VTK grid for the mesh.
vtkUnstructuredGrid *grid = vtkUnstructuredGrid::New();
// return grid;
vtkPoints *vtkpoints = vtkPoints::New();
vtkpoints->Allocate(size);
vtkpoints->SetNumberOfPoints((vtkIdType) size);
float pt[3];