Challenge

Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation

Date:- 01-03-2021

Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation

  • Same as last week challenge, we do matlab automation for each angle and for each boundary condition wedge and symmetry.
  • we end up with 6 text files for creating block meshes for each cases. Program and matlab code shown at end of this report.

Validation of velocity profiles: -

Fig(1)

Fig(2)

Fig(3)

Conclusion form above figures: -

  • From above plots we can say that by increasing the wedge angle from 10 to 45 accuracy of the numerical solution is decreasing and error with respect to analytical solution is increasing.
  • Error between the numerical solutions of wedge and symmetry boundary conditions is very less or simply more or less both are giving same numerical solutions.

Validation of hydrodynamic entry length: -

  • These velocity profiles are for theta at 10 degrees
  • Figure 4 at L= 3meters and figure 5 at L=4 meters and figure 6 at L=4.2 meters and figure7 and figure8 at L= 4.3 and 4.5 respectively
  • Form figure 4 to 6 changes in velocity profiles are more.
  • Form 6 to 8 changes in velocity profile is less .
  • From above discussion we can say that length which is more than 4.2 meters we achieve constant velocity profile .then numerical value for hydrodynamic length is 4,2 meters
  • Analytical value of hydrodynamic length form week11 challenge is 4.2 meters.
  • This is true for all different wedge angles .

Fig(4) Fig(5)

Fig(6) Fig(7)

Fig(8)

Validation of maximum velocity:

  • Form figure 1 and 2 and 3 we can say that numerical value for maximum velocity is nearly equal to 092 m/sec.
  • Form analytical results we can say maximum velocity from week 11 challenge is 093 m/sec.

Pressure drop:-

  • Analytical value of pressure drop is 4.17103 pascals from week 11 challenge .pressure drop is very minimum because we use laminar flow.

Note:- Note that hydrodynamic length and maximum velocity and sher stress are independent on wedge angels so for validating them we took one case on each validation.

Post processing of shear stress:

  • Analytical value for shear stress at wall is constant and value is 0.08342 N/m2.
  • Here in figure 9 we can see that numerical values of shear stress profile alone the radius of pipe. Both analytical and numerical values are nearly matching.

Fig(9): shear stress for wedge angle 10o with wedge boundary condition case

Differences in both boundary conditions: -

  • Theoretically symmetry boundary condition just do mirroring but wedge boundary conditions do axial and spherical symmetry and needs to perform coordinate transformation with given edge angle.
  • That means with wedge boundary conditions we achieve good accuracy compare to symmetry boundary conditions.

MATLAB CODE FOR AUTOMATION FOR BLOCKMESH :-

clc;
clear all;
close all;

%% Inputs
Re = 2100;
D =0.04;
mu =0.00089;
rho =997;
Lh = 0.05*Re*D;
L =Lh+0.8;
r = D/2;
theta=[10,25,45];
%% header text
h1 = '/*--------------------------------*- C++ -*----------------------------------*\';
h2 = '=========                 |';
h3 = '\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox';
h4 =  ' \\    /   O peration     | Website:  https://openfoam.org';
h5=  '\\  /    A nd           | Version:  8';
h6 = ' \\/     M anipulation  |';
h7 = '\*---------------------------------------------------------------------------*/';
h8 = 'FoamFile';
h9 = '{';
h10= 'version     2.0;';
h11 = 'format      ascii;';
h12 =  'class       dictionary;';
h13 = 'object      blockMeshDict;';
h14 ='}';
h15 = '// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //';

