double *
make_coord_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_coord_field_dofs, NULL);
int node_ct_x = edge_ct_x+1, /* Number of nodes in x. */
node_ct_y = edge_ct_y+1, /* Number of nodes in y. */
dofs_ub = node_ct_x*node_ct_y*2, /* Number of dofs. */
i, j, node_id;
double delx = 1.0/edge_ct_x, /* X increment between nodes in x. */
dely = 1.0/edge_ct_y, /* Y increment between nodes in y. */
*dofs, /* The array of dofs. */
x, y; /* x and y coordinates. */
/* 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[nx+1][ny+1][2]; */
dofs = (double*)malloc(dofs_ub*sizeof(double));
for(i = 0; i < node_ct_x; i++)
{
x = i*delx;
for(j = 0; j < node_ct_y; j++)
{
y = j*dely;
node_id = NODE_ID(i,j);
dofs[2*node_id] = x;
dofs[2*node_id+1] = y;
}
}
/* Postconditions */
/* Exit */
SAF_LEAVE(dofs);
}