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