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
61
62
63
64
65
66
67
68
 void make_coord_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 coords_ftmpl, /* Handle to the coordinate field field
                                 * template. */
                  coords_ctmpl, /* Handle to the coordinate field's components'
                                 * field templates. */
                  tmp_ftmpl[3]; /* temporary field template handle for
                                 * component field templates. */
    SAF_Field coords,           /* Handle to the coordinate field. */
              coord_compon[2];  /* Handle to the 2 components of the
                                 * coordinate field. */
    SAF_Unit umeter;            /* Handle to the units for the coordinates. */
    double *lcoord_dof_tuple;   /* The coordinate field dofs. */

    /* Create the coordinate field dofs. */
    lcoord_dof_tuple = make_coord_field_dofs(edge_ct_x, edge_ct_y);

    /*
     ---------------------------------------------------------------------------
     *                         DECLARE FIELD TEMPLATES
     ---------------------------------------------------------------------------
     */
    saf_declare_field_tmpl(SAF_ALL, db, "e2_on_triangle_mesh_ctmpl",
                            SAF_ALGTYPE_VECTOR, 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, "e2_on_triangle_mesh_tmpl",
                            SAF_ALGTYPE_VECTOR, SAF_CARTESIAN, SAF_QLENGTH, 2,
                            tmp_ftmpl, &coords_ftmpl);

    /*
     ---------------------------------------------------------------------------
     *                         DECLARE AND WRITE FIELDS
     *                       (buf 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",           mesh, &umeter,
                      SAF_SELF(db), SAF_NODAL(nodes, elems), SAF_DOUBLE,
                      NULL,         SAF_INTERLEAVE_NONE,   SAF_IDENTITY, NULL,
                      coord_compon);
    saf_declare_field(SAF_ALL, db, &coords_ctmpl, "Y",           mesh, &umeter,
                      SAF_SELF(db), SAF_NODAL(nodes, elems), SAF_DOUBLE,
                      NULL,         SAF_INTERLEAVE_NONE,   SAF_IDENTITY, NULL,
                      coord_compon+1);
    saf_declare_field(SAF_ALL, db, &coords_ftmpl, "coord field", mesh, &umeter,
                      SAF_SELF(db), SAF_NODAL(nodes, elems), SAF_DOUBLE,
                      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,(void**)&lcoord_dof_tuple, saf_file);

    /* Specify that is a coordinate field */
    saf_declare_coords(SAF_ALL, &coords);

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

    return;
 }