Changeset 27174


Ignore:
Timestamp:
08/02/22 02:44:42 (3 years ago)
Author:
bdef
Message:

BUG:some fixes and path discovery addition

Location:
issm/trunk-jpl/src/m/mesh/planet/gmsh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.m

    r27158 r27174  
    1414%      md.mesh=gmshplanet('radius',6000,'resolution',100);
    1515%      md.mesh=gmshplanet('radius',6000,'resolution',100);
     16
     17        %Find path to gmsh
     18        paths = {[issmdir() 'bin/gmsh'],...
     19                 [issmdir() 'externalpackages/gmsh/install/gmsh'],...
     20                 ['/usr/bin/gmsh']...
     21                };
     22        gmshpath = '';
     23        for i=paths
     24                if exist(i{1},'file'),
     25                        gmshpath = i{1};
     26                        break;
     27                end
     28        end
     29        if isempty(gmshpath),
     30                error('gmsh not found, make sure it is properly installed');
     31        end
    1632
    1733        % Get Gmsh version
     
    5167
    5268        % NOTE:
    53         % - The default format in Gmsh 3 is "msh2". Rather than conditionally 
    54         % modifying our parsing scheme for Gmsh 4, for now, we simply set the 
     69        % - The default format in Gmsh 3 is "msh2". Rather than conditionally
     70        % modifying our parsing scheme for Gmsh 4, for now, we simply set the
    5571        % 'Mesh.MshFileVersion' option.
    56         % - Decreasing the value of the 'Mesh.RandomFactor' option leads to an 
    57         % equal number of nodes and elements being produced under macOS and Linux 
     72        % - Decreasing the value of the 'Mesh.RandomFactor' option leads to an
     73        % equal number of nodes and elements being produced under macOS and Linux
    5874        % at certain resolutions using certain meshing algorithms.
    5975        %
     
    142158
    143159        % Call gmsh
     160        %
     161        % NOTE: The default format in Gmsh 3 is "msh2". Rather than conditionally
     162        %               modifying our parsing scheme for Gmsh 4, for now, we simply set the
     163        %               "-format" option.
     164        %
    144165        if  exist(options,'refine'),
    145166                system(['gmsh -2 sphere.geo -bgm sphere.pos']);
     
    195216        %}}}
    196217
    197         %a little technicality here. the mesh generate is not exactly on the 
    198         %sphere. we create lat,long coordinates, and reproject on an exact sphere. 
     218        %a little technicality here. the mesh generate is not exactly on the
     219        %sphere. we create lat,long coordinates, and reproject on an exact sphere.
    199220        mesh.r=sqrt(mesh.x.^2+mesh.y.^2+mesh.z.^2);
    200221
    201         %make sure we don't have south and north pole: 
     222        %make sure we don't have south and north pole:
    202223        pos=find(mesh.x==0 & mesh.y==0);
    203224        mesh.lat = asind(mesh.z./mesh.r);
  • issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py

    r27119 r27174  
    2626    subproc = subprocess.Popen(subproc_args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
    2727    outs, errs = subproc.communicate()
    28     if ((not isinstance(errs, bytes)) & (errs != '')) or (isinstance(errs, bytes) & (errs.decode() != '')):
     28    try:
     29        strErrs = errs.decode()
     30    except AttributeError:  #this is not a byte variable, let's assume string
     31        strErrs = errs
     32    if strErrs != '':
    2933        raise Exception('gmshplanet: call to gmsh failed: {}'.format(errs))
    3034    gmshmajorversion = int(outs)
Note: See TracChangeset for help on using the changeset viewer.