%%
for i=1:length(theta)
if i==1
f1= fopen('blockMeshDict_10_symmetry.txt','w');
fprintf(f1,'%s\n',h1);
fprintf(f1,'%s\n',h2);
fprintf(f1,'%s\n',h3);
fprintf(f1,'%s\n',h4);
fprintf(f1,'%s\n',h5);
fprintf(f1,'%s\n',h6);
fprintf(f1,'%s\n',h7);
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'\t%s\n',h10);
fprintf(f1,'\t%s\n',h11);
fprintf(f1,'\t%s\n',h12);
fprintf(f1,'\t%s\n',h13);
fprintf(f1,'%s\n',h14);
fprintf(f1,'%s\n\n\n',h15);
fprintf(f1,'convertToMeters 1;\n\n');
fprintf(f1,'vertices\n');
fprintf(f1,'(\n');
fprintf(f1,'\t(%d %d %d)\n',0,0,0);
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,'\t(%d %d %d)\n',L,0,0);
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,');\n\n');
fprintf(f1,'blocks\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\thex (%d %d %d %d %d %d %d %d) (%d %d %d) simpleGrading (%d %d %d)\n\n',0,3,5,2,0,3,4,1,200,20,1,1,0.1,1);
fprintf(f1,');\n\n');
fprintf(f1,'edges\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(f1,'\tarc %d %d (%d %d %d)\n\n',4,5,L,r,0);
fprintf(f1,');\n\n');
fprintf(f1,'boundary\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tinlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,1,2,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\toutlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',3,5,4,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\tfront\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype symmetry;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,4,1);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tback\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype symmetry;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,2,5,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\taxis\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,3,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\ttop\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wall;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',1,4,5,2);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,');\n\n');
fprintf(f1,'mergePatchPairs\n');
fprintf(f1,'(\n');
fprintf(f1,');\n');
fprintf(f1,'// ************************************************************************* //');
fclose(f1);
%
f1= fopen('blockMeshDict_10_wedge.txt','w');
fprintf(f1,'%s\n',h1);
fprintf(f1,'%s\n',h2);
fprintf(f1,'%s\n',h3);
fprintf(f1,'%s\n',h4);
fprintf(f1,'%s\n',h5);
fprintf(f1,'%s\n',h6);
fprintf(f1,'%s\n',h7);
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'\t%s\n',h10);
fprintf(f1,'\t%s\n',h11);
fprintf(f1,'\t%s\n',h12);
fprintf(f1,'\t%s\n',h13);
fprintf(f1,'%s\n',h14);
fprintf(f1,'%s\n\n\n',h15);
fprintf(f1,'convertToMeters 1;\n\n');
fprintf(f1,'vertices\n');
fprintf(f1,'(\n');
fprintf(f1,'\t(%d %d %d)\n',0,0,0);
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,'\t(%d %d %d)\n',L,0,0);
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,');\n\n');
fprintf(f1,'blocks\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\thex (%d %d %d %d %d %d %d %d) (%d %d %d) simpleGrading (%d %d %d)\n\n',0,3,5,2,0,3,4,1,200,20,1,1,0.1,1);
fprintf(f1,');\n\n');
fprintf(f1,'edges\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(f1,'\tarc %d %d (%d %d %d)\n\n',4,5,L,r,0);
fprintf(f1,');\n\n');
fprintf(f1,'boundary\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tinlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,1,2,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\toutlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',3,5,4,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\tfront\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wedge;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,4,1);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tback\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wedge;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,2,5,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\taxis\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,3,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\ttop\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wall;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',1,4,5,2);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,');\n\n');
fprintf(f1,'mergePatchPairs\n');
fprintf(f1,'(\n');
fprintf(f1,');\n');
fprintf(f1,'// ************************************************************************* //');
fclose(f1);
%
elseif i == 2
f1= fopen('blockMeshDict_25_symmetry.txt','w');
fprintf(f1,'%s\n',h1);
fprintf(f1,'%s\n',h2);
fprintf(f1,'%s\n',h3);
fprintf(f1,'%s\n',h4);
fprintf(f1,'%s\n',h5);
fprintf(f1,'%s\n',h6);
fprintf(f1,'%s\n',h7);
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'\t%s\n',h10);
fprintf(f1,'\t%s\n',h11);
fprintf(f1,'\t%s\n',h12);
fprintf(f1,'\t%s\n',h13);
fprintf(f1,'%s\n',h14);
fprintf(f1,'%s\n\n\n',h15);
fprintf(f1,'convertToMeters 1;\n\n');
fprintf(f1,'vertices\n');
fprintf(f1,'(\n');
fprintf(f1,'\t(%d %d %d)\n',0,0,0);
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,'\t(%d %d %d)\n',L,0,0);
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,');\n\n');
fprintf(f1,'blocks\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\thex (%d %d %d %d %d %d %d %d) (%d %d %d) simpleGrading (%d %d %d)\n\n',0,3,5,2,0,3,4,1,200,20,1,1,0.1,1);
fprintf(f1,');\n\n');
fprintf(f1,'edges\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(f1,'\tarc %d %d (%d %d %d)\n\n',4,5,L,r,0);
fprintf(f1,');\n\n');
fprintf(f1,'boundary\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tinlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,1,2,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\toutlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',3,5,4,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\tfront\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype symmetry;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,4,1);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tback\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype symmetry;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,2,5,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\taxis\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,3,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\ttop\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wall;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',1,4,5,2);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,');\n\n');
fprintf(f1,'mergePatchPairs\n');
fprintf(f1,'(\n');
fprintf(f1,');\n');
fprintf(f1,'// ************************************************************************* //');
fclose(f1);
%
f1= fopen('blockMeshDict_25_wedge.txt','w');
fprintf(f1,'%s\n',h1);
fprintf(f1,'%s\n',h2);
fprintf(f1,'%s\n',h3);
fprintf(f1,'%s\n',h4);
fprintf(f1,'%s\n',h5);
fprintf(f1,'%s\n',h6);
fprintf(f1,'%s\n',h7);
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'\t%s\n',h10);
fprintf(f1,'\t%s\n',h11);
fprintf(f1,'\t%s\n',h12);
fprintf(f1,'\t%s\n',h13);
fprintf(f1,'%s\n',h14);
fprintf(f1,'%s\n\n\n',h15);
fprintf(f1,'convertToMeters 1;\n\n');
fprintf(f1,'vertices\n');
fprintf(f1,'(\n');
fprintf(f1,'\t(%d %d %d)\n',0,0,0);
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,'\t(%d %d %d)\n',L,0,0);
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,');\n\n');
fprintf(f1,'blocks\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\thex (%d %d %d %d %d %d %d %d) (%d %d %d) simpleGrading (%d %d %d)\n\n',0,3,5,2,0,3,4,1,200,20,1,1,0.1,1);
fprintf(f1,');\n\n');
fprintf(f1,'edges\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(f1,'\tarc %d %d (%d %d %d)\n\n',4,5,L,r,0);
fprintf(f1,');\n\n');
fprintf(f1,'boundary\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tinlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,1,2,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\toutlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',3,5,4,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\tfront\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wedge;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,4,1);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tback\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wedge;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,2,5,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\taxis\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,3,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\ttop\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wall;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',1,4,5,2);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,');\n\n');
fprintf(f1,'mergePatchPairs\n');
fprintf(f1,'(\n');
fprintf(f1,');\n');
fprintf(f1,'// ************************************************************************* //');
fclose(f1);
elseif i == 3
f1= fopen('blockMeshDict_45_symmetry.txt','w');
fprintf(f1,'%s\n',h1);
fprintf(f1,'%s\n',h2);
fprintf(f1,'%s\n',h3);
fprintf(f1,'%s\n',h4);
fprintf(f1,'%s\n',h5);
fprintf(f1,'%s\n',h6);
fprintf(f1,'%s\n',h7);
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'\t%s\n',h10);
fprintf(f1,'\t%s\n',h11);
fprintf(f1,'\t%s\n',h12);
fprintf(f1,'\t%s\n',h13);
fprintf(f1,'%s\n',h14);
fprintf(f1,'%s\n\n\n',h15);
fprintf(f1,'convertToMeters 1;\n\n');
fprintf(f1,'vertices\n');
fprintf(f1,'(\n');
fprintf(f1,'\t(%d %d %d)\n',0,0,0);
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,'\t(%d %d %d)\n',L,0,0);
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,');\n\n');
fprintf(f1,'blocks\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\thex (%d %d %d %d %d %d %d %d) (%d %d %d) simpleGrading (%d %d %d)\n\n',0,3,5,2,0,3,4,1,200,20,1,1,0.1,1);
fprintf(f1,');\n\n');
fprintf(f1,'edges\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(f1,'\tarc %d %d (%d %d %d)\n\n',4,5,L,r,0);
fprintf(f1,');\n\n');
fprintf(f1,'boundary\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tinlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,1,2,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\toutlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',3,5,4,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\tfront\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype symmetry;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,4,1);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tback\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype symmetry;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,2,5,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\taxis\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,3,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\ttop\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wall;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',1,4,5,2);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,');\n\n');
fprintf(f1,'mergePatchPairs\n');
fprintf(f1,'(\n');
fprintf(f1,');\n');
fprintf(f1,'// ************************************************************************* //');
fclose(f1);
%
f1= fopen('blockMeshDict_45_wedge.txt','w');
fprintf(f1,'%s\n',h1);
fprintf(f1,'%s\n',h2);
fprintf(f1,'%s\n',h3);
fprintf(f1,'%s\n',h4);
fprintf(f1,'%s\n',h5);
fprintf(f1,'%s\n',h6);
fprintf(f1,'%s\n',h7);
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'\t%s\n',h10);
fprintf(f1,'\t%s\n',h11);
fprintf(f1,'\t%s\n',h12);
fprintf(f1,'\t%s\n',h13);
fprintf(f1,'%s\n',h14);
fprintf(f1,'%s\n\n\n',h15);
fprintf(f1,'convertToMeters 1;\n\n');
fprintf(f1,'vertices\n');
fprintf(f1,'(\n');
fprintf(f1,'\t(%d %d %d)\n',0,0,0);
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',0,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,'\t(%d %d %d)\n',L,0,0);
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),r*sind(theta(i)/2));
fprintf(f1,'\t(%d %f %f)\n',L,r*cosd(theta(i)/2),-r*sind(theta(i)/2));
fprintf(f1,');\n\n');
fprintf(f1,'blocks\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\thex (%d %d %d %d %d %d %d %d) (%d %d %d) simpleGrading (%d %d %d)\n\n',0,3,5,2,0,3,4,1,200,20,1,1,0.1,1);
fprintf(f1,');\n\n');
fprintf(f1,'edges\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tarc %d %d (%d %d %d)\n',1,2,0,r,0);
fprintf(f1,'\tarc %d %d (%d %d %d)\n\n',4,5,L,r,0);
fprintf(f1,');\n\n');
fprintf(f1,'boundary\n\n');
fprintf(f1,'(\n\n');
fprintf(f1,'\tinlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,1,2,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\toutlet\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype patch;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',3,5,4,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n\n');
fprintf(f1,'\tfront\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wedge;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,4,1);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\tback\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wedge;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,2,5,3);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\taxis\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype empty;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',0,3,3,0);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,'\ttop\n');
fprintf(f1,'\t{\n');
fprintf(f1,'\t\ttype wall;\n');
fprintf(f1,'\t\tfaces\n');
fprintf(f1,'\t\t(\n');
fprintf(f1,'\t\t\t(%d %d %d %d)\n',1,4,5,2);
fprintf(f1,'\t\t);\n');
fprintf(f1,'\t}\n');
fprintf(f1,');\n\n');
fprintf(f1,'mergePatchPairs\n');
fprintf(f1,'(\n');
fprintf(f1,');\n');
fprintf(f1,'// ************************************************************************* //');
fclose(f1);
end
end
       
