Example #1
0
int get_elem_elev(HashTable *NodeTable, MatProps *matprops, 
		   Element *EmTemp, double *elevation){
  int j;
  double resolution, xcoord, ycoord;
  Node *NdTemp;


  NdTemp = (Node*) NodeTable->lookup(EmTemp->pass_key());

  if(NdTemp == NULL){
    //printf("\"start\" of get_elem_elev return(1)\n"); fflush(stdout);
    j = Get_max_resolution(&resolution);
    if(j != 0) {
      printf("error in Get_max_resolution\n");
      exit(1);
    }    

    xcoord = *(EmTemp->get_coord())*(matprops->LENGTH_SCALE);
    ycoord = *(EmTemp->get_coord()+1)*(matprops->LENGTH_SCALE);
    //printf("elev_ptr=%d, ",(int) elevation);
    j = Get_elevation(resolution, xcoord, ycoord, elevation);
    //printf("elev_ptr=%d\n",(int) elevation);
    if(j != 0) {
      printf("error in Get_elevation\n");
      exit(1);
    }   
    //printf("End of get_elem_elev return(1)\n"); fflush(stdout);
    return(1);
  }
  else{
    *elevation = NdTemp->get_elevation()*(matprops->LENGTH_SCALE);
    return(0);
  }
}
Node:: Node(unsigned* keyi, double* coordi, MatProps* matprops_ptr)
{
  int      i;
  nextptr =0;
  preptr = 0;
  
  info   = INIT;
	 
  for(i=0; i<DIMENSION; i++)
    coord[i] = *(coordi+i);
  
  for(i=0; i<KEYLENGTH; i++)
    key[i] = *(keyi+i);
  dof[0] = INIT;
  dof[1] = INIT;
  // find the max resolution of the GIS info and then get the elevation at this node
  double resolution = 0;
  double xcoord = coord[0]*(matprops_ptr->LENGTH_SCALE);
  double ycoord = coord[1]*(matprops_ptr->LENGTH_SCALE);
  i = Get_max_resolution(&resolution);
  if(i != 0) {
    printf("error in Get_max_resolution\n");
    exit(1);
  }    
  i = Get_elevation(resolution, xcoord, ycoord, &elevation);
  if(i != 0) {
    printf("error in Get_elevation\n");
    exit(1);
  }    
  elevation = elevation/matprops_ptr->LENGTH_SCALE;
}
Example #3
0
Node:: Node(unsigned* keyi, double* coordi, MatProps* matprops_ptr)
{
  int      i;
  id     =0;  /* keith added this so save_node wouldn't write an uninitialized
		 variable and valgrind wouldn't flag an error.  id is used in
		 ../repartition/BSFC_update_and_send_elements.C */
  order  =0;  /* keith added this for no good reason, so if you don't know 
		 that this is right find out, keith isn't responsible for 
		 any errors it may cause because right now the node order 
		 is unused, it shouldn't be used, but I wanted to see if 
		 assigning it zero gets rid of what looks like a "self 
		 contained" memory error
	      */
  nextptr =0;
  preptr = 0;
  sol    = 0;
  sol_deleted = 0;

  connection_id = -1;
  
  info   = INIT;
	 
  for(i=0; i<DIMENSION; i++)
    coord[i] = *(coordi+i);
  
  for(i=0; i<KEYLENGTH; i++)
    key[i] = *(keyi+i);
  dof[0] = INIT;
  dof[1] = INIT;
  zero_flux();
  // find the max resolution of the GIS info and then get the elevation at this node
  double resolution = 0;
  double xcoord = coord[0]*(matprops_ptr->LENGTH_SCALE);
  double ycoord = coord[1]*(matprops_ptr->LENGTH_SCALE);
  i = Get_max_resolution(&resolution);
  if(i != 0) {
    printf("error in Get_max_resolution\n");
    exit(1);
  }    
  i = Get_elevation(resolution, xcoord, ycoord, &elevation);
  if(i != 0) {
    printf("error in Get_elevation(%d) r=%g (x,y)=(%g,%g) e=%g\n",i,resolution,xcoord,ycoord,elevation);
    exit(1);
  }    
  elevation = elevation/matprops_ptr->LENGTH_SCALE;
/*  if((unsigned) 1548032885 == key[0])
    printf("created the missing node...\n"); */

/*
  if((coord[0]==0)||(coord[1]==0)){
    printf("node={%u,%u} coord=(%20g,%20g)\n",key[0],key[1],coord[0],coord[1]);
    assert(coord[0]*coord[1]);
  }
*/
}
Example #4
0
Node::Node(unsigned* keyi, double* coordi, int inf, int ord, MatProps* matprops_ptr)  //for refined
{
  int      i;
  id     =0;  /* keith added this so save_node wouldn't write an uninitialized
		 variable and valgrind wouldn't flag an error.  id is used in
		 ../repartition/BSFC_update_and_send_elements.C */

  nextptr =0;
  preptr = 0;
  sol    = 0;
  sol_deleted = 0;
  connection_id = -1; 
  info   = INIT;
  
  for(i=0; i<DIMENSION; i++)
    coord[i] = *(coordi+i);
  
  for(i=0; i<KEYLENGTH; i++)
    key[i] = *(keyi+i);
  dof[0] = INIT;
  dof[1] = INIT;
  
  info=inf;
  order=ord;
  //geoflow stuff
  zero_flux();
  // find the max resolution of the GIS info and then get the elevation at this node
  double resolution = 0;
  i = Get_max_resolution(&resolution);
  if(i != 0) {
    printf("error in Get_max_resolution\n");
    exit(1);
  }    
  double xcoord = coord[0]*(matprops_ptr->LENGTH_SCALE);
  double ycoord = coord[1]*(matprops_ptr->LENGTH_SCALE);
  i = Get_elevation(resolution, xcoord, ycoord, &elevation);
  if(i != 0) {
    printf("error in Get_elevation\n");
    exit(1);
  }  
  elevation = elevation/matprops_ptr->LENGTH_SCALE;
/*  if((unsigned) 1548032885 == key[0])
    printf("created the missing node111111...\n");*/

/*
  if((coord[0]==0)||(coord[1]==0)){
    printf("node={%u,%u} coord=(%20g,%20g)\n",key[0],key[1],coord[0],coord[1]);
    assert(coord[0]*coord[1]);
  }
*/
  return;
}
Example #5
0
Node::Node(FILE* fp, MatProps* matprops_ptr) {

	FourBytes temp4;
	EightBytes temp8;
	//unsigned readspace[13];
	unsigned readspace[8];
	int Itemp = 0, itemp;

	//fread(readspace,sizeof(unsigned),13,fp);
	fread(readspace, sizeof(unsigned), 8, fp);

	//KEYLENGTH should be 2 but put it in a loop to make it generic.
	for (itemp = 0; itemp < KEYLENGTH; itemp++) {
		key[itemp] = readspace[Itemp++];
	}
	assert(Itemp == 2);

	//DIMENSION should be 2 but put it in a loop to make it generic.
	for (itemp = 0; itemp < DIMENSION; itemp++) {
		temp8.u[0] = readspace[Itemp++];
		temp8.u[1] = readspace[Itemp++];
		coord[itemp] = temp8.d;
	}
	assert(Itemp == 6);

	temp4.u = readspace[Itemp++];
	id = temp4.i;
	assert(Itemp == 7);

	temp4.u = readspace[Itemp++];
	info = temp4.i;
	assert(Itemp == 8);

	// find the max resolution of the GIS info and then get the elevation at this node
	double resolution = 0;
	double xcoord = coord[0] * (matprops_ptr->LENGTH_SCALE);
	double ycoord = coord[1] * (matprops_ptr->LENGTH_SCALE);
	int i = Get_max_resolution(&resolution);
	if (i != 0) {
		printf("error in Get_max_resolution\n");
		exit(1);
	}
	i = Get_elevation(resolution, xcoord, ycoord, &elevation);
	if (i != 0) {
		printf("error in Get_elevation\n");
		exit(1);
	}
	elevation = elevation / matprops_ptr->LENGTH_SCALE;

	return;
}
Example #6
0
void Node::set_elevation(MatProps* matprops_ptr) {
	double resolution = 0;
	double xcoord = coord[0] * (matprops_ptr->LENGTH_SCALE);
	double ycoord = coord[1] * (matprops_ptr->LENGTH_SCALE);
	int i = Get_max_resolution(&resolution);
	if (i != 0) {
		printf("error in Get_max_resolution\n");
		exit(1);
	}
	i = Get_elevation(resolution, xcoord, ycoord, &elevation);
	if (i != 0) {
		printf("error in Get_elevation\n");
		exit(1);
	}
	elevation = elevation / matprops_ptr->LENGTH_SCALE;

}
Example #7
0
Node::Node(unsigned* keyi, double* coordi, MatProps* matprops_ptr) {
	int i;
	id = 0; /* keith added this so save_node wouldn't write an uninitialized
	 variable and valgrind wouldn't flag an error.  id is used in
	 ../repartition/BSFC_update_and_send_elements.C */

	info = INIT;

	for (i = 0; i < DIMENSION; i++)
		coord[i] = *(coordi + i);

	for (i = 0; i < KEYLENGTH; i++)
		key[i] = *(keyi + i);

	zero_flux();
	// find the max resolution of the GIS info and then get the elevation at this node
	double resolution = 0;
	double xcoord = coord[0] * (matprops_ptr->LENGTH_SCALE);
	double ycoord = coord[1] * (matprops_ptr->LENGTH_SCALE);
	i = Get_max_resolution(&resolution);
	if (i != 0) {
		printf("error in Get_max_resolution\n");
		exit(1);
	}
	i = Get_elevation(resolution, xcoord, ycoord, &elevation);
	if (i != 0) {
		printf("error in Get_elevation(%d) r=%g (x,y)=(%g,%g) e=%g\n", i, resolution, xcoord, ycoord,
		    elevation);
		exit(1);
	}
	elevation = elevation / matprops_ptr->LENGTH_SCALE;
	/*  if((unsigned) 1548032885 == key[0])
	 printf("created the missing node...\n"); */

	/*
	 if((coord[0]==0)||(coord[1]==0)){
	 printf("node={%u,%u} coord=(%20g,%20g)\n",key[0],key[1],coord[0],coord[1]);
	 assert(coord[0]*coord[1]);
	 }
	 */
}
Example #8
0
int
get_elem_elev (HashTable * NodeTable, MatProps * matprops,
               Element * EmTemp, double *elevation)
{
  int j;
  double resolution, xcoord, ycoord;
  Node *NdTemp;


  NdTemp = (Node *) NodeTable->lookup (EmTemp->pass_key ());

  if (NdTemp == NULL)
    {
      j = Get_max_resolution (&resolution);
      if (j != 0)
        {
          printf ("error in Get_max_resolution\n");
          exit (1);
        }

      xcoord = *(EmTemp->get_coord ()) * (matprops->LENGTH_SCALE);
      ycoord = *(EmTemp->get_coord () + 1) * (matprops->LENGTH_SCALE);
      j = Get_elevation (resolution, xcoord, ycoord, elevation);
      if (j != 0)
        {
          printf ("error in Get_elevation\n");
          exit (1);
        }
      return (1);
    }
  else
    {
      *elevation = NdTemp->get_elevation () * (matprops->LENGTH_SCALE);
      return (0);
    }
}
Example #9
0
Node::Node(FILE* fp, MatProps* matprops_ptr) {

  sol=0;           //never USED anywhere in TITAN except when initialized
  sol_deleted=0;   //never USED anywhere in TITAN except when initialized
  nextptr=preptr=0;//never USED anywhere in TITAN except when initialized

  FourBytes  temp4;
  EightBytes temp8;
  //unsigned readspace[13];
  unsigned readspace[8];
  int Itemp=0, itemp;

  //fread(readspace,sizeof(unsigned),13,fp);
  fread(readspace,sizeof(unsigned),8,fp);

  //KEYLENGTH should be 2 but put it in a loop to make it generic.
  for(itemp=0;itemp<KEYLENGTH;itemp++) {
    key[itemp]=readspace[Itemp++];
  }
  assert(Itemp==2);

  //DIMENSION should be 2 but put it in a loop to make it generic.
  for(itemp=0;itemp<DIMENSION;itemp++) {
    temp8.u[0]=readspace[Itemp++];
    temp8.u[1]=readspace[Itemp++];
    coord[itemp]=temp8.d;
  }
  assert(Itemp==6);

  temp4.u=readspace[Itemp++];
  id=temp4.i;
  assert(Itemp==7);

  temp4.u=readspace[Itemp++];
  info=temp4.i;
  assert(Itemp==8);

  /* these are legacy and are not used
  temp4.u=readspace[Itemp++];
  order=temp4.i;
  assert(Itemp==9);

  temp4.u=readspace[Itemp++];
  dof[0]=temp4.i;
  temp4.u=readspace[Itemp++];
  dof[1]=temp4.i;
  assert(Itemp==11);

  temp4.u=readspace[Itemp++];
  glnum=temp4.i;
  assert(Itemp==12);

  temp4.u=readspace[Itemp++];
  reconstructed=temp4.i;
  assert(Itemp==13);
  */
  // find the max resolution of the GIS info and then get the elevation at this node
  double resolution = 0;
  double xcoord = coord[0]*(matprops_ptr->LENGTH_SCALE);
  double ycoord = coord[1]*(matprops_ptr->LENGTH_SCALE);
  int i = Get_max_resolution(&resolution);
  if(i != 0) {
    printf("error in Get_max_resolution\n");
    exit(1);
  }    
  i = Get_elevation(resolution, xcoord, ycoord, &elevation);
  if(i != 0) {
    printf("error in Get_elevation\n");
    exit(1);
  }    
  elevation = elevation/matprops_ptr->LENGTH_SCALE;

  return;
}