1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 void make_displacement_field(void)
 {
    SAF_Unit umeter;            /* Handle to the units for the coordinates. */
    /* The displacement field dofs. */
    float displacement_dof_tuple[] = {.25,.25,   .25,.25,   .25,.25,   .25,.25,
                                      .25,.25,   .25,.25,   .25,.25,   .25,.25,
                                      .25,.25,   .25,.25,   .25,.25,   .25,.25,
                                      .25,.25,              .25,.25,   .25,.25,
                                      .25,.25,              .25,.25,   .25,.25};
    void *dofs = &displacement_dof_tuple[0];

    /*
     ---------------------------------------------------------------------------
     *                         DECLARE AND WRITE FIELDS
     *                      (dofs specified in write call)
     ---------------------------------------------------------------------------
     */
    /* Get a handle to the units for this field. */
    saf_find_one_unit(db, "meter", &umeter);

    /* Declare the fields. */
    saf_declare_field(SAF_ALL, db, &coords_ctmpl, "dX",            &top, &umeter,
                      SAF_SELF(db), SAF_NODAL(&nodes, &elems), H5T_NATIVE_FLOAT,
                      NULL,         SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
                      &(disp_compons[0]));
    saf_declare_field(SAF_ALL, db, &coords_ctmpl, "dY",            &top, &umeter,
                      SAF_SELF(db), SAF_NODAL(&nodes, &elems), H5T_NATIVE_FLOAT,
                      NULL,         SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
                      &(disp_compons[1]));
    saf_declare_field(SAF_ALL, db, &coords_ftmpl, "displacements", &top, &umeter,
                      SAF_SELF(db), SAF_NODAL(&nodes, &elems), H5T_NATIVE_FLOAT,
                      disp_compons, SAF_INTERLEAVE_VECTOR, SAF_IDENTITY, NULL,
                      &disps);

    /* Write the field. */
    saf_write_field(SAF_ALL, &disps, SAF_WHOLE_FIELD, 1,
                    H5I_INVALID_HID, &dofs, saf_file);

    return;
 }