| 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 |
* |
| 10 |
* expev - ex_put_elem_var |
| 11 |
* |
| 12 |
* entry conditions - |
| 13 |
* input parameters: |
| 14 |
* int exoid exodus file id |
| 15 |
* int time_step time step number |
| 16 |
* int elem_var_index element variable index |
| 17 |
* int elem_blk_id element block id |
| 18 |
* int num_elem_this_blk number of elements in this block |
| 19 |
* |
| 20 |
* exit conditions - |
| 21 |
* |
| 22 |
* |
| 23 |
* exit conditions - |
| 24 |
* |
| 25 |
* revision history - |
| 26 |
* |
| 27 |
* |
| 28 |
*****************************************************************************/ |
| 29 |
|
| 30 |
#include "exodusII.h" // for ex_put_var, ex_entity_id, etc |
| 31 |
|
| 32 |
/*! |
| 33 |
\deprecated Use ex_put_var()(exoid, time_step, EX_ELEM_BLOCK, elem_var_index, |
| 34 |
elem_blk_id, num_elem_this_blk, elem_var_vals) |
| 35 |
|
| 36 |
The function ex_put_elem_var() writes the values of a single element |
| 37 |
variable for one element block at one time step. It is recommended, |
| 38 |
but not required, to write the element variable truth table (with |
| 39 |
ex_put_elem_var_tab() before this function is invoked for better |
| 40 |
efficiency. |
| 41 |
|
| 42 |
Because element variables are floating point values, the application |
| 43 |
code must declare the array passed to be the appropriate type |
| 44 |
(float or double) to match the compute word size passed in |
| 45 |
ex_create() or ex_open(). |
| 46 |
|
| 47 |
\return In case of an error, ex_put_elem_var() returns a negative number; a |
| 48 |
warning will return a positive number. Possible causes of errors |
| 49 |
include: |
| 50 |
- data file not properly opened with call to ex_create() or ex_open() |
| 51 |
- data file opened for read only. |
| 52 |
- data file not initialized properly with call to ex_put_init(). |
| 53 |
- invalid element block ID. |
| 54 |
- ex_put_elem_block() not called previously to specify parameters for this |
| 55 |
element block. |
| 56 |
- ex_put_variable_param() not called previously specifying the number of |
| 57 |
element variables. |
| 58 |
- an element variable truth table was stored in the file but |
| 59 |
contains a zero (indicating no valid element variable) for the |
| 60 |
specified element block and element variable. |
| 61 |
|
| 62 |
\param[in] exoid exodus file ID returned from a previous call to |
| 63 |
ex_create() or ex_open(). |
| 64 |
\param[in] time_step The time step number, as described under |
| 65 |
ex_put_time(). |
| 66 |
This is essentially a counter that is incremented |
| 67 |
only when results |
| 68 |
variables are output. The first time step is 1. |
| 69 |
\param[in] elem_var_index The index of the element variable. The first variable |
| 70 |
has |
| 71 |
an index of 1. |
| 72 |
\param[in] elem_blk_id The element block ID. |
| 73 |
\param[in] num_elem_this_blk The number of elements in the given element block. |
| 74 |
\param[in] elem_var_vals Array of num_elem_this_blk values of the |
| 75 |
elem_var_index-th |
| 76 |
element variable for the element block with ID of |
| 77 |
elem_blk_id |
| 78 |
at the time_step-th time step. |
| 79 |
|
| 80 |
The following coding will write out all of the element variables for a |
| 81 |
single time step n to an open exodus file : |
| 82 |
|
| 83 |
~~~{.c} |
| 84 |
int num_ele_vars, num_elem_blk, *num_elem_in_block,error, |
| 85 |
exoid, n, *ebids; |
| 86 |
|
| 87 |
float *elem_var_vals; |
| 88 |
|
| 89 |
\comment{write element variables} |
| 90 |
for (k=1; k <= num_ele_vars; k++) { |
| 91 |
for (j=0; j < num_elem_blk; j++) { |
| 92 |
elem_var_vals = (float *) |
| 93 |
calloc(num_elem_in_block[j], sizeof(float)); |
| 94 |
|
| 95 |
for (m=0; m < num_elem_in_block[j]; m++) { |
| 96 |
\comment{simulation code fills this in} |
| 97 |
elem_var_vals[m] = 10.0; |
| 98 |
} |
| 99 |
|
| 100 |
error = ex_put_elem_var (exoid, n, k, ebids[j], |
| 101 |
num_elem_in_block[j], elem_var_vals); |
| 102 |
|
| 103 |
\comment{Using non-deprecated function:} |
| 104 |
error = ex_put_var (exoid, n, EX_ELEM_BLOCK, k, ebids[j], |
| 105 |
num_elem_in_block[j], elem_var_vals); |
| 106 |
|
| 107 |
free (elem_var_vals); |
| 108 |
} |
| 109 |
} |
| 110 |
~~~ |
| 111 |
|
| 112 |
*/ |
| 113 |
|
| 114 |
int ex_put_elem_var(int exoid, int time_step, int elem_var_index, ex_entity_id elem_blk_id, |
| 115 |
int64_t num_elem_this_blk, const void *elem_var_vals) |
| 116 |
{ |
| 117 |
return ex_put_var(exoid, time_step, EX_ELEM_BLOCK, elem_var_index, elem_blk_id, num_elem_this_blk, |
| 118 |
elem_var_vals); |
| 119 |
} |