call_gmsh

PURPOSE ^

call_gmsh: call Gmsh to create a vol_file from a geo_file

SYNOPSIS ^

function status= call_gmsh(geo_file, 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)
 extra    = additional string options for gmsh (see gmsh manual at
            http://geuz.org/gmsh/doc/texinfo/gmsh.html#Command_002dline-options

 NOTE: Make sure the geo file contains the Mesh command!

 To debug the shapes and view the gmsh interface, use
   eidors_debug on call_gmsh

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status= call_gmsh(geo_file, 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 % extra    = additional string options for gmsh (see gmsh manual at
0008 %            http://geuz.org/gmsh/doc/texinfo/gmsh.html#Command_002dline-options
0009 %
0010 % NOTE: Make sure the geo file contains the Mesh command!
0011 %
0012 % To debug the shapes and view the gmsh interface, use
0013 %   eidors_debug on call_gmsh
0014 
0015 
0016 % (C) 2009-2024 Bartosz Sawicki and Bartlomiej Grychtol
0017 % License: GPL  version 2
0018 % $Id: call_gmsh.m 6837 2024-05-02 08:29:02Z bgrychtol $
0019 
0020 % default to 2-D model
0021 if nargin<2
0022     dim = 2;
0023 end
0024 if nargin<3
0025    extra = [];
0026 end
0027 
0028 isoctave = getfield(eidors_obj('interpreter_version'),'isoctave');
0029 
0030 cache_path = eidors_cache('cache_path');
0031 
0032 % Gmsh executable filename
0033 if  ~ispc
0034    % Matlab plays with libraries
0035    gmsh_name = 'LD_LIBRARY_PATH="" gmsh';
0036 else
0037    gmsh_name = [cache_path,'/gmsh'];
0038 end
0039 
0040 % Matlab reports physical cores, Octave reports logical ones
0041 num_threads = max(maxNumCompThreads -1 -isoctave, 2);
0042 cmd = sprintf( '%s "%s" -nt %d %s',  gmsh_name, geo_file, ...
0043                num_threads, extra);
0044 if ~eidors_debug('query','call_gmsh')
0045    cmd = [cmd ' -term -v 2 -save'];
0046 end
0047 while( 1 )
0048 
0049     status= system_cmd(cmd);
0050 
0051     if status==0; break; end
0052 
0053     if ~ispc
0054         disp(['It seems you are running Linux or MacOS and Gmsh has not worked. ' ...
0055             'Check that it is installed and on the path. \n' ...
0056             'Perhaps LD_LIBRARY_PATH needs to be set?' ]);
0057         break;
0058     else
0059         fprintf([ ...
0060             'Gmsh call failed. Is Gmsh installed and on the search path?\n' ...
0061             'You are running under windows, I can attempt to create\n' ...
0062             'a batch file to access gmsh.\n' ...
0063             'Please enter the directory in which to find gmsh.\n' ...
0064             'If you dont have a copy, download it from ' ...
0065             'http://www.geuz.org/gmsh/\n\n' ]);
0066 
0067         gmsh_path = input('gmsh_path? [or i=ignore, e=error] ','s');
0068         if strcmp(gmsh_path,'i'); break;end
0069         if strcmp(gmsh_path,'e'); error('user requested'),end;
0070         if exist( sprintf('%s/gmsh.exe',gmsh_path) , 'file' ) || ...
0071                 exist( sprintf('%s/bin/gmsh.exe',gmsh_path) , 'file' )
0072             disp('Found gmsh');
0073             gmsh_exe = gmsh_path;
0074             if exist( sprintf('%s/bin/gmsh.exe',gmsh_path) , 'file' )
0075                 gmsh_exe = [gmsh_path '/bin'];
0076             end
0077 
0078 
0079             fid= fopen([cache_path, '/gmsh.bat'],'w');
0080             fprintf(fid,'"%s/gmsh.exe" %%*\n', gmsh_exe);
0081             fclose(fid);
0082         end
0083     end
0084 end

Generated on Sun 29-Dec-2024 11:41:59 by m2html © 2005