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;
}