Changeset 28158


Ignore:
Timestamp:
03/15/24 14:25:42 (13 months ago)
Author:
jdquinn
Message:

CHG: Need to deepcopy model; clean up

Location:
issm/trunk-jpl
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/interp

    • Property svn:ignore
      •  

        old new  
        11Makefile.in
        22Makefile
         3__pycache__
  • issm/trunk-jpl/src/m/mesh/bamg.m

    r25619 r28158  
    2929%   - NoBoundaryRefinementAllBoundaries: do not refine boundary, only follow contour provided (default 0)
    3030%   - maxnbv :            maximum number of vertices used to allocate memory (default is 10^6)
    31 %   - maxsubdiv :         maximum subdivision of exisiting elements (default is 10)
     31%   - maxsubdiv :         maximum subdivision of existing elements (default is 10)
    3232%   - metric :            matrix (numberofnodes x 3) used as a metric
    3333%   - Metrictype :        0 -> absolute error          c/(err coeff^2) * Abs(H)        (default)
     
    5858options=deleteduplicates(options,1);
    5959
    60 %initialize the structures required as input of Bamg
     60%initialize the structures required as input of BAMG
    6161bamg_options=struct();
    6262bamg_geometry=bamggeom();
     
    6565subdomain_ref = 1;
    6666hole_ref = 1;
    67 % Bamg Geometry parameters {{{
     67% BAMG Geometry parameters {{{
    6868if exist(options,'domain'),
    6969
     
    453453end
    454454%}}}
    455 % Bamg Mesh parameters {{{
     455% BAMG Mesh parameters {{{
    456456if (~exist(options,'domain') & md.mesh.numberofvertices~=0 & strcmp(elementtype(md.mesh),'Tria')),
    457457
     
    468468end
    469469%}}}
    470 % Bamg Options {{{
     470% BAMG Options {{{
    471471bamg_options.Crack=getfieldvalue(options,'Crack',0);
    472 bamg_options.anisomax=getfieldvalue(options,'anisomax',10.^30);
     472bamg_options.anisomax=getfieldvalue(options,'anisomax',1e30);
    473473bamg_options.coeff=getfieldvalue(options,'coeff',1.);
    474 bamg_options.cutoff=getfieldvalue(options,'cutoff',10.^-5);
     474bamg_options.cutoff=getfieldvalue(options,'cutoff',1e-5);
    475475bamg_options.err=getfieldvalue(options,'err',0.01);
    476476bamg_options.errg=getfieldvalue(options,'errg',0.1);
     
    478478bamg_options.gradation=getfieldvalue(options,'gradation',1.5);
    479479bamg_options.Hessiantype=getfieldvalue(options,'Hessiantype',0);
    480 bamg_options.hmin=getfieldvalue(options,'hmin',10.^-100);
    481 bamg_options.hmax=getfieldvalue(options,'hmax',10.^100);
     480bamg_options.hmin=getfieldvalue(options,'hmin',1e-100);
     481bamg_options.hmax=getfieldvalue(options,'hmax',1e100);
    482482bamg_options.hminVertices=getfieldvalue(options,'hminVertices',[]);
    483483bamg_options.hmaxVertices=getfieldvalue(options,'hmaxVertices',[]);
    484484bamg_options.hVertices=getfieldvalue(options,'hVertices',[]);
    485485bamg_options.KeepVertices=getfieldvalue(options,'KeepVertices',1);
    486 bamg_options.maxnbv=getfieldvalue(options,'maxnbv',10^6);
     486bamg_options.maxnbv=getfieldvalue(options,'maxnbv',1e6);
    487487bamg_options.maxsubdiv=getfieldvalue(options,'maxsubdiv',10.);
    488488bamg_options.metric=getfieldvalue(options,'metric',[]);
     
    496496%}}}
    497497
    498 %call Bamg
     498%call BAMG
    499499[bamgmesh_out bamggeom_out]=BamgMesher(bamg_mesh,bamg_geometry,bamg_options);
    500500
     
    550550end
    551551
    552 %Bamg private fields
     552%BAMG private fields
    553553md.private.bamg=struct();
    554554md.private.bamg.mesh=bamgmesh(bamgmesh_out);
  • issm/trunk-jpl/src/m/mesh/bamg.py

    r27458 r28158  
    1919
    2020def bamg(md, *args):
    21     """BAMG - mesh generation
     21    """bamg - mesh generation
    2222
    2323    Available options (for more details see ISSM website http://issm.jpl.nasa.gov/):
    2424
    25     - domain :                              followed by an ARGUS file that
    26                                             prescribes the domain outline
    27     - holes :                               followed by an ARGUS file that
    28                                             prescribes the holes
    29     - subdomains :                          followed by an ARGUS file that
    30                                             prescribes the list of subdomains
    31                                             (that need to be inside domain)
    32 
    33     - hmin :                                minimum edge length (default is
    34                                             1.0e-100)
    35     - hmax :                                maximum edge length (default is
    36                                             1.0e100)
    37     - hVertices :                           imposed edge length for each vertex
    38                                             (geometry or mesh)
    39     - hminVertices :                        minimum edge length for each vertex
    40                                             (mesh)
    41     - hmaxVertices :                        maximum edge length for each vertex
    42                                             (mesh)
    43 
    44     - anisomax :                            maximum ratio between the smallest
    45                                             and largest edges (default is
    46                                             1.0e30)
    47     - coeff :                               coefficient applied to the metric
    48                                             (2 -> twice as many elements,
    49                                             default is 1)
    50     - cutoff :                              scalar used to compute the metric
    51                                             when metric type 2 or 3 are applied
    52     - err :                                 error used to generate the metric
    53                                             from a field
     25    - domain :                              followed by an ARGUS file that prescribes the domain outline
     26    - holes :                               followed by an ARGUS file that prescribes the holes
     27    - subdomains :                          followed by an ARGUS file that prescribes the list of subdomains (that need to be inside domain)
     28
     29    - hmin :                                minimum edge length (default is 1.0e-100)
     30    - hmax :                                maximum edge length (default is 1.0e100)
     31    - hVertices :                           imposed edge length for each vertex (geometry or mesh)
     32    - hminVertices :                        minimum edge length for each vertex (mesh)
     33    - hmaxVertices :                        maximum edge length for each vertex (mesh)
     34
     35    - anisomax :                            maximum ratio between the smallest and largest edges (default is 1.0e30)
     36    - coeff :                               coefficient applied to the metric (2 -> twice as many elements, default is 1)
     37    - cutoff :                              scalar used to compute the metric when metric type 2 or 3 are applied
     38    - err :                                 error used to generate the metric from a field
    5439    - errg :                                geometric error (default is 0.1)
    55     - field :                               field of the model that will be
    56                                             used to compute the metric to apply
    57                                             several fields, use one column per
    58                                             field
    59     - gradation :                           maximum ratio between two adjacent
    60                                             edges
    61     - Hessiantype :                         0 -> use double P2 projection
    62                                             (default)
     40    - field :                               field of the model that will be used to compute the metric to apply several fields, use one column per field
     41    - gradation :                           maximum ratio between two adjacent edges
     42    - Hessiantype :                         0 -> use double P2 projection (default)
    6343                                            1 -> use Green formula
    64     - KeepVertices :                        try to keep initial vertices when
    65                                             adaptation is done on an existing
    66                                             mesh (default 1)
    67     - NoBoundaryRefinement :                do not refine boundary, only follow
    68                                             contour provided (default 0). Allow
    69                                             subdomain boundary refinement
    70                                             though
    71     - NoBoundaryRefinementAllBoundaries :   do not refine boundary, only follow
    72                                             contour provided (default 0)
    73     - maxnbv :                              maximum number of vertices used to
    74                                             allocate memory (default is 1.0e6)
    75     - maxsubdiv :                           maximum subdivision of exisiting
    76                                             elements (default is 10)
    77     - metric :                              matrix (numberofnodes x 3) used as
    78                                             a metric
    79     - Metrictype :                          1 -> absolute error
    80                                             c/(err coeff^2) * Abs(H) (default)
    81                                             2 -> relative error
    82                                             c / (err coeff^2) * Abs(H) /
    83                                             max(s, cutoff * max(s))
    84                                             3 -> rescaled absolute error
    85                                             c / (err coeff^2) * Abs(H) /
    86                                             (smax - smin)
    87     - nbjacoby :                            correction used by Hessiantype = 1
    88                                             (default is 1)
    89     - nbsmooth :                            number of metric smoothing
    90                                             procedure (default is 3)
    91     - omega :                               relaxation parameter of the
    92                                             smoothing procedure (default is
    93                                             1.8)
    94     - power :                               power applied to the metric
    95                                             (default is 1)
    96     - splitcorners :                        split triangles which have 3
    97                                             vertices on the outline (default is
    98                                             1)
     44    - KeepVertices :                        try to keep initial vertices when adaptation is done on an existing mesh (default 1)
     45    - NoBoundaryRefinement :                do not refine boundary, only follow contour provided (default 0). Allow subdomain boundary refinement though
     46    - NoBoundaryRefinementAllBoundaries :   do not refine boundary, only follow contour provided (default 0)
     47    - maxnbv :                              maximum number of vertices used to allocate memory (default is 1.0e6)
     48    - maxsubdiv :                           maximum subdivision of existing elements (default is 10)
     49    - metric :                              matrix (numberofnodes x 3) used as a metric
     50    - Metrictype :                          1 -> absolute error          c/(err coeff^2) * Abs(H)        (default)
     51                                            2 -> relative error          c / (err coeff^2) * Abs(H) / max(s, cutoff * max(s))
     52                                            3 -> rescaled absolute error c / (err coeff^2) * Abs(H) / (smax - smin)
     53    - nbjacoby :                            correction used by Hessiantype = 1 (default is 1)
     54    - nbsmooth :                            number of metric smoothing procedure (default is 3)
     55    - omega :                               relaxation parameter of the smoothing procedure (default is 1.8)
     56    - power :                               power applied to the metric (default is 1)
     57    - splitcorners :                        split triangles which have 3 vertices on the outline (default is 1)
    9958    - verbose :                             level of verbosity (default is 1)
    10059
    101     - rifts :                               followed by an ARGUS file that
    102                                             prescribes the rifts
    103     - toltip :                              tolerance to move tip on an
    104                                             existing point of the domain
    105                                             outline
    106     - tracks :                              followed by an ARGUS file that
    107                                             prescribes the tracks that the mesh
    108                                             will stick to
    109     - RequiredVertices :                    mesh vertices that are required.
    110                                             [x, y, ref]; ref is optional
    111     - tol :                                 if the distance between 2 points of
    112                                             the domain outline is less than
    113                                             tol, they will be merged
     60    - vertical :                            is this a 2d vertical mesh (flowband, default is 0)
     61    - rifts :                               followed by an ARGUS file that prescribes the rifts
     62    - toltip :                              tolerance to move tip on an existing point of the domain outline
     63    - tracks :                              followed by an ARGUS file that prescribes the tracks that the mesh will stick to
     64    - RequiredVertices :                    mesh vertices that are required. [x, y, ref]; ref is optional
     65    - tol :                                 if the distance between 2 points of the domain outline is less than tol, they will be merged
    11466
    11567    Examples:
     
    12678    #options = deleteduplicates(options, 1)
    12779
    128     # Initialize the structures required as input of Bamg
     80    # Initialize the structures required as input of BAMG
    12981    bamg_options = OrderedDict()
    13082    bamg_geometry = bamggeom()
     
    13486    hole_ref = 1
    13587
    136     # Bamg Geometry parameters {{{
     88    # BAMG Geometry parameters {{{
    13789    if options.exist('domain'):
    13890        #Check that file exists
     
    532484        bamg_geometry = bamggeom(md.private.bamg['geometry'].__dict__)
    533485    else:
    534         #do nothing...
     486        # Do nothing...
    535487        pass
    536488    # }}}
    537     # Bamg mesh parameters {{{
     489    # BAMG mesh parameters {{{
    538490    if not options.exist('domain') and md.mesh.numberofvertices and md.mesh.elementtype() == 'Tria':
    539491        if isinstance(md.private.bamg, dict) and 'mesh' in md.private.bamg:
     
    548500
    549501        if isinstance(md.rifts.riftstruct, dict):
    550             raise TypeError("bamg error message: rifts not supported yet. Do meshprocessrift AFTER bamg")
     502            raise TypeError('bamg error message: rifts not supported yet. Do meshprocessrift AFTER bamg')
    551503    # }}}
    552     # Bamg options {{{
     504    # BAMG options {{{
    553505    bamg_options['Crack'] = options.getfieldvalue('Crack', 0)
    554     bamg_options['anisomax'] = options.getfieldvalue('anisomax', pow(10.0, 18))
     506    bamg_options['anisomax'] = options.getfieldvalue('anisomax', 1e30)
    555507    bamg_options['coeff'] = options.getfieldvalue('coeff', 1.0)
    556     bamg_options['cutoff'] = options.getfieldvalue('cutoff', pow(10.0, -5))
    557     bamg_options['err'] = options.getfieldvalue('err', np.array([[0.01]]))
     508    bamg_options['cutoff'] = options.getfieldvalue('cutoff', 1e-5)
     509    bamg_options['err'] = options.getfieldvalue('err', 0.01)
    558510    bamg_options['errg'] = options.getfieldvalue('errg', 0.1)
    559511    bamg_options['field'] = options.getfieldvalue('field', np.empty((0, 1)))
    560512    bamg_options['gradation'] = options.getfieldvalue('gradation', 1.5)
    561513    bamg_options['Hessiantype'] = options.getfieldvalue('Hessiantype', 0)
    562     bamg_options['hmin'] = options.getfieldvalue('hmin', pow(10.0, -100))
    563     bamg_options['hmax'] = options.getfieldvalue('hmax', pow(10.0, 100))
     514    bamg_options['hmin'] = options.getfieldvalue('hmin', 1e-100)
     515    bamg_options['hmax'] = options.getfieldvalue('hmax', 1e100)
    564516    bamg_options['hminVertices'] = options.getfieldvalue('hminVertices', np.empty((0, 1)))
    565517    bamg_options['hmaxVertices'] = options.getfieldvalue('hmaxVertices', np.empty((0, 1)))
    566518    bamg_options['hVertices'] = options.getfieldvalue('hVertices', np.empty((0, 1)))
    567519    bamg_options['KeepVertices'] = options.getfieldvalue('KeepVertices', 1)
    568     bamg_options['maxnbv'] = options.getfieldvalue('maxnbv', pow(10, 6))
     520    bamg_options['maxnbv'] = options.getfieldvalue('maxnbv', 1e6)
    569521    bamg_options['maxsubdiv'] = options.getfieldvalue('maxsubdiv', 10.0)
    570522    bamg_options['metric'] = options.getfieldvalue('metric', np.empty((0, 1)))
     
    578530    # }}}
    579531
    580     # Call Bamg
     532    # Call BAMG
    581533    bamgmesh_out, bamggeom_out = BamgMesher(bamg_mesh.__dict__, bamg_geometry.__dict__, bamg_options)
    582534
     
    632584        md.mesh.vertexonboundary[md.mesh.segments[:, 0:2] - 1] = 1
    633585
    634     # Bamg private fields
     586    # BAMG private fields
    635587    md.private.bamg = OrderedDict()
    636588    md.private.bamg['mesh'] = bamgmesh(bamgmesh_out)
     
    732684
    733685    if num:
    734         print(('WARNING: {} points outside the domain outline have been removed'.format(num)))
     686        print('WARNING: {} points outside the domain outline have been removed'.format(num))
    735687
    736688    """
  • issm/trunk-jpl/src/m/modules/ContourToMesh.py

    r24213 r28158  
    33
    44def ContourToMesh(index, x, y, contourname, interptype, edgevalue):
    5     """
     5    """ContourToMesh - Flag the elements or nodes inside a contour
    66
    7     CONTOURTOMESH - Flag the elements or nodes inside a contour
     7    Usage:
     8        [in_nod, in_elem] = ContourToMesh(index, x, y, contourname, interptype, edgevalue)
    89
    9         Usage:
    10             [in_nod, in_elem] = ContourToMesh(index, x, y, contourname, interptype, edgevalue)
     10        index, x, y: mesh triangulation.
     11        contourname: name of .exp file containing the contours.
     12        interptype: string defining type of interpolation ('element', or 'node').
     13        edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.
     14        in_nod: vector of flags (0 or 1), of size nel if interptype is set to 'node' or 'element and node', or of size 0 otherwise.
     15        in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node', or of size 0 otherwise.
    1116
    12             index, x, y: mesh triangulation.
    13             contourname: name of .exp file containing the contours.
    14             interptype: string defining type of interpolation ('element', or 'node').
    15             edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.
    16             in_nod: vector of flags (0 or 1), of size nel if interptype is set to 'node' or 'element and node',
    17                 or of size 0 otherwise.
    18             in_elem: vector of flags (0 or 1), of size nel if interptype is set to 'element' or 'element and node',
    19                 or of size 0 otherwise.
    20 
    21         Example:
    22             in_nod = ContourToMesh(md.elements, md.x, md.y, 'Contour.exp', 'node', 1)
    23             in_elements = ContourToMesh(md.elements, md.x, md.y, 'Contour.exp', 'element', 0)
    24             [in_nodes, in_elements] = ContourToMesh(md.elements, md.x, md.y, 'Contour.exp', 'element and node', 0)
     17    Example:
     18        in_nod = ContourToMesh(md.elements, md.x, md.y, 'Contour.exp', 'node', 1)
     19        in_elements = ContourToMesh(md.elements, md.x, md.y, 'Contour.exp', 'element', 0)
     20        [in_nodes, in_elements] = ContourToMesh(md.elements, md.x, md.y, 'Contour.exp', 'element and node', 0)
    2521    """
    2622    #Call mex module
  • issm/trunk-jpl/src/m/modules/ContourToNodes.py

    r25455 r28158  
    33
    44def ContourToNodes(x, y, contourname, edgevalue):
    5     """CONTOURTONODES - flags vertices inside contour
     5    """ContourToNodes - flags vertices inside contour
    66
    77    x, y:           list of nodes
  • issm/trunk-jpl/src/m/solve/WriteData.py

    r26553 r28158  
    88
    99def WriteData(fid, prefix, *args):
    10     """WRITEDATA - write model field in binary file
     10    """WriteData - write model field in binary file
    1111
    1212    Usage:
     
    1414    """
    1515
    16     #process options
     16    # Process options
    1717    options = pairoptions.pairoptions(*args)
    18     #Get data properties
     18    # Get data properties
    1919    if options.exist('object'):
    20         #This is an object field, construct enum and data
     20        # This is an object field, construct enum and data
    2121        obj = options.getfieldvalue('object')
    2222        fieldname = options.getfieldvalue('fieldname')
     
    2727            data = getattr(obj, fieldname)
    2828    else:
    29         #No processing required
     29        # No processing required
    3030        data = options.getfieldvalue('data')
    3131        name = options.getfieldvalue('name')
     
    3535    timeserieslength = options.getfieldvalue('timeserieslength', -1)
    3636
    37     #Process sparse matrices
     37    # Process sparse matrices
    3838    #       if issparse(data),
    3939    #               data = full(data)
    4040    #       end
    4141
    42     # Make a copy of the the data so that we do not accidently overwrite any
     42    # Make a copy of the the data so that we do not accidentally overwrite any
    4343    # model fields.
    4444    #
    4545    data = copy(data)
    4646
    47     #Scale data if necessary
     47    # Scale data if necessary
    4848    if datatype == 'MatArray':
    49         #if it is a matrix array we loop over the matrices
     49        # If it is a matrix array we loop over the matrices
    5050        for i in range(len(data)):
    5151            if options.exist('scale'):
    5252                scale = options.getfieldvalue('scale')
    5353                if np.ndim(data[i]) > 1 and data[i].shape[0] == timeserieslength:
    54                     #We scale everything but the last line that holds time
     54                    # We scale everything but the last line that holds time
    5555                    data[i][:-1, :] = scale * data[i][:-1, :]
    5656                else:
    5757                    data[i] = scale * data[i]
    5858            if np.ndim(data[i]) > 1 and data[i].shape[0] == timeserieslength:
    59                 #no scaling given, just get the time right
     59                # No scaling given, just get the time right
    6060                yts = options.getfieldvalue('yts')
    61                 #We scale only the last line that holds time
     61                # We scale only the last line that holds time
    6262                data[i][-1, :] = yts * data[i][-1, :]
    6363    else:
     
    6565            scale = options.getfieldvalue('scale')
    6666            if np.ndim(data) > 1 and data.shape[0] == timeserieslength:
    67                 #We scale everything but the last line that holds time
     67                # We scale everything but the last line that holds time
    6868                data[:-1, :] = scale * data[:-1, :]
    6969            elif type(data) is list: # Deal with "TypeError: can't multiply sequence by non-int of type 'float'" for type list
     
    7272                    scaleddata.append(scale * data[i])
    7373                data = scaleddata
    74             else: #
     74            else:
    7575                data = scale * data
    7676        if np.ndim(data) > 1 and data.shape[0] == timeserieslength:
    7777            yts = options.getfieldvalue('yts')
    78             #We scale only the last line that holds time
     78            # We scale only the last line that holds time
    7979            # scaler = np.ones((np.shape(data)))
    8080            # scaler[-1, :] = yts
     
    8282            data[-1, :] = yts * data[-1, :]
    8383
    84     #Step 1: write the enum to identify this record uniquely
     84    # Step 1: write the enum to identify this record uniquely
    8585    fid.write(pack('i', len(name)))
    8686    fid.write(pack('{}s'.format(len(name)), name.encode()))
    8787
    88     #Step 2: write the data itself.
     88    # Step 2: write the data itself.
    8989    if datatype == 'Boolean':  # {{{
    90         #first write length of record
     90        # First write length of record
    9191        fid.write(pack('q', 4 + 4))  #1 bool (disguised as an int) + code
    92         #write data code:
    93         fid.write(pack('i', FormatToCode(datatype)))
    94 
    95         #now write bool as an integer
     92        # Write data code
     93        fid.write(pack('i', FormatToCode(datatype)))
     94
     95        # Now write bool as an integer
    9696        try:
    9797            fid.write(pack('i', int(data)))  #send an int, not easy to send a bool
     
    101101
    102102    elif datatype == 'Integer':  # {{{
    103         #first write length of record
     103        # First write length of record
    104104        fid.write(pack('q', 4 + 4))  #1 integer + code
    105         #write data code:
    106         fid.write(pack('i', FormatToCode(datatype)))
    107         #now write integer
    108         try:
    109             fid.write(pack('i', int(data)))  #force an int,
     105        # Write data code:
     106        fid.write(pack('i', FormatToCode(datatype)))
     107        # Now write integer
     108        try:
     109            fid.write(pack('i', int(data))) # force an int
    110110        except error as Err:
    111111            raise ValueError('field {} cannot be marshaled, {}'.format(name, Err))
     
    113113
    114114    elif datatype == 'Double':  # {{{
    115         #first write length of record
    116         fid.write(pack('q', 8 + 4))  #1 double + code
    117 
    118     #write data code:
    119         fid.write(pack('i', FormatToCode(datatype)))
    120 
    121     #now write double
     115        # First write length of record
     116        fid.write(pack('q', 8 + 4)) # 1 double + code
     117
     118        # Write data code
     119        fid.write(pack('i', FormatToCode(datatype)))
     120
     121        # Now write double
    122122        try:
    123123            fid.write(pack('d', data))
     
    127127
    128128    elif datatype == 'String':  # {{{
    129         #first write length of record
    130         fid.write(pack('q', len(data) + 4 + 4))  #string + string size + code
    131         #write data code:
    132         fid.write(pack('i', FormatToCode(datatype)))
    133         #now write string
     129        # First write length of record
     130        fid.write(pack('q', len(data) + 4 + 4)) # string + string size + code
     131        # Write data code
     132        fid.write(pack('i', FormatToCode(datatype)))
     133        # Now write string
    134134        fid.write(pack('i', len(data)))
    135135        fid.write(pack('{}s'.format(len(data)), data.encode()))
     
    147147                data = data.reshape(0, 0)
    148148
    149     #Get size
     149        # Get size
    150150        s = data.shape
    151     #if matrix = NaN, then do not write anything
     151        # If matrix = NaN, then do not write anything
    152152        if np.ndim(data) == 2 and np.product(s) == 1 and np.all(np.isnan(data)):
    153153            s = (0, 0)
    154154
    155     #first write length of record
    156         recordlength = 4 + 4 + 8 * np.product(s) + 4 + 4  #2 integers (32 bits) + the double matrix + code + matrix type
     155        # First write length of record
     156        recordlength = 4 + 4 + 8 * np.product(s) + 4 + 4 # 2 integers (32 bits) + the double matrix + code + matrix type
    157157        fid.write(pack('q', recordlength))
    158158
    159     #write data code and matrix type:
     159        # Write data code and matrix type
    160160        fid.write(pack('i', FormatToCode(datatype)))
    161161        fid.write(pack('i', mattype))
    162162
    163     #now write matrix
     163        # Now write matrix
    164164        fid.write(pack('i', s[0]))
    165165        try:
     
    186186                data = data.reshape(0, 0)
    187187
    188     #Get size
     188        # Get size
    189189        s = data.shape
    190     #if matrix = NaN, then do not write anything
     190        # If matrix = NaN, then do not write anything
    191191        if np.ndim(data) == 1 and np.product(s) == 1 and np.all(np.isnan(data)):
    192192            s = (0, 0)
    193193
    194     #first write length of record
    195         recordlength = 4 + 4 + 8 * np.product(s) + 4 + 4  #2 integers (32 bits) + the double matrix + code + matrix type
     194        # First write length of record
     195        recordlength = 4 + 4 + 8 * np.product(s) + 4 + 4 # 2 integers (32 bits) + the double matrix + code + matrix type
    196196
    197197        try:
     
    200200            raise ValueError('Field {} can not be marshaled, {}, with "number" the length of the record.'.format(name, Err))
    201201
    202     #write data code and matrix type:
     202        # Write data code and matrix type
    203203        fid.write(pack('i', FormatToCode(datatype)))
    204204        fid.write(pack('i', mattype))
    205     #now write matrix
     205        # Now write matrix
    206206        fid.write(pack('i', s[0]))
    207207        try:
     
    211211        for i in range(s[0]):
    212212            if np.ndim(data) == 1:
    213                 fid.write(pack('d', float(data[i])))  #get to the "c" convention, hence the transpose
     213                fid.write(pack('d', float(data[i]))) # get to the "c" convention, hence the transpose
    214214            else:
    215215                for j in range(s[1]):
    216                     fid.write(pack('d', float(data[i][j])))  #get to the "c" convention, hence the transpose
     216                    fid.write(pack('d', float(data[i][j]))) # get to the "c" convention, hence the transpose
    217217    # }}}
    218218
     
    228228                data = data.reshape(0, 0)
    229229
    230     #Get size
     230        # Get size
    231231        s = data.shape
    232232        if np.ndim(data) == 1:
     
    235235            n2 = s[1]
    236236
    237     #if matrix = NaN, then do not write anything
     237        # If matrix = NaN, then do not write anything
    238238        if np.ndim(data) == 1 and np.product(s) == 1 and np.all(np.isnan(data)):
    239239            s = (0, 0)
    240240            n2 = 0
    241241
    242     #first write length of record
    243         recordlength = 4 + 4 + 8 + 8 + 1 * (s[0] - 1) * n2 + 8 * n2 + 4 + 4  #2 integers (32 bits) + the matrix + code + matrix type
     242        # First write length of record
     243        recordlength = 4 + 4 + 8 + 8 + 1 * (s[0] - 1) * n2 + 8 * n2 + 4 + 4 # 2 integers (32 bits) + the matrix + code + matrix type
    244244        try:
    245245            fid.write(pack('q', recordlength))
     
    247247            raise ValueError('Field {} can not be marshaled, {}, with "number" the lenght of the record.'.format(name, Err))
    248248
    249     #write data code and matrix type:
     249        # Write data code and matrix type
    250250        fid.write(pack('i', FormatToCode(datatype)))
    251251        fid.write(pack('i', mattype))
    252252
    253     #Write offset and range
     253        # Write offset and range
    254254        A = data[0:s[0] - 1]
    255255        offsetA = A.min()
     
    261261            A = (A - offsetA) / rangeA * 255.
    262262
    263     #now write matrix
     263        # Now write matrix
    264264        fid.write(pack('i', s[0]))
    265265        try:
     
    272272            for i in range(s[0] - 1):
    273273                fid.write(pack('B', int(A[i])))
    274             fid.write(pack('d', float(data[s[0] - 1])))  #get to the "c" convention, hence the transpose
     274            fid.write(pack('d', float(data[s[0] - 1]))) # get to the "c" convention, hence the transpose
    275275
    276276        elif np.product(s) > 0:
    277277            for i in range(s[0] - 1):
    278278                for j in range(s[1]):
    279                     fid.write(pack('B', int(A[i][j])))  #get to the "c" convention, hence the transpose
     279                    fid.write(pack('B', int(A[i][j]))) # get to the "c" convention, hence the transpose
    280280
    281281            for j in range(s[1]):
     
    285285
    286286    elif datatype == 'MatArray':  # {{{
    287         #first get length of record
    288         recordlength = 4 + 4  #number of records + code
     287        # First get length of record
     288        recordlength = 4 + 4 # number of records + code
    289289        for matrix in data:
    290290            if isinstance(matrix, (bool, int, float)):
     
    299299
    300300            s = matrix.shape
    301             recordlength += 4 * 2 + np.product(s) * 8  #row and col of matrix + matrix of doubles
    302 
    303     #write length of record
     301            recordlength += 4 * 2 + np.product(s) * 8 # row and col of matrix + matrix of doubles
     302
     303        # Write length of record
    304304        fid.write(pack('q', recordlength))
    305305
    306     #write data code:
    307         fid.write(pack('i', FormatToCode(datatype)))
    308 
    309     #write data, first number of records
     306        # Write data code
     307        fid.write(pack('i', FormatToCode(datatype)))
     308
     309        # Write data, first number of records
    310310        fid.write(pack('i', len(data)))
    311311
     
    327327            for i in range(s[0]):
    328328                if np.ndim(matrix) == 1:
    329                     fid.write(pack('d', float(matrix[i])))  #get to the "c" convention, hence the transpose
     329                    fid.write(pack('d', float(matrix[i]))) # get to the "c" convention, hence the transpose
    330330                else:
    331331                    for j in range(s[1]):
     
    334334
    335335    elif datatype == 'StringArray':  # {{{
    336         #first get length of record
    337         recordlength = 4 + 4  #for length of array + code
     336        # First get length of record
     337        recordlength = 4 + 4 # for length of array + code
    338338        for string in data:
    339             recordlength += 4 + len(string)  #for each string
    340 
    341         #write length of record
     339            recordlength += 4 + len(string) # for each string
     340
     341        # Write length of record
    342342        fid.write(pack('q', recordlength))
    343         #write data code:
    344         fid.write(pack('i', FormatToCode(datatype)))
    345         #now write length of string array
     343        # Write data code
     344        fid.write(pack('i', FormatToCode(datatype)))
     345        # Now write length of string array
    346346        fid.write(pack('i', len(data)))
    347         #now write the strings
     347        # Now write the strings
    348348        for string in data:
    349349            fid.write(pack('i', len(string)))
     
    357357
    358358def FormatToCode(datatype):  # {{{
    359     """ FORMATTOCODE - This routine takes the datatype string, and hardcodes it
     359    """ FormatToCode - This routine takes the datatype string, and hardcodes it
    360360    into an integer, which is passed along the record, in order to identify the
    361361    nature of the dataset being sent.
  • issm/trunk-jpl/test/NightlyRun/runme.m

    r27262 r28158  
    1212%
    1313%   Available options:
    14 %      'id'            followed by the list of ids requested
    15 %      'exclude'       ids to be excluded from the test
     14%      'id'            followed by the list of test ID's or names to run
     15%      'exclude'       followed by the list of test ID's or names to exclude
    1616%      'benchmark'     'all'         : (all of them)
    1717%                      'nightly'     : (nightly run
     
    6161
    6262%Process options
    63 %GET benchmark {{{
     63%Get benchmark {{{
    6464benchmark=getfieldvalue(options,'benchmark','nightly');
    6565if ~ismember(benchmark,{'all','nightly','ismip','eismint','thermal','mesh','validation','tranforcing','adolc','slc','qmu'})
     
    6868end
    6969% }}}
    70 %GET procedure {{{
     70%Get procedure {{{
    7171procedure=getfieldvalue(options,'procedure','check');
    7272if ~ismember(procedure,{'check','update','valgrind','ncExport'})
     
    7575end
    7676% }}}
    77 %GET output {{{
     77%Get output {{{
    7878output=getfieldvalue(options,'output','none');
    7979if ~ismember(output,{'nightly','none'})
     
    8282end
    8383% }}}
    84 %GET RANK and NUMPROCS for multithreaded runs  {{{
     84%Get rank and numprocs for multi-threaded runs  {{{
    8585rank=getfieldvalue(options,'rank',1);
    8686numprocs=getfieldvalue(options,'numprocs',1);
    8787if (numprocs<rank), numprocs=1; end
    8888% }}}
    89 %GET ids {{{
     89%Get IDs (create a list of all the test files in this directory that match a certain naming scheme) {{{
    9090flist=dir; %use dir, as it seems to act OS independent
    9191list_ids=[];
    9292for i=1:numel(flist),
    9393        fname=flist(i).name;
    94         if (any(fname=='.')), %Before split, check that file name contains '.'
    95                 ftokens=strsplit(fname,'.'); %Tokenize file name on '.'
    96                 if (regexp(ftokens{1},'^test[0-9]+$') &... %Basename must start with 'test' and end with a number
    97                         strcmp(ftokens{end},'m') ... %Extension (less '.') must be 'm'
     94        if (any(fname=='.')), %before split, check that file name contains '.'
     95                ftokens=strsplit(fname,'.'); %tokenize file name on '.'
     96                if (regexp(ftokens{1},'^test[0-9]+$') &... %basename must start with 'test' and end with an integer
     97                        strcmp(ftokens{end},'m') ... %extension (less '.') must be 'm'
    9898                ),
    9999                        id=sscanf(ftokens{1},'test%d');
     
    101101                                disp(['WARNING: ignore file ' flist(i).name]);
    102102                        else
    103                                 list_ids(end+1)=id; %Keep test id only (strip 'test' and '.m')
     103                                list_ids(end+1)=id; %keep test id only (strip 'test' and '.m')
    104104                        end
    105105                end
    106106        end
    107107end
    108 [i1,i2]=parallelrange(rank,numprocs,length(list_ids)); %Get tests for this cpu only
     108[i1,i2]=parallelrange(rank,numprocs,length(list_ids)); %get tests for this CPU only
    109109list_ids=list_ids(i1:i2);
    110110
     
    112112test_ids=intersect(test_ids,list_ids);
    113113% }}}
    114 %GET exclude {{{
     114%Get excluded tests {{{
    115115exclude_ids=getfieldvalue(options,'exclude',[]);
    116116exclude_ids=[exclude_ids];
     
    118118test_ids(pos)=[];
    119119% }}}
    120 %Process Ids according to benchmarks{{{
     120%Process IDs according to benchmarks{{{
    121121if strcmpi(benchmark,'nightly'),
    122122        test_ids=intersect(test_ids,[1:999]);
     
    155155                run(['test' num2str(id)]);
    156156
    157                 %UPDATE ARCHIVE?
     157                %Update archive?
    158158                archive_name=['Archive' num2str(id) ];
    159159                if strcmpi(procedure,'update'),
     
    165165                        disp(sprintf(['File ./../Archives/' archive_name '.arch saved\n']));
    166166
    167                 %CHECK for memory leaks?
     167                %Check for memory leaks?
    168168                elseif strcmpi(procedure,'valgrind'),
    169169                        fields = fieldnames(md.results);
     
    217217                                end
    218218                        end
    219                 %PRODUCE nc files?
     219                %Produce nc files?
    220220                elseif strcmpi(procedure,'ncExport'),
    221221                        export_netCDF(md, ['test' num2str(id) 'ma.nc'])
    222222
    223                 %ELSE: CHECK TEST
     223                %Else: Check test
    224224                else,
    225225                        for k=1:length(field_names),
     
    231231                                        tolerance=field_tolerances{k};
    232232
    233                                         %compare to archive
    234                                         %our output is in the correct order (n,1) or (1,1), so we do not need to transpose again
     233                                        %Compare to archive
     234                                        %Our output is in the correct order (n,1) or (1,1), so we do not need to transpose again
    235235                                        archive_cell=archread(['../Archives/' archive_name '.arch'],[archive_name '_field' num2str(k)]);
    236236                                        archive=archive_cell{1};
     
    247247                                catch me2
    248248
    249                                         %something went wrong, print failure message:
     249                                        %Something went wrong, print failure message
    250250                                        message=getReport(me2);
    251251                                        fprintf('%s',message);
     
    267267        catch me,
    268268
    269                 %something went wrong, print failure message:
     269                %Something went wrong, print failure message
    270270                message=getReport(me);
    271271                fprintf('%s',message);
  • issm/trunk-jpl/test/NightlyRun/test204.py

    r28148 r28158  
    1010from generic import generic
    1111
    12 md = triangle(model(), '../Exp/Square.exp', 180000)
     12md = triangle(model(), '../Exp/Square.exp', 180000.)
    1313md = setmask(md, 'all', '')
    1414md = parameterize(md, '../Par/SquareShelf.py')
    1515md.extrude(3, 2.)
    1616md = setflowequation(md, 'FS', 'all')
    17 md.cluster = generic('name', gethostname(), 'np', 3)
     17md.cluster = generic('name', gethostname(), 'np', 1)
    1818md.stressbalance.shelf_dampening = 1
    1919md.timestepping.time_step = 0
    20 md1 = solve(md, 'Stressbalance')
     20md1 = deepcopy(md)
     21md1 = solve(md1, 'Stressbalance')
    2122md.stressbalance.shelf_dampening = 0
    2223md = solve(md, 'Stressbalance')
  • issm/trunk-jpl/test/NightlyRun/test703.py

    r24862 r28158  
    9292md.cluster = generic('np', 3)
    9393md.stressbalance.shelf_dampening = 1
    94 md1 = copy.deepcopy(md)
     94md1 = deepcopy(md)
    9595md1 = solve(md1, 'Transient')
    9696
  • issm/trunk-jpl/test/Par/SquareShelf.py

    r25461 r28158  
    7474md.thermal.stabilization = 1
    7575md.settings.waitonlock = 30
    76 md.verbose = verbose()
     76md.verbose = verbose(0)
    7777md.stressbalance.restol = 0.10
    7878md.steadystate.reltol = 0.02
  • issm/trunk-jpl/test/Par/SquareShelf2.py

    r25455 r28158  
    6464md.thermal.stabilization = 1.
    6565md.settings.waitonlock = 30
    66 md.verbose = verbose()
     66md.verbose = verbose(0)
    6767md.stressbalance.restol = 0.10
    6868md.steadystate.reltol = 0.02
Note: See TracChangeset for help on using the changeset viewer.