function ib = bandwidth ( element_num, element_node, ... node_num, node_p_variable, node_u_variable, node_v_variable ) %% BANDWIDTH determines the bandwidth of the coefficient matrix. % % Discussion: % % We take the bandwidth to be the maximum difference between the % indices of two variables associated with nodes that share an element. % % Therefore, we can compute the bandwidth by examining each element, % and finding the maximum difference in indices of any two variables % associated with nodes in that element. % % Modified: % % 30 July 2005 % % Author: % % John Burkardt % % Parameters: % % Input, integer ELEMENT_NUM, the number of elements. % % Input, integer ELEMENT_NODE(6,ELEMENT_NUM); % ELEMENT_NODE(I,J) is the global index of local node I in element J. % % Input, integer NODE_NUM, the number of nodes. % % Input, integer NODE_P_VARIABLE(NODE_NUM), % is the index of the pressure variable associated with the node, % or -1 if there is no associated pressure variable. % % Input, integer NODE_U_VARIABLE(NODE_NUM), % is the index of the horizontal velocity variable associated with the node. % % Input, integer NODE_V_VARIABLE(NODE_NUM), % is the index of the vertical velocity variable associated with the node. % % Output, integer IB, the half bandwidth of the matrix. % ib = 0; for element = 1 : element_num v_max = -i4_huge ( 'DUMMY' ); v_min = i4_huge ( 'DUMMY' ); for local = 1 : 6 node = element_node(local,element); v = node_u_variable(node); v_max = max ( v_max, v ); v_min = min ( v_min, v ); v = node_v_variable(node); v_max = max ( v_max, v ); v_min = min ( v_min, v ); if ( 0 < node_p_variable(node) ) v = node_p_variable(node); v_max = max ( v_max, v ); v_min = min ( v_min, v ); end end ib = max ( ib, v_max - v_min ); end