function [ dim_num, node_num, element_num, element_order, node_data_num, ... node_coord, element_node, node_data ] = fem_read ( node_coord_file_name, ... element_file_name, node_data_file_name ) %% FEM_READ reads data files associated with a finite element solution. % % Discussion: % % This program reads 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 not supplied, it will be requested. If the interactive % response is blank, or otherwise defective, then the program terminates. % % Input, character ELEMENT_FILE_NAME(*), the name of the element file. If % this argument is not supplied, it will be requested. If the interactive % response is blank, then the program will assume that no element information % is to be supplied. (But the node coordinates must be available and may be plotted. % And if a node data file is supplied, then the data can be plotted against % the node coordinates without using any finite element structure.) % % Input, character NODE_DATA_FILE_NAME(*), the name of the node data file. If % this argument is not supplied, it will be requested. If the interactive % response is blank, then the program will assume that no node data information % is to be supplied. (But the node coordinates will be available and may be plotted. % And if an element file is supplied, then the elements can also be displayed.) % % Output, integer DIM_NUM, the spatial dimension, inferred from the % "shape" of the data in the node file. % % Output, integer NODE_NUM, the number of nodes, inferred from the % number of lines of data in the node coordinate file. % % Output, integer ELEMENT_NUM, the number of elements, inferred from the % number of lines of data in the element file. % % Output, integer ELEMENT_ORDER, the order of the elements, inferred from % the number of items in the first line of the element file. % % Output, integer NODE_DATA_NUM, the number of data items per node, % inferred from the number of items in the first line of the node data file. % % Output, real NODE_COORD(DIM_NUM,NODE_NUM), the coordinates of nodes. % % Output, integer ELEMENT_NODE(ELEMENT_ORDER,ELEMENT_NUM); % the global index of local node I in element J. % % Output, real NODE_DATA(NODE_DATA_NUM,NODE_NUM), the data values associated % with each node. % % % Read the node coordinate file. % [ dim_num, node_num ] = dtable_header_read ( node_coord_file_name ); [ element_order, element_num ] = itable_header_read ( element_file_name ); [ node_data_num, node_num2 ] = dtable_header_read ( node_data_file_name ); if ( node_num2 ~= node_num ) fprintf ( 1, '\n' ); fprintf ( 1, ... ' The number of nodes in the node coordinate file is %d.\n', ... node_num ); fprintf ( 1, ... ' but the number in the node data file is %d\n', node_num2 ); fprintf ( 1, ' Because of this, no node data will be stored.\n' ); node_data_num = 0; end node_coord = dtable_data_read ( node_coord_file_name, dim_num, node_num ); element_node = itable_data_read ( element_file_name, element_order, ... element_num ); node_data = dtable_data_read ( node_data_file_name, node_data_num, node_num );