0001 function status= call_gmsh(geo_file, dim,extra)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if nargin<2
0017 dim = 2;
0018 end
0019 if nargin<3
0020 extra = [];
0021 end
0022
0023 cache_path = eidors_cache('cache_path');
0024
0025 if exist('OCTAVE_VERSION')
0026 islinux =1;
0027 elseif ~strncmp(computer,'PC',2)
0028 islinux =1;
0029 else
0030 islinux =0;
0031 end
0032
0033
0034 if islinux
0035 gmsh_name = 'gmsh';
0036 else
0037 gmsh_name = [cache_path,'/gmsh'];
0038 end
0039
0040 while( 1 )
0041 ldpath='';
0042 if ~exist('OCTAVE_VERSION') && ~isempty(strfind(system_dependent('getos'),'Linux'))
0043 islinux =1;
0044 else
0045 islinux =0;
0046 end
0047
0048 status= system_cmd(sprintf( '%s "%s" -%d -v 2 %s', gmsh_name, geo_file, dim, extra));
0049
0050 if status==0; break; end
0051
0052 if islinux
0053 disp(['It seems you are running Linux and Gmsh has not worked. ' ...
0054 'Check that it is installed and on the path. \n' ...
0055 'Perhaps LD_LIBRARY_PATH needs to be set?' ]);
0056 break;
0057 else
0058 fprintf([ ...
0059 'Gmsh call failed. Is Gmsh installed and on the search path?\n' ...
0060 'You are running under windows, I can attempt to create\n' ...
0061 'a batch file to access gmsh.\n' ...
0062 'Please enter the directory in which to find gmsh.\n' ...
0063 'If you dont have a copy, download it from' ...
0064 'http://www.geuz.org/gmsh/\n\n' ]);
0065
0066 gmsh_path = input('gmsh_path? [or i=ignore, e=error] ','s');
0067 if strcmp(gmsh_name,'i'); break;end
0068 if strcmp(gmsh_name,'e'); error('user requested'),end;
0069 if exist( sprintf('%s/gmsh.exe',gmsh_path) , 'file' ) || ...
0070 exist( sprintf('%s/bin/gmsh.exe',gmsh_path) , 'file' )
0071 disp('Found gmsh');
0072 gmsh_exe = gmsh_path;
0073 if exist( sprintf('%s/bin/gmsh.exe',gmsh_path) , 'file' )
0074 gmsh_exe = [gmsh_path '/bin'];
0075 end
0076
0077
0078 fid= fopen([cache_path, '/gmsh.bat'],'w');
0079 fprintf(fid,'"%s/gmsh.exe" %%*\n', gmsh_exe);
0080 fclose(fid);
0081 end
0082 end
0083 end