Changeset 22865
- Timestamp:
- 06/22/18 01:03:19 (7 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/consistency/checkfield.py
r22267 r22865 9 9 10 10 Used to check model consistency., 11 Requires: 12 'field' or 'fieldname' option. If 'fieldname' is provided, it will retrieve it from the model md. (md.(fieldname)) 11 Requires: 12 'field' or 'fieldname' option. If 'fieldname' is provided, it will retrieve it from the model md. (md.(fieldname)) 13 13 If 'field' is provided, it will assume the argument following 'field' is a numeric array. 14 14 … … 40 40 fieldname=options.getfieldvalue('fieldname','no fieldname') 41 41 else: 42 fieldname=options.getfieldvalue('fieldname') 42 fieldname=options.getfieldvalue('fieldname') 43 43 exec("field=md.{}".format(fieldname)) 44 44 … … 80 80 if (not np.size(field,0)==fieldsize[0]) or (not np.size(field,1)==fieldsize[1]): 81 81 md = md.checkmessage(options.getfieldvalue('message',"field '%s' size should be %d x %d" % (fieldname,fieldsize[0],fieldsize[1]))) 82 82 83 83 #Check numel 84 84 if options.exist('numel'): … … 164 164 165 165 if options.getfieldvalue('singletimeseries',0): 166 field2 = np.reshape(field[0], np.prod(np.shape(field[0])),1)166 field2 = np.reshape(field[0],int(np.prod(np.shape(field[0]))),1) 167 167 168 168 if np.any(field2>upperbound): … … 176 176 177 177 if options.getfieldvalue('singletimeseries',0): 178 field2 = np.reshape(field[0], np.prod(np.shape(field[0])),1)178 field2 = np.reshape(field[0],int(np.prod(np.shape(field[0]))),1) 179 179 180 180 if np.any(field2>=upperbound): … … 228 228 229 229 return md 230 231 -
issm/trunk-jpl/src/m/mesh/ComputeHessian.py
r21303 r22865 33 33 linesize=3*numberofelements 34 34 35 #get areas and nodal functions coefficients N(x,y)=alpha x + beta y + gamma 35 #get areas and nodal functions coefficients N(x,y)=alpha x + beta y + gamma 36 36 [alpha,beta,dum]=GetNodalFunctionsCoeff(index,x,y) 37 37 areas=GetAreas(index,x,y) 38 38 39 39 #compute weights that hold the volume of all the element holding the node i 40 weights=m.sparse(line,np.ones((linesize,1) ),np.tile(areas.reshape(-1,),(3,1)),numberofnodes,1)40 weights=m.sparse(line,np.ones((linesize,1),dtype=int),np.tile(areas,(3,1)),numberofnodes,1) 41 41 42 42 #compute field on nodes if on elements 43 43 if np.size(field,axis=0)==numberofelements: 44 field=m.sparse(line,np.ones((linesize,1) ),np.tile(areas*field,(3,1)),numberofnodes,1)/weights44 field=m.sparse(line,np.ones((linesize,1),dtype=int),np.tile(areas*field,(3,1)),numberofnodes,1)/weights 45 45 46 46 #Compute gradient for each element 47 grad_elx=np.sum(field[index-1 ,0]*alpha,axis=1)48 grad_ely=np.sum(field[index-1 ,0]*beta,axis=1)47 grad_elx=np.sum(field[index-1]*alpha,axis=1) 48 grad_ely=np.sum(field[index-1]*beta,axis=1) 49 49 50 50 #Compute gradient for each node (average of the elements around) 51 gradx=m.sparse(line,np.ones((linesize,1) ),np.tile((areas*grad_elx).reshape(-1,),(3,1)),numberofnodes,1)52 grady=m.sparse(line,np.ones((linesize,1) ),np.tile((areas*grad_ely).reshape(-1,),(3,1)),numberofnodes,1)51 gradx=m.sparse(line,np.ones((linesize,1),dtype=int),np.tile((areas*grad_elx),(3,1)),numberofnodes,1) 52 grady=m.sparse(line,np.ones((linesize,1),dtype=int),np.tile((areas*grad_ely),(3,1)),numberofnodes,1) 53 53 gradx=gradx/weights 54 54 grady=grady/weights 55 55 56 56 #Compute hessian for each element 57 hessian=np.vstack((np.sum(gradx[index-1,0]*alpha,axis=1) .reshape(-1,),np.sum(grady[index-1,0]*alpha,axis=1).reshape(-1,),np.sum(grady[index-1,0]*beta,axis=1).reshape(-1,))).T57 hessian=np.vstack((np.sum(gradx[index-1,0]*alpha,axis=1),np.sum(grady[index-1,0]*alpha,axis=1),np.sum(grady[index-1,0]*beta,axis=1))).T 58 58 59 59 if m.strcmpi(type,'node'): 60 60 #Compute Hessian on the nodes (average of the elements around) 61 hessian=np.hstack((m.sparse(line,np.ones((linesize,1) ),np.tile((areas*hessian[:,0]).reshape(-1,),(3,1)),numberofnodes,1)/weights,62 m.sparse(line,np.ones((linesize,1) ),np.tile((areas*hessian[:,1]).reshape(-1,),(3,1)),numberofnodes,1)/weights,63 m.sparse(line,np.ones((linesize,1) ),np.tile((areas*hessian[:,2]).reshape(-1,),(3,1)),numberofnodes,1)/weights ))61 hessian=np.hstack((m.sparse(line,np.ones((linesize,1),dtype=int),np.tile((areas*hessian[:,0]),(3,1)),numberofnodes,1)/weights, 62 m.sparse(line,np.ones((linesize,1),dtype=int),np.tile((areas*hessian[:,1]),(3,1)),numberofnodes,1)/weights, 63 m.sparse(line,np.ones((linesize,1),dtype=int),np.tile((areas*hessian[:,2]),(3,1)),numberofnodes,1)/weights )) 64 64 65 65 return hessian 66 -
issm/trunk-jpl/src/m/miscellaneous/MatlabFuncs.py
r21303 r22865 105 105 106 106 return y 107
Note:
See TracChangeset
for help on using the changeset viewer.