Esempio n. 1
0
int ne_get_init_global(int       neid,            /* NemesisI file ID */
                       void_int *num_nodes_g,     /* Number of global FEM nodes */
                       void_int *num_elems_g,     /* Number of global FEM elements */
                       void_int *num_elem_blks_g, /* Number of global elem blocks */
                       void_int *num_node_sets_g, /* Number of global node sets */
                       void_int *num_side_sets_g  /* Number of global side sets */
                       )
{
  return ex_get_init_global(neid, num_nodes_g, num_elems_g, num_elem_blks_g, num_node_sets_g,
                            num_side_sets_g);
}
int ne_test_ginig(int fileid)
{

  int error;
  int num_nodes_g, num_elems_g, num_elem_blks_g, num_ns_g, num_ss_g;

/*-----------------------------Execution Begins-----------------------------*/

  error = ex_get_init_global(fileid, &num_nodes_g, &num_elems_g,
                             &num_elem_blks_g, &num_ns_g, &num_ss_g);

  if (error < 0) return error;

  if (num_nodes_g     != NNG)  return -1;
  if (num_elems_g     != NEG)  return -1;
  if (num_elem_blks_g != NEBG) return -1;
  if (num_ns_g        != NNSG) return -1;
  if (num_ss_g        != NSSG) return -1;

  return 0;
}
Esempio n. 3
0
void NemSpread<T,INT>::read_lb_init(int lb_exoid,
				    INT *Int_Space,
				    INT *Int_Node_Num,
				    INT *Bor_Node_Num,
				    INT *Ext_Node_Num,
				    INT *Int_Elem_Num,
				    INT *Bor_Elem_Num,
				    INT *Node_Comm_Num,
				    INT *Elem_Comm_Num,
				    char *Title
				    )

