function node_r = residual_adjust_dirichlet ( node_num, node_xy, ... node_p_variable, node_u_variable, node_v_variable, node_p_condition, ... node_u_condition, node_v_condition, variable_num, node_c, node_r ) %% RESIDUAL_ADJUST_DIRICHLET adjusts the residual for Dirichlet conditions. % % Modified: % % 08 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 NODE_C(VARIABLE_NUM), the finite element % coefficient vector. % % Input, real NODE_R(VARIABLE_NUM), the residual vector. % % Output, real NODE_R(VARIABLE_NUM), the adjusted residual. % DIRICHLET = 2; [ u_bc, v_bc, p_bc ] = dirichlet_condition ( node_num, node_xy ); 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 ) node_r(iu) = node_c(iu) - u_bc(node); end if ( node_v_condition(node) == DIRICHLET ) node_r(iv) = node_c(iv) - v_bc(node); end if ( 0 < ip ) if ( node_p_condition(node) == DIRICHLET ) node_r(ip) = node_c(ip) - p_bc(node); end end end return end