Mercurial > repos > public > sbplib
annotate +multiblock/+domain/Annulus.m @ 1343:09a5783a3d37 feature/D2_boundary_opt
Improve on default choice of number of grid points for each block
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 14 Oct 2022 14:42:32 +0200 |
parents | 4d472d020ccf |
children |
rev | line source |
---|---|
1254 | 1 classdef Annulus < multiblock.DefCurvilinear |
2 properties | |
1256
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
3 r_inner % Radii of inner disk |
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
4 c_inner % Center of inner disk |
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
5 r_outer % Radii of outer disk |
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
6 c_outer % Radii of outer disk |
1254 | 7 end |
8 | |
9 methods | |
1256
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
10 function obj = Annulus(r_inner, c_inner, r_outer, c_outer) |
1254 | 11 default_arg('r_inner', 0.3); |
1256
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
12 default_arg('c_inner', [0; 0]); |
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
13 default_arg('r_outer', 1) |
1254 | 14 default_arg('c_outer', [0; 0]); |
1256
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
15 % Assert that the problem is well-defined |
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
16 d = norm(c_outer-c_inner,2); |
1257
4d472d020ccf
Assert that the inner radius is positive
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1256
diff
changeset
|
17 assert(r_inner > 0, 'Inner radius must be greater than zero'); |
1256
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
18 assert(r_outer > d+r_inner, 'Inner disk not contained in outer disk'); |
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
19 |
1254 | 20 cir_out_A = parametrization.Curve.circle(c_outer,r_outer,[-pi/2 pi/2]); |
21 cir_in_A = parametrization.Curve.circle(c_inner,r_inner,[pi/2 -pi/2]); | |
22 | |
23 cir_out_B = parametrization.Curve.circle(c_outer,r_outer,[pi/2 3*pi/2]); | |
24 cir_in_B = parametrization.Curve.circle(c_inner,r_inner,[3*pi/2 pi/2]); | |
25 | |
26 c0_out = cir_out_A(0); | |
27 c1_out = cir_out_A(1); | |
28 | |
29 c0_in_A = cir_in_A(1); | |
30 c1_in_A = cir_in_A(0); | |
31 | |
32 c0_out_B = cir_out_B(0); | |
33 c1_out_B = cir_out_B(1); | |
34 | |
35 c0_in_B = cir_in_B(1); | |
36 c1_in_B = cir_in_B(0); | |
37 | |
38 | |
39 sp2_A = parametrization.Curve.line(c0_in_A,c0_out); | |
40 sp3_A = parametrization.Curve.line(c1_in_A,c1_out); | |
41 | |
42 sp2_B = parametrization.Curve.line(c0_in_B,c0_out_B); | |
43 sp3_B = parametrization.Curve.line(c1_in_B,c1_out_B); | |
44 | |
45 | |
46 A = parametrization.Ti(sp2_A, cir_out_A, sp3_A.reverse, cir_in_A); | |
1256
479d5672fecd
Minor cleanup
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1255
diff
changeset
|
47 B = parametrization.Ti(sp2_B , cir_out_B,sp3_B.reverse, cir_in_B ); |
1254 | 48 |
49 blocks = {A,B}; | |
50 blocksNames = {'A','B'}; | |
51 | |
52 conn = cell(2,2); | |
53 | |
54 conn{1,2} = {'n','s'}; | |
55 conn{2,1} = {'n','s'}; | |
56 | |
57 boundaryGroups = struct(); | |
1255 | 58 boundaryGroups.out = multiblock.BoundaryGroup({{1,'e'},{2,'e'}}); |
59 boundaryGroups.in = multiblock.BoundaryGroup({{1,'w'},{2,'w'}}); | |
1254 | 60 boundaryGroups.all = multiblock.BoundaryGroup({{1,'e'},{2,'w'},{1,'w'},{2,'e'}}); |
61 | |
62 obj = obj@multiblock.DefCurvilinear(blocks, conn, boundaryGroups, blocksNames); | |
63 | |
64 obj.r_inner = r_inner; | |
65 obj.r_outer = r_outer; | |
66 obj.c_inner = c_inner; | |
67 obj.c_outer = c_outer; | |
68 end | |
69 | |
70 function ms = getGridSizes(obj, m) | |
1343
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
71 mx = m; |
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
72 % Use same grid spacing along inner |
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
73 % half circle as in radial direction |
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
74 ds = pi*(obj.r_inner); |
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
75 dr = (obj.r_outer-obj.r_inner); |
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
76 my = ceil(ds/dr*(mx-1))+1; |
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
77 |
09a5783a3d37
Improve on default choice of number of grid points for each block
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
1257
diff
changeset
|
78 ms = {[mx my], [mx my]}; |
1254 | 79 end |
80 end | |
81 end |