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
 void make_global_coord_field(void)
 {
    SAF_Unit umeter;            /* Handle to the units for the coordinates. */
    /* The coordinate field dofs. */
    float lcoord_dof_tuple[] = {0.,4., 1.,4., 2.,4., 2.5,4.,
                                0.,3., 1.,3., 2.,3., 2.5,3.,
                                0.,2., 1.,2., 2.,2., 2.5,2.,
                                0.,1.,        2.,1., 2.5,1.,
                                0.,0.,        2.,0., 2.5,0.};
    void *dofs = &lcoord_dof_tuple[0];

    /*
     ---------------------------------------------------------------------------
     *                         DECLARE FIELD TEMPLATES
     ---------------------------------------------------------------------------
     */
    saf_declare_field_tmpl(SAF_ALL, db, "coordinate_ctmpl", SAF_ALGTYPE_SCALAR,
                           SAF_CARTESIAN, SAF_QLENGTH, 1,
                           NULL, &coords_ctmpl);

    tmp_ftmpl[0] = coords_ctmpl;
    tmp_ftmpl[1] = coords_ctmpl;
    saf_declare_field_tmpl(SAF_ALL, db, "coordinate_tmpl", SAF_ALGTYPE_VECTOR,
                           SAF_CARTESIAN, SAF_QLENGTH, 2,
                           tmp_ftmpl, &coords_ftmpl);

    /*
     ---------------------------------------------------------------------------
     *                         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, "X",      &top, &umeter,
                      SAF_SELF(db), SAF_NODAL(&nodes, &elems), H5T_NATIVE_FLOAT,
                      NULL,         SAF_INTERLEAVE_NONE,   SAF_IDENTITY, NULL,
                      &(coord_compon[0]));
    saf_declare_field(SAF_ALL, db, &coords_ctmpl, "Y",      &top, &umeter,
                      SAF_SELF(db), SAF_NODAL(&nodes, &elems), H5T_NATIVE_FLOAT,
                      NULL,         SAF_INTERLEAVE_NONE,   SAF_IDENTITY, NULL,
                      &(coord_compon[1]));
    saf_declare_field(SAF_ALL, db, &coords_ftmpl, "coords", &top, &umeter,
                      SAF_SELF(db), SAF_NODAL(&nodes, &elems), H5T_NATIVE_FLOAT,
                      coord_compon, SAF_INTERLEAVE_VECTOR, SAF_IDENTITY, NULL,
                      &coords);

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

    /* specify that is a coordinate field */
    saf_declare_coords(SAF_ALL, &coords);
    saf_declare_default_coords(SAF_ALL, &top, &coords);

    return;
 }