function [ a, f ] = assemble_boundary_sparse ( node_num, node_xy, ... node_condition, time, a, f ) %% ASSEMBLE_BOUNDARY_SPARSE modifies the linear system for the boundary conditions. % % Discussion: % % For now, we are only working with Dirichlet boundary conditions. % % Modified: % % 07 January 2007 % % 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_CONDITION(NODE_NUM), reports the condition % used to set the unknown associated with the node. % 0, unknown. % 1, finite element equation. % 2, Dirichlet condition; % 3, Neumann condition. % % Input, real TIME, the current time. % % Input, real sparse A, the NODE_NUM by NODE_NUM coefficient % matrix, stored in a compressed format. % % Input, real F(NODE_NUM), the right hand side. % % Output, real sparse A, the matrix has been adjusted for % Dirichlet boundary conditions. % % Output, real F(NODE_NUM), the right hand side has been adjusted for % Dirichlet boundary conditions. % DIRICHLET = 2; node_bc = dirichlet_condition ( node_num, node_xy, time ); for node = 1 : node_num if ( node_condition(node) == DIRICHLET ) a(node,:) = 0.0; a(node,node) = 1.0; f(node) = node_bc(node); end end