%% Analyticl_solution
d = linspace(0,r,1000);
v_avg =(2100*(mu/rho))/D;
v_max = 2*v_avg;
v_anl = v_max*(1-((2*d./D).^2));
%%

For theta 10deg with symmetry boundary condition:-

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 \\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  8
 \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
	version     2.0;
	format      ascii;
	class       dictionary;
	object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


convertToMeters 1;

vertices
(
	(0 0 0)
	(0 0.019924 0.001743)
	(0 0.019924 -0.001743)
	(5 0 0)
	(5 0.019924 0.001743)
	(5 0.019924 -0.001743)
);

blocks

(

	hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (1 1.000000e-01 1)

);

edges
(

	arc 1 2 (0 2.000000e-02 0)
	arc 4 5 (5 2.000000e-02 0)

);

boundary

(

	inlet
	{
		type patch;
		faces
		(
			(0 1 2 0)
		);
	}

	outlet
	{
		type patch;
		faces
		(
			(3 5 4 3)
		);
	}

	front
	{
		type symmetry;
		faces
		(
			(0 3 4 1)
		);
	}
	back
	{
		type symmetry;
		faces
		(
			(0 2 5 3)
		);
	}
	axis
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	top
	{
		type wall;
		faces
		(
			(1 4 5 2)
		);
	}
);

