Commit 0107ed9f authored by allens's avatar allens

fixed a lookup issue when near 2pi

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21376 18c085ea-50e0-402c-830e-de6fd14e8384
parent 4ea0fb2a
......@@ -581,53 +581,6 @@ void avtIVPM3DC1Field::add_edge(std::multimap< int, edge > &edgeListMap,
}
// ****************************************************************************
// Method: get_tri_coords2D
//
// Creationist: Joshua Breslau
// Creation: 20 November 2009
//
// ****************************************************************************
int avtIVPM3DC1Field::get_tri_coords2D(double *xin, int el, double *xout) const
{
float *tri;
double co, sn, rrel, zrel;
int index;
tri = elements + element_size*el;
/* Compute coordinates local to the current element */
// if( element_dimension == 2 )
index = 2 * el;
// else //if( element_dimension == 3 )
// index = 2*(el%tElements);
co = trigtable[index];
sn = trigtable[index + 1];
rrel = xin[0] - (tri[4] + tri[1]*co);
zrel = xin[2] - (tri[5] + tri[1]*sn);
xout[0] = rrel*co + zrel*sn; /* = xi */
xout[1] = zrel*co - rrel*sn; /* = eta */
if( element_dimension == 3 ) /* = zi */
{
float phi = xin[1];
while( phi < 0 )
phi += 2.0*M_PI;
while( phi >= 2.0*M_PI )
phi -= 2.0*M_PI;
xout[2] = phi - tri[8]; // tri[8] = phi0
}
return el;
}
// ****************************************************************************
// Method: get_tri_coords2D
//
......
......@@ -96,7 +96,6 @@ class IVP_API avtIVPM3DC1Field: public avtIVPVTKField
int *vertexIndexs, int side, int element, int *neighborList);
int get_tri_coords2D(double *x, double *xout) const;
int get_tri_coords2D(double *x, int el, double *xout) const;
Result operator()( const double &t, const avtVector &v, avtVector &retV ) const;
......
......@@ -48,6 +48,7 @@
#include <vtkIntArray.h>
#include <vtkFloatArray.h>
#include <avtCallback.h>
#include <InvalidVariableException.h>
#define ELEMENT_SIZE_2D 7
......@@ -92,12 +93,6 @@ avtM3DC1Field::avtM3DC1Field( float *elementsPtr,
tElements = nelms / nplanes;
findElementNeighbors();
// int el = 1280;
// cerr << "Neighbors " << neighbors[3*el + 0] << " "
// << neighbors[3*el + 1] << " "
// << neighbors[3*el + 2] << endl;
}
......@@ -178,24 +173,24 @@ void avtM3DC1Field::findElementNeighbors()
ptr = elements + element_size*el;
trigtable[2*el] = cos(ptr[3]);
trigtable[2*el + 1] = sin(ptr[3]);
co = trigtable[2*el];
sn = trigtable[2*el + 1];
x[0] = ptr[4];
y[0] = ptr[5];
// co = trigtable[2*el];
// sn = trigtable[2*el + 1];
// x[0] = ptr[4];
// y[0] = ptr[5];
x[1] = x[0] + (ptr[0] + ptr[1])*co;
y[1] = y[0] + (ptr[0] + ptr[1])*sn;
// x[1] = x[0] + (ptr[0] + ptr[1])*co;
// y[1] = y[0] + (ptr[0] + ptr[1])*sn;
x[2] = x[0] + ptr[1]*co - ptr[2]*sn;
y[2] = y[0] + ptr[1]*sn + ptr[2]*co;
// x[2] = x[0] + ptr[1]*co - ptr[2]*sn;
// y[2] = y[0] + ptr[1]*sn + ptr[2]*co;
for (vert=0; vert<3; vert++)
tri[vert] = register_vert(vertexList, x[vert], y[vert]);
// for (vert=0; vert<3; vert++)
// tri[vert] = register_vert(vertexList, x[vert], y[vert]);
for (vert=0; vert<3; vert++)
add_edge(edgeListMap, tri, vert, el, neighbors);
// for (vert=0; vert<3; vert++)
// add_edge(edgeListMap, tri, vert, el, neighbors);
} /* end loop el */
}
......@@ -348,13 +343,17 @@ int avtM3DC1Field::get_tri_coords2D(double *xin, int el, double *xout) const
{
float phi = xin[1];
while( phi < 0 )
phi += 2.0*M_PI;
xout[2] = phi - tri[8]; // tri[8] = phi0
while( phi >= 2.0*M_PI )
phi -= 2.0*M_PI;
if( xout[2] < -1.0e8 || tri[7] + 1.0e8 < xout[2] )
{
char buf[1024];
xout[2] = phi - tri[8]; // tri[8] = phi0
sprintf( buf, "avtM3DC1Field::get_tri_coords2D - Get Triangle Coords 2d an element was specified but the point is outside the phi tollerance",
xin[0], xin[1], xin[2] );
avtCallback::IssueWarning( buf );
}
}
return el;
......
......@@ -564,7 +564,7 @@ avtM3DC1FileFormat::GetElements(int timestate, const char *meshname)
H5Dread( datasetId,
H5T_NATIVE_FLOAT, H5S_ALL, spaceId, H5P_DEFAULT, elements );
H5Dclose(spaceId);
H5Sclose(spaceId);
H5Dclose(datasetId);
H5Gclose( meshId );
......@@ -1292,7 +1292,7 @@ avtM3DC1FileFormat::GetFieldVar(int timestate, const char *varname)
hid_t type = H5Dget_type(datasetId);
vtkDataArray *var;
vtkDataArray *vtkVar;
hid_t nativeType;
// Create the VTK structure to hold the field variable.
......@@ -1303,14 +1303,16 @@ avtM3DC1FileFormat::GetFieldVar(int timestate, const char *varname)
// For now type cast everything to floats as that is the storage
// and what is assumed down stream.
vtkFloatArray *varFloat = vtkFloatArray::New();
var = varFloat;
//varFloat->SetNumberOfValues( sdim[0]*sdim[1] );
vtkVar = varFloat;
nativeType = H5T_NATIVE_FLOAT;
// if( size == 4 )
// {
// vtkFloatArray *varFloat = vtkFloatArray::New();
// var = varFloat;
// varFloat->SetNumberOfValues( sdim[0]*sdim[1] );
// vtkVar = varFloat;
// nativeType = H5T_NATIVE_FLOAT;
......@@ -1318,7 +1320,8 @@ avtM3DC1FileFormat::GetFieldVar(int timestate, const char *varname)
// else if( size == 8 )
// {
// vtkDoubleArray *varDouble = vtkDoubleArray::New();
// var = varDouble;
// varDouble->SetNumberOfValues( sdim[0]*sdim[1] );
// vtkVar = varDouble;
// nativeType = H5T_NATIVE_DOUBLE;
// }
......@@ -1331,35 +1334,32 @@ avtM3DC1FileFormat::GetFieldVar(int timestate, const char *varname)
"' is not of native float or double type" );
}
// Set the number of components before setting the number of tuples
// for proper memory allocation.
var->SetNumberOfComponents( sdim[1] );
var->SetNumberOfTuples( sdim[0] );
// Normally an array would be created but instead use the VTK memory
// directly - this usage works because the vtk and hdf5 memory
// layout are the same.
// void *vals;
// if( type == H5T_NATIVE_FLOAT )
// if( nativeType == H5T_NATIVE_FLOAT )
// vals = (void *) new float[sdim[0]*sdim[1]];
// else if( type == H5T_NATIVE_DOUBLE )
// else if( nativeType == H5T_NATIVE_DOUBLE )
// vals = (void *) new double[sdim[0]*sdim[1]];
// if( H5Dread( datasetId,
// type, H5S_ALL, spaceId, H5P_DEFAULT, vals ) < 0 )
// EXCEPTION2( NonCompliantException, "M3DC1 Dataset Read",
// "Dataset '" + std::string(groupStr) + std::string("/") + std::string(varStr) +
// "' can not be read" );
// var->SetNumberOfValues( sdim[0]*sdim[1] );
// var->SetArray( vals, sdim[0]*sdim[1], 0, // ); delete[]( void *) );
// delete [] vals;
// if( H5Dread( datasetId,
// nativeType, H5S_ALL, spaceId, H5P_DEFAULT, vals ) < 0 )
// EXCEPTION2( NonCompliantException, "M3DC1 Dataset Read",
// "Dataset '" + std::string(groupStr) + std::string("/") + std::string(varStr) +
// "' can not be read" );
// ((vtkFloatArray*)vtkVar)->SetArray( ((float*)vals), sdim[0]*sdim[1], 0 ); //, operator delete[]( void* ) );
//delete [] vals;
// Set the number of components before setting the number of tuples
// for proper memory allocation.
vtkVar->SetNumberOfComponents( sdim[1] );
vtkVar->SetNumberOfTuples( sdim[0] );
// Pointer to the vtk memory.
void* values = (void*) var->GetVoidPointer(0);
void* values = (void*) vtkVar->GetVoidPointer(0);
// Read the data directly into the vtk memory - this call assume
// that the hdfd5 and vtk memory layout are the same.
......@@ -1369,19 +1369,11 @@ avtM3DC1FileFormat::GetFieldVar(int timestate, const char *varname)
"Dataset '" + std::string(groupStr) + std::string("/") + std::string(varStr) +
"' can not be read" );
int ncomponents = sdim[1];
// std::cerr << "READ " << varname << std::endl;
// for( int j=0; j<ncomponents; ++j )
// std::cerr << values[0*ncomponents+j] << " ";
// std::cerr << std::endl;
// std::cerr << std::endl;
H5Dclose(spaceId);
H5Sclose(spaceId);
H5Dclose(datasetId);
H5Gclose( groupId );
return var;
return vtkVar;
}
......@@ -2440,6 +2432,9 @@ avtM3DC1FileFormat::LoadFile()
std::cerr << buf << std::endl;
m_times.push_back( -1 );
m_cycles.push_back( t );
continue;
EXCEPTION1( InvalidVariableException,
......@@ -2456,7 +2451,6 @@ avtM3DC1FileFormat::LoadFile()
m_times.push_back( time );
m_cycles.push_back( t );
// Read in the mesh information.
hid_t meshId = H5Gopen( groupID, "mesh", H5P_DEFAULT);
......
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