Debian Codegraph @

packages/seacas/libraries/exodus/src/ex_get_var.c

raw
1 /*
2 * Copyright(C) 1999-2020, 2023 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_err, ex_name_of_object, etc
10 #include "exodusII_int.h" // for exi_check_valid_file_id, etc
11
12 /*!
13 \ingroup ResultsData
14
15 The function ex_get_var() reads the values of the
16 selected entity variables for a single time step. Memory must be allocated for
17 the variables values array before this function is invoked.
18
19 Because variables are floating point values, the application
20 code must declare the array passed to be the appropriate type
21 (float or double) to match the compute word size passed in
22 ex_create() or ex_open().
23
24 In case of an error, ex_get_var() returns a negative
25 number; a warning will return a positive number. Possible causes of
26 errors include:
27
28 - data file not properly opened with call to ex_create() or ex_open()
29 - variable does not exist for the desired block or set.
30 - invalid block or set.
31 - no variables of the selected type stored in the file.
32 - a warning value is returned if no variables of the selected entity type are stored in the file.
33
34 \param[in] exoid exodus file ID returned from a previous call to
35 ex_create() or ex_open().
36
37 \param[in] time_step The time step, as described under ex_put_time(), at
38 which the variable values are desired. This is
39 essentially an index (in the time dimension) into the entity
40 variable values array stored in the database. The first time step is 1.
41
42 \param[in] var_type block/variable type node, edge/face/element block, or
43 node/edge/face/side/element set of type ex_entity_type.
44 \param[in] var_index variable index; 1-based
45 \param[in] obj_id object id, see ex_get_ids()
46 \param[in] num_entry_this_obj The number of entities in this object stored in the database.
47 \param[out] var_vals Returned array of num_entry_this_obj variable values
48 for the time_step'th time step.
49
50 The following is an example code segment that reads the 10th element variable for element block with
51 id 100
52 at time step 5. There are 'num_elements_this_block' elements in element block 100.
53
54 ~~~{.c}
55 int num_elements_this_block, error, time_step;
56 int var_index = 10;
57 int blk_id = 100;
58 int num_variables;
59 float *var_values;
60
61 var_values = (float *) callo(num_elements_this_block, sizeof(float));
62 error = ex_get_var (idexo, time_step, EX_ELEM_BLOCK, var_index, blk_id,
63 num_elements_this_block, var_values);
64 ~~~
65
66 */
67
68 int ex_get_var(int exoid, int time_step, ex_entity_type var_type, int var_index,
69 ex_entity_id obj_id, int64_t num_entry_this_obj, void *var_vals)
70 {
71 return ex_get_var_multi_time(exoid, var_type, var_index, obj_id, num_entry_this_obj, time_step,
72 time_step, var_vals);
73 }