Simulation of flow through a pipe
Matlab Code for block mesh :
clear all
close all
clc
%input
theta=2; %In degrees for Wedge angle
grading=0.25; %Grading factor along the walls of cylinder
length=1000;
radius=10;
b1=400; %cells along the length of cylinder
b2=12; %cells along the radius of cylinder
%vertices of the wedge
v0=[0 0 0];
v1=[length 0 0];
v2=[length radius*cosd(theta/2) -radius*sind(theta/2)];
v3=[0 radius*cosd(theta/2) -radius*sind(theta/2)];
v4=[0 radius*cosd(theta/2) radius*sind(theta/2)];
v5=[length radius*cosd(theta/2) radius*sind(theta/2)];
%wedge block
% hex (0 1 2 3 0 1 5 4) (80 20 1) simpleGrading(1 1 1)
f1=fopen(\'blockMeshDict.txt\',\'wt\');
fprintf(f1,\'FoamFile\\n{\\n\');
fprintf(f1,\'%16s \\t 2.0;\\n\',\'version\');
fprintf(f1,\'%16s \\t ascii;\\n\',\'format\');
fprintf(f1,\'%16s \\t dictionary;\\n\',\'class\');
fprintf(f1,\'%16s \\t blockMeshDict;\\n}\\n\',\'object\');
fprintf(f1,\'%s\\n\\n\',s8);
fprintf(f1,\'convertToMeters 0.001;\\n\\n\');
fprintf(f1,\'vertices\\n(\\n\');
fprintf(f1,\'\\t(%d %d %d)\\n\',v0(1),v0(2),v0(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v1(1),v1(2),v1(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v2(1),v2(2),v2(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v3(1),v3(2),v3(3));
fprintf(f1,\'\\t(%d %d %d)\\n\',v4(1),v4(2),v4(3));
fprintf(f1,\'\\t(%d %d %d)\\n);\\n\\n\',v5(1),v5(2),v5(3));
fprintf(f1,\'blocks\\n(\\n\');
fprintf(f1,\'\\t hex (0 1 2 3 0 1 5 4) (%d %d %d)\\n\',b1,b2,1);
fprintf(f1,\'\\t simpleGrading\\n\\t (1 %d 1)\\n);\\n\\n\',grading);
fprintf(f1,\'edges\\n(\\n);\\n\\n\');
fprintf(f1,\'boundary\\n(\\n\');
fprintf(f1,\'\\t%s\\n\\t{\\n\\t\\t type %s;\\n\\t\\t faces \\n\\t\\t (\\n\\t\\t\\t (%d %d %d %d) \\n\\t\\t );\\n\\t}\\n\\n\',\'inlet\',\'patch\',0,4,3,0);
fprintf(f1,\'\\t%s\\n\\t{\\n\\t\\t type %s;\\n\\t\\t faces \\n\\t\\t (\\n\\t\\t\\t (%d %d %d %d) \\n\\t\\t );\\n\\t}\\n\\n\',\'outlet\',\'patch\',1,2,5,1);
fprintf(f1,\'\\t%s\\n\\t{\\n\\t\\t type %s;\\n\\t\\t faces \\n\\t\\t (\\n\\t\\t\\t (%d %d %d %d) \\n\\t\\t );\\n\\t}\\n\\n\',\'Wall\',\'wall\',2,3,4,5);
fprintf(f1,\'\\t%s\\n\\t{\\n\\t\\t type %s;\\n\\t\\t faces \\n\\t\\t (\\n\\t\\t\\t (%d %d %d %d) \\n\\t\\t );\\n\\t}\\n\\n\',\'axis\',\'empty\',0,1,1,0);
fprintf(f1,\'\\t%s\\n\\t{\\n\\t\\t type %s;\\n\\t\\t faces \\n\\t\\t (\\n\\t\\t\\t (%d %d %d %d) \\n\\t\\t );\\n\\t}\\n\\n\',\'wedgeFront\',\'wedge\',0,1,2,3);
fprintf(f1,\'\\t%s\\n\\t{\\n\\t\\t type %s;\\n\\t\\t faces \\n\\t\\t (\\n\\t\\t\\t (%d %d %d %d) \\n\\t\\t );\\n\\t}\\n\\n\',\'wedgeBack\',\'wedge\',0,1,5,4);
fprintf(f1,\');\\n\\n\');
fprintf(f1,\'mergePatchPairs\\n(\\n);\\n\\n\');
fprintf(f1,\'%s\',s8);
fclose(f1);
Different mesh can be generated by varying degree in angle in matlab code.
Basically we can see the velocity obtained by Block mesh and Hagen poiseuille\'s equation(Analytical Velocity) is almost similar i.e, 0.05m/s wrt wedge angle\'s.
Now the velocity profile obtained at inlet.
Shear stress and the outlet velocity profile curves obtained are: