Debian Codegraph @

packages/seacas/libraries/exodus/src/deprecated/ex_get_elem_var.c

raw
1 /*
2 * Copyright(C) 1999-2020 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 #include "exodusII.h" // for ex_get_var, ex_entity_id, etc
10
11 /*!
12 \deprecated Use ex_get_var()(exoid, time_step, EX_ELEM_BLOCK, elem_var_index,
13 elem_blk_id, num_elem_this_blk, elem_var_vals) instead
14
15 The function ex_get_elem_var() reads the values of a single element
16 variable for one element block at one time step. Memory must be
17 allocated for the element variable values array before this function
18 is invoked.
19
20 Because element variables are floating point values, the application
21 code must declare the array passed to be the appropriate type
22 (float or double) to match the compute word size passed in
23 ex_create() or ex_open().
24
25 \return In case of an error, ex_get_elem_var() returns a negative
26 number; a warning will return a positive number. Possible causes of
27 errors include:
28 - data file not properly opened with call to ex_create() or ex_open()
29 - variable does not exist for the desired element block.
30 - invalid element block.
31
32 \param[in] exoid exodus file ID returned from a previous call to
33 ex_create() or ex_open().
34 \param[in] time_step The time step number, as described under
35 ex_put_time(), at
36 which the element variable values are desired. This
37 is essentially an
38 index (in the time dimension) into the element
39 variable values array
40 stored in the database. The first time step is 1.
41
42 \param[in] elem_var_index The index of the desired element variable. The first
43 variable
44 has an index of 1.
45
46 \param[in] elem_blk_id The desired element block ID.
47
48 \param[in] num_elem_this_blk The number of elements in this element block.
49
50 \param[out] elem_var_vals Returned array of num_elem_this_blk values of the
51 elem_var_index
52 element variable for the element block with ID of
53 elem_blk_id at the time_step time step.
54
55 As an example, the following code segment will read the
56 var_index-th element variable at one time step stored in an exodus
57 file :
58
59 ~~~{.c}
60 int *ids, num_elem_blk, error, exoid, *num_elem_in_block,
61 step, var_ind;
62
63 float *var_vals;
64
65 ids = (int *) calloc(num_elem_blk, sizeof(int));
66 error = ex_get_elem_blk_ids (exoid, ids);
67
68 step = 1; \comment{read at the first time step}
69 for (i=0; i < num_elem_blk; i++) {
70 var_vals = (float *) calloc (num_elem_in_block[i], sizeof(float));
71 error = ex_get_elem_var (exoid, step, var_ind, ids[i],
72 num_elem_in_block[i], var_vals);
73
74 \comment{Using non-deprecated function:}
75 error = ex_get_var (exoid, step, EX_ELEM_BLOCK, var_ind, ids[i],
76 num_elem_in_block[i], var_vals);
77
78 free (var_values);
79 }
80 ~~~
81
82 */
83
84 int ex_get_elem_var(int exoid, int time_step, int elem_var_index, ex_entity_id elem_blk_id,
85 int64_t num_elem_this_blk, void *elem_var_vals)
86 {
87 return ex_get_var(exoid, time_step, EX_ELEM_BLOCK, elem_var_index, elem_blk_id, num_elem_this_blk,
88 elem_var_vals);
89 }