function write_mesh(nodes,elements,filename)

fid = fopen([filename,'.inp'],'w');
[~,name,~] = fileparts(filename);
fprintf(fid,'*Part, name=%s \n',name);
fprintf(fid,'*Node \n');
for i=1:size(nodes,1)
    fprintf(fid,'%d, %f, %f, %f \n',nodes(i,:));
end

fprintf(fid,'*Element, type=C3D8R \n');
for i = 1:size(elements,1)
    fprintf(fid,'%d, %d, %d, %d, %d, %d, %d, %d, %d \n',elements(i,:));
end

fprintf(fid,'*End Part \n');
fclose(fid);
end