/*
 *    read_lb_init:
 *
 *         This function reads the initial information contained in the
 * load balance file
 *
 *
 */
{
  const char *yo = "read_lb_init";

  /*********************BEGIN EXECUTABLE STATEMENTS****************************/

  /* Read Set-up information from the load-balance file on Proc 0 */

  /*
   * If debugging is not on go ahead and report errors from init. This
   * will show version mismatch information by default.
   */
  if(Debug_Flag == 0)
    ex_opts(EX_VERBOSE);

  /* Read the title of the LB File and about the size of the mesh */
  INT   num_nodes, num_elem, num_elem_blk, num_node_sets, num_side_sets;
  int error = ex_get_init_global(lb_exoid, &num_nodes, &num_elem,
				 &num_elem_blk, &num_node_sets, &num_side_sets);

  check_exodus_error (error, "ex_get_init");

  if(Debug_Flag == 0)
    ex_opts(!EX_VERBOSE);

#ifdef DEBUG
  if(Debug_Flag >= 2) {
    printf("---------------------------------------------------------\n");
    printf("\t\tLoad balance file global information\n");
    printf("---------------------------------------------------------\n");
    printf("\tNumber of nodes: %d\n", num_nodes);
    printf("\tNumber of elements: %d\n", num_elem);
    printf("\tNumber of element blocks: %d\n", num_elem_blk);
    printf("---------------------------------------------------------\n");
  }
#endif

  /* Cross-check the load balance file info against the mesh info */
  if(((size_t)num_nodes != globals.Num_Node) || ((size_t)num_elem != globals.Num_Elem) ||
     (num_elem_blk != globals.Num_Elem_Blk)) {
    fprintf(stderr,
	    "%s: ERROR: Problem dimensions in the LB File don't match with those \
in mesh file",yo);
    exit(1);
  }
Esempio n. 4
0
char *do_exodus_meta(char *filename)
{
  int exoid;
  int ndim, nnodes, nelems, nblks, nnsets, nssets;
  char *title;
  symrec *ptr;

  int *ids = NULL;
  
  /*
   * Open the specified exodusII file, read the metadata and set
   * variables for each item.
   * Examples include "node_count", "element_count", ...
   */
  exoid = open_exodus_file(filename);
  if (exoid < 0) return "";

  /* read database paramters */
  title = (char *)calloc ((MAX_LINE_LENGTH+1),sizeof(char *));
  ex_get_init(exoid,title,&ndim,&nnodes,&nelems,&nblks,&nnsets,&nssets);
  
  ptr = putsym("ex_title", SVAR, 0);
  ptr->value.svar = title;

  ptr = putsym("ex_dimension", VAR, 0);
  ptr->value.var = ndim;

  ptr = putsym("ex_node_count", VAR, 0);
  ptr->value.var = nnodes;

  ptr = putsym("ex_element_count", VAR, 0);
  ptr->value.var = nelems;

  ptr = putsym("ex_block_count", VAR, 0);
  ptr->value.var = nblks;

  ptr = putsym("ex_nset_count", VAR, 0);
  ptr->value.var = nnsets;

  ptr = putsym("ex_sset_count", VAR, 0);
  ptr->value.var = nssets;
  
  { /* Nemesis Information */
    int proc_count;
    int proc_in_file;
    char file_type[MAX_STR_LENGTH+1];

    int global_nodes;
    int global_elements;
    int global_blocks;
    int global_nsets;
    int global_ssets;
    int error;
    
    error = ex_get_init_info(exoid, &proc_count, &proc_in_file, file_type);

    if (error >= 0) {
      ptr = putsym("ex_processor_count", VAR, 0);
      ptr->value.var = proc_count;
      
      ex_get_init_global(exoid, &global_nodes, &global_elements,
			 &global_blocks, &global_nsets, &global_ssets);
      
      ptr = putsym("ex_node_count_global", VAR, 0);
      ptr->value.var = global_nodes;
      
      ptr = putsym("ex_element_count_global", VAR, 0);
      ptr->value.var = global_elements;
    }
  }
    
  /*
   * Read The Element Blocks And Set Variables For Those Also.
   * The Scheme Is:
   * -- 'Ex_Block_Ids' Is A List Of Ids.  Due To Aprepro Limitations,
   *     This List Is A String, Not An Integer List...
   * -- Each Block Is Named 'Ex_Block_X' Where X Is Replaced By The
   *    Blocks Position In The List. For Example, The First Block Will
   *    Be Named 'Ex_Block_1'
   *
   * -- Each Block Will Have The Following Symbols:
   *    -- Ex_Block_X_Id = Id Of This Element Block
   *    -- Ex_Block_X_Name = Composed Name "Block_" + Id
   *    -- Ex_Block_X_Element_Count = Number Of Elements In Block
   *    -- Ex_Block_X_Nodes_Per_Element = Number Of Nodes Per Element
   *    -- Ex_Block_X_Topology = Type Of Elements In Block
   *      (Lowercased)
   *    -- Ex_Block_X_Attribute_Count = Number Of Attributes.
   */

  ids = malloc(nblks * sizeof(int));
  ex_get_elem_blk_ids (exoid, ids);

  {
    int i;
    char *buffer = NULL;
    char cid[33];     /* arbitrary size, large enough for INT_MAX */
    int size = 2048;
    char *tmp = NULL;
    
    buffer = calloc(size, sizeof(char));
    if (buffer != NULL) {
      for (i=0; i < nblks; i++) {
	sprintf(cid, "%d ", ids[i]);
	if (strlen(buffer) + strlen(cid) +1 > size) {
	  if (realloc(buffer, size *=2) == NULL) {
	    free(buffer);
	    yyerror("Error allocating memory.");
	  }
	  memset(&buffer[size/2], 0, size/2);
	}
	strcat(buffer, cid);
      }
      NEWSTR(buffer, tmp);
      ptr = putsym("ex_block_ids", SVAR, 0);
      ptr->value.svar = tmp;
      free(buffer);
    }
  }
    
  {
    int i;
    char var[128];
    char type[MAX_STR_LENGTH+1];
    char *tmp = NULL;
    int nel;
    int nnel;
    int natr;
    
    for (i=0; i < nblks; i++) {
      ex_get_elem_block(exoid, ids[i], type, &nel, &nnel, &natr);

      sprintf(var, "ex_block_seq_%d_id", i+1);
      ptr = putsym(var, VAR, 0);
      ptr->value.var = ids[i];

      sprintf(var, "ex_block_%d_name", ids[i]);
      ptr = putsym(var, SVAR, 0);
      sprintf(var, "block_%d", ids[i]);
      NEWSTR(var, tmp);
      ptr->value.svar = tmp;

      sprintf(var, "ex_block_%d_element_count", ids[i]);
      ptr = putsym(var, VAR, 0);
      ptr->value.var = nel;

      sprintf(var, "ex_block_%d_nodes_per_element", ids[i]);
      ptr = putsym(var, VAR, 0);
      ptr->value.var = nnel;

      sprintf(var, "ex_block_%d_topology", ids[i]);
      ptr = putsym(var, SVAR, 0);
      NEWSTR(type, tmp);

      /* lowercase the string */
      LowerCaseTrim(tmp);
      ptr->value.svar = tmp;

      sprintf(var, "ex_block_%d_attribute_count", ids[i]);
      ptr = putsym(var, VAR, 0);
      ptr->value.var = natr;
    }
  }
  if (ids != NULL) free(ids);

  {
    /* Get timestep count */
    int ts_count = ex_inquire_int(exoid, EX_INQ_TIME);
    ptr = putsym("ex_timestep_count", VAR, 0);
    ptr->value.var = ts_count;
    
    if (ts_count > 0) {
      int i;
      symrec *format = getsym("_FORMAT");
      char *buffer = NULL;
      char cid[33];     /* arbitrary size, large enough for double... */
      int size = 2048;
      char *tmp = NULL;
      double *timesteps = malloc(ts_count * sizeof(double));

      ex_get_all_times(exoid, timesteps);

      buffer = calloc(size, sizeof(char));
      if (buffer != NULL) {

	for (i=0; i < ts_count; i++) {
	  sprintf(cid, format->value.svar, timesteps[i]);
	  if (strlen(buffer) + strlen(cid) +2 > size) {
	    if (realloc(buffer, size *=2) == NULL) {
	      free(buffer);
	      yyerror("Error allocating memory.");
	    }
	    memset(&buffer[size/2], 0, size/2);
	  }
	  strcat(buffer, cid);
	  strcat(buffer, " ");
	}
	NEWSTR(buffer, tmp);
	ptr = putsym("ex_timestep_times", SVAR, 0);
	ptr->value.svar = tmp;

	free(buffer);
      }
    }
  }
  
  ex_close(exoid);
  return "";
}