Mercurial > repos > public > sbplib
annotate +parametrization/old/triang_interp.m @ 1031:2ef20d00b386 feature/advectionRV
For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 17 Jan 2019 10:25:06 +0100 |
parents | 81e0ead29431 |
children |
rev | line source |
---|---|
0 | 1 classdef triang_interp |
2 properties | |
3 g1, g2 ,g3 % Curves encirling the tirangle in the positive direction. | |
4 A,B,C % The corners of the triangle | |
5 Sa, Sb, Sc % Mappings from square with different sides collapsed | |
6 end | |
7 | |
8 methods | |
9 function o = triang_interp(g1,g2,g3) | |
10 o.g1 = g1; | |
11 o.g2 = g2; | |
12 o.g3 = g3; | |
13 o.A = g1(0); | |
14 o.B = g2(0); | |
15 o.C = g3(0); | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
16 o.Sa = parametrization.triang_interp.square_to_triangle_interp(g2,g3,g1); |
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
17 o.Sb = parametrization.triang_interp.square_to_triangle_interp(g3,g1,g2); |
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
18 o.Sc = parametrization.triang_interp.square_to_triangle_interp(g1,g2,g3); |
0 | 19 end |
20 | |
21 | |
22 function show(o,N) | |
23 % Show the mapped meridians of the triangle. | |
24 % Might be used for the barycentric coordinates. | |
25 ma = @(t)o.Sa(1/2,1-t); | |
26 mb = @(t)o.Sb(1/2,1-t); | |
27 mc = @(t)o.Sc(1/2,1-t); | |
28 | |
29 na = @(t)o.Sa(t,1/2); | |
30 | |
31 ka = @(t)(o.g1(1-t)+o.g2(t))/2; | |
32 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
33 h = parametrization.plot_curve(ma); |
0 | 34 h.Color = Color.blue; |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
35 h = parametrization.plot_curve(mb); |
0 | 36 h.Color = Color.blue; |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
37 h = parametrization.plot_curve(mc); |
0 | 38 h.Color = Color.blue; |
39 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
40 h = parametrization.plot_curve(na); |
0 | 41 h.Color = Color.red; |
42 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
43 h = parametrization.plot_curve(ka); |
0 | 44 h.Color = Color.red; |
45 | |
46 [a(1),a(2)] = ma(1/3); | |
47 [b(1),b(2)] = mb(1/3); | |
48 [c(1),c(2)] = mc(1/3); | |
49 | |
50 d = ka(1-1/3); | |
51 | |
52 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
53 parametrization.label_pt(a,b,c,d); |
0 | 54 |
55 | |
56 % t = linspace(0,1,N); | |
57 % for i = 1:N | |
58 % sa = @(s)o.Sa(s,t(i)); | |
59 % sb = @(s)o.Sb(s,t(i)); | |
60 % sc = @(s)o.Sc(s,t(i)); | |
61 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
62 % h = parametrization.plot_curve(sa); |
0 | 63 % h.Color = Color.blue; |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
64 % h = parametrization.plot_curve(sb); |
0 | 65 % h.Color = Color.blue; |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
66 % h = parametrization.plot_curve(sc); |
0 | 67 % h.Color = Color.blue; |
68 % end | |
69 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
70 h = parametrization.plot_curve(o.g1); |
0 | 71 h.LineWidth = 2; |
72 h.Color = Color.red; | |
73 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
74 h = parametrization.plot_curve(o.g2); |
0 | 75 h.LineWidth = 2; |
76 h.Color = Color.red; | |
77 | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
78 h = parametrization.plot_curve(o.g3); |
0 | 79 h.LineWidth = 2; |
80 h.Color = Color.red; | |
81 | |
82 end | |
83 | |
84 | |
85 end | |
86 | |
87 methods(Static) | |
88 % Makes a mapping from the unit square to a triangle by collapsing | |
89 % one of the sides of the squares to a corner on the triangle | |
90 % The collapsed side is mapped to the corner oposite to g1. | |
91 % This is done such that for S(s,t), S(s,1) = g1(s) | |
92 function S = square_to_triangle_interp(g1,g2,g3) | |
248
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
93 corner = parametrization.line_segment(g3(0),g3(0)); |
81e0ead29431
Fixed package names in +parametrization
Jonatan Werpers <jonatan@werpers.com>
parents:
151
diff
changeset
|
94 S = parametrization.transfinite_interp(corner,g3,f(g1),f(g2)) |
0 | 95 |
96 % Function to flip a curve | |
97 function h = f(g) | |
98 h = @(t)g(1-t); | |
99 end | |
100 end | |
101 end | |
102 | |
103 end | |
104 | |
105 % % Return a mapping from u.v to x,y of the domain encircled by g1 g2 g3 in the the positive direction. created be using transfinite interpolation. | |
106 % function S = triang_interp(g1,g2,g3) | |
107 % A = g1(0) | |
108 % B = g2(0) | |
109 % C = g3(0) | |
110 | |
111 % function [x,y] = S_fun(u,v) | |
112 % w = sqrt((u-1)^2+v^2)/sqrt(2); % Parameter for g3 | |
113 % v = v*(1-u-v)*g1(u) + u*(1-u-v)*g2(v) + u*v*g3(w) ... | |
114 % +(1-u)*(1-v)*A+u*(1-v)*B + (1-u)*v*C; | |
115 % x = v(1); | |
116 % y = v(2); | |
117 % end | |
118 % S = @S_fun; | |
119 % end | |
120 | |
121 | |
122 | |
123 % function subsref(obj,S) | |
124 % if ~all(isnumeric(S.subs{:})) | |
125 % error('Only supports calling object with number') | |
126 % end | |
127 % if numel(S.subs{:}) > 1 | |
128 % disp('You''ve called the object with more than one argument'); | |
129 % else | |
130 % disp(['You called the object with argument = ',num2str(S.subs{:})]); | |
131 % end | |
132 % end |