function [ a, f ] = adjust_boundary ( node_num, node_xy, node_boundary, ib, ... time, a, f ) %% ADJUST_BOUNDARY modifies the linear system for boundary conditions. % % Modified: % % 06 April 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_BOUNDARY(NODE_NUM), is % 0, if a node is an interior node; % 1, if a node is a Dirichlet boundary node. % % Input, integer IB, the half-bandwidth of the matrix. % % Input, real TIME, the current time. % % Input, real A(3*IB+1,NODE_NUM), the NODE_NUM by NODE_NUM % coefficient matrix, stored in a compressed format. % % Input, real F(NODE_NUM), the right hand side. % % Output, real A(3*IB+1,NODE_NUM), has been adjusted for boundary conditions. % % Output, real F(NODE_NUM), has been adjusted for boundary conditions. % % % Get the exact solution at every node. % u_exact = exact_u ( node_num, node_xy, time ); for node = 1 : node_num if ( node_boundary(node) ~= 0 ) jlo = max ( node - ib, 1 ); jhi = min ( node + ib, node_num ); for j = jlo : jhi a(node-j+2*ib+1,j) = 0.0; end a(node-node+2*ib+1,node) = 1.0; f(node) = u_exact(node); end end