function [ indx, nunk ] = indx_set ( nx, ny, node_num ) %% INDX_SET assigns a boundary value index or unknown value index at each node. % % Discussion: % % Every finite element node will is assigned an index which % indicates the finite element basis function and its coefficient % which are associated with that node. % % Example: % % On a simple 5 by 5 grid, where the nodes are numbered starting % at the lower left, and increasing in X first, we would have the % following values of INDX: % % 21 22 23 24 25 % 16 17 18 19 20 % 11 12 13 14 15 % 6 7 8 9 10 % 1 2 3 4 5 % % Modified: % % 17 May 2005 % % Parameters: % % Input, integer NX, NY, the number of elements in the X and Y directions. % % Input, integer NODE_NUM, the number of nodes. % % Output, integer INDX(NODE_NUM), the index of the unknown in the finite % element linear system. % % Output, integer NUNK, the number of unknowns. % nunk = 0; in = 0; for j = 1 : 2 * ny - 1 for i = 1 : 2 * nx - 1 in = in + 1; nunk = nunk + 1; indx(in) = nunk; end end