|
16 | 16 | %
|
17 | 17 | % You should have received a copy of the GNU General Public License
|
18 | 18 | % along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 19 | + % |
| 20 | + % Available options: |
| 21 | + % ef % edgefx class |
| 22 | + % bou % geodata class |
| 23 | + % h0 % minimum edge length (optional if bou exists) |
| 24 | + % bbox % bounding box [xmin,ymin; xmax,ymax] (manual specification, no bou) |
| 25 | + % proj % structure containing the m_map projection info |
| 26 | + % plot_on % flag to plot (def: 1) or not (0) |
| 27 | + % nscreen % how many it to plot and write temp files (def: 5) |
| 28 | + % itmax % maximum number of iterations. |
| 29 | + % pfix % fixed node positions (nfix x 2 ) |
| 30 | + % egfix % edge constraints |
| 31 | + % outer % meshing boundary (manual specification, no bou) |
| 32 | + % inner % island boundaries (manual specification, no bou) |
| 33 | + % mainland % the shoreline boundary (manual specification, no bou) |
| 34 | + % fixboxes % a flag that indicates which boxes will use fixed constraints |
| 35 | + % memory_gb % memory in GB allowed to use for initial rejector |
| 36 | + % cleanup % logical flag or string to trigger cleaning of topology (default is on). |
| 37 | + % direc_smooth % logical flag to trigger direct smoothing of mesh in the cleanup |
| 38 | + % dj_cutoff % the cutoff area fraction for disjoint portions to delete |
| 39 | + % qual_tol % tolerance for the accepted negligible change in quality |
| 40 | + % enforceWeirs % whether or not to enforce weirs in meshgen |
| 41 | + % enforceMin % whether or not to enfore minimum edgelength for all edgefxs |
| 42 | + % big_mesh % set to 1 to remove the bou data from memory |
19 | 43 | properties
|
20 | 44 | fd % handle to distance function
|
21 | 45 | fh % handle to edge function
|
|
30 | 54 | bou % geodata class
|
31 | 55 | ef % edgefx class
|
32 | 56 | itmax % maximum number of iterations.
|
33 |
| - outer % meshing boundary |
34 |
| - inner % island boundaries |
35 |
| - mainland % the shoreline boundary |
| 57 | + outer % meshing boundary (manual specification, no bou) |
| 58 | + inner % island boundaries (manual specification, no bou) |
| 59 | + mainland % the shoreline boundary (manual specification, no bou) |
36 | 60 | boubox % the bbox as a polygon 2-tuple
|
37 | 61 | inpoly_flip % used to flip the inpoly test to determine the signed distance.
|
38 | 62 | memory_gb % memory in GB allowed to use for initial rejector
|
39 | 63 | cleanup % logical flag or string to trigger cleaning of topology (default is on).
|
40 | 64 | direc_smooth % logical flag to trigger direct smoothing of mesh in the cleanup
|
41 | 65 | dj_cutoff % the cutoff area fraction for disjoint portions to delete
|
42 | 66 | grd = msh(); % create empty mesh class to return p and t in.
|
43 |
| - big_mesh |
44 |
| - ns_fix % improve spacing for boundary vertices |
| 67 | + big_mesh % release bou data from memory |
45 | 68 | qual % mean, lower 3rd sigma, and the minimum element quality.
|
46 | 69 | qual_tol % tolerance for the accepted negligible change in quality
|
47 | 70 | proj % structure containing the m_map projection info
|
|
99 | 122 | addOptional(p,'direc_smooth',1);
|
100 | 123 | addOptional(p,'dj_cutoff',0.25);
|
101 | 124 | addOptional(p,'big_mesh',defval);
|
102 |
| - addOptional(p,'ns_fix',defval); |
103 | 125 | addOptional(p,'proj',defval);
|
104 | 126 | addOptional(p,'qual_tol',defval);
|
105 | 127 | addOptional(p,'enforceWeirs',1);
|
|
122 | 144 | 'plot_on','nscreen','itmax',...
|
123 | 145 | 'memory_gb','qual_tol','cleanup',...
|
124 | 146 | 'direc_smooth','dj_cutoff',...
|
125 |
| - 'big_mesh','ns_fix','proj'}); |
| 147 | + 'big_mesh','proj'}); |
126 | 148 | % get the fieldnames of the edge functions
|
127 | 149 | fields = fieldnames(inp);
|
128 | 150 | % loop through and determine which args were passed.
|
|
185 | 207 | end
|
186 | 208 | if obj.enforceWeirs
|
187 | 209 | for j = 1 : length(obj.bou)
|
188 |
| - if ~isempty(obj.bou{j}.weirEgfix) && ~isempty(obj.egfix) |
| 210 | + if ~isempty(obj.bou{j}.weirEgfix) && ~isempty(obj.egfix) |
189 | 211 | obj.egfix = [obj.egfix ; obj.bou{j}.weirEgfix+max(obj.egfix(:))];
|
190 | 212 | else
|
191 | 213 | obj.egfix = obj.bou{j}.weirEgfix;
|
|
195 | 217 | obj.egfix = renumberEdges(obj.egfix);
|
196 | 218 | case('fixboxes')
|
197 | 219 | obj.fixboxes= inp.(fields{i});
|
198 |
| - |
199 | 220 | case('bou')
|
200 | 221 | % got it from user arg
|
201 | 222 | if obj.outer~=0, continue; end
|
|
311 | 332 | obj.plot_on= inp.(fields{i});
|
312 | 333 | case('big_mesh')
|
313 | 334 | obj.big_mesh = inp.(fields{i});
|
314 |
| - case('ns_fix') |
315 |
| - obj.ns_fix = inp.(fields{i}); |
316 | 335 | case('nscreen')
|
317 | 336 | obj.nscreen= inp.(fields{i});
|
318 | 337 | if obj.nscreen ~=0
|
|
455 | 474 | %%
|
456 | 475 | tic
|
457 | 476 | it = 1 ;
|
458 |
| - imp = 10; |
459 |
| - qual_diff = 0; |
460 | 477 | Re = 6378.137e3;
|
461 | 478 | geps = 1e-3*min(obj.h0)/Re;
|
462 | 479 | deps = sqrt(eps);
|
463 | 480 | ttol=0.1; Fscale = 1.2; deltat = 0.1;
|
464 | 481 | delIT = 0 ; delImp = 2;
|
| 482 | + imp = 10; % number of iterations to do mesh improvements (delete/add) |
465 | 483 |
|
466 | 484 | % unpack initial points.
|
467 | 485 | p = obj.grd.p;
|
|
546 | 564 | p1 = p1(rand(size(p1,1),1) < r0/max_r0,:); % Rejection method
|
547 | 565 | p = [p; p1]; % Adding p1 to p
|
548 | 566 | end
|
| 567 | + % add new points along boundary of multiscale nests |
| 568 | + if box_num < length(obj.h0) |
| 569 | + h0_rat = ceil(h0_l/obj.h0(box_num+1)); |
| 570 | + nsplits = floor(log(h0_rat)/log(2)); |
| 571 | + for add = 1:nsplits |
| 572 | + new_points = split(p,fh_l); |
| 573 | + p = [p; new_points]; |
| 574 | + end |
| 575 | + end |
549 | 576 | end
|
550 | 577 | else
|
551 | 578 | disp('User-supplied initial points!');
|
552 | 579 | obj.grd.b = [];
|
553 |
| - imp = 10; % number of iterations to do mesh improvements (delete/add) |
554 | 580 | h0_l = obj.h0(end); % finest h0 (in case of a restart of meshgen.build).
|
555 | 581 | end
|
556 | 582 |
|
| 583 | + |
| 584 | + |
557 | 585 | % remove pfix/egfix outside of desired subdomain
|
558 | 586 | nfix = size(obj.pfix,1); % Number of fixed points
|
559 | 587 | negfix = size(obj.egfix,1); % Number of edge constraints
|
|
687 | 715 | end
|
688 | 716 |
|
689 | 717 | % Termination quality, mesh quality reached is copacetic.
|
| 718 | + qual_diff = mq_l3sig - obj.qual(max(1,it-imp),2); |
690 | 719 | if ~mod(it,imp)
|
691 |
| - qual_diff = mq_l3sig - obj.qual(max(1,it-imp),2); |
692 | 720 | if abs(qual_diff) < obj.qual_tol
|
693 | 721 | % Do the final elimination of small connectivity
|
694 | 722 | [t,p] = delaunay_elim(p,obj.fd,geps,1);
|
|
752 | 780 | % Mesh improvements (deleting and addition)
|
753 | 781 | if ~mod(it,imp)
|
754 | 782 | nn = []; pst = [];
|
755 |
| - if qual_diff < imp*0.01 && qual_diff > 0 |
| 783 | + if qual_diff < imp*obj.qual_tol && qual_diff > 0 |
756 | 784 | % Remove elements with small connectivity
|
757 | 785 | nn = get_small_connectivity(p,t);
|
758 | 786 | disp(['Deleting ' num2str(length(nn)) ' due to small connectivity'])
|
|
953 | 981 |
|
954 | 982 |
|
955 | 983 | end % end distmesh2d_plus
|
956 |
| - |
957 |
| - function obj = nearshorefix(obj) |
958 |
| - %% kjr make sure boundaries have good spacing on boundary. |
959 |
| - % This is experimentary. |
960 |
| - t = obj.grd.t ; p = obj.grd.t; |
961 |
| - [bnde, ~] = extdom_edges2(t,p); |
962 |
| - [poly] = extdom_polygon(bnde,p,1); |
963 |
| - |
964 |
| - new = []; |
965 |
| - for j = 1 : length(poly) |
966 |
| - for i = 1 : length(poly{j})-2 |
967 |
| - pt = poly{j}(i,:) ; % current point |
968 |
| - nxt= poly{j}(i+1,:) ; % next point |
969 |
| - nxt2 = poly{j}(i+2,:) ; % next next point |
970 |
| - |
971 |
| - dst1 = sqrt( (nxt(:,1)-pt(:,1)).^2 + (nxt(:,2)-pt(:,2)).^2 ); % dist to next point |
972 |
| - dst2 = sqrt( (nxt2(:,1)-nxt(:,1)).^2 + (nxt2(:,2)-nxt(:,2)).^2 ); % dist to next next point |
973 |
| - |
974 |
| - if dst2/dst1 > 2 |
975 |
| - % split bar |
976 |
| - q = (nxt2 + nxt)/2; |
977 |
| - new = [new; q]; |
978 |
| - end |
979 |
| - end |
980 |
| - end |
981 |
| - p = [p; new]; % post fix new points (to avoid problems with pfix.) |
982 |
| - t = delaunay_elim(p,obj.fd,geps,0); % Delaunay with elimination |
983 |
| - obj.grd.t = t ; obj.grd.p = t; |
984 |
| - end |
| 984 | + |
985 | 985 |
|
986 | 986 |
|
987 | 987 | end % end methods
|
|
0 commit comments