示例#1
0
static void test(buffer *buf)
{
  const double *const x_base[D]=INITD(testx,testx+1,testx+2);
  const unsigned x_stride[D]=
    INITD(D*sizeof(double),D*sizeof(double),D*sizeof(double));
  struct findpts_local_data fld;
  rand_mesh();
  test_mesh();
  findpts_local_setup(&fld,elx,nr,NEL,mr,BBOX_TOL,MAX_HASH_SIZE,
                      NPT_MAX,NEWT_TOL);
  findpts_local(&testp[0].code , sizeof(struct pt_data),
                &testp[0].el   , sizeof(struct pt_data),
                 testp[0].r    , sizeof(struct pt_data),
                &testp[0].dist2, sizeof(struct pt_data),
                x_base, x_stride,
                NEL*MULD(TN,TN,TN), &fld, buf);
  findpts_local_free(&fld);
  print_ptdata();
}
avtIVPNek5000Field::avtIVPNek5000Field( vtkDataSet* dataset, 
                                        avtCellLocator* locator) :
  avtIVPVTKField( dataset, locator )
{
  vtkFieldData *fieldData = dataset->GetFieldData();

  // Pick off all of the data stored with the vtk field.
  vtkUnstructuredGrid *ugrid = (vtkUnstructuredGrid*) dataset;

  vtkPoints *pts = ugrid->GetPoints();
  if (pts == NULL) {
    EXCEPTION1( InvalidVariableException,
                "avtIVPNek5000Field - Can not find vertices." );
  }

  vtkDataArray *vecs = ugrid->GetPointData()->GetVectors();
  if (vecs == NULL) {
    EXCEPTION1( InvalidVariableException,
                "avtIVPNek5000Field - Can not find velocity variable." );
  }

  // Get the number of point per spectrial elements
  unsigned int iDim = 0;
  unsigned int iBlockSize[3] = {0,0,0};
  unsigned int iNumBlocks = 0;
  unsigned int npts = 1;

  vtkIntArray *semVTK =
    (vtkIntArray *) fieldData->GetAbstractArray("Nek_SpectralElementData");  

  if( semVTK )
  {
    iBlockSize[0] = semVTK->GetValue(0);
    iBlockSize[1] = semVTK->GetValue(1);
    iBlockSize[2] = semVTK->GetValue(2);
    iNumBlocks    = semVTK->GetValue(3);

    if( iBlockSize[2] > 1 )
      iDim = 3;
    else
      iDim = 2;
  }
  else 
  {
    EXCEPTION1( InvalidVariableException,
                "Uninitialized option. (Please contact visit-developer mailing list to report)" );
  }

  unsigned int iBlockSize2[3] = { 2*iBlockSize[0],
                                  2*iBlockSize[1],
                                  2*iBlockSize[2] };

  unsigned int pts_per_element = iBlockSize[0] * iBlockSize[1];
  if (iDim == 3)
    pts_per_element *= iBlockSize[2];
 
  // Get the numver of elements for checking the validity of the data.
  unsigned int num_elements = pts->GetNumberOfPoints() / pts_per_element;

  if( num_elements != iNumBlocks )
  {
    std::string str("The number of elements available for advection does not "
                    "match the number blocks in the dataset. As such, curves "
                    "may not be advected across element boundaries. "
                    "This can occur when the Nek5000 file contains boundary or "
                    "extents meta data. In the 'Advanced' tab select "
                    "'Parallelization' to be 'Parallelize over domains'.");

    avtCallback::IssueWarning(str.c_str());
  }

  unsigned int hexes_per_element = (iBlockSize[0]-1)*(iBlockSize[1]-1);
  if (iDim == 3)
    hexes_per_element *= (iBlockSize[2]-1);

  // Move the vertices from the VTK structure into a form that Nek5000
  // uses.
  nek_pts[0] = new double[pts_per_element*num_elements];
  nek_pts[1] = new double[pts_per_element*num_elements];
  nek_pts[2] = new double[pts_per_element*num_elements];

  // Get the pointer to the points that make up the spetral element.
  int pts_type = pts->GetDataType();

  if( pts_type == VTK_FLOAT ) {
    float *pts_ptr = (float*) pts->GetVoidPointer(0);

    for( unsigned int i=0; i<pts_per_element*num_elements; ++i )
    {
      nek_pts[0][i] = pts_ptr[i*3+0];
      nek_pts[1][i] = pts_ptr[i*3+1];
      nek_pts[2][i] = pts_ptr[i*3+2];
    }
  } else if( pts_type == VTK_DOUBLE ) {
    double *pts_ptr = (double*) pts->GetVoidPointer(0);

    for( unsigned int i=0; i<pts_per_element*num_elements; ++i )
    {
      nek_pts[0][i] = pts_ptr[i*3+0];
      nek_pts[1][i] = pts_ptr[i*3+1];
      nek_pts[2][i] = pts_ptr[i*3+2];
    }
  }
  else {
    EXCEPTION1( InvalidVariableException,
                "avtIVPNek5000Field - Expected single or double precison floating point vertices." );
  }

  // Move the vectors from the VTK structure into a form that Nek5000
  // uses.
  nek_vec[0] = new double[pts_per_element*num_elements];
  nek_vec[1] = new double[pts_per_element*num_elements];
  nek_vec[2] = new double[pts_per_element*num_elements];

  // Get the pointer to the vectors that make up the spetral element.
  if( vecs->GetNumberOfComponents() != 3 ) {
    EXCEPTION1( InvalidVariableException,
                "avtIVPNek5000Field - Velocity variable does not contain three components." );
  }

  int vec_type = vecs->GetDataType();

  if( vec_type == VTK_FLOAT ) {
    float *vec_ptr = (float*) vecs->GetVoidPointer(0);

    for( unsigned int i=0; i<pts_per_element*num_elements; ++i )
    {
      nek_vec[0][i] = vec_ptr[i*3+0];
      nek_vec[1][i] = vec_ptr[i*3+1];
      nek_vec[2][i] = vec_ptr[i*3+2];
    }
  } else if( vec_type == VTK_DOUBLE ) {
    double *vec_ptr = (double*) vecs->GetVoidPointer(0);

    for( unsigned int i=0; i<pts_per_element*num_elements; ++i )
    {
      nek_vec[0][i] = vec_ptr[i*3+0];
      nek_vec[1][i] = vec_ptr[i*3+1];
      nek_vec[2][i] = vec_ptr[i*3+2];
    }
  }
  else {
    EXCEPTION1( InvalidVariableException,
                "avtIVPNek5000Field - Expected single or double precison floating point vectors." );
  }

  // Create the internal Nek5000 field
  nek_fld = findpts_local_setup(iDim, nek_pts, iBlockSize, num_elements,
                                iBlockSize2, 0.01, pts_per_element*num_elements,
                                npts, 1024.0*std::numeric_limits<double>::epsilon());
}