forked from project-asgard/DG-SparseGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_adapt.m
More file actions
91 lines (66 loc) · 2.14 KB
/
plot_adapt.m
File metadata and controls
91 lines (66 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function [coordinates] = plot_adapt(pde,opts,hash_table,pos)
num_elements = numel(hash_table.elements_idx);
num_dims = numel(pde.dimensions);
xMin = pde.dimensions{1}.domainMin;
xMax = pde.dimensions{1}.domainMax;
%%
% Get grid point coordinates
coordinates = zeros (num_elements, num_dims);
levels = zeros (num_elements, 1);
style = strings (num_elements, 1);
for i=1:num_elements
idx = hash_table.elements_idx(i);
%c = hash_table.elements.type(idx);
c = 1;
if c == 1
style(i) = 'ob';
elseif c == 2
style(i) = 'or';
else
error('why are there elements without a type tag?');
end
coordinates(i,:) = get_my_realspace_coord(pde,opts,hash_table,idx);
levels(i) = sum (hash_table.elements.lev_p1(idx,:)-1,'all');
assert(levels(i)>=0);
end
figure(222);
if num_dims == 1
subplot(2,3,pos)
cla
hold on
for i=1:num_elements
idx = hash_table.elements_idx(i);
y = hash_table.elements.lev_p1(idx,1)-1;
c = hash_table.elements.type(idx);
style = 'ob';
if c == 1
style = 'ob';
elseif c == 2
style = 'ob';
end
coord_D = get_my_realspace_coord(pde,opts,hash_table,idx);
plot(coord_D(1),-y,style,'MarkerSize',10);
[child_elements_idx, cnt] ...
= get_child_elements_idx (num_dims, pde.max_lev, idx, opts.refinement_method);
for child=1:cnt
try
child_coord_D = get_my_realspace_coord(pde,opts,hash_table,child_elements_idx(child));
child_y = hash_table.elements.lev_p1(child_elements_idx(child),1)-1;
xx = [coord_D(1),child_coord_D(1)];
yy = [-y,-child_y];
plot(xx,yy,'Color','black','LineWidth',2);
end
end
xlim([xMin,xMax]);
end
elseif num_dims == 2
subplot(4,3,pos)
cla
hold on
for i=1:num_elements
plot3 (coordinates(i,1), coordinates(i,2), levels(i), style(i));
hold on
end
end
hold off
end