Commit 416c8f7c authored by bonnell's avatar bonnell
Browse files

Use double internally instead of float.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23203 18c085ea-50e0-402c-830e-de6fd14e8384
parent 24eb0b79
......@@ -494,6 +494,9 @@ avtCompactnessQuery::PostExecute(void)
// Kathleen Biagas, Fri Jan 25 16:32:38 PST 2013
// Call Update on filter, not data object.
//
// Kathleen Biagas, Tue Apr 22 07:46:17 MST 2014
// Use double instead of float.
//
// ****************************************************************************
void
......@@ -516,10 +519,10 @@ avtCompactnessQuery::Execute1(vtkDataSet *ds, const int dom)
// Create the area, volume and centroid arrays
//
int ncells2d = ds_2d_nogz->GetNumberOfCells();
float *cellArea = new float[ncells2d];
float *cellVol = new float[ncells2d];
float *cellCentX = new float[ncells2d];
float *cellCentY = new float[ncells2d];
double *cellArea = new double[ncells2d];
double *cellVol = new double[ncells2d];
double *cellCentX = new double[ncells2d];
double *cellCentY = new double[ncells2d];
for (i = 0 ; i < ncells2d ; i++)
{
vtkCell *cell = ds_2d_nogz->GetCell(i);
......@@ -550,7 +553,7 @@ avtCompactnessQuery::Execute1(vtkDataSet *ds, const int dom)
// calculate the whole mass
for (i = 0 ; i < ncells2d ; i++)
{
float d = den->GetTuple1(i);
double d = den->GetTuple1(i);
totalRotMass += d * cellVol[i];
centMassX += d * cellCentX[i] * cellVol[i];
centMassY += d * cellCentY[i] * cellVol[i];
......@@ -577,13 +580,7 @@ avtCompactnessQuery::Execute1(vtkDataSet *ds, const int dom)
geomFilter->SetInputData(ds);
boundaryFilter->SetInputConnection(geomFilter->GetOutputPort());
// FIX_ME_VTK6.0, ESB, is this correct?
vtkStreamingDemandDrivenPipeline::SetUpdateGhostLevel(boundaryFilter->GetInformation(), 2);
//boundaryFilter->GetOutput()->SetUpdateGhostLevel(2);
//boundaryFilter->Update();
//vtkPolyData *allLines = boundaryFilter->GetOutput();
//allLines->SetSource(NULL);
gzFilter1->SetInputConnection(boundaryFilter->GetOutputPort());
gzFilter1->Update();
......@@ -674,6 +671,9 @@ avtCompactnessQuery::Execute1(vtkDataSet *ds, const int dom)
// Kathleen Biagas, Fri Jan 25 16:32:38 PST 2013
// Call Update on filter, not data object.
//
// Kathleen Biagas, Tue Apr 22 07:46:17 MST 2014
// Use double instead of float.
//
// ****************************************************************************
void
......@@ -694,10 +694,10 @@ avtCompactnessQuery::Execute2(vtkDataSet *ds, const int dom)
// Create the area, volume and centroid arrays
//
int ncells2d = ds_2d_nogz->GetNumberOfCells();
float *cellArea = new float[ncells2d];
float *cellVol = new float[ncells2d];
float *cellCentX = new float[ncells2d];
float *cellCentY = new float[ncells2d];
double *cellArea = new double[ncells2d];
double *cellVol = new double[ncells2d];
double *cellCentX = new double[ncells2d];
double *cellCentY = new double[ncells2d];
for (i = 0 ; i < ncells2d ; i++)
{
vtkCell *cell = ds_2d_nogz->GetCell(i);
......@@ -709,8 +709,8 @@ avtCompactnessQuery::Execute2(vtkDataSet *ds, const int dom)
//
// Calculate the distance to the boundary and origin
//
float *distOrigin = new float[ncells2d];
float *distBoundary = new float[ncells2d];
double *distOrigin = new double[ncells2d];
double *distBoundary = new double[ncells2d];
int npts1d = xBound.size();
for (i = 0 ; i < ncells2d ; i++)
{
......@@ -718,7 +718,7 @@ avtCompactnessQuery::Execute2(vtkDataSet *ds, const int dom)
distOrigin[i] = sqrt(cellCentX[i]*cellCentX[i] +
cellCentY[i]*cellCentY[i]);
distBoundary[i] = FLT_MAX;
distBoundary[i] = DBL_MAX;
for (j = 0 ; j < npts1d ; j++)
{
// semi-hack: ignore points along the y=0 line,
......@@ -729,9 +729,9 @@ avtCompactnessQuery::Execute2(vtkDataSet *ds, const int dom)
if (yBound[j] < 0.00001)
continue;
float dx = cellCentX[i] - xBound[j];
float dy = cellCentY[i] - yBound[j];
float dist2 = dx*dx + dy*dy;
double dx = cellCentX[i] - xBound[j];
double dy = cellCentY[i] - yBound[j];
double dist2 = dx*dx + dy*dy;
if (dist2 < distBoundary[i])
distBoundary[i] = dist2;
}
......@@ -763,11 +763,11 @@ avtCompactnessQuery::Execute2(vtkDataSet *ds, const int dom)
// calculate the two density-based queries
for (i = 0 ; i < ncells2d ; i++)
{
float d = den->GetTuple1(i);
double d = den->GetTuple1(i);
float dx = cellCentX[i] - centMassX;
float dy = cellCentY[i] - centMassY;
float distCentMass = sqrt(dx*dx + dy*dy);
double dx = cellCentX[i] - centMassX;
double dy = cellCentY[i] - centMassY;
double distCentMass = sqrt(dx*dx + dy*dy);
distBound_dv_den_vol += cellVol[i] * distBoundary[i] * d;
distCMass_dv_den_vol += cellVol[i] * distCentMass * d;
......@@ -799,13 +799,17 @@ avtCompactnessQuery::Execute2(vtkDataSet *ds, const int dom)
// Gets the area of a triangle.
//
// Arguments:
// p0,p1,p2 three two-float arrays
// p0,p1,p2 three two-double arrays
//
// Programmer: Jeremy Meredith
// Creation: April 12, 2003
//
// Modifications:
// Kathleen Biagas, Tue Apr 22 07:48:16 MST 2014
// Return double instead of float.
//
// ****************************************************************************
float
double
avtCompactnessQuery::Get2DTriangleArea(double *p0, double *p1, double *p2)
{
double vx1 = p1[0]-p0[0];
......@@ -828,11 +832,15 @@ avtCompactnessQuery::Get2DTriangleArea(double *p0, double *p1, double *p2)
// Programmer: Jeremy Meredith
// Creation: April 12, 2003
//
// Modifications:
// Kathleen Biagas, Tue Apr 22 07:48:16 MST 2014
// Return double instead of float.
//
// ****************************************************************************
float
double
avtCompactnessQuery::Get2DCellArea(vtkCell *cell)
{
float area = 0;
double area = 0;
vtkPoints *pts = cell->GetPoints();
int npts = cell->GetNumberOfPoints();
......@@ -882,10 +890,14 @@ avtCompactnessQuery::Get2DCellArea(vtkCell *cell)
// Programmer: Jeremy Meredith
// Creation: April 12, 2003
//
// Modifications:
// Kathleen Biagas, Tue Apr 22 07:49:21 MST 2014
// Use double instead of float.
//
// ****************************************************************************
void
avtCompactnessQuery::Get2DCellCentroid(vtkCell *cell,
float &xCent, float &yCent)
double &xCent, double &yCent)
{
xCent=0.;
yCent=0.;
......@@ -901,6 +913,6 @@ avtCompactnessQuery::Get2DCellCentroid(vtkCell *cell,
yCent += pt[1];
}
xCent /= float(npts);
yCent /= float(npts);
xCent /= double(npts);
yCent /= double(npts);
}
......@@ -78,6 +78,9 @@ class vtkCell;
// Kathleen Bonnell, Fri Sep 3 10:10:28 PDT 2004
// Added VerifyInput.
//
// Kathleen Biagas, Tue Apr 22 07:45:21 MST 2014
// Use double instead of float.
//
// ****************************************************************************
class QUERY_API avtCompactnessQuery : public avtTwoPassDatasetQuery
......@@ -94,8 +97,8 @@ class QUERY_API avtCompactnessQuery : public avtTwoPassDatasetQuery
protected:
int numDomains;
std::vector<float> xBound;
std::vector<float> yBound;
std::vector<double> xBound;
std::vector<double> yBound;
double totalXSectArea;
double totalRotVolume;
......@@ -121,9 +124,9 @@ class QUERY_API avtCompactnessQuery : public avtTwoPassDatasetQuery
virtual void PostExecute(void);
virtual void VerifyInput(void);
static void Get2DCellCentroid(vtkCell*,float&,float&);
static float Get2DCellArea(vtkCell*);
static float Get2DTriangleArea(double*,double*,double*);
static void Get2DCellCentroid(vtkCell*,double&,double&);
static double Get2DCellArea(vtkCell*);
static double Get2DTriangleArea(double*,double*,double*);
};
......
......@@ -123,6 +123,9 @@ avtEllipticalCompactnessFactorQuery::~avtEllipticalCompactnessFactorQuery()
// Jeremy Meredith, Thu Feb 15 11:55:03 EST 2007
// Call inherited PreExecute before everything else.
//
// Kathleen Biagas, Tue Apr 22 07:51:19 MST 2014
// Use double instead of float.
//
// ****************************************************************************
void
......@@ -134,12 +137,12 @@ avtEllipticalCompactnessFactorQuery::PreExecute(void)
centroid[i] = 0.;
total_volume = 0.;
bounds[0] = +FLT_MAX;
bounds[1] = -FLT_MAX;
bounds[2] = +FLT_MAX;
bounds[3] = -FLT_MAX;
bounds[4] = +FLT_MAX;
bounds[5] = -FLT_MAX;
bounds[0] = +DBL_MAX;
bounds[1] = -DBL_MAX;
bounds[2] = +DBL_MAX;
bounds[3] = -DBL_MAX;
bounds[4] = +DBL_MAX;
bounds[5] = -DBL_MAX;
}
......@@ -157,6 +160,9 @@ avtEllipticalCompactnessFactorQuery::PreExecute(void)
// Fixed parallel bug: Extents need to be unified across all processors
// before trying to calculate the ellipsoid axes.
//
// Kathleen Biagas, Tue Apr 22 07:51:19 MST 2014
// Use double instead of float.
//
// ****************************************************************************
void
......@@ -196,33 +202,33 @@ avtEllipticalCompactnessFactorQuery::MidExecute(void)
//
if (is2D)
{
float Amax = ((bounds[1] - bounds[0]) / 2.)*1.5;
float Bmax = (bounds[3])*1.5;
float Bmin = sqrt(total_volume * 0.75 / (M_PI*Amax));
double Amax = ((bounds[1] - bounds[0]) / 2.)*1.5;
double Bmax = (bounds[3])*1.5;
double Bmin = sqrt(total_volume * 0.75 / (M_PI*Amax));
for (int i = 0 ; i < numGuesses ; i++)
{
y_radius[i] = Bmin + (Bmax-Bmin)*((float)i/(float)numGuesses);
y_radius[i] = Bmin + (Bmax-Bmin)*((double)i/(double)numGuesses);
z_radius[i] = y_radius[i];
x_radius[i] = total_volume*0.75 / (M_PI*y_radius[i]*z_radius[i]);
}
}
else
{
float Amax = ((bounds[1] - bounds[0]) / 2.)*1.5;
float Bmax = ((bounds[3] - bounds[2]) / 2.)*1.5;
float Cmax = ((bounds[5] - bounds[4]) / 2.)*1.5;
float Amin = sqrt(total_volume * 0.75 / (M_PI*Bmax*Cmax));
float Bmin = sqrt(total_volume * 0.75 / (M_PI*Amax*Cmax));
float Cmin = sqrt(total_volume * 0.75 / (M_PI*Amax*Bmax));
double Amax = ((bounds[1] - bounds[0]) / 2.)*1.5;
double Bmax = ((bounds[3] - bounds[2]) / 2.)*1.5;
double Cmax = ((bounds[5] - bounds[4]) / 2.)*1.5;
double Amin = sqrt(total_volume * 0.75 / (M_PI*Bmax*Cmax));
double Bmin = sqrt(total_volume * 0.75 / (M_PI*Amax*Cmax));
double Cmin = sqrt(total_volume * 0.75 / (M_PI*Amax*Bmax));
// Get integer square root.
int dims = (int) ceil(sqrt(numGuesses-0.1));
for (int i = 0 ; i < dims ; i++)
{
float A = Amin + (Amax-Amin)*((float)i/(float)dims);
double A = Amin + (Amax-Amin)*((double)i/(double)dims);
for (int j = 0 ; j < dims ; j++)
{
float B = Bmin + (Bmax-Bmin)*((float)j/(float)dims);
float C = total_volume*0.75 / (M_PI*A*B);
double B = Bmin + (Bmax-Bmin)*((double)j/(double)dims);
double C = total_volume*0.75 / (M_PI*A*B);
int index = i*dims+j;
x_radius[index] = A;
y_radius[index] = B;
......@@ -326,6 +332,10 @@ avtEllipticalCompactnessFactorQuery::PostExecute(void)
// Programmer: Hank Childs
// Creation: May 8, 2006
//
// Modifications:
// Kathleen Biagas, Tue Apr 22 07:51:19 MST 2014
// Use double instead of float for volume.
//
// ****************************************************************************
void
......@@ -345,7 +355,7 @@ avtEllipticalCompactnessFactorQuery::Execute1(vtkDataSet *ds, const int dom)
vtkCell *cell = ds->GetCell(i);
double center[3];
vtkVisItUtility::GetCellCenter(cell, center);
float volume = var->GetTuple1(i);
double volume = var->GetTuple1(i);
volume = (volume < 0 ? -volume : volume);
centroid[0] += volume*center[0];
centroid[1] += volume*center[1];
......@@ -371,6 +381,10 @@ avtEllipticalCompactnessFactorQuery::Execute1(vtkDataSet *ds, const int dom)
// Programmer: Hank Childs
// Creation: May 8, 2006
//
// Modifications:
// Kathleen Biagas, Tue Apr 22 07:51:19 MST 2014
// Use double instead of float for volume.
//
// ****************************************************************************
void
......@@ -383,7 +397,7 @@ avtEllipticalCompactnessFactorQuery::Execute2(vtkDataSet *ds, const int dom)
{
EXCEPTION0(ImproperUseException);
}
float d[3];
double d[3];
for (int i = 0 ; i < nCells ; i++)
{
if (ghosts != NULL && ghosts->GetTuple1(i) != 0.)
......@@ -394,11 +408,11 @@ avtEllipticalCompactnessFactorQuery::Execute2(vtkDataSet *ds, const int dom)
d[0] = center[0] - ellipse_center[0];
d[1] = center[1] - ellipse_center[1];
d[2] = center[2] - ellipse_center[2];
float volume = var->GetTuple1(i);
double volume = var->GetTuple1(i);
volume = (volume < 0 ? -volume : volume);
for (int j = 0 ; j < numGuesses ; j++)
{
float dist = 0;
double dist = 0;
dist += d[0]*d[0] / (x_radius[j]*x_radius[j]);
dist += d[1]*d[1] / (y_radius[j]*y_radius[j]);
dist += d[2]*d[2] / (z_radius[j]*z_radius[j]);
......
......@@ -249,6 +249,10 @@ avtSphericalCompactnessFactorQuery::PostExecute(void)
// Programmer: Hank Childs
// Creation: July 14, 2005
//
// Modifications:
// Kathleen Biagas, Tue Apr 22 07:54:11 MST 2014
// Use double instead of float.
//
// ****************************************************************************
void
......@@ -268,7 +272,7 @@ avtSphericalCompactnessFactorQuery::Execute1(vtkDataSet *ds, const int dom)
vtkCell *cell = ds->GetCell(i);
double center[3];
vtkVisItUtility::GetCellCenter(cell, center);
float volume = var->GetTuple1(i);
double volume = var->GetTuple1(i);
volume = (volume < 0 ? -volume : volume);
centroid[0] += volume*center[0];
centroid[1] += volume*center[1];
......@@ -288,6 +292,10 @@ avtSphericalCompactnessFactorQuery::Execute1(vtkDataSet *ds, const int dom)
// Programmer: Hank Childs
// Creation: July 14, 2005
//
// Modifications:
// Kathleen Biagas, Tue Apr 22 07:54:11 MST 2014
// Use double instead of float.
//
// ****************************************************************************
void
......@@ -300,7 +308,7 @@ avtSphericalCompactnessFactorQuery::Execute2(vtkDataSet *ds, const int dom)
{
EXCEPTION0(ImproperUseException);
}
float rad_squared = radius*radius;
double rad_squared = radius*radius;
for (int i = 0 ; i < nCells ; i++)
{
if (ghosts != NULL && ghosts->GetTuple1(i) != 0.)
......@@ -308,12 +316,12 @@ avtSphericalCompactnessFactorQuery::Execute2(vtkDataSet *ds, const int dom)
vtkCell *cell = ds->GetCell(i);
double center[3];
vtkVisItUtility::GetCellCenter(cell, center);
float dist = (center[0]-sphere_center[0])*(center[0]-sphere_center[0])
double dist = (center[0]-sphere_center[0])*(center[0]-sphere_center[0])
+ (center[1]-sphere_center[1])*(center[1]-sphere_center[1])
+ (center[2]-sphere_center[2])*(center[2]-sphere_center[2]);
if (dist > rad_squared)
continue; // Not inside.
float volume = var->GetTuple1(i);
double volume = var->GetTuple1(i);
volume = (volume < 0 ? -volume : volume);
volume_inside += volume;
}
......
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