Hello,
I'm trying to refine the mesh around some velocity hotspots that are causing the transient simulation to crash. The refining bit isn't working. Thanks in advance for any help you can provide!
I've used code from the user guide:
md=triangle(model,'kns_domain.exp',100000);
% plotmodel(md,'data','mesh');
disp(' Refining Mesh');
ncdatavx = 'Trunk\Data\Velocity\vel_vx.nc';
ncdatavy = 'Trunk\Data\Velocity\vel_vy.nc';
velx= ncread(ncdatavx,'Band1');
xx= ncread(ncdatavx,'x');
xx=single(xx);
xx=sort(xx);
yx= ncread(ncdatavx,'y');
yx=single(yx);
yx=sort(yx);
vx = InterpFromGridToMesh(xx,yx,velx',md.mesh.x,md.mesh.y,0);
vely= ncread(ncdatavy,'Band1');
xy= ncread(ncdatavx,'x');
xy=single(xy);
xy=sort(xy);
yy= ncread(ncdatavx,'y');
yy=single(yy);
yy=sort(yy);
vy = InterpFromGridToMesh(xy,yy,vely',md.mesh.x,md.mesh.y,0);
vel = sqrt(vx.^2+vy.^2);
% Refine mesh using surface velocities as metric
md=bamg(md,'hmin',500,'hmax',25000,'field',vel,'err',5); % all values here are arbitrary
[md.mesh.lat,md.mesh.long] = xy2ll(md.mesh.x,md.mesh.y,+1,39,71);
% plotmodel(md,'data','mesh');
% ### Notes on Mesh refinement from ISSM user guide ###
% 1. 'field' followed by vel : the field we want to adapt the mesh to
% 2. err : the allowed interpolation error
% 3. hmin : minimum edge length
% 4. hmax : maximum edge length
% 5. gradation : ratio between two consecutive edges
% 6. Force the triangles to be equilateral by using the Fanisomax option, which specifies the maximum level of anisotropy (between 0 and 1, 1 being fully isotropic).
% 7. You can further refine mesh in a specific region, see user guide pages 45-48 for instructions.
%%
% plotmodel(md,'data','mesh','edgecolor','w');
% exptool('refinement.exp')
h=NaN*ones(md.mesh.numberofvertices,1);
in=ContourToNodes(md.mesh.x,md.mesh.y,'refinement.exp',1);
h(find(in))=0.02;
plotmodel(md,'data',in,'edgecolor','w');
vel=shock(md.mesh.x,md.mesh.y);
% Everything works till this bit
md=bamg(md,'hmin',500,'hmax',25000,'field',vel,'err',5,'hVertices',h);
vel=shock(md.mesh.x,md.mesh.y);
plotmodel(md,'data','mesh');
This is the error I'm getting (would look at BamgMesher_matlab to figure out the issue, but don't have access to this file):
Error using BamgMesher_matlab
Error in ==> ./bamg/Mesh.cpp:2982
MakeGeomEdgeToEdge error message: See above
Error in BamgMesher (line 18)
[bamgmesh, bamggeom] = BamgMesher_matlab(bamgmesh,bamggeom,bamgoptions);
Error in bamg (line 499)
[bamgmesh_out bamggeom_out]=BamgMesher(bamg_mesh,bamg_geometry,bamg_options);
Error in refined_inversion (line 65)
md=bamg(md,'hmin',500,'hmax',25000,'field',vel,'err',5,'hVertices',h);