Changeset 13710
- Timestamp:
- 10/17/12 10:28:51 (12 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/rifts.m
r13020 r13710 38 38 md = checkmessage(md,['model should be processed for rifts (run meshprocessrifts)!']); 39 39 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 41 43 else 42 44 if ~isnans(obj.riftstruct), -
issm/trunk-jpl/src/m/classes/rifts.py
r13043 r13710 53 53 #We have segments with rift markers, but no rift structure! 54 54 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()]) 56 57 else: 57 58 if numpy.any(numpy.logical_not(isnans(self.riftstruct))): 58 md.checkmessage("riftstruct shou d be NaN since numrifts is 0!")59 md.checkmessage("riftstruct should be NaN since numrifts is 0!") 59 60 60 61 return md … … 70 71 71 72 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) 74 75 75 76 # 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. 76 77 data=numpy.zeros((numpairs,12)) 77 78 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) 86 87 count+=numpairsforthisrift 87 88 -
issm/trunk-jpl/src/m/mesh/rifts/meshprocessrifts.py
r13524 r13710 1 1 import numpy 2 #from TriMeshProcessRifts import *2 from TriMeshProcessRifts import * 3 3 from ContourToMesh import * 4 4 from meshprocessoutsiderifts import * … … 23 23 #Call MEX file 24 24 [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: 26 28 raise RuntimeError("TriMeshProcessRifts did not find any rift") 27 29 … … 40 42 #get coordinates of rift tips 41 43 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))) 44 46 45 47 #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) 47 49 found=0 48 50 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: 50 52 found=1 51 53 break 52 if flags[rift .tips[1].astype(int)-1]==0:54 if flags[rift['tips'][0,1].astype(int)-1]==0: 53 55 found=1 54 56 break … … 59 61 aires=GetAreas(md.mesh.elements,md.mesh.x,md.mesh.y) 60 62 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))) 62 64 63 65 return md
Note:
See TracChangeset
for help on using the changeset viewer.