Debian Codegraph @

packages/seacas/libraries/exodus/src/deprecated/ex_put_elem_block.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 *
10 * expelb - ex_put_elem_block: write element block parameters
11 *
12 * entry conditions -
13 * input parameters:
14 * int idexo exodus file id
15 * int elem_blk_id block identifier
16 * char* elem_type element type string
17 * int num_elem_this_blk number of elements in the element blk
18 * int num_nodes_per_elem number of nodes per element block
19 * int num_attr_per_elem number of attributes per element
20 *
21 * exit conditions -
22 *
23 *
24 *****************************************************************************/
25
26 #include "exodusII.h" // for ex_put_block, ex_entity_id, etc
27
28 /*!
29 \deprecated Use ex_put_block()(exoid, EX_ELEM_BLOCK, elem_blk_id, elem_type,
30 num_elem_this_blk, num_nodes_per_elem, 0, 0, num_attr_per_elem)
31
32 The function ex_put_elem_block() writes the parameters used to
33 describe an element block.
34
35 \return In case of an error, ex_put_elem_block() returns a negative
36 number; a warning will return a positive number. Possible causes of
37 errors include:
38 - data file not properly opened with call to ex_create() or ex_open()
39 - data file opened for read only.
40 - data file not initialized properly with call to ex_put_init().
41 - an element block with the same ID has already been specified.
42 - the number of element blocks specified in the call to ex_put_init() has
43 been exceeded.
44
45 \param[in] exoid exodus file ID returned from a previous call to
46 ex_create() or ex_open().
47 \param[in] elem_blk_id The element block ID.
48 \param[in] elem_type The type of elements in the element block. The
49 maximum length of this
50 string is \p MAX_STR_LENGTH .
51 \param[in] num_elem_this_blk The number of elements in the element block.
52 \param[in] num_nodes_per_elem The number of nodes per element in the element
53 block.
54 \param[in] num_attr_per_elem The number of attributes per element in the
55 element block.
56
57 For example, the following code segment will initialize an element
58 block with an ID of 10, write out the connectivity array, and write
59 out the element attributes array:
60
61 ~~~{.c}
62 int id, error, exoid, num_elem_in_blk, num_nodes_per_elem, *connect, num_attr;
63 float *attrib;
64
65 \comment{write element block parameters}
66 id = 10;
67 num_elem_in_blk = 2;
68 num_nodes_per_elem = 4; \comment{elements are 4-node shells}
69 num_attr = 1; \comment{one attribute per element}
70
71 error = ex_put_elem_block(exoid, id, "SHELL", num_elem_in_blk,
72 num_nodes_per_elem, num_attr);
73
74 \comment{write element connectivity}
75 connect = (int *)calloc(num_elem_in_blk*num_nodes_per_elem, sizeof(int));
76
77 \comment{fill connect with node numbers; nodes for first element}
78 connect[0] = 1; connect[1] = 2; connect[2] = 3; connect[3] = 4;
79
80 \comment{nodes for second element}
81 connect[4] = 5; connect[5] = 6; connect[6] = 7; connect[7] = 8;
82
83 error = ex_put_elem_conn (exoid, id, connect);
84
85 \comment{write element block attributes}
86 attrib = (float *) calloc (num_attr*num_elem_in_blk, sizeof(float));
87
88 for (i=0, cnt=0; i < num_elem_in_blk; i++) {
89 for (j=0; j < num_attr; j++, cnt++) {
90 attrib[cnt] = 1.0;
91 }
92 }
93
94 error = ex_put_elem_attr (exoid, id, attrib);
95
96 \comment{Same result using non-deprecated code}
97 error = ex_put_block(exoid, EX_ELEM_BLOCK, id, "SHELL", num_elem_in_blk,
98 num_nodes_per_elem, 0, 0, num_attr);
99 error = ex_put_conn (exoid, EX_ELEM_BLOCK, id, connect);
100 error = ex_put_attr (exoid, EX_ELEM_BLOCK, id, attrib);
101
102 ~~~
103
104 */
105
106 int ex_put_elem_block(int exoid, ex_entity_id elem_blk_id, const char *elem_type,
107 int64_t num_elem_this_blk, int64_t num_nodes_per_elem,
108 int64_t num_attr_per_elem)
109 {
110 return ex_put_block(exoid, EX_ELEM_BLOCK, elem_blk_id, elem_type, num_elem_this_blk,
111 num_nodes_per_elem, 0 /*num_edge_per_elem*/, 0 /*num_face_per_elem*/,
112 num_attr_per_elem);
113 }