function a = jacobian_adjust_dirichlet_sparse ( node_num, node_xy, node_p_variable, ... node_u_variable, node_v_variable, node_p_condition, ... node_u_condition, node_v_condition, variable_num, a ) %% JACOBIAN_ADJUST_DIRICHLET_SPARSE adjusts the jacobian matrix for Dirichlet conditions. % % Modified: % % 20 September 2006 % % Author: % % John Burkardt % % Parameters: % % Input, integer NODE_NUM, the number of nodes. % % Input, real NODE_XY(2,NODE_NUM), the coordinates 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. % % Input, integer NODE_P_CONDITION(NODE_NUM), % indicates the condition used to determine pressure at a node. % 0, there is no condition at this node. % 1, a finite element equation is used; % 2, a Dirichlet condition is used. % 3, a Neumann condition is used. % % Input, integer NODE_U_CONDITION(NODE_NUM), % indicates the condition used to determine horizontal velocity at a node. % 0, there is no condition at this node. % 1, a finite element equation is used; % 2, a Dirichlet condition is used. % 3, a Neumann condition is used. % % Input, integer NODE_V_CONDITION(NODE_NUM), % indicates the condition used to determine vertical velocity at a node. % 0, there is no condition at this node. % 1, a finite element equation is used; % 2, a Dirichlet condition is used. % 3, a Neumann condition is used. % % Input, integer VARIABLE_NUM, the number of variables. % % Input, real sparse A, the coefficient matrix, % stored as a MATLAB sparse matrix. % % Output, real sparse A, the coefficient matrix has % been adjusted for Dirichlet boundary conditions. % DIRICHLET = 2; for node = 1 : node_num iu = node_u_variable(node); iv = node_v_variable(node); ip = node_p_variable(node); if ( node_u_condition(node) == DIRICHLET ) a(iu,:) = 0.0; a(iu,iu) = 1.0; end if ( node_v_condition(node) == DIRICHLET ) a(iv,:) = 0.0; a(iv,iv) = 1.0; end if ( 0 < ip ) if ( node_p_condition(node) == DIRICHLET ) a(ip,:) = 0.0; a(ip,ip) = 1.0; end end end