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
 void make_scalar_field(int edge_ct_x, int edge_ct_y, SAF_Db *db, SAF_Set *mesh,
                        SAF_Cat *nodes, SAF_Cat *elems, SAF_Db *saf_file)
 {
    SAF_FieldTmpl scalar_ftmpl; /* Handle to the field template. */
    SAF_Field scalar;           /* Handle to the field. */
    SAF_Unit umeter;            /* Handle to the units of the field. */
    double *lscalar_dof_tuple;  /* The scalar field dofs. */

    /* Create the scalar field dofs. */
    lscalar_dof_tuple = make_scalar_field_dofs(edge_ct_x, edge_ct_y);

    /*
     ---------------------------------------------------------------------------
     *                          DECLARE FIELD TEMPLATE
     ---------------------------------------------------------------------------
     */
    saf_declare_field_tmpl(SAF_ALL, db, "at0_on_triangle_mesh_tmpl",
                            SAF_ALGTYPE_SCALAR, SAF_UNITY, SAF_QLENGTH, 1,
                            NULL, &scalar_ftmpl);

    /*
     ---------------------------------------------------------------------------
     *                          DECLARE AND WRITE FIELD
     *                       (buf specified in write call)
     ---------------------------------------------------------------------------
     */
    /* Get the units for the field. */
    saf_find_one_unit(db, "meter", &umeter);

    /* Declare the field. */
    saf_declare_field(SAF_ALL, db, &scalar_ftmpl, "scalar field", mesh, &umeter,
                      SAF_SELF(db), SAF_NODAL(nodes, elems), SAF_DOUBLE,
                      NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
                      &scalar);

    /* Write the field. */
    saf_write_field(SAF_ALL, &scalar, SAF_WHOLE_FIELD, 1,
                    H5I_INVALID_HID,(void**)&lscalar_dof_tuple, saf_file);

    /* Free the dofs now that we are done with them. */
    free(lscalar_dof_tuple);

    return;
 }