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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 void make_stress_on_cell_1_field(void)
 {
    SAF_Unit upascal;           /* Handle to the units for the stress. */
    /* Made up stresses. */
    float stress_dof_tuple[] = {0.5, 0.25, 0.5,0.5, 0.25, 0.5,
                                0.5, 0.25, 0.5,0.5, 0.25, 0.5};
    void *dofs = &stress_dof_tuple[0];

    /*
     ---------------------------------------------------------------------------
     *                         DECLARE FIELD TEMPLATES
     ---------------------------------------------------------------------------
     */
    saf_declare_field_tmpl(SAF_ALL,  db,"stress_on_cell_1_tmpl",
                           SAF_ALGTYPE_SCALAR, SAF_UNITY,
                           SAF_QNAME(db,"pressure"), 1, NULL,
                           &stress_ctmpl);

    tmp_ftmpl[0] = stress_ctmpl;
    tmp_ftmpl[1] = stress_ctmpl;
    tmp_ftmpl[2] = stress_ctmpl;
    saf_declare_field_tmpl(SAF_ALL,  db,"stress_on_cell_1_tmpl",
                           SAF_ALGTYPE_SYMTENSOR, SAF_UPPERTRI,
                           SAF_QNAME(db,"pressure"), 3, tmp_ftmpl,
                           &stress_ftmpl);

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

    /* Declare the field. */
    saf_declare_field(SAF_ALL, db, &stress_ctmpl, "Sx",     &cell_1, &upascal, SAF_SELF(db),
                      SAF_ZONAL(&elems), H5T_NATIVE_FLOAT, NULL,
                      SAF_INTERLEAVE_NONE, SAF_IDENTITY,
                      NULL, &(stress_compon[0]));
    saf_declare_field(SAF_ALL, db, &stress_ctmpl, "Sy",     &cell_1, &upascal, SAF_SELF(db),
                      SAF_ZONAL(&elems), H5T_NATIVE_FLOAT, NULL,
                      SAF_INTERLEAVE_NONE, SAF_IDENTITY,
                      NULL, &(stress_compon[1]));
    saf_declare_field(SAF_ALL, db, &stress_ctmpl, "Sxy",    &cell_1, &upascal, SAF_SELF(db),
                      SAF_ZONAL(&elems), H5T_NATIVE_FLOAT, NULL,
                      SAF_INTERLEAVE_NONE, SAF_IDENTITY,
                      NULL, &(stress_compon[2]));

    saf_declare_field(SAF_ALL, db, &stress_ftmpl, "stress", &cell_1, &upascal, SAF_SELF(db),
                      SAF_ZONAL(&elems), H5T_NATIVE_FLOAT, stress_compon,
                      SAF_INTERLEAVE_VECTOR, SAF_IDENTITY,
                      &dofs, &stress);


    /* Write the field. */
    saf_write_field(SAF_ALL, &stress, SAF_WHOLE_FIELD, 0, H5I_INVALID_HID, NULL, saf_file);

    return;
 }