Changeset 26759


Ignore:
Timestamp:
01/10/22 02:56:01 (3 years ago)
Author:
bdef
Message:

CHG:do not treat rift if 0 rifts present

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/rifts.py

    r24256 r26759  
    6767
    6868        numpairs = 0
    69         for rift in self.riftstruct:
    70             numpairs += np.size(rift['penaltypairs'], axis=0)
     69        if numrifts > 0:
     70            for rift in self.riftstruct:
     71                numpairs += np.size(rift['penaltypairs'], axis=0)
    7172
    72     # Convert strings in riftstruct to hard coded numbers
    73         FillDict = {'Air': 0,
    74                     'Ice': 1,
    75                     'Melange': 2,
    76                     'Water': 3}
    77         for rift in self.riftstruct:
    78             if rift['fill'] in ['Air', 'Ice', 'Melange', 'Water']:
    79                 rift['fill'] = FillDict[rift['fill']]
     73            # Convert strings in riftstruct to hard coded numbers
     74            FillDict = {'Air': 0,
     75                        'Ice': 1,
     76                        'Melange': 2,
     77                        'Water': 3}
     78            for rift in self.riftstruct:
     79                if rift['fill'] in ['Air', 'Ice', 'Melange', 'Water']:
     80                    rift['fill'] = FillDict[rift['fill']]
    8081
    81     # 2 for nodes + 2 for elements + 2 for  normals + 1 for length + 1 for fill + 1 for friction + 1 for fraction + 1 for fractionincrement + 1 for state.
    82         data = np.zeros((numpairs, 12))
    83         count = 0
    84         for rift in self.riftstruct:
    85             numpairsforthisrift = np.size(rift['penaltypairs'], 0)
    86             data[count:count + numpairsforthisrift, 0:7] = rift['penaltypairs']
    87             data[count:count + numpairsforthisrift, 7] = rift['fill']
    88             data[count:count + numpairsforthisrift, 8] = rift['friction']
    89             data[count:count + numpairsforthisrift, 9] = rift['fraction']
    90             data[count:count + numpairsforthisrift, 10] = rift['fractionincrement']
    91             data[count:count + numpairsforthisrift, 11] = rift['state'].reshape(-1)
    92             count += numpairsforthisrift
    93 
     82            # 2 for nodes + 2 for elements + 2 for  normals + 1 for length + 1 for fill + 1 for friction + 1 for fraction + 1 for fractionincrement + 1 for state.
     83            data = np.zeros((numpairs, 12))
     84            count = 0
     85            for rift in self.riftstruct:
     86                numpairsforthisrift = np.size(rift['penaltypairs'], 0)
     87                data[count:count + numpairsforthisrift, 0:7] = rift['penaltypairs']
     88                data[count:count + numpairsforthisrift, 7] = rift['fill']
     89                data[count:count + numpairsforthisrift, 8] = rift['friction']
     90                data[count:count + numpairsforthisrift, 9] = rift['fraction']
     91                data[count:count + numpairsforthisrift, 10] = rift['fractionincrement']
     92                data[count:count + numpairsforthisrift, 11] = rift['state'].reshape(-1)
     93                count += numpairsforthisrift
     94        else:
     95            data = np.zeros((numpairs, 12))
    9496        WriteData(fid, prefix, 'data', numrifts, 'name', 'md.rifts.numrifts', 'format', 'Integer')
    9597        WriteData(fid, prefix, 'data', data, 'name', 'md.rifts.riftstruct', 'format', 'DoubleMat', 'mattype', 3)
Note: See TracChangeset for help on using the changeset viewer.