%% Creation of the initial meshed domain:
% Create two meshed longitudinal surfaces for both the 0.5-mm thick beams:
[n_beam_1,f_beam_1]=meshabox([-11 3 -2.6],[11 2 2.6],0.01,1); % Create meshed volume for the first beam;
[n_beam_1,el_beam_1,fa_beam_1]=surf2mesh(n_beam_1,f_beam_1,[],[],1,0.01); % Extract longitudinal surface from the meshed beam;
[no_beam_1,fa_beam_1]=removeisolatednode(n_beam_1,fa_beam_1(:,1:3)); % Remove isolated nodes in the beam surface;
[n_beam_2,f_beam_2]=meshabox([-11 -2 -2.6],[11 -3 2.6],0.01,1); % Create meshed volume for the second beam;
[n_beam_2,el_beam_2,fa_beam_2]=surf2mesh(n_beam_2,f_beam_2,[],[],1,0.01); % Extract longitudinal surface from the meshed beam;
[no_beam_2,fa_beam_2]=removeisolatednode(n_beam_2,fa_beam_2(:,1:3)); % Remove isolated nodes in the beam surface;
% Create the meshed surface of the bounding 20x20x5 mm slab:
[no_slab,fa_slab]=meshabox([-10 -10 -2.5],[10 10 2.5],0.01,1); % Create the meshed slab surface;
% Combine the meshed surfaces of the two beams:
[no_beams,fa_beams]=mergemesh(no_beam_1,fa_beam_1,no_beam_2,fa_beam_2);
% Create the final meshed volume of the bounding 20x20x5 mm box around the inner meshed volumes of the two cylinders:
[no_mesh,fa_mesh]=surfboolean(no_slab,fa_slab(:,[1 3 2]),'first',no_beams,fa_beams); % Combine the surfaces of the beams with the slab;
no_mesh=round(no_mesh,4); % Refine merged surfaces;
[node,elem]=s2m(no_mesh,fa_mesh,1,0.01,'tetgen',[0 0 0; 0 2.5 0; 0 -2.5 0]); % Convert the merged surfaces into the final meshed domain volume;
[node,elem]=sortmesh([],node,elem,1:4); % Sort nodes and elements in the final meshed domain;
elem(:,1:4)=meshreorient(node,elem(:,1:4)); % Re-orient elements of the final meshed domain;