Week 12 - Validation studies of Symmetry BC vs Wedge BC in OpenFOAM vs Analytical H.P equation
This is the continuation of week 11 challenge. For this challenge,there will be 6 blockMeshDict files,each for three different angles (10°,25° and 45°) and for 2 different boundary conditions(wedge and symmetric).
Matlab code for symmetry boundary condition
In this code by giving the input angle you will get different blockMeshdict files accordingly.
clear all
close all
clc
%% GIVEN PARAMETERS
rho=1000;
v=0.1246; %Velocity inlet (m/s)
mu=8.90e-4; %DYNAMIC VISCOUSITY (Pa-s)
Re=1000; %REYNOLDS NUMBER
D=0.015;
r=D/2;
theta=input('Enter value for wedge angle = ');
L_e=0.05*Re*D;
L=L_e+0.5;
%% vertices
v_0=[0 0 0];
v_1=[r*sind(theta/2) r*cosd(theta/2) 0];
v_2=[-r*sind(theta/2) r*cosd(theta/2) 0];
v_3=[0 0 L];
v_4=[r*sind(theta/2) r*cosd(theta/2) L];
v_5=[-r*sind(theta/2) r*cosd(theta/2) L];
%% BLOCKS
H_0='hex (0 3 4 1 0 3 5 2) (100 50 1) simpleGrading (1 1 1)';
%% edges
edge1=' arc 1 2 (0 0.0075 0)';
edge2=' arc 4 5 (0 0.0075 1.25)';
%% Faces
inlet=' (0 2 1 0)'
outlet=' (3 4 5 3)'
wedge1=' (0 1 4 3)'
wedge2=' (0 3 5 2)'
noSlipwall=' (1 2 5 4)'
axis=' (3 0 0 3)'
f1=fopen('blockMeshDict.txt','w')
text1='/*------------------------------*-C++-*----------------------------------- *\'
text2='| ========== | |'
text3='| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |'
text4='| \\ / O peration | Version: v2112 |'
text5='| \\ / A nd | Website: www.openfoam.com |'
text6='| \\/ M anipulation | |'
text15='\*------------------------------------------------------------------------*/'
text8= 'FoamFile'
text9='{'
text10= 'version 2.0;'
text11= 'format ascii; '
text12= 'class dictionary;'
text13= 'object blockMeshDict; '
text14='}'
text16='scale 1;'
text17='vertices'
text18='('
text19=');'
text20='blocks'
text21='('
text22=');'
text23='edges'
text24='('
text25=');'
text26='boundary'
text27='('
text28=' inletWall'
text29=' {'
text30=' type patch;'
text31=' faces'
text32=' ('
text33=' );'
text34=' }'
text35=' outletWall'
text36=' {'
text37=' type patch;'
text38=' faces'
text39=' ('
text40=' );'
text41=' }'
text42=' front'
text43=' {'
text44=' type symmetry;'
text45=' faces'
text46=' ('
text47=' );'
text48=' }'
text49=' Back'
text50=' {'
text51=' type symmetry;'
text52=' faces'
text53=' ('
text54=' );'
text55=' }'
text56=' noSlipwall'
text57=' {'
text58=' type wall;'
text59=' faces'
text60=' ('
text61=' );'
text62=' }'
text63=' axis'
text64=' {'
text65=' type empty;'
text66=' faces'
text67=' ('
text68=' );'
text69=' }'
text70=');'
text71='//****************************************************//'
fprintf(f1,'%s\n' ,text1);
fprintf(f1,'%s\n' ,text2);
fprintf(f1,'%s\n' ,text3);
fprintf(f1,'%s\n' ,text4);
fprintf(f1,'%s\n' ,text5);
fprintf(f1,'%s\n' ,text6);
fprintf(f1,'%s\n' ,text15);
fprintf(f1,'%s\n' ,text8);
fprintf(f1,'%s\n' ,text9);
fprintf(f1,'%s\n' ,text10);
fprintf(f1,'%s\n' ,text11);
fprintf(f1,'%s\n' ,text12);
fprintf(f1,'%s\n' ,text13);
fprintf(f1,'%s\n\n' ,text14);
fprintf(f1,'%s\n\n' ,text16);
fprintf(f1,'%s\n' ,text17);
fprintf(f1,'%s\n\n' ,text18);
fprintf(f1,'(%f %f %f) \n' ,v_0);
fprintf(f1,'(%f %f %f) \n' ,v_1);
fprintf(f1,'(%f %f %f) \n' ,v_2);
fprintf(f1,'(%f %f %f) \n' ,v_3);
fprintf(f1,'(%f %f %f) \n' ,v_4);
fprintf(f1,'(%f %f %f) \n\n' ,v_5);
fprintf(f1,'%s\n\n',text19);
fprintf(f1,'%s\n',text20);
fprintf(f1,'%s\n',text21);
fprintf(f1,'%s\n',H_0);
fprintf(f1,'%s\n\n',text22);
fprintf(f1,'%s\n' ,text23);
fprintf(f1,'%s\n' ,text24);
fprintf(f1, '%s\n %s\n' ,edge1,edge2 );
fprintf(f1,'%s\n\n' ,text25);
fprintf(f1,'%s\n' ,text26);
fprintf(f1,'%s\n' ,text27);
fprintf(f1,'%s\n' ,text28);
fprintf(f1,'%s\n' ,text29);
fprintf(f1,'%s\n' ,text30);
fprintf(f1,'%s\n' ,text31);
fprintf(f1,'%s\n' ,text32);
fprintf(f1,'%s\n',inlet);
fprintf(f1,'%s\n' ,text33);
fprintf(f1,'%s\n\n' ,text34);
fprintf(f1,'%s\n' ,text35);
fprintf(f1,'%s\n' ,text36);
fprintf(f1,'%s\n' ,text37);
fprintf(f1,'%s\n' ,text38);
fprintf(f1,'%s\n' ,text39);
fprintf(f1,'%s\n' ,outlet);
fprintf(f1,'%s\n' ,text40);
fprintf(f1,'%s\n\n' ,text41);
fprintf(f1,'%s\n',text42);
fprintf(f1,'%s\n',text43);
fprintf(f1,'%s\n',text44);
fprintf(f1,'%s\n',text45);
fprintf(f1,'%s\n',text46);
fprintf(f1,'%s\n',wedge1);
fprintf(f1,'%s\n',text47);
fprintf(f1,'%s\n\n',text48);
fprintf(f1,'%s\n',text49);
fprintf(f1,'%s\n',text50);
fprintf(f1,'%s\n',text51);
fprintf(f1,'%s\n',text52);
fprintf(f1,'%s\n',text53);
fprintf(f1,'%s\n',wedge2);
fprintf(f1,'%s\n',text54);
fprintf(f1,'%s\n\n',text55);
fprintf(f1,'%s\n',text56);
fprintf(f1,'%s\n',text57);
fprintf(f1,'%s\n',text58);
fprintf(f1,'%s\n',text59);
fprintf(f1,'%s\n',text60);
fprintf(f1,'%s\n',noSlipwall);
fprintf(f1,'%s\n',text61);
fprintf(f1,'%s\n\n',text62);
fprintf(f1,'%s\n',text63);
fprintf(f1,'%s\n',text64);
fprintf(f1,'%s\n',text65);
fprintf(f1,'%s\n',text66);
fprintf(f1,'%s\n',text67);
fprintf(f1,'%s\n',axis);
fprintf(f1,'%s\n',text68);
fprintf(f1,'%s\n\n',text69);
fprintf(f1,'%s\n',text70);
fprintf(f1,'%s\n','mergePatchPairs');
fprintf(f1,'%s\n%s\n','(',');');
fprintf(f1,'%s\n',text71);
fclose(f1);
%% Calculation of Shear Stress
v_max=2*v;
Tau_max=(2*mu*v_max)/r;
%% Haigen-Poiseuille equation
dP=(32*mu*v)/(D^2);
Matlab code for wedge boundary condition
clear all
close all
clc
%% GIVEN PARAMETERS
rho=1000;
v=0.1246; %Velocity inlet (m/s)
mu=8.90e-4; %DYNAMIC VISCOUSITY (Pa-s)
Re=1000; %REYNOLDS NUMBER
D=0.015;
r=D/2;
theta=input('Enter value for wedge angle = ');
L_e=0.05*Re*D;
L=L_e+0.5;
%% vertices
v_0=[0 0 0];
v_1=[r*sind(theta/2) r*cosd(theta/2) 0];
v_2=[-r*sind(theta/2) r*cosd(theta/2) 0];
v_3=[0 0 L];
v_4=[r*sind(theta/2) r*cosd(theta/2) L];
v_5=[-r*sind(theta/2) r*cosd(theta/2) L];
%% BLOCKS
H_0='hex (0 3 4 1 0 3 5 2) (100 50 1) simpleGrading (1 1 1)';
%% edges
edge1=' arc 1 2 (0 0.0075 0)';
edge2=' arc 4 5 (0 0.0075 1.25)';
%% Faces
inlet=' (0 2 1 0)'
outlet=' (3 4 5 3)'
wedge1=' (0 1 4 3)'
wedge2=' (0 3 5 2)'
noSlipwall=' (1 2 5 4)'
axis=' (3 0 0 3)'
f1=fopen('blockMeshDict.txt','w')
text1='/*------------------------------*-C++-*----------------------------------- *\'
text2='| ========== | |'
text3='| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |'
text4='| \\ / O peration | Version: v2112 |'
text5='| \\ / A nd | Website: www.openfoam.com |'
text6='| \\/ M anipulation | |'
text15='\*------------------------------------------------------------------------*/'
text8= 'FoamFile'
text9='{'
text10= 'version 2.0;'
text11= 'format ascii; '
text12= 'class dictionary;'
text13= 'object blockMeshDict; '
text14='}'
text16='scale 1;'
text17='vertices'
text18='('
text19=');'
text20='blocks'
text21='('
text22=');'
text23='edges'
text24='('
text25=');'
text26='boundary'
text27='('
text28=' inletWall'
text29=' {'
text30=' type patch;'
text31=' faces'
text32=' ('
text33=' );'
text34=' }'
text35=' outletWall'
text36=' {'
text37=' type patch;'
text38=' faces'
text39=' ('
text40=' );'
text41=' }'
text42=' front'
text43=' {'
text44=' type wedge;'
text45=' faces'
text46=' ('
text47=' );'
text48=' }'
text49=' Back'
text50=' {'
text51=' type wedge;'
text52=' faces'
text53=' ('
text54=' );'
text55=' }'
text56=' noSlipwall'
text57=' {'
text58=' type wall;'
text59=' faces'
text60=' ('
text61=' );'
text62=' }'
text63=' axis'
text64=' {'
text65=' type empty;'
text66=' faces'
text67=' ('
text68=' );'
text69=' }'
text70=');'
text71='//****************************************************//'
fprintf(f1,'%s\n' ,text1);
fprintf(f1,'%s\n' ,text2);
fprintf(f1,'%s\n' ,text3);
fprintf(f1,'%s\n' ,text4);
fprintf(f1,'%s\n' ,text5);
fprintf(f1,'%s\n' ,text6);
fprintf(f1,'%s\n' ,text15);
fprintf(f1,'%s\n' ,text8);
fprintf(f1,'%s\n' ,text9);
fprintf(f1,'%s\n' ,text10);
fprintf(f1,'%s\n' ,text11);
fprintf(f1,'%s\n' ,text12);
fprintf(f1,'%s\n' ,text13);
fprintf(f1,'%s\n\n' ,text14);
fprintf(f1,'%s\n\n' ,text16);
fprintf(f1,'%s\n' ,text17);
fprintf(f1,'%s\n\n' ,text18);
fprintf(f1,'(%f %f %f) \n' ,v_0);
fprintf(f1,'(%f %f %f) \n' ,v_1);
fprintf(f1,'(%f %f %f) \n' ,v_2);
fprintf(f1,'(%f %f %f) \n' ,v_3);
fprintf(f1,'(%f %f %f) \n' ,v_4);
fprintf(f1,'(%f %f %f) \n\n' ,v_5);
fprintf(f1,'%s\n\n',text19);
fprintf(f1,'%s\n',text20);
fprintf(f1,'%s\n',text21);
fprintf(f1,'%s\n',H_0);
fprintf(f1,'%s\n\n',text22);
fprintf(f1,'%s\n' ,text23);
fprintf(f1,'%s\n' ,text24);
fprintf(f1, '%s\n %s\n' ,edge1,edge2 );
fprintf(f1,'%s\n\n' ,text25);
fprintf(f1,'%s\n' ,text26);
fprintf(f1,'%s\n' ,text27);
fprintf(f1,'%s\n' ,text28);
fprintf(f1,'%s\n' ,text29);
fprintf(f1,'%s\n' ,text30);
fprintf(f1,'%s\n' ,text31);
fprintf(f1,'%s\n' ,text32);
fprintf(f1,'%s\n',inlet);
fprintf(f1,'%s\n' ,text33);
fprintf(f1,'%s\n\n' ,text34);
fprintf(f1,'%s\n' ,text35);
fprintf(f1,'%s\n' ,text36);
fprintf(f1,'%s\n' ,text37);
fprintf(f1,'%s\n' ,text38);
fprintf(f1,'%s\n' ,text39);
fprintf(f1,'%s\n' ,outlet);
fprintf(f1,'%s\n' ,text40);
fprintf(f1,'%s\n\n' ,text41);
fprintf(f1,'%s\n',text42);
fprintf(f1,'%s\n',text43);
fprintf(f1,'%s\n',text44);
fprintf(f1,'%s\n',text45);
fprintf(f1,'%s\n',text46);
fprintf(f1,'%s\n',wedge1);
fprintf(f1,'%s\n',text47);
fprintf(f1,'%s\n\n',text48);
fprintf(f1,'%s\n',text49);
fprintf(f1,'%s\n',text50);
fprintf(f1,'%s\n',text51);
fprintf(f1,'%s\n',text52);
fprintf(f1,'%s\n',text53);
fprintf(f1,'%s\n',wedge2);
fprintf(f1,'%s\n',text54);
fprintf(f1,'%s\n\n',text55);
fprintf(f1,'%s\n',text56);
fprintf(f1,'%s\n',text57);
fprintf(f1,'%s\n',text58);
fprintf(f1,'%s\n',text59);
fprintf(f1,'%s\n',text60);
fprintf(f1,'%s\n',noSlipwall);
fprintf(f1,'%s\n',text61);
fprintf(f1,'%s\n\n',text62);
fprintf(f1,'%s\n',text63);
fprintf(f1,'%s\n',text64);
fprintf(f1,'%s\n',text65);
fprintf(f1,'%s\n',text66);
fprintf(f1,'%s\n',text67);
fprintf(f1,'%s\n',axis);
fprintf(f1,'%s\n',text68);
fprintf(f1,'%s\n\n',text69);
fprintf(f1,'%s\n',text70);
fprintf(f1,'%s\n','mergePatchPairs');
fprintf(f1,'%s\n%s\n','(',');');
fprintf(f1,'%s\n',text71);
fclose(f1);
%% Calculation of Shear Stress
v_max=2*v;
Tau_max=(2*mu*v_max)/r;
%% Haigen-Poiseuille equation
dP=(32*mu*v)/(D^2);
Results:
Type: Wedge boundary and Angle=10 degree

Variation of shear stress with radial distance

Variation of Velocity with radial distance

Type: Wedge boundary and Angle=25 degree

Variation of shear stress with radial distance

Variation of Velocity with radial distance

Type: Wedge boundary and Angle=45 degree

Variation of shear stress with radial distance

Variation of Velocity with radial distance
