function fem_write ( node_coord_file_name, element_file_name, ... node_data_file_name, dim_num, node_num, element_num, element_order, ... node_data_num, node_coord, element_node, node_data ) %% FEM_WRITE writes data files associated with a finite element solution. % % Discussion: % % This program writes the node, element and data files that define % a finite element geometry and data based on that geometry: % * a set of nodes, % * a set of elements based on those nodes, % * a set of data values associated with each node. % % Modified: % % 26 January 2006 % % Author: % % John Burkardt % % Parameters: % % Input, character NODE_COORD_FILE_NAME(*), the name of the node coordinate % file. If this argument is empty, no node coordinate file will be written. % % Input, character ELEMENT_FILE_NAME(*), the name of the element file. If % this argument is empty, no element file will be written. % % Input, character NODE_DATA_FILE_NAME(*), the name of the node data file. If % this argument is empty, no node data file will be written. % % Input, integer DIM_NUM, the spatial dimension. % % Input, integer NODE_NUM, the number of nodes. % % Input, integer ELEMENT_NUM, the number of elements. % % Input, integer ELEMENT_ORDER, the order of the elements. % % Input, integer NODE_DATA_NUM, the number of data items per node. % % Input, real NODE_COORD(DIM_NUM,NODE_NUM), the coordinates of nodes. % % Input, integer ELEMENT_NODE(ELEMENT_ORDER,ELEMENT_NUM); % the global index of local node I in element J. % % Input, real NODE_DATA(NODE_DATA_NUM,NODE_NUM), the data values associated % with each node. % % % Write the node coordinate file. % if ( ~isempty ( node_coord_file_name ) & ... 0 < s_len_trim ( node_coord_file_name ) ) node_coord_file_unit = fopen ( node_coord_file_name, 'wt' ); if ( node_coord_file_unit < 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'FEM_WRITE - Error!\n' ); fprintf ( 1, ' Could not open the node coordinate file.\n' ); error ( 'FEM_WRITE - Error!' ); return; end r8table_header_write ( node_coord_file_name, node_coord_file_unit, ... dim_num, node_num ); r8table_data_write ( node_coord_file_unit, ... dim_num, node_num, node_coord ); fclose ( node_coord_file_unit ); fprintf ( 1, '\n' ); fprintf ( 1, 'FEM_WRITE wrote node coordinates to "%s".\n', ... node_coord_file_name ); end % % Write the element file. % if ( ~isempty ( element_file_name ) & ... 0 < s_len_trim ( element_file_name ) ) element_file_unit = fopen ( element_file_name, 'wt' ); if ( element_file_unit < 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'FEM_WRITE - Error!\n' ); fprintf ( 1, ' Could not open the element file.\n' ); error ( 'FEM_WRITE - Error!' ); return; end itable_header_write ( element_file_name, element_file_unit, ... element_order, element_num ); itable_data_write ( element_file_unit, ... element_order, element_num, element_node ); fclose ( element_file_unit ); fprintf ( 1, '\n' ); fprintf ( 1, 'FEM_WRITE wrote element data to "%s".\n', ... element_file_name ); end % % Write the node data file. % if ( ~isempty ( node_data_file_name ) & ... 0 < s_len_trim ( node_data_file_name ) ) node_data_file_unit = fopen ( node_data_file_name, 'wt' ); if ( node_data_file_unit < 0 ) fprintf ( 1, '\n' ); fprintf ( 1, 'FEM_WRITE - Error!\n' ); fprintf ( 1, ' Could not open the node data file.\n' ); error ( 'FEM_WRITE - Error!' ); return; end r8table_header_write ( node_data_file_name, node_data_file_unit, ... node_data_num, node_num ); r8rtable_data_write ( node_data_file_unit, ... node_data_num, node_num, node_data ); fclose ( node_data_file_unit ); fprintf ( 1, '\n' ); fprintf ( 1, 'FEM_WRITE wrote node data to "%s".\n', ... node_data_file_name ); end