NiHu  2.0
elastostatics_test.m
1 clear;
2 
3 %% parameters
4 R = 1;
5 H = 4;
6 Le = .15;
7 nu = .33;
8 mu = 1e8;
9 
10 %% create mesh
11 N = ceil(2*pi*R/Le/4);
12 disc = create_circle(R, N);
13 b = get_boundary(disc);
14 Nz = ceil(H/Le);
15 side = extrude_mesh(b, [0 0 H/Nz], Nz);
16 mesh = join_meshes(disc,...
17  flip_mesh(side),...
18  translate_mesh(flip_mesh(disc), [0 0 H]));
19 mesh = merge_coincident_nodes(mesh);
20 mesh = drop_unused_nodes(mesh);
21 
22 %% quadratic elements and blow up
23 qmesh = quadratise(mesh, struct('quad_with_mid', true));
24 [nodidx, elidx] = mesh_select(qmesh, sprintf('abs(r-%g) < 1e-2', R), 'ind');
25 sidenodes = qmesh.Nodes(nodidx,2:3);
26 r = sqrt(dot(sidenodes, sidenodes, 2));
27 qmesh.Nodes(nodidx,2:3) = bsxfun(@times, qmesh.Nodes(nodidx,2:3), R./r);
28 
29 %% Compile mex file
30 if(0)
31 mex -v CXXFLAGS="$CXXFLAGS -std=c++11 -O3 -fPIC" ...
32  ../../src/tutorial/elastostatics.mex.cpp ...
33  ../../src/library/lib_element.cpp ...
34  ../../src/library/lib_shape.cpp ...
35  ../../src/library/lib_domain.cpp ...
36  -I../../src ...
37  -I/usr/local/include/eigen3 ...
38  -o elastostatics
39 end
40 %% Call NiHu to compute system matrices
41 [nodes, elements] = extract_core_mesh(qmesh);
42 tic;
43 [U, T] = elastostatics(nodes, elements, nu, mu);
44 toc;
45 
46 %% Boundary conditions
47 [xc, nc] = centnorm(mesh);
48 phi = atan2(xc(:,2), xc(:,1));
49 tpre = [sin(phi) -cos(phi) zeros(size(phi,1),1)];
50 tpre(xc(:,3) < H,:) = 0;
51 
52 upind = find(xc(:,3) > 0);
53 updofind = union(union(3*upind-2, 3*upind-1), 3*upind);
54 
55 Uc = U(updofind, updofind);
56 Tc = T(updofind, updofind);
57 
58 ures(updofind) = (Tc - .5*eye(size(Tc))) \ (Uc * reshape(tpre(upind,:).', [], 1));
59 ures = reshape(ures, 3, []).';
60 
61 Trans = cell2node_interp(mesh);
62 Trans(end,:) = Trans(end,:)/4;
63 ures_node = Trans * ures;
64 
65 %% plot results
66 disp_mesh = mesh;
67 disp_mesh.Nodes(:,2:4) = disp_mesh.Nodes(:,2:4)-ures_node/10e-8;
68 figure;
69 formatfig([6 10], [0 0 0 0]);
70 % shading interp;
71 quiver3(xc(:,1), xc(:,2), xc(:,3)+.5, tpre(:,1), tpre(:,2), tpre(:,3), 'LineWidth', 2, 'Color', 'black');
72 hold on;
73 plot_mesh(disp_mesh, ures_node(:,1));
74 view(56, 25);
75 light
76 lighting phong
77 axis equal off
78 %print -dpng bar -r600
NiHu::bessel::H
make_complex< T >::type H(T const &z)
H^(K)_nu(z) Bessel function.
Definition: math_functions.hpp:365