Loading [MathJax]/extensions/tex2jax.js
NiHu  2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
helmholtz_bem_3d_fict_test.m
1 %// sphere radiator with radius R = 1, divided into 6 elements along the radius.
2 radiator = quad2tria(create_sphere_boundary(1, 6));
3 %// CHIEF-points: element centers of cube boundary
4 chief_points = create_brick_boundary(.4, 5);
5 
6 %// extract the mesh description matrices
7 [r_nodes, r_elem] = extract_core_mesh(radiator);
8 [c_nodes, c_elem] = extract_core_mesh(chief_points);
9 
10 %// call C++ code at wave number k \approx pi
11 k = pi + 1.2e-2;
12 [Ls, Ms, Lc, Mc, Mts, Ns] =...
13  helmholtz_bem_3d_fict(r_nodes, r_elem, c_nodes, c_elem, k);
14 
15 %// define the incident velocity field and analytical solutions
16 x0 = [0 0 0];
17 [r_cent, r_norm] = centnorm(radiator);
18 [ps_ana, qs_ana] = incident('point', x0, r_cent, r_norm, k);
19 
20 %// acoustic pressure on the surface and in the field points
21 ps_conv = Ms \ (Ls * qs_ana); %// conventional
22 ps_chief = [Ms; Mc] \ ([Ls; Lc] * qs_ana); %// CHIEF
23 coup = -1i/k; %// coupling constant
24 ps_bm = (Ms + coup * Ns) \ (Ls * qs_ana + coup * Mts * qs_ana);
25 
26 % // calculate errors
27 ps_conv_err = abs(ps_conv./ps_ana - 1); %// conventional
28 ps_chief_err = abs(ps_chief./ps_ana - 1); %// CHIEF
29 ps_bm_err = abs(ps_bm./ps_ana - 1); %// BM
30 
31 % // plot results
32 figure;
33 
34 plot_mesh(radiator, log10(ps_conv_err));
35 text(0,1.3,0, 'Conventional', 'HorizontalAlignment', 'center');
36 plot_mesh(translate_mesh(radiator, [2.3 0 0]), log10(ps_chief_err));
37 text(2.3,1.3,0, 'CHIEF', 'HorizontalAlignment', 'center');
38 plot_mesh(translate_mesh(radiator, [2*2.3 0 0]), log10(ps_bm_err));
39 text(2*2.3,1.3,0, 'Burton-Miller', 'HorizontalAlignment', 'center');
40 err_tot = [ps_conv_err; ps_chief_err; ps_bm_err];
41 shading flat; caxis(log10([min(err_tot) max(err_tot)]));
42 view(2);
43 c = colorbar('SouthOutside');
44 xlabel(c, 'Log 10 error of solution');
45 
46 %// display error information
47 fprintf('Conventional log10 error: % .3f \n', log10(mean(ps_conv_err)));
48 fprintf('CHIEF log10 error: % .3f \n', log10(mean(ps_chief_err)));
49 fprintf('Burton-Miller log10 error: % .3f \n', log10(mean(ps_bm_err)));