Week 12 - Symmetry vs Wedge vs HP equation
WEDGE BOUNDARY CONDITION :
wedge boundary condition is used for the wedge angle that is less than 5. Whereas, for more than 5 wedge symmetry condition is used.
In this challenge we are supposed to run the stimulation for different angles of 10, 25, 45 and calculate the parameter each.The intial conditipon for each case of simulation are same, The main difference is that the front and the back wedge boundary condition. Here symmetry boundary condition is used and the input is recieved from the user.
MATLAB CODE :
close all
clear all
clc
Re=2100;
rho=1000;
d=0.02;
r=d/2;
l_in=0.06*Re*d;
mu=0.00089;
nu=mu/rho;
fprintf('Enter the wedge ange fro BC 10,25,45 \n');
theta =input('enter the angle:');
v_avg=Re*nu/d;
l=l_in+0.3;
delp=(8*v_avg*mu*l)/r^2;
v0=[0 0 0];
v1=[0 r*cosd(theta/2) r*sind(theta/2)];
v2=[0 r*cosd(theta/2) -r*sind(theta/2)];
v3=[l 0 0];
v4=[l r*cosd(theta/2) r*sind(theta/2)];
v5=[l r*cosd(theta/2) -r*sind(theta/2)];
b1=200;
b2=20;
b3=1;
grading=0.2;
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=' version 2.0;'
h9=' format ascii;'
h10=' class dictionary;'
h11=' object blockMeshDict;'
h12='// ************************************************************************* //';
f1=fopen('blockMeshDict2.txt','wt');
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 \n',h7);
fprintf(f1,'FoamFile \n {\n ');
fprintf(f1,'%s\n',h8);
fprintf(f1,'%s\n',h9);
fprintf(f1,'%s\n',h10);
fprintf(f1,'%s\n',h11);
fprintf(f1,'%2s\n','}');
fprintf(f1,'%2s\n\n','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f1,'%2s\n\n','convertToMeters 1;');
fprintf(f1,'vertices \n (\n ');
fprintf(f1,'\t(%d %d %d)\n',v0);
fprintf(f1,'\t(%d %d %d)\n',v1);
fprintf(f1,'\t(%d %d %d)\n',v2);
fprintf(f1,'\t(%d %d %d)\n',v3);
fprintf(f1,'\t(%d %d %d)\n',v4);
fprintf(f1,'\t(%d %d %d)\n',v5);
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'blocks \n (\n ');
fprintf(f1,'\t %s (%d %d %d %d %d %d %d %d) (%d %d %d) %s (%d %d %d) \n','hex', 0, 3, 5, 2, 0, 3, 4, 1, 200, 20, 1, 'simpleGrading', 0.2, 1, 1 );
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'edges \n (\n ');
fprintf(f1,'\t %s (0 %d 0)\n','arc 1 2',r);
fprintf(f1,'\t %s (%d %d 0)\n','arc 4 5',l,r);
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'boundary \n (\n ');
fprintf(f1,'\t %5s \n','inlet','{');
fprintf(f1,'\t %13s %s\n','type','patch;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 1 2 0)',');','}');
fprintf(f1,'\t %5s \n','outlet','{');
fprintf(f1,'\t %13s %s\n','type','patch;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(3 5 4 3)',');','}');
fprintf(f1,'\t %5s \n','frontwedge','{');
fprintf(f1,'\t %13s %s\n','type','wedge;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 3 4 1)',');','}');
fprintf(f1,'\t %5s \n','backwedge','{');
fprintf(f1,'\t %13s %s\n','type','wedge;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 2 5 3)',');','}');
fprintf(f1,'\t %5s \n','wall','{');
fprintf(f1,'\t %13s %s\n','type','wall;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(1 4 5 2)',');','}');
fprintf(f1,'\t %5s \n','axis','{');
fprintf(f1,'\t %13s %s\n','type','empty;');
fprintf(f1,'\t %14s\n %18s\n','faces','(');
fprintf(f1,'\t \t %15s\n %19s\n\n %14s\n\n','(0 3 3 0)',');','}');
fprintf(f1,'%2s\n\n',');');
fprintf(f1,'mergePatchPairs \n (\n );\n');
fprintf(f1,'%2s\n\n',h12);
fclose(f1);
CONTROLDICT FILE :
/*--------------------------------*- 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 "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 10;
deltaT 0.01;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
TRANSPORTPROPERTIES FILE :
/*--------------------------------*- 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] 0.89e-6;
// ************************************************************************* //
PRESSURE FILE :
/*--------------------------------*- 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 0.018;
}
frontwedge
{
type wedge;
}
backwedge
{
type wedge;
}
wall
{
type zeroGradient;
}
axis
{
type empty;
}
}
// ************************************************************************* //
VELOCITY FILE :
/*--------------------------------*- 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 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.09345 0 0);
}
outlet
{
type zeroGradient;
}
frontwedge
{
type wedge;
}
backwedge
{
type wedge;
}
wall
{
type fixedValue;
value uniform (0 0 0);
}
axis
{
type empty;
}
}
// ************************************************************************* //
GENERATED BlockMeshDict FILE (for wedge angle 10) :
/*--------------------------------*- 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.00996195 0.000871557)
(0 0.00996195 -0.000871557)
(2.82 0 0)
(2.82 0.00996195 0.000871557)
(2.82 0.00996195 -0.000871557)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2.82 0.01 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
frontwedge
{
type wedge;
faces
(
(0 3 4 1)
);
}
backwedge
{
type wedge;
faces
(
(0 2 5 3)
);
}
wall
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
BLOCKMESH FOR WEDGE 10 :


FLOW FOR WEDGE 10 :


FULLY DEVELOPED GRAPH FOR WEDGE 10 :

GENERATED BlockMeshDict FILE (for wedge angle 25) :
/*--------------------------------*- 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.00976296 0.0021644)
(0 0.00976296 -0.0021644)
(2.82 0 0)
(2.82 0.00976296 0.0021644)
(2.82 0.00976296 -0.0021644)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2.82 0.01 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
frontwedge
{
type wedge;
faces
(
(0 3 4 1)
);
}
backwedge
{
type wedge;
faces
(
(0 2 5 3)
);
}
wall
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
BLOCKMESH FOR WEDGE 25 :


FLOW FOR WEDGE 25 :


FULLY DEVELOPED GRAPH FOR WEDGE 25 :

GENERATED BlockMeshDict FILE (for wedge angle 45) :
/*--------------------------------*- 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.0092388 0.00382683)
(0 0.0092388 -0.00382683)
(2.82 0 0)
(2.82 0.0092388 0.00382683)
(2.82 0.0092388 -0.00382683)
);
blocks
(
hex (0 3 5 2 0 3 4 1) (200 20 1) simpleGrading (0.2 1 1)
);
edges
(
arc 1 2 (0 0.01 0)
arc 4 5 (2.82 0.01 0)
);
boundary
(
inlet
{
type patch;
faces
(
(0 1 2 0)
);
}
outlet
{
type patch;
faces
(
(3 5 4 3)
);
}
frontwedge
{
type wedge;
faces
(
(0 3 4 1)
);
}
backwedge
{
type wedge;
faces
(
(0 2 5 3)
);
}
wall
{
type wall;
faces
(
(1 4 5 2)
);
}
axis
{
type empty;
faces
(
(0 3 3 0)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
BLOCKMESH FOR WEDGE 45 :


FLOW FOR WEDGE 45 :

FULLY DEVELOPED GRAPH FOR WEDGE 45 :

CONCLUSION :
- Simulation time is larger for wedge bc compared to that of symmetry bc.
- The accuracy is more for symmetry than wedge.
- The CFL number increases with the wedge angle increase.
| execution time | clock time | max CFL | mean CFL | |
| wedge 10 | 30.57s | 49s | 0.3086 | 0.06710 |
| wedge 25 | 30.67s | 51s | 0.3104 | 0.06711 |
| wedge 45 | 30.98s | 52s | 0.3149 | 0.06712 |