Esempio n. 1
0
char *ex_name_var_of_object(ex_entity_type obj_type, int i, int j)
{
  switch (obj_type) {
  case EX_EDGE_BLOCK: return VAR_EDGE_VAR(i, j);
  case EX_FACE_BLOCK: return VAR_FACE_VAR(i, j);
  case EX_ELEM_BLOCK: return VAR_ELEM_VAR(i, j);
  case EX_NODE_SET: return VAR_NS_VAR(i, j);
  case EX_EDGE_SET: return VAR_ES_VAR(i, j);
  case EX_FACE_SET: return VAR_FS_VAR(i, j);
  case EX_SIDE_SET: return VAR_SS_VAR(i, j);
  case EX_ELEM_SET: return VAR_ELS_VAR(i, j);
  default: return 0;
  }
}
Esempio n. 2
0
int ex_get_nset_var (int   exoid,
                     int   time_step,
                     int   nset_var_index,
                     int   nset_id, 
                     int   num_node_this_nset,
                     void *nset_var_vals)
{
   int varid, nset_id_ndx;
   long start[2], count[2];
   char errmsg[MAX_ERR_LENGTH];

   exerrval = 0; /* clear error code */

  /* Determine index of nset_id in VAR_NS_IDS array */
  nset_id_ndx = ex_id_lkup(exoid,VAR_NS_IDS,nset_id);
  if (exerrval != 0) 
  {
    if (exerrval == EX_NULLENTITY)
    {
      sprintf(errmsg,
              "Warning: no nodeset variables for NULL nodeset %d in file id %d",
              nset_id,exoid);
      ex_err("ex_get_nset_var",errmsg,EX_MSG);
      return (EX_WARN);
    }
    else
    {
      sprintf(errmsg,
     "Error: failed to locate nodeset id %d in %s variable in file id %d",
              nset_id, VAR_ID_EL_BLK, exoid);
      ex_err("ex_get_nset_var",errmsg,exerrval);
      return (EX_FATAL);
    }
  }


/* inquire previously defined variable */

   if((varid=ncvarid(exoid,VAR_NS_VAR(nset_var_index,nset_id_ndx))) == -1)
   {
     exerrval = ncerr;
     sprintf(errmsg,
          "Error: failed to locate nodeset variable %d for nodeset %d in file id %d",
          nset_var_index,nset_id,exoid); /* this msg needs to be improved */
     ex_err("ex_get_nset_var",errmsg,exerrval);
     return (EX_FATAL);
   }

/* read values of nodeset variable */

   start[0] = --time_step;
   start[1] = 0;

   count[0] = 1;
   count[1] = num_node_this_nset;

   if (ncvarget (exoid, varid, start, count,
        ex_conv_array(exoid,RTN_ADDRESS,nset_var_vals,num_node_this_nset)) == -1)
   {
     exerrval = ncerr;
     sprintf(errmsg,
        "Error: failed to get nodeset variable %d for nodeset %d in file id %d",
             nset_var_index,nset_id,exoid);/*this msg needs to be improved*/
     ex_err("ex_get_nset_var",errmsg,exerrval);
     return (EX_FATAL);
   }


   ex_conv_array( exoid, READ_CONVERT, nset_var_vals, num_node_this_nset );

   return (EX_NOERR);
}
Esempio n. 3
0
int define_truth_table(char type, int exoid, int num_ent, int num_var,
		       int *var_tab, int *status, int *ids, const char *label)
{
  char errmsg[MAX_ERR_LENGTH];
  int k = 0;
  int i, j;
  int time_dim;
  int dims[2];
  int varid;

  time_dim = ncdimid (exoid, DIM_TIME);

  if (var_tab == NULL) {
    exerrval = EX_NULLENTITY;
    sprintf(errmsg,
	    "Error: %s variable truth table is NULL in file id %d", label, exoid);
    ex_err("ex_put_all_var_param",errmsg, exerrval);
    return -1;
  }
  
  for (i=0; i<num_ent; i++) {
    for (j=1; j<=num_var; j++) {
      
      /* check if variables are to be put out for this block */
      if (var_tab[k] != 0) {
	if (status[i] == 0) {/* check for NULL entity */
	  var_tab[k] = 0;
#if 0
	  exerrval = EX_NULLENTITY;
	  sprintf(errmsg,
		  "Warning: %s variable truth table specifies invalid entry for NULL %s %d, variable %d in file id %d",
		  label, label, ids[i], j, exoid);
	  ex_err("ex_put_all_var_param",errmsg,exerrval);
#endif	  
	} else {
	  dims[0] = time_dim;
		
	  /* Determine number of entities in entity */
	  /* Need way to make this more generic... */
	  if (type == 'e')
	    dims[1] = ncdimid (exoid, DIM_NUM_EL_IN_BLK(i+1));
	  else if (type == 'm')
	    dims[1] = ncdimid (exoid, DIM_NUM_NOD_NS(i+1));
	  else if (type == 's')
	    dims[1] = ncdimid (exoid, DIM_NUM_SIDE_SS(i+1));
	  
	  if (dims[1] == -1) {
	    exerrval = ncerr;
	    sprintf(errmsg,
		    "Error: failed to locate number of entities in %s %d in file id %d",
		    label, ids[i], exoid);
	    ex_err("ex_put_all_var_param",errmsg,exerrval);
	    return -1;
	  }
	  
	  /* define netCDF variable to store variable values;
	   * the j index cycles from 1 through the number of variables so 
	   * that the index of the EXODUS II variable (which is part of 
	   * the name of the netCDF variable) will begin at 1 instead of 0
	   */
		
	  if (type == 'e')
	    varid = ncvardef(exoid, VAR_ELEM_VAR(j,i+1), nc_flt_code(exoid), 2, dims);
	  else if (type == 'm')
	    varid = ncvardef(exoid, VAR_NS_VAR(j,i+1),   nc_flt_code(exoid), 2, dims);
	  else if (type == 's')
	    varid = ncvardef(exoid, VAR_SS_VAR(j,i+1),   nc_flt_code(exoid), 2, dims);
	    
	  if (varid == -1) {
	    if (ncerr != NC_ENAMEINUSE) {
	      exerrval = ncerr;
	      sprintf(errmsg,
		      "Error: failed to define %s variable for %s %d in file id %d",
		      label, label, ids[i], exoid);
	      ex_err("ex_put_all_var_param",errmsg,exerrval);
	      return -1;
	    }
	  }
	}
      }  /* if */
      k++; /* increment truth table pointer */
    }  /* for j */
  }  /* for i */
  return 0;
}