mergePatchPairs
(
);
// ************************************************************************* //

theta 10 deg for wedge b.c:-

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 \\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  8
 \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
	version     2.0;
	format      ascii;
	class       dictionary;
	object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


convertToMeters 1;

vertices
(
	(0 0 0)
	(0 0.019924 0.001743)
	(0 0.019924 -0.001743)
	(5 0 0)
	(5 0.019924 0.001743)
	(5 0.019924 -0.001743)
);

blocks

(

	hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (1 1.000000e-01 1)

);

edges
(

	arc 1 2 (0 2.000000e-02 0)
	arc 4 5 (5 2.000000e-02 0)

);

boundary

(

	inlet
	{
		type patch;
		faces
		(
			(0 1 2 0)
		);
	}

	outlet
	{
		type patch;
		faces
		(
			(3 5 4 3)
		);
	}

	front
	{
		type wedge;
		faces
		(
			(0 3 4 1)
		);
	}
	back
	{
		type wedge;
		faces
		(
			(0 2 5 3)
		);
	}
	axis
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	top
	{
		type wall;
		faces
		(
			(1 4 5 2)
		);
	}
);

mergePatchPairs
(
);
// ************************************************************************* //

Theta 25 deg for symmetry b.c:-

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 \\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  8
 \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
	version     2.0;
	format      ascii;
	class       dictionary;
	object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


