Changeset 27632


Ignore:
Timestamp:
03/06/23 19:46:15 (2 years ago)
Author:
jdquinn
Message:

CHG: Corrections to allow for finding of gmsh at all typical locations

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

    r27560 r27632  
    11function mesh=gmshplanet(varargin)
    2 %GMSHPLANET - mesh generation for a sphere. Very specific code for gmsh from $ISSM_DIR/src/demos/simple_geo/sphere.geo
     2%GMSHPLANET - mesh generation for a sphere. Very specific code for Gmsh from $ISSM_DIR/src/demos/simple_geo/sphere.geo
    33%
    44%   Available options (for more details see ISSM website http://issm.jpl.nasa.gov/):
     
    1616
    1717        %Find path to gmsh
    18         paths = {
    19                 [getenv('ISSM_EXT_DIR') '/shared/gmsh/install/bin/gmsh'],...
    20                 [getenv('ISSM_EXT_DIR') '/static/gmsh/install/bin/gmsh'],...
    21                 [getenv('ISSM_EXT_DIR') '/gmsh/install/bin/gmsh'],...
    22                 [issmdir() 'externalpackages/gmsh/install/bin/gmsh'],...
    23                 [issmdir() 'bin/gmsh'],...
    24                 ['/usr/bin/gmsh']...
     18        paths={
     19                [getenv('ISSM_EXT_DIR') '/shared/gmsh/install/bin'],...
     20                [getenv('ISSM_EXT_DIR') '/static/gmsh/install/bin'],...
     21                [getenv('ISSM_EXT_DIR') '/gmsh/install/bin'],...
     22                [issmdir() '/externalpackages/gmsh/install/bin'],...
     23                [issmdir() '/bin'],...
     24                ['/usr/bin']...
    2525        };
    26         gmshpath = '';
     26        gmshpath='';
    2727        for i=paths
    28                 if exist(i{1},'file'),
     28                if exist([i{1} '/gmsh'],'file'),
    2929                        gmshpath = i{1};
    3030                        break;
     
    3232        end
    3333        if isempty(gmshpath),
    34                 error('Gmsh not found, make sure it is properly installed');
    35         end
     34                error('gmshplanet: gmsh executable not found!');
     35        end
     36
     37        setenv('PATH', [gmshpath ':' getenv('PATH')]);
    3638
    3739        % Get Gmsh version
     
    3941        if s~=0 || contains(r, 'dyld'),
    4042                error(['gmshplanet: ' r]);
    41         elseif isempty(r),
    42                 % If this function is called from one of our distributable packages, we
    43                 % need to do a bit more to find the Gmsh executable
    44                 [filepath,name,ext]=fileparts(which('gmsh.'));
    45                 setenv('PATH',[filepath ':' getenv('PATH')]);
    46                 [s,r]=system(['gmsh -info | command grep ''Version'' | sed -e ''s/Version[[:blank:]]*:[[:blank:]]//'' | cut -d ''.'' -f1']);
    47                 if s~=0 || contains(r, 'dyld'),
    48                         error(['gmshplanet: ' r]);
    49                 elseif isempty(r),
    50                         error('gmshplanet: Gmsh executable not found!');
    51                 end
    5243        end
    5344        gmshmajorversion=str2num(r);
  • issm/trunk-jpl/src/m/mesh/planet/gmsh/gmshplanet.py

    r27458 r27632  
     1import os
    12import subprocess
    23import numpy as np
     4from issmdir import issmdir
    35from MatlabFuncs import *
    46from mesh3dsurface import *
     
    79
    810def gmshplanet(*args):
    9     """GMSHPLANET - mesh generation for a sphere. Very specific code for gmsh from $ISSM_DIR/src/demos/simple_geo/sphere.geo
     11    """gmshplanet - mesh generation for a sphere. Very specific code for Gmsh from $ISSM_DIR/src/demos/simple_geo/sphere.geo
    1012
    1113    Available options (for more details see ISSM website http://issm.jpl.nasa.gov/):
     
    2123        md.mesh = gmshplanet('radius', 6000, 'resolution', 100);
    2224    """
     25
     26    # Find path to gmsh
     27    paths = [
     28        os.environ.get('ISSM_EXT_DIR') + '/shared/gmsh/install/bin',
     29        os.environ.get('ISSM_EXT_DIR') + '/static/gmsh/install/bin',
     30        os.environ.get('ISSM_EXT_DIR') + '/gmsh/install/bin',
     31        issmdir() + '/externalpackages/gmsh/install/bin',
     32        issmdir() + '/bin',
     33        '/usr/bin'
     34    ]
     35    gmshpath = ''
     36    for path in paths:
     37        if exists(path + '/gmsh'):
     38            gmshpath = path
     39            break
     40    if gmshpath == '':
     41        error('gmshplanet: gmsh executable not found!')
     42
     43    os.environ['PATH'] = gmshpath ':' os.environ.get['PATH']
    2344
    2445    # Get Gmsh version
     
    195216
    196217    # A little technicality here. The mesh is not exactly on the sphere. We
    197     # create lat,long coordiantes, and reproject onto an exact sphere.
     218    # create lat,long coordinates, and reproject onto an exact sphere.
    198219    mesh.r = np.sqrt(mesh.x ** 2 + mesh.y ** 2 + mesh.z ** 2)
    199220
Note: See TracChangeset for help on using the changeset viewer.