void make_stress_field(int edge_ct_x, int edge_ct_y, SAF_Db *db,
SAF_Set *mesh, SAF_Cat *elems, SAF_Db *saf_file)
{
SAF_FieldTmpl stress_ftmpl, /* Handle to the stress field template. */
stress_ctmpl, /* Handle to the stress field's components'
* field templates. */
tmp_ftmpl[3]; /* temporary field template handles for
* component field templates. */
SAF_Field stress, /* Handle to the stress field. */
stress_compon[3]; /* Handle to the stress field's components. */
SAF_Unit upascal; /* Handle to the units for this field. */
double *lstress_dof_tuple; /* The stress field dofs. */
SAF_Quantity *qbuf=NULL;
/* Create the stress field dofs. */
lstress_dof_tuple = make_stress_field_dofs(edge_ct_x, edge_ct_y);
/*
---------------------------------------------------------------------------
* DECLARE FIELD TEMPLATES
---------------------------------------------------------------------------
*/
qbuf = SAF_QNAME(db,"pressure");
saf_declare_field_tmpl(SAF_ALL, db, "st2_ei_on_triangle_mesh",
SAF_ALGTYPE_SCALAR, SAF_UNITY,
qbuf, 1, NULL,
&stress_ctmpl);
tmp_ftmpl[0] = stress_ctmpl;
tmp_ftmpl[1] = stress_ctmpl;
tmp_ftmpl[2] = stress_ctmpl;
saf_declare_field_tmpl(SAF_ALL, db, "st2_e2_on_triangle_mesh",
SAF_ALGTYPE_SYMTENSOR, SAF_UPPERTRI,
qbuf, 3, tmp_ftmpl,
&stress_ftmpl);
/*
---------------------------------------------------------------------------
* DECLARE AND WRITE FIELDS
* (buf specified in declare call)
---------------------------------------------------------------------------
*/
/* Get the units for the field. */
saf_find_one_unit(db, "pascal", &upascal);
/* Declare the fields. */
saf_declare_field(SAF_ALL, db, &stress_ctmpl, "Sxx", mesh, &upascal,
SAF_SELF(db), SAF_ZONAL(elems), SAF_DOUBLE,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY,
NULL, stress_compon);
saf_declare_field(SAF_ALL, db, &stress_ctmpl, "Syy", mesh, &upascal,
SAF_SELF(db), SAF_ZONAL(elems), SAF_DOUBLE,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY,
NULL, stress_compon+1);
saf_declare_field(SAF_ALL, db, &stress_ctmpl, "Sxy", mesh, &upascal,
SAF_SELF(db), SAF_ZONAL(elems), SAF_DOUBLE,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY,
NULL, stress_compon+2);
saf_declare_field(SAF_ALL, db, &stress_ftmpl, "stress tensor", mesh, &upascal,
SAF_SELF(db), SAF_ZONAL(elems), SAF_DOUBLE,
stress_compon, SAF_INTERLEAVE_VECTOR, SAF_IDENTITY,
(void**)&lstress_dof_tuple, &stress);
/* Write the field. */
saf_write_field(SAF_ALL, &stress, SAF_WHOLE_FIELD, 0, H5I_INVALID_HID,NULL, saf_file);
/* Free the dofs now that we are done with them. */
free(lstress_dof_tuple);
if (qbuf)free(qbuf);
return;
}