double *
make_stress_field_dofs(int edge_ct_x, /*number of edges in X direction*/
int edge_ct_y /*number of edges in Y direction*/
)
{
SAF_ENTER(make_stress_field_dofs, NULL);
int dofs_ub = edge_ct_x*edge_ct_y*2*3, /* Number of dofs. */
tri_ct = 0, /* Triangle counter. */
i, j;
double *dofs; /* The array of dofs. */
/* Preconditions */
SAF_REQUIRE(edge_ct_x > 0, SAF_LOW_CHK_COST, NULL,
_saf_errmsg("there must be at least 1 edge in the x direction"));
SAF_REQUIRE(edge_ct_y > 0, SAF_LOW_CHK_COST, NULL,
_saf_errmsg("there must be at least 1 edge in the y direction"));
/* Body */
/* allocate dofs as single index array,
* but treat as dofs[edge_ct_x][edge_ct_y][3]; */
dofs = (double*)malloc(dofs_ub*sizeof(double));
for(i=0; i<edge_ct_x; i++)
{
for(j=0; j<edge_ct_y; j++)
{
/* Each (i,j) pair is the lower-left-hand node in
* a quad containing two triangles. */
/* Stress for lower triangle in quad, */
dofs[3*tri_ct] = tri_ct+0.0; /* xx component */
dofs[3*tri_ct+1] = tri_ct+0.1; /* xy component */
dofs[3*tri_ct+2] = tri_ct+0.2; /* yy component */
tri_ct++;
/* Stress for upper triangle in quad, */
dofs[3*tri_ct] = tri_ct+0.0; /* xx component */
dofs[3*tri_ct+1] = tri_ct+0.1; /* xy component */
dofs[3*tri_ct+2] = tri_ct+0.2; /* yy component */
tri_ct++;
}
}
/* Postconditions */
/* Exit */
SAF_LEAVE(dofs);
}