Changeset 27841


Ignore:
Timestamp:
07/20/23 11:25:51 (20 months ago)
Author:
jdquinn
Message:

CHG: MATLAB -> Python; cleanup

Location:
issm/trunk-jpl/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/mesh/roundmesh.m

    r26953 r27841  
    1111
    1212%First we have to create the domain outline
    13 if nargin<4
     13if nargin>=4:
     14        expname = varargin{1};
     15else
    1416        expname = [tempname() '.exp'];
    15 else
    16         expname = varargin{1};
    1717end
    1818
     
    2020pointsonedge=floor((2.*pi*radius) / resolution)+1; %+1 to close the outline
    2121
    22 %Calculate the cartesians coordinates of the points
     22%Calculate the Cartesian coordinates of the points
    2323theta=linspace(0,2*pi,pointsonedge)';
    2424x_list=roundsigfig(radius*cos(theta),12);
  • issm/trunk-jpl/src/m/mesh/roundmesh.py

    r26982 r27841  
    33from collections import OrderedDict
    44from expwrite import expwrite
     5from MatlabFuncs import tempname
    56from triangle import triangle
    67
    78
    8 def roundmesh(md, radius, resolution):
    9     """
    10     ROUNDMESH - create an unstructured round mesh
     9def roundmesh(md, radius, resolution, *args):
     10    """roundmesh - create an unstructured round mesh
    1111
    12        This script will generate a structured round mesh
    13  - radius     : specifies the radius of the circle in meters
    14  - resolution : specifies the resolution in meters
     12    This script will generate a structured round mesh
     13    - radius     : specifies the radius of the circle in meters
     14    - resolution : specifies the resolution in meters
    1515
    16        Usage:
    17           md = roundmesh(md, radius, resolution)
     16    Usage:
     17        md = roundmesh(md, radius, resolution)
     18        md = roundmesh(md, radius, resolution, 'domain.exp')
    1819    """
    1920    # First we have to create the domain outline
     21    if len(args):
     22        expname = args[0]
     23    else:
     24        expname = tempname() + '.exp'
     25        print(expname)
     26        exit()
     27
    2028    # Get number of points on the circle
    21     pointsonedge = int(np.floor((2. * np.pi * radius) / resolution) + 1)  # + 1 to close the outline
     29    pointsonedge = int(np.floor((2. * np.pi * radius) / resolution) + 1)  # +1 to close the outline
    2230
    23     # Calculate the cartesians coordinates of the points
     31    # Calculate the Cartesian coordinates of the points
    2432    theta = np.linspace(0., 2. * np.pi, pointsonedge)
    2533    x_list = roundsigfig(radius * np.cos(theta), 12)
     
    2937    A['y'] = y_list
    3038    A['density'] = 1.
    31     expwrite(A, 'RoundDomainOutline.exp')
     39    expwrite(A, expname)
    3240
    3341    # Call Bamg
    34     md = triangle(md, 'RoundDomainOutline.exp', resolution)
     42    md = triangle(md, expname, resolution)
    3543    # md = bamg(md, 'domain', 'RoundDomainOutline.exp', 'hmin', resolution)
    3644
    37     # move the closest node to the center
     45    # Move the closest node to the center
    3846    pos = np.argmin(md.mesh.x**2 + md.mesh.y**2)
    3947    md.mesh.x[pos] = 0.
    4048    md.mesh.y[pos] = 0.
    4149
    42     # delete domain
    43     os.remove('RoundDomainOutline.exp')
     50    # Delete domain
     51    os.remove(expname)
    4452
    4553    return md
     
    4755
    4856def roundsigfig(x, n):
    49 
    5057    nonzeros = np.where(x != 0)
    5158    digits = np.ceil(np.log10(np.abs(x[nonzeros])))
  • issm/trunk-jpl/src/m/miscellaneous/MatlabFuncs.py

    r27458 r27841  
    372372        return False
    373373# }}}
     374
     375def tempname():  # {{{
     376    import random
     377    import string
     378
     379    alphanumlist = string.ascii_lowercase + string.digits
     380    return '/tmp/tp' + ''.join(random.choices(alphanumlist, k=8)) + '_' + ''.join(random.choices(alphanumlist, k=4)) + '_' + ''.join(random.choices(alphanumlist, k=4)) + '_' + ''.join(random.choices(alphanumlist, k=4)) + '_' + ''.join(random.choices(alphanumlist, k=12))
     381# }}}
  • issm/trunk-jpl/src/wrappers/Triangle/Triangle.h

    r26036 r27841  
    1919#ifdef _HAVE_JAVASCRIPT_MODULES_
    2020#undef _DO_NOT_LOAD_GLOBALS_ /*only module where this needs to be undefined, so as to
    21                                                            not include IssmComm several times in the javascript Modle construct.*/
     21                                                           not include IssmComm several times in the JavaScript module construct.*/
    2222#endif
    2323
Note: See TracChangeset for help on using the changeset viewer.