1
- % DEMO_BARBELL_2
2
- %
3
- % Define a polygonal "barbell" shaped domain with
4
- % prescribed constant boundary data on each edge.
5
- % Solves the corresponding Helmholtz Dirichlet problem
6
- % using corner rounding and smoothing the boundary data
7
- % across the rounded corners
8
- %
9
-
10
- % profile clear
11
- % profile on
12
-
13
- clearvars ; close all ;
14
- iseed = 8675309 ;
15
- rng(iseed ,' twister' );
16
- addpaths_loc();
17
-
1
+ % testing product quadrature rule
18
2
% planewave vec
19
3
20
4
kvec = 10 *[1 ;-1.5 ];
25
9
26
10
% define geometry and boundary conditions
27
11
% (vertices defined by another function)
28
- verts = chnk .demo .barbell(2.0 ,2.0 ,1.0 ,1.0 );
29
- nv = size(verts ,2 );
30
- edgevals = randn(1 ,nv );
31
-
32
- % parameters for curve rounding/chunking routine to oversample boundary
33
- cparams = [];
34
- cparams.widths = 0.1 * ones(size(verts ,2 ),1 );% width to cut about each corner
35
- cparams.eps = 1e- 12 ; % tolerance at which to resolve curve
36
- cparams.rounded = true ;
37
-
38
- % call smoothed-polygon chunking routine
39
- % a smoothed version of edgevals is returned in
40
- % chnkr.data
41
- chnkr = chunkerpoly(verts ,cparams ,[],edgevals );
42
- chnkr = refine(chnkr ,struct(' nover' ,1 ));
43
- %
44
- % plot smoothed geometry and data
45
12
46
- figure(1 )
47
- clf
48
- plot(chnkr ,' -x' )
49
- hold on
50
- quiver(chnkr )
51
- axis equal
52
-
53
- figure(2 )
54
- clf
55
- nchplot = 1 : chnkr .nch ;
56
- plot3(chnkr ,1 )
13
+ cparams = []; cparams.eps = 1e-9 ;
14
+ chnkr = chunkerfunc(@(t ) starfish(t ),cparams );
15
+ chnkr = refine(chnkr ,struct(' nover' ,1 ));
57
16
58
17
% solve and visualize the solution
59
18
111
70
fprintf(' %5.2e s : time for kerneval (adaptive for near)\n ' ,t1 );
112
71
113
72
% Compare with reference solution Dsol
114
- error = max(abs(Csol - Csolpquad ))/max(abs(Csol ));
115
- fprintf(' %5.2e : Relative max error\n ' ,error );
73
+ rel_error = max(abs(Csol - Csolpquad ))/max(abs(Csol ));
74
+ fprintf(' %5.2e : Relative max error\n ' ,rel_error );
116
75
%
117
76
118
- assert(error < 1e- 10 )
119
- % profile viewer
77
+ assert(rel_error < 1e- 10 )
78
+ % profile viewer
0 commit comments