| 1 |
/* |
| 2 |
* Copyright(C) 1999-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, etc |
| 10 |
#include "exodusII_int.h" // for EX_FATAL, etc |
| 11 |
|
| 12 |
/*! |
| 13 |
\ingroup ResultsData |
| 14 |
writes the values of a single variable of the specified type for a |
| 15 |
single time step. The function ex_put_variable_param() must be invoked |
| 16 |
before this call is made. |
| 17 |
|
| 18 |
Because variables are floating point values, the application |
| 19 |
code must declare the array passed to be the appropriate type |
| 20 |
(float or double) to match the compute word size passed in |
| 21 |
ex_create() or ex_open(). |
| 22 |
|
| 23 |
\return In case of an error, ex_put_var() returns a negative number; a |
| 24 |
warning will return a positive number. Possible causes of errors |
| 25 |
include: |
| 26 |
- data file not properly opened with call to ex_create() or ex_open() |
| 27 |
- data file opened for read only. |
| 28 |
- data file not initialized properly with call to ex_put_init(). |
| 29 |
- ex_put_variable_param() not called previously specifying the number of |
| 30 |
variables. |
| 31 |
|
| 32 |
\param[in] exoid |
| 33 |
exodus file ID returned from a previous call to |
| 34 |
ex_create() or ex_open(). |
| 35 |
|
| 36 |
\param[in] time_step |
| 37 |
The time step number, as described under |
| 38 |
ex_put_time(). This is essentially a counter that is incremented when |
| 39 |
results variables are output. The first time step is 1. |
| 40 |
|
| 41 |
\param[in] var_type |
| 42 |
type (edge block, face block, edge set, ... ) |
| 43 |
|
| 44 |
\param[in] var_index |
| 45 |
The index of the variable. The first variable has an index of 1. |
| 46 |
|
| 47 |
\param[in] obj_id |
| 48 |
entity block/set id (ignored for global and nodal variables) |
| 49 |
|
| 50 |
\param[in] num_entries_this_obj |
| 51 |
The number of items in this block/set |
| 52 |
|
| 53 |
\param[in] var_vals |
| 54 |
Array of `num_entries_this_obj` values of the `var_index`-th variable for the `time_step`-th time |
| 55 |
step. |
| 56 |
|
| 57 |
As an example, the following code segment writes all the nodal |
| 58 |
variables for a single time step: |
| 59 |
|
| 60 |
~~~{.c} |
| 61 |
int num_nod_vars, num_nodes, error, exoid, time_step; |
| 62 |
float *nodal_var_vals; |
| 63 |
|
| 64 |
\comment{write nodal variables} |
| 65 |
nodal_var_vals = (float *) calloc(num_nodes, sizeof(float)); |
| 66 |
for (k=1; k <= num_nod_vars; k++) { |
| 67 |
for (j=0; j < num_nodes; j++) { |
| 68 |
\comment{application code fills in this array} |
| 69 |
nodal_var_vals[j] = 10.0; |
| 70 |
} |
| 71 |
error = ex_put_var(exoid, time_step, EX_NODAL, 0, k, num_nodes, |
| 72 |
nodal_var_vals); |
| 73 |
} |
| 74 |
~~~ |
| 75 |
*/ |
| 76 |
|
| 77 |
int ex_put_var(int exoid, int time_step, ex_entity_type var_type, int var_index, |
| 78 |
ex_entity_id obj_id, int64_t num_entries_this_obj, const void *var_vals) |
| 79 |
{ |
| 80 |
return ex_put_var_multi_time(exoid, var_type, var_index, obj_id, num_entries_this_obj, time_step, |
| 81 |
time_step, var_vals); |
| 82 |
} |