convertToMeters 1;

vertices
(
	(0 0 0)
	(0 0.019526 0.004329)
	(0 0.019526 -0.004329)
	(5 0 0)
	(5 0.019526 0.004329)
	(5 0.019526 -0.004329)
);

blocks

(

	hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (1 1.000000e-01 1)

);

edges
(

	arc 1 2 (0 2.000000e-02 0)
	arc 4 5 (5 2.000000e-02 0)

);

boundary

(

	inlet
	{
		type patch;
		faces
		(
			(0 1 2 0)
		);
	}

	outlet
	{
		type patch;
		faces
		(
			(3 5 4 3)
		);
	}

	front
	{
		type symmetry;
		faces
		(
			(0 3 4 1)
		);
	}
	back
	{
		type symmetry;
		faces
		(
			(0 2 5 3)
		);
	}
	axis
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	top
	{
		type wall;
		faces
		(
			(1 4 5 2)
		);
	}
);

mergePatchPairs
(
);
// ************************************************************************* //

Theta 25 deg for wedge b.c :-

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 \\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  8
 \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
	version     2.0;
	format      ascii;
	class       dictionary;
	object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


convertToMeters 1;

vertices
(
	(0 0 0)
	(0 0.019526 0.004329)
	(0 0.019526 -0.004329)
	(5 0 0)
	(5 0.019526 0.004329)
	(5 0.019526 -0.004329)
);

blocks

(

	hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (1 1.000000e-01 1)

);

edges
(

	arc 1 2 (0 2.000000e-02 0)
	arc 4 5 (5 2.000000e-02 0)

);

boundary

(

	inlet
	{
		type patch;
		faces
		(
			(0 1 2 0)
		);
	}

	outlet
	{
		type patch;
		faces
		(
			(3 5 4 3)
		);
	}

	front
	{
		type wedge;
		faces
		(
			(0 3 4 1)
		);
	}
	back
	{
		type wedge;
		faces
		(
			(0 2 5 3)
		);
	}
	axis
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	top
	{
		type wall;
		faces
		(
			(1 4 5 2)
		);
	}
);

mergePatchPairs
(
);
// ************************************************************************* //

Theta 45 deg for symmetry b.c :-

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 \\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  8
 \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
	version     2.0;
	format      ascii;
	class       dictionary;
	object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


