Changeset 13482
- Timestamp:
- 09/28/12 16:04:47 (12 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/mesh/ComputeHessian.m
r9734 r13482 20 20 error('ComputeHessian error message: the given field size not supported yet'); 21 21 end 22 if strcmpi(type,'node') &strcmpi(type,'element'),22 if ~strcmpi(type,'node') & ~strcmpi(type,'element'), 23 23 error('ComputeHessian error message: only ''node'' or ''element'' type supported yet'); 24 24 end … … 28 28 linesize=3*numberofelements; 29 29 30 %get areas and 30 %get areas and nodal functions coefficients N(x,y)=alpha x + beta y + gamma 31 31 [alpha beta]=GetNodalFunctionsCoeff(index,x,y); 32 32 areas=GetAreas(index,x,y); 33 33 34 %comput weights that holdsthe volume of all the element holding the node i34 %compute weights that hold the volume of all the element holding the node i 35 35 weights=sparse(line,ones(linesize,1),repmat(areas,3,1),numberofnodes,1); 36 36 -
issm/trunk-jpl/src/m/mesh/ComputeMetric.m
r9224 r13482 9 9 % metric=ComputeMetric(hessian,2/9,10^-1,100,10^5,find(md.nodeonwater) 10 10 11 %first, find the eigen values of ea h line of H=[hessian(i,1) hessian(i,2); hessian(i,2)hessian(i,3)]11 %first, find the eigen values of each line of H=[hessian(i,1) hessian(i,2); hessian(i,2) hessian(i,3)] 12 12 a=hessian(:,1); b=hessian(:,2); d=hessian(:,3); 13 lambda1=0.5*((a+d)+sqrt(4 *b.^2+(a-d).^2));14 lambda2=0.5*((a+d)-sqrt(4 *b.^2+(a-d).^2));13 lambda1=0.5*((a+d)+sqrt(4.*b.^2+(a-d).^2)); 14 lambda2=0.5*((a+d)-sqrt(4.*b.^2+(a-d).^2)); 15 15 pos1=find(lambda1==0); 16 16 pos2=find(lambda2==0); … … 18 18 19 19 %Modify the eigen values to control the shape of the elements 20 lambda1=min(max(abs(lambda1)*scale/epsilon,1 /hmax^2),1/hmin^2);21 lambda2=min(max(abs(lambda2)*scale/epsilon,1 /hmax^2),1/hmin^2);20 lambda1=min(max(abs(lambda1)*scale/epsilon,1./hmax^2),1./hmin^2); 21 lambda2=min(max(abs(lambda2)*scale/epsilon,1./hmax^2),1./hmin^2); 22 22 23 23 %compute eigen vectors 24 norm1=sqrt(8 *b.^2+2*(d-a).^2+2*(d-a).*sqrt((a-d).^2+4*b.^2));25 v1x=2 *b./norm1;26 v1y=((d-a)+sqrt((a-d).^2+4 *b.^2))./norm1;27 norm2=sqrt(8 *b.^2+2*(d-a).^2-2*(d-a).*sqrt((a-d).^2+4*b.^2));28 v2x=2 *b./norm2;29 v2y=((d-a)-sqrt((a-d).^2+4 *b.^2))./norm2;24 norm1=sqrt(8.*b.^2+2.*(d-a).^2+2.*(d-a).*sqrt((a-d).^2+4.*b.^2)); 25 v1x=2.*b./norm1; 26 v1y=((d-a)+sqrt((a-d).^2+4.*b.^2))./norm1; 27 norm2=sqrt(8.*b.^2+2.*(d-a).^2-2.*(d-a).*sqrt((a-d).^2+4.*b.^2)); 28 v2x=2.*b./norm2; 29 v2y=((d-a)-sqrt((a-d).^2+4.*b.^2))./norm2; 30 30 31 v1x(pos3)=1 ; v1y(pos3)=0;32 v2x(pos3)=0 ; v2y(pos3)=1;31 v1x(pos3)=1.; v1y(pos3)=0.; 32 v2x(pos3)=0.; v2y(pos3)=1.; 33 33 34 34 %Compute new metric (for each node M=V*Lambda*V^-1) … … 38 38 39 39 %some corrections for 0 eigen values 40 metric(pos1,:)=repmat([1 /hmax^2 0 1/hmax^2],length(pos1),1);41 metric(pos2,:)=repmat([1 /hmax^2 0 1/hmax^2],length(pos2),1);40 metric(pos1,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos1),1); 41 metric(pos2,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos2),1); 42 42 43 43 %take care of water elements 44 metric(pos,:)=repmat([1 /hmax^2 0 1/hmax^2],length(pos),1);44 metric(pos,:)=repmat([1./hmax^2 0. 1./hmax^2],length(pos),1); 45 45 46 46 %take care of NaNs if any (use Matlab eig in a loop) … … 54 54 lambda1=v(1,1); 55 55 lambda2=v(2,2); 56 v(1,1)=min(max(abs(lambda1)*scale/epsilon,1 /hmax^2),1/hmin^2);57 v(2,2)=min(max(abs(lambda2)*scale/epsilon,1 /hmax^2),1/hmin^2);56 v(1,1)=min(max(abs(lambda1)*scale/epsilon,1./hmax^2),1./hmin^2); 57 v(2,2)=min(max(abs(lambda2)*scale/epsilon,1./hmax^2),1./hmin^2); 58 58 59 59 metricTria=u*v*u^(-1); -
issm/trunk-jpl/src/m/mesh/GetNodalFunctionsCoeff.py
r13472 r13482 19 19 20 20 #make columns out of x and y 21 x=x.r shape(-1)22 y=y.r shape(-1)21 x=x.reshape(-1) 22 y=y.reshape(-1) 23 23 24 24 #get nels and nods … … 48 48 49 49 #get alpha and beta 50 alpha=numpy.hstack(( invdet*(y2-y3),invdet*(y3-y1),invdet*(y1-y2)))51 beta =numpy.hstack(( invdet*(x3-x2),invdet*(x1-x3),invdet*(x2-x1)))50 alpha=numpy.hstack(((invdet*(y2-y3)).reshape(-1,1),(invdet*(y3-y1)).reshape(-1,1),(invdet*(y1-y2)).reshape(-1,1))) 51 beta =numpy.hstack(((invdet*(x3-x2)).reshape(-1,1),(invdet*(x1-x3)).reshape(-1,1),(invdet*(x2-x1)).reshape(-1,1))) 52 52 53 53 #get gamma if requested 54 54 gamma=numpy.zeros((nels,3)) 55 gamma=numpy.hstack(( invdet*(x2*y3-x3*y2),invdet*(y1*x3-y3*x1),invdet*(x1*y2-x2*y1)))55 gamma=numpy.hstack(((invdet*(x2*y3-x3*y2)).reshape(-1,1),(invdet*(y1*x3-y3*x1)).reshape(-1,1),(invdet*(x1*y2-x2*y1)).reshape(-1,1))) 56 56 57 57 return alpha,beta,gamma -
issm/trunk-jpl/src/m/mesh/bamg.py
r13470 r13482 262 262 263 263 elif isinstance(md.private.bamg,dict) and 'geometry' in md.private.bamg: 264 bamg_geometry=bamggeom(md.private.bamg['geometry'] )264 bamg_geometry=bamggeom(md.private.bamg['geometry'].__dict__) 265 265 else: 266 266 #do nothing... … … 310 310 311 311 #call Bamg 312 bamgmesh_out,bamggeom_out=BamgMesher(bamg_mesh.__dict__,bamg_geometry.__dict__,bamg_options)312 [bamgmesh_out,bamggeom_out]=BamgMesher(bamg_mesh.__dict__,bamg_geometry.__dict__,bamg_options) 313 313 314 314 # plug results onto model -
issm/trunk-jpl/src/m/miscellaneous/MatlabFuncs.py
r13436 r13482 74 74 raise TypeError("MatlabFunc.det only implemented for shape (2, 2), not for shape %s." % str(a.shape)) 75 75 76 def sparse(ivec,jvec,svec,m=0,n=0,nzmax=0): 77 import numpy 78 79 if not m: 80 m=numpy.max(ivec) 81 if not n: 82 n=numpy.max(jvec) 83 84 a=numpy.zeros((m,n)) 85 86 for i,j,s in zip(ivec.reshape(-1,order='F'),jvec.reshape(-1,order='F'),svec.reshape(-1,order='F')): 87 a[i-1,j-1]+=s 88 89 return a 90
Note:
See TracChangeset
for help on using the changeset viewer.