Commit 64b3e536 authored by hrchilds's avatar hrchilds

Update from March 19, 2006

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@640 18c085ea-50e0-402c-830e-de6fd14e8384
parent d80e8115
......@@ -25,6 +25,14 @@ class vtkDataSet;
// Programmer: Hank Childs
// Creation: January 21, 2006 (originally in avtPosCMFEExpression)
//
// Modifications:
//
// Hank Childs, Sat Mar 18 09:42:29 PST 2006
// Add support for rectilinear desired points. Also have
// FastLookupGrouping cache lists of overlapping elements, so that
// subsequent searches can use this as a guess rather than traversing
// the interval tree.
//
// ****************************************************************************
class EXPRESSION_API avtPosCMFEAlgorithm
......@@ -38,6 +46,26 @@ class EXPRESSION_API avtPosCMFEAlgorithm
class DesiredPoints
{
//
// DesiredPoints is a tricky class because of two subtleties.
// First: It has two ways to store data. It stores rectilinear grids
// one way and other grids another way. Further, its interface tries
// to unify them in places and not unify them in other places. For
// example, pt_list and pt_list_size correspond to non-rectilinear grids,
// while rgrid_pts and rgrid_pts_size correspond to rectilinear grids.
// But total_nvals corresponds to the total number of values across both.
// The thinking is that the interface for the class should be
// generalized, except where having knowledge of rectilinear layout will
// impact performance, such as is the case for pivot finding. Of course,
// the bookkeeping under the covers is difficult.
//
// The other subtlety is the two forms this object will take. Before
// calling "RelocatePointsUsingSpatialPartition", this object contains
// the desired points for this processor. But, after the call, it
// contains the desired points for this processor's spatial partition.
// When "UnRelocatePoints" is called, it switches back to the desired
// points for this processor. Again, bookkeeping overhead causes the
// coding of this class to be more complex.
public:
DesiredPoints(bool, int);
virtual ~DesiredPoints();
......@@ -45,8 +73,12 @@ class EXPRESSION_API avtPosCMFEAlgorithm
void AddDataset(vtkDataSet *);
void Finalize();
int GetNumberOfPoints() {return total_nvals;};
int GetNumberOfPoints() { return total_nvals; };
int GetRGridStart() { return rgrid_start; };
int GetNumberOfRGrids() { return num_rgrids; };
void GetPoint(int, float *) const;
void GetRGrid(int, const float *&, const float *&,
const float *&, int &, int &, int &);
void SetValue(int, float *);
const float *GetValue(int, int) const;
......@@ -59,15 +91,27 @@ class EXPRESSION_API avtPosCMFEAlgorithm
int nComps;
int total_nvals;
int num_datasets;
int num_rgrids;
int rgrid_start;
vector<float *> pt_list;
vector<int> pt_list_size;
vector<float *> rgrid_pts;
vector<int> rgrid_pts_size;
int *map_to_ds;
int *ds_start;
float *vals;
vector<float *> orig_pt_list;
vector<int> orig_pt_list_size;
vector<int> num_return_to_proc;
vector<float *> orig_rgrid_pts;
vector<int> orig_rgrid_pts_size;
vector<int> pt_list_came_from;
vector<int> rgrid_came_from;
void GetProcessorsForGrid(int, std::vector<int> &,
std::vector<float> &,
SpatialPartition &);
bool GetSubgridForBoundary(int, float *, int *);
};
class FastLookupGrouping
......@@ -83,6 +127,8 @@ class EXPRESSION_API avtPosCMFEAlgorithm
void RelocateDataUsingPartition(SpatialPartition &);
bool GetValue(const float *, float *);
bool GetValueUsingList(std::vector<int> &, const float *,
float *);
protected:
std::string varname;
......@@ -92,6 +138,7 @@ class EXPRESSION_API avtPosCMFEAlgorithm
avtIntervalTree *itree;
int *map_to_ds;
int *ds_start;
std::vector<int> list_from_last_successful_search;
};
class SpatialPartition
......@@ -106,6 +153,8 @@ class EXPRESSION_API avtPosCMFEAlgorithm
int GetProcessor(float *);
int GetProcessor(vtkCell *);
void GetProcessorList(vtkCell *, std::vector<int> &);
void GetProcessorBoundaries(float *,
std::vector<int> &, std::vector<float> &);
protected:
avtIntervalTree *itree;
......
......@@ -4,41 +4,7 @@
#include <avtPosCMFEExpression.h>
#include <float.h>
#include <math.h>
#ifdef PARALLEL
#include <mpi.h>
#endif
#include <vtkAppendFilter.h>
#include <vtkCellData.h>
#include <vtkCellLocator.h>
#include <vtkCharArray.h>
#include <vtkDataArray.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkGenericCell.h>
#include <vtkPointData.h>
#include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridRelevantPointsFilter.h>
#include <vtkUnstructuredGridWriter.h>
#include <vtkUnstructuredGridReader.h>
#include <Utility.h>
#include <vtkVisItUtility.h>
#include <avtCommonDataFunctions.h>
#include <avtDatasetExaminer.h>
#include <avtIntervalTree.h>
#include <avtParallel.h>
#include <avtPosCMFEAlgorithm.h>
#include <avtSILRestrictionTraverser.h>
#include <DebugStream.h>
#include <ExpressionException.h>
#include <InvalidMergeException.h>
#include <TimingsManager.h>
// ****************************************************************************
......
......@@ -8,6 +8,7 @@
#include <vtkCell.h>
#include <vtkCellData.h>
#include <vtkGenericCell.h>
#include <vtkHexahedron.h>
#include <vtkIntArray.h>
#include <vtkPointData.h>
#include <vtkPointSet.h>
......@@ -807,3 +808,87 @@ vtkVisItUtility::ContainsMixedGhostZoneTypes(vtkDataSet *ds)
}
return mixed;
}
// ****************************************************************************
// Function: CellContainsPoint
//
// Purpose:
// Tests whether or not a cell contains a point. Does this by testing
// the side the point lies on each face of the cell.
//
// Programmer: Hank Childs
// Creation: March 18, 2006
//
// ****************************************************************************
bool
vtkVisItUtility::CellContainsPoint(vtkCell *cell, const float *pt)
{
int cellType = cell->GetCellType();
if (cellType == VTK_HEXAHEDRON)
{
vtkHexahedron *hex = (vtkHexahedron *) cell;
vtkPoints *pts = hex->GetPoints();
float *pts_ptr = (float *) pts->GetVoidPointer(0);
static int faces[6][4] = { {0,4,7,3}, {1,2,6,5},
{0,1,5,4}, {3,7,6,2},
{0,3,2,1}, {4,5,6,7} };
for (int i = 0 ; i < 6 ; i++)
{
float dir1[3], dir2[3];
int idx0 = faces[i][0];
int idx1 = faces[i][1];
int idx2 = faces[i][3];
dir1[0] = pts_ptr[3*idx1] - pts_ptr[3*idx0];
dir1[1] = pts_ptr[3*idx1+1] - pts_ptr[3*idx0+1];
dir1[2] = pts_ptr[3*idx1+2] - pts_ptr[3*idx0+2];
dir2[0] = pts_ptr[3*idx0] - pts_ptr[3*idx2];
dir2[1] = pts_ptr[3*idx0+1] - pts_ptr[3*idx2+1];
dir2[2] = pts_ptr[3*idx0+2] - pts_ptr[3*idx2+2];
float cross[3];
cross[0] = dir1[1]*dir2[2] - dir1[2]*dir2[1];
cross[1] = dir1[2]*dir2[0] - dir1[0]*dir2[2];
cross[2] = dir1[0]*dir2[1] - dir1[1]*dir2[0];
float origin[3];
origin[0] = pts_ptr[3*idx0];
origin[1] = pts_ptr[3*idx0+1];
origin[2] = pts_ptr[3*idx0+2];
//
// The plane is of the form Ax + By + Cz - D = 0.
//
// Using the origin, we can calculate D:
// D = A*origin[0] + B*origin[1] + C*origin[2]
//
// We want to know if 'pt' gives:
// A*pt[0] + B*pt[1] + C*pt[2] - D >=? 0.
//
// We can substitute in D to get
// A*(pt[0]-origin[0]) + B*(pt[1]-origin[1]) + C*(pt[2-origin[2])
// ?>= 0
//
float val = cross[0]*(pt[0] - origin[0])
+ cross[1]*(pt[1] - origin[1])
+ cross[2]*(pt[2] - origin[2]);
if (val < 0.)
return false;
}
return true;
}
float closestPt[3];
int subId;
float pcoords[3];
float dist2;
float weights[100]; // MUST BE BIGGER THAN NPTS IN A CELL (ie 8).
float non_const_pt[3];
non_const_pt[0] = pt[0];
non_const_pt[1] = pt[1];
non_const_pt[2] = pt[2];
return (cell->EvaluatePosition(non_const_pt, closestPt, subId,
pcoords, dist2, weights) > 0);
}
......@@ -12,6 +12,14 @@ class vtkDataSet;
class vtkPoints;
class vtkRectilinearGrid;
// ****************************************************************************
// Modifications:
//
// Hank Childs, Sat Mar 18 14:16:09 PST 2006
// Added function CellContainsPoint.
//
// ****************************************************************************
namespace vtkVisItUtility
{
VISIT_VTK_LIGHT_API vtkPoints *GetPoints(vtkDataSet *);
......@@ -41,6 +49,7 @@ namespace vtkVisItUtility
VISIT_VTK_LIGHT_API void GetCellCenter(vtkCell* cell, float center[3]);
VISIT_VTK_LIGHT_API bool ContainsMixedGhostZoneTypes(vtkDataSet *);
VISIT_VTK_LIGHT_API bool CellContainsPoint(vtkCell *, const float *);
}
#endif
......
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