convertToMeters 1;

vertices
(
	(0 0 0)
	(0 0.018478 0.007654)
	(0 0.018478 -0.007654)
	(5 0 0)
	(5 0.018478 0.007654)
	(5 0.018478 -0.007654)
);

blocks

(

	hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (1 1.000000e-01 1)

);

edges
(

	arc 1 2 (0 2.000000e-02 0)
	arc 4 5 (5 2.000000e-02 0)

);

boundary

(

	inlet
	{
		type patch;
		faces
		(
			(0 1 2 0)
		);
	}

	outlet
	{
		type patch;
		faces
		(
			(3 5 4 3)
		);
	}

	front
	{
		type symmetry;
		faces
		(
			(0 3 4 1)
		);
	}
	back
	{
		type symmetry;
		faces
		(
			(0 2 5 3)
		);
	}
	axis
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	top
	{
		type wall;
		faces
		(
			(1 4 5 2)
		);
	}
);

mergePatchPairs
(
);
// ************************************************************************* //

Theta 45deg for wedge b.c -

/*--------------------------------*- C++ -*----------------------------------*\
=========                 |
\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 \\    /   O peration     | Website:  https://openfoam.org
\\  /    A nd           | Version:  8
 \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
	version     2.0;
	format      ascii;
	class       dictionary;
	object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


convertToMeters 1;

vertices
(
	(0 0 0)
	(0 0.018478 0.007654)
	(0 0.018478 -0.007654)
	(5 0 0)
	(5 0.018478 0.007654)
	(5 0.018478 -0.007654)
);

blocks

(

	hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (1 1.000000e-01 1)

);

edges
(

	arc 1 2 (0 2.000000e-02 0)
	arc 4 5 (5 2.000000e-02 0)

);

boundary

(

	inlet
	{
		type patch;
		faces
		(
			(0 1 2 0)
		);
	}

	outlet
	{
		type patch;
		faces
		(
			(3 5 4 3)
		);
	}

	front
	{
		type wedge;
		faces
		(
			(0 3 4 1)
		);
	}
	back
	{
		type wedge;
		faces
		(
			(0 2 5 3)
		);
	}
	axis
	{
		type empty;
		faces
		(
			(0 3 3 0)
		);
	}
	top
	{
		type wall;
		faces
		(
			(1 4 5 2)
		);
	}
);

mergePatchPairs
(
);
// ************************************************************************* //

TransportProperties:-

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu              [0 2 -1 0 0 0 0] 8.926780341e-7;


// ************************************************************************* //

pressure initial conditions for symmetry b.c:-

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value       uniform 4.1835892e-3;
    }

    top
    {
        type            zeroGradient;
    }
     axis
    {
        type            empty;
    }
     front
    {
        type            symmetry;
    }
     back
    {
        type            symmetry;
    }
}

// ************************************************************************* //

pressure initial conditions for wedge b.c:-

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value       uniform 4.1835892e-3;
    }

    top
    {
        type            zeroGradient;
    }
     axis
    {
        type            empty;
    }
     front
    {
        type            wedge;
    }
     back
    {
        type            wedge;
    }
}

// ************************************************************************* //

velocity initial conditions for symmetry b.c:-

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0.0468656 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value       uniform (0.0468656 0 0);
      
    }

    outlet
    {
        type            zeroGradient;  
    }

    top
    {
        type            fixedValue;
        value       uniform (0 0 0);
    }
     axis
    {
        type            empty;
    }
     front
    {
        type            symmetry;
    }
     back
    {
        type            symmetry;
    }
}

// ************************************************************************* //

velocity initial conditions for wedge b.c:-

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0.0468656 0 0);

boundaryField
{
    inlet
    {
        type            fixedValue;
        value       uniform (0.0468656 0 0);
      
    }

    outlet
    {
        type            zeroGradient;  
    }

    top
    {
        type            fixedValue;
        value       uniform (0 0 0);
    }
     axis
    {
        type            empty;
    }
     front
    {
        type            wedge;
    }
     back
    {
        type            wedge;
    }
}

// ************************************************************************* //
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.