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