| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
/***************************************************************************** |
| 9 |
* |
| 10 |
* exgini - ex_get_init |
| 11 |
* |
| 12 |
* entry conditions - |
| 13 |
* input parameters: |
| 14 |
* int exoid exodus file id |
| 15 |
* |
| 16 |
* exit conditions - |
| 17 |
* char* title title of file |
| 18 |
* int* num_dim number of dimensions (per node) |
| 19 |
* int* num_nodes number of nodes |
| 20 |
* int* num_elem number of elements |
| 21 |
* int* num_elem_blk number of element blocks |
| 22 |
* int* num_node_sets number of node sets |
| 23 |
* int* num_side_sets number of side sets |
| 24 |
* |
| 25 |
* revision history - |
| 26 |
* David Thompson - Moved to exginix.c (exgini.c now a special case) |
| 27 |
* |
| 28 |
* |
| 29 |
*****************************************************************************/ |
| 30 |
|
| 31 |
#include "exodusII.h" // for ex_init_params, void_int, etc |
| 32 |
#include "exodusII_int.h" |
| 33 |
|
| 34 |
/*! |
| 35 |
\ingroup ModelDescription |
| 36 |
|
| 37 |
The function ex_get_init() reads the initialization |
| 38 |
parameters from an opened exodus file. |
| 39 |
|
| 40 |
\return In case of an error, ex_get_init() returns a negative number; |
| 41 |
a warning will return a positive number. Possible causes of errors |
| 42 |
include: |
| 43 |
- data file not properly opened with call to ex_create() or ex_open(). |
| 44 |
|
| 45 |
\param exoid exodus file ID returned from a previous call to |
| 46 |
ex_create() or ex_open(). |
| 47 |
\param[out] title Returned database title. String length may be up to \c |
| 48 |
MAX_LINE_LENGTH+1 bytes. |
| 49 |
\param[out] num_dim Returned dimensionality of the database. This is the |
| 50 |
number of coordinates per node. |
| 51 |
\param[out] num_nodes Returned number of nodal points. |
| 52 |
\param[out] num_elem Returned number of elements |
| 53 |
\param[out] num_elem_blk Returned number of element blocks |
| 54 |
\param[out] num_node_sets Returned number of node sets |
| 55 |
\param[out] num_side_sets Returned number of side sets |
| 56 |
|
| 57 |
\sa ex_get_init_ext() |
| 58 |
|
| 59 |
The following code segment will read the initialization parameters |
| 60 |
from the open exodus file: |
| 61 |
|
| 62 |
~~~{.c} |
| 63 |
int num_dim, num_nodes, num_elem, num_elem_blk, |
| 64 |
num_node_sets, num_side_sets, error, exoid; |
| 65 |
|
| 66 |
char title[MAX_LINE_LENGTH+1]; |
| 67 |
|
| 68 |
\comment{read database parameters} |
| 69 |
error = ex_get_init (exoid, title, &num_dim, &num_nodes, |
| 70 |
&num_elem, &num_elem_blk, &num_node_sets, &num_side_sets); |
| 71 |
~~~ |
| 72 |
|
| 73 |
*/ |
| 74 |
|
| 75 |
int ex_get_init(int exoid, char *title, void_int *num_dim, void_int *num_nodes, void_int *num_elem, |
| 76 |
void_int *num_elem_blk, void_int *num_node_sets, void_int *num_side_sets) |
| 77 |
{ |
| 78 |
ex_init_params info; |
| 79 |
int errval; |
| 80 |
|
| 81 |
EX_FUNC_ENTER(); |
| 82 |
if (exi_check_valid_file_id(exoid, __func__) == EX_FATAL) { |
| 83 |
EX_FUNC_LEAVE(EX_FATAL); |
| 84 |
} |
| 85 |
|
| 86 |
info.title[0] = '\0'; |
| 87 |
errval = ex_get_init_ext(exoid, &info); |
| 88 |
if (errval < 0) { |
| 89 |
EX_FUNC_LEAVE(errval); |
| 90 |
} |
| 91 |
|
| 92 |
if (ex_int64_status(exoid) & EX_BULK_INT64_API) { |
| 93 |
int64_t *n_dim = num_dim; |
| 94 |
int64_t *n_nodes = num_nodes; |
| 95 |
int64_t *n_elem = num_elem; |
| 96 |
int64_t *n_elem_blk = num_elem_blk; |
| 97 |
int64_t *n_node_sets = num_node_sets; |
| 98 |
int64_t *n_side_sets = num_side_sets; |
| 99 |
|
| 100 |
*n_dim = info.num_dim; |
| 101 |
*n_nodes = info.num_nodes; |
| 102 |
*n_elem = info.num_elem; |
| 103 |
*n_elem_blk = info.num_elem_blk; |
| 104 |
*n_node_sets = info.num_node_sets; |
| 105 |
*n_side_sets = info.num_side_sets; |
| 106 |
} |
| 107 |
else { |
| 108 |
int *n_dim = num_dim; |
| 109 |
int *n_nodes = num_nodes; |
| 110 |
int *n_elem = num_elem; |
| 111 |
int *n_elem_blk = num_elem_blk; |
| 112 |
int *n_node_sets = num_node_sets; |
| 113 |
int *n_side_sets = num_side_sets; |
| 114 |
|
| 115 |
*n_dim = (int)info.num_dim; |
| 116 |
*n_nodes = (int)info.num_nodes; |
| 117 |
*n_elem = (int)info.num_elem; |
| 118 |
*n_elem_blk = (int)info.num_elem_blk; |
| 119 |
*n_node_sets = (int)info.num_node_sets; |
| 120 |
*n_side_sets = (int)info.num_side_sets; |
| 121 |
} |
| 122 |
ex_copy_string(title, info.title, MAX_LINE_LENGTH + 1); |
| 123 |
|
| 124 |
EX_FUNC_LEAVE(EX_NOERR); |
| 125 |
} |