Ejemplo n.º 1
0
bool OSUFlow::DeferredLoadData() 
{
  if (deferred_load_case == -1) return(false); 

  switch(deferred_load_case) {
  case 0: 
    if(bStaticFlow) {
      InitStaticFlowField();
    }
    else
      InitTimeVaryingFlowField();
    has_data = true; 
    break; 
  case 1: 
    if(bStaticFlow) {
      InitStaticFlowField(lMin, lMax);
    }
    else
      InitTimeVaryingFlowField(lMin, lMax); 
    has_data = true; 
    break; 
  case 2: 
    if(bStaticFlow) {  // ignore the time range 
      InitStaticFlowField(lMin, lMax);
    }
    else
      InitTimeVaryingFlowField(lMin, lMax, MinT, MaxT); 
    has_data = true; 
    break; 
  }
  ScaleField(10.0); 
  return(true); 
}
Ejemplo n.º 2
0
void OSUFlow::InitStaticFlowField(VECTOR3 sMin, VECTOR3 sMax)
{
	FILE *fIn;
	int dimension[3], totalNum;
	float* pData = NULL;
	int lxdim, lydim, lzdim; 
	
	fIn = fopen(flowName, "rb");
	assert(fIn != NULL);
	fread(dimension, sizeof(int), 3, fIn);
	gMin.Set(0.0,0.0,0.0); 
	gMax.Set((float)(dimension[0]-1), (float)(dimension[1]-1), (float)(dimension[2]-1));
	lxdim = sMax[0]-sMin[0]+1; 
	lydim = sMax[1]-sMin[1]+1; 
	lzdim = sMax[2]-sMin[2]+1; 
	
	totalNum = lxdim*lydim*lzdim; 
	pData = new float[totalNum * 3];
	float *p = pData; 
	for (int z = sMin[2]; z<=sMax[2]; z++) {
	  for (int y = sMin[1]; y<=sMax[1]; y++) {
	    long offset = (z*dimension[0]*dimension[1]+y*dimension[0]+sMin[0])*3*4; 
	    fseek(fIn, offset, SEEK_SET); 
	    int size = (sMax[0]-sMin[0]+1)*3; 
	    fread(p, sizeof(float), size, fIn); 
	    p+=size; 
	  }
	}
	fclose(fIn);
    InitStaticFlowField(pData, sMin, sMax); 
}
Ejemplo n.º 3
0
/////////////////////////////////////////////////////////////
//
//   Read a partial data set 
//   sMin/sMax are local min and max range of the data that are held 
//
void OSUFlow::LoadData(const char* fname, bool bStatic,
		       VECTOR3 sMin, VECTOR3 sMax, bool deferred)  
{
	flowName = new char[255];
	strcpy(flowName, fname);
	bStaticFlow = bStatic;
	lMin = sMin; lMax = sMax; 
	has_data = false; 

	if(bStaticFlow) {
	  numTimesteps = 1; 
	  MinT = MaxT = 0; 
	  if (deferred == true) {
	    deferred_load_case = 1; 
	    return; 
	  }
	  InitStaticFlowField(sMin, sMax);
	}
	else {
	  if (deferred == true) {
	    deferred_load_case = 1; 
	    return; 
	  }
	  InitTimeVaryingFlowField(sMin, sMax); 
	}
	has_data = true; 
}
Ejemplo n.º 4
0
void OSUFlow::LoadData(const char* fname, bool bStatic)
{
	flowName = new char[255];
	strcpy(flowName, fname);

	bStaticFlow = bStatic;

	if(bStaticFlow)
		InitStaticFlowField();
	else
		InitTimeVaryingFlowField();
}
Ejemplo n.º 5
0
//sMin/sMax are local min and max range of the data that are held within 
void OSUFlow::LoadData(const char* fname, bool bStatic, 
		       VECTOR3 sMin, VECTOR3 sMax)  
{
	flowName = new char[255];
	strcpy(flowName, fname);

	bStaticFlow = bStatic;

	if(bStaticFlow)
	  InitStaticFlowField(sMin, sMax);
	else
	  InitTimeVaryingFlowField(); // to be implemented 
}
Ejemplo n.º 6
0
//added by lijie to read static irregular grid
void OSUFlow::InitStaticIrregularFlowField(VECTOR3 sMin, VECTOR3 sMax)
{
        int dimension[3], totalNum;
	int lxdim, lydim, lzdim; 

	char fsz[255],gsz[255],hsz[255];
	sprintf(fsz,"%s.soln",flowName);
	sprintf(gsz,"%s.grid",flowName);
	sprintf(hsz,"%s.tetra",flowName);
	CPlot3DReader* reader=new CPlot3DReader(fsz,gsz,hsz);

	Solution* pSol=reader->CreateSolution();
	IrregularGrid* pGrid=reader->CreateIrregularGrid(false,false);

       InitStaticFlowField(pSol, pGrid, sMin, sMax); 
	delete reader;
}
Ejemplo n.º 7
0
/////////////////////////////////////////////////////////////
//
//  Load a partial time-varying data set 
//  sMin/sMax are local min and max range of the data that are held
//  t_min/t_max are the time range (for time-varying field) 
//
void OSUFlow::LoadData(const char* fname, bool bStatic,
		       VECTOR3 sMin, VECTOR3 sMax, int min_t, int max_t, 
		       bool deferred)  
{
	flowName = new char[255];
	strcpy(flowName, fname);

	bStaticFlow = bStatic;
	lMin = sMin; lMax = sMax; 
	has_data = false; 

	if (max_t >= min_t) {
	  numTimesteps = max_t-min_t+1; 
	  MinT = min_t; MaxT = max_t; 
	}
	else {   //exception. goes back to default 
	  numTimesteps = 1; 
	  MinT = MaxT = min_t; 
	}
	  
	if(bStaticFlow) {  // ignore the time range 
	  numTimesteps = 1; 
	  MinT = MaxT = 0; 
	  if (deferred == true) {
	    deferred_load_case = 2; 
	    return; 
	  }
	  InitStaticFlowField(sMin, sMax);
	}
	else {
	  if (deferred == true) {
	    deferred_load_case = 2; 
	    return; 
	  }
	  InitTimeVaryingFlowField(sMin, sMax, min_t, max_t); 
	}
	has_data = true; 
}