call_gmsh

PURPOSE ^

call_gmsh: call Gmsh to create a vol_file from a geo_file

SYNOPSIS ^

function status= call_gmsh(geo_file, dim,extra)

DESCRIPTION ^

 call_gmsh: call Gmsh to create a vol_file from a geo_file
 status= call_gmsh(geo_file, dim, extra)
  staus = 0 -> success , negative -> failure

 geo_file = geometry file (input)
 dim      = model dimenstion (default: 2)
 extra    = additional string options for gmsh (see gmsh manual at
            http://geuz.org/gmsh/doc/texinfo/gmsh.html#Command_002dline-options

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status= call_gmsh(geo_file, dim,extra)
0002 % call_gmsh: call Gmsh to create a vol_file from a geo_file
0003 % status= call_gmsh(geo_file, dim, extra)
0004 %  staus = 0 -> success , negative -> failure
0005 %
0006 % geo_file = geometry file (input)
0007 % dim      = model dimenstion (default: 2)
0008 % extra    = additional string options for gmsh (see gmsh manual at
0009 %            http://geuz.org/gmsh/doc/texinfo/gmsh.html#Command_002dline-options
0010 
0011 % (C) 2009-2012 Bartosz Sawicki and Bartlomiej Grychtol
0012 % License: GPL  version 2
0013 % $Id: call_gmsh.m 4162 2013-06-10 20:22:20Z bgrychtol $
0014 
0015 % default to 2-D model
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') % FIXME
0026    islinux =1;
0027 elseif ~strncmp(computer,'PC',2) % Don't know if we have isunix
0028    islinux =1;
0029 else
0030    islinux =0;
0031 end
0032 
0033 % Gmsh executable filename
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

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005