Changeset 13710


Ignore:
Timestamp:
10/17/12 10:28:51 (12 years ago)
Author:
jschierm
Message:

FIX: Fixes to run python rifts (plus a matlab fix as well).

Location:
issm/trunk-jpl/src/m
Files:
3 edited

Legend:

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

    r13020 r13710  
    3838                                        md = checkmessage(md,['model should be processed for rifts (run meshprocessrifts)!']);
    3939                                end
    40                                 md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
     40                                for i=1:numrifts,
     41                                        md = checkfield(md,sprintf('rifts.riftstruct(%d).fill',i),'values',[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
     42                                end
    4143                        else
    4244                                if ~isnans(obj.riftstruct),
  • issm/trunk-jpl/src/m/classes/rifts.py

    r13043 r13710  
    5353                                #We have segments with rift markers, but no rift structure!
    5454                                md.checkmessage("model should be processed for rifts (run meshprocessrifts)!")
    55                         md = checkfield(md,'rifts.riftstruct.fill','values',[WaterEnum(),AirEnum(),IceEnum(),MelangeEnum()])
     55                        for i,rift in enumerate(self.riftstruct):
     56                                md = checkfield(md,"rifts.riftstruct[%d]['fill']" % i,'values',[WaterEnum(),AirEnum(),IceEnum(),MelangeEnum()])
    5657                else:
    5758                        if numpy.any(numpy.logical_not(isnans(self.riftstruct))):
    58                                 md.checkmessage("riftstruct shoud be NaN since numrifts is 0!")
     59                                md.checkmessage("riftstruct should be NaN since numrifts is 0!")
    5960
    6061                return md
     
    7071
    7172                numpairs=0
    72                 for i in xrange(0,numrifts):
    73                         numpairs+=numpy.size(self.riftstruct[i].penaltypairs,0)
     73                for rift in self.riftstruct:
     74                        numpairs+=numpy.size(rift['penaltypairs'],axis=0)
    7475
    7576                # 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.
    7677                data=numpy.zeros((numpairs,12))
    7778                count=0
    78                 for i in xrange(0,numrifts):
    79                         numpairsforthisrift=numpy.size(self.riftstruct[i]['penaltypairs'],0)
    80                         data[count:count+numpairsforthisrift-1,0:6]=self.riftstruct[i]['penaltypairs']
    81                         data[count:count+numpairsforthisrift-1,7]=self.riftstruct[i]['fill']
    82                         data[count:count+numpairsforthisrift-1,8]=self.riftstruct[i]['friction']
    83                         data[count:count+numpairsforthisrift-1,9]=self.riftstruct[i]['fraction']
    84                         data[count:count+numpairsforthisrift-1,10]=self.riftstruct[i]['fractionincrement']
    85                         data[count:count+numpairsforthisrift-1,11]=self.riftstruct[i]['state']
     79                for rift in self.riftstruct:
     80                        numpairsforthisrift=numpy.size(rift['penaltypairs'],0)
     81                        data[count:count+numpairsforthisrift,0:7]=rift['penaltypairs']
     82                        data[count:count+numpairsforthisrift,7]=rift['fill']
     83                        data[count:count+numpairsforthisrift,8]=rift['friction']
     84                        data[count:count+numpairsforthisrift,9]=rift['fraction']
     85                        data[count:count+numpairsforthisrift,10]=rift['fractionincrement']
     86                        data[count:count+numpairsforthisrift,11]=rift['state'].reshape(-1)
    8687                        count+=numpairsforthisrift
    8788
  • issm/trunk-jpl/src/m/mesh/rifts/meshprocessrifts.py

    r13524 r13710  
    11import numpy
    2 #from TriMeshProcessRifts import *
     2from TriMeshProcessRifts import *
    33from ContourToMesh import *
    44from meshprocessoutsiderifts import *
     
    2323        #Call MEX file
    2424        [md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers,md.rifts.riftstruct]=TriMeshProcessRifts(md.mesh.elements,md.mesh.x,md.mesh.y,md.mesh.segments,md.mesh.segmentmarkers)
    25         if not isinstance(md.rifts.riftstruct,'list') or not md.rifts.riftstruct:
     25        md.mesh.x=md.mesh.x.reshape(-1)
     26        md.mesh.y=md.mesh.y.reshape(-1)
     27        if not isinstance(md.rifts.riftstruct,list) or not md.rifts.riftstruct:
    2628                raise RuntimeError("TriMeshProcessRifts did not find any rift")
    2729
     
    4042        #get coordinates of rift tips
    4143        for rift in md.rifts.riftstruct:
    42                 rift.tip1coordinates=numpy.hstack((md.mesh.x[rift.tips[0].astype(int)-1].reshape(-1,1),md.mesh.y[rift.tips[0].astype(int)-1].reshape(-1,1)))
    43                 rift.tip2coordinates=numpy.hstack((md.mesh.x[rift.tips[1].astype(int)-1].reshape(-1,1),md.mesh.y[rift.tips[1].astype(int)-1].reshape(-1,1)))
     44                rift['tip1coordinates']=numpy.hstack((md.mesh.x[rift['tips'][0,0].astype(int)-1].reshape(-1,1),md.mesh.y[rift['tips'][0,0].astype(int)-1].reshape(-1,1)))
     45                rift['tip2coordinates']=numpy.hstack((md.mesh.x[rift['tips'][0,1].astype(int)-1].reshape(-1,1),md.mesh.y[rift['tips'][0,1].astype(int)-1].reshape(-1,1)))
    4446
    4547        #In case we have rifts that open up the domain outline, we need to open them:
    46         flags=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),domainoutline,'node',0)
     48        [flags,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),domainoutline,'node',0)
    4749        found=0
    4850        for rift in md.rifts.riftstruct:
    49                 if flags[rift.tips[0].astype(int)-1]==0:
     51                if flags[rift['tips'][0,0].astype(int)-1]==0:
    5052                        found=1
    5153                        break
    52                 if flags[rift.tips[1].astype(int)-1]==0:
     54                if flags[rift['tips'][0,1].astype(int)-1]==0:
    5355                        found=1
    5456                        break
     
    5961        aires=GetAreas(md.mesh.elements,md.mesh.x,md.mesh.y)
    6062        pos=numpy.nonzero(aires<0)[0]
    61         md.mesh.elements[pos,:]=numpy.array([[md.mesh.elements[pos,1],md.mesh.elements[pos,0],md.mesh.elements[pos,2]]])
     63        md.mesh.elements[pos,:]=numpy.hstack((md.mesh.elements[pos,1].reshape(-1,1),md.mesh.elements[pos,0].reshape(-1,1),md.mesh.elements[pos,2].reshape(-1,1)))
    6264
    6365        return md
Note: See TracChangeset for help on using the changeset viewer.