Challenge

Week 12 - Symmetry vs Wedge vs HP equation

In this challenge, the procedure is completely the same as the previous challenge with some modifications. The wedge angle is different, they are 10, 25, and 45. The steps are of the simulations are completely the same as the previous one.

Here in the code, there is a need to change the theta values from 10 to 25 and 25 to 45. After that, there is a need to create the edges in the blockMeshDict to create the arc.

Matlab Code:

clear all
close all
clc

R = 0.0025; % radius of the pipe
theta = 25; % angle of the wedge

f1 = fopen('blockMeshDict2.txt','w');

fprintf(f1,'%s\n','/*--------------------------------*- C++ -*----------------------------------*\');
fprintf(f1,'%s\n','  =========                 |');
fprintf(f1,'%s\n','  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox');
fprintf(f1,'%s\n','   \\    /   O peration     | Website:  https://openfoam.org');
fprintf(f1,'%s\n','    \\  /    A nd           | Version:  8');
fprintf(f1,'%s\n','     \\/     M anipulation  |');
fprintf(f1,'%s\n','\*---------------------------------------------------------------------------*/');
fprintf(f1,'%s\n','FoamFile');
fprintf(f1,'%s\n','{');
fprintf(f1,'%s\n','    version     2.0;');
fprintf(f1,'%s\n','    format      ascii;');
fprintf(f1,'%s\n','    class       dictionary;');
fprintf(f1,'%s\n','    object      blockMeshDict;');
fprintf(f1,'%s\n','}');
fprintf(f1,'%s\n','// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //');
fprintf(f1,'%s\n','convertToMeters 1;');

fprintf(f1,'%s\n','vertices');
fprintf(f1,'%s\n','(');
fprintf(f1,'\t(%d %d %d)  //V1\n', 0,0,0);
fprintf(f1,'\t(%d %d %d)  //V2\n', 0, R*cosd(theta/2), R*sind(theta/2));
fprintf(f1,'\t(%d %d %d)  //V3\n', 0, R*cosd(theta/2), -R*sind(theta/2));
fprintf(f1,'\t(%d %d %d)  //V4\n', 1, 0, 0);
fprintf(f1,'\t(%d %d %d)  //V5\n', 1, R*cosd(theta/2), R*sind(theta/2));
fprintf(f1,'\t(%d %d %d)  //V6\n', 1, R*cosd(theta/2), -R*sind(theta/2));
fprintf(f1,'%s\n',');');
fprintf(f1,'%s\n','blocks');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s\n','    hex (0 0 2 1 3 3 5 4) (1 20 200) simpleGrading (1 0.2 1)');
fprintf(f1,'%s\n',');');
fprintf(f1,'%s\n','edges');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s\n','     arc (1 2) (0 2.5e-3 0)');
fprintf(f1,'%s\n','     arc (4 5) (1 2.5e-3 0)');
fprintf(f1,'%s\n',');');
fprintf(f1,'%s\n','boundary');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s\n','   inlet');
fprintf(f1,'%s\n','    {');
fprintf(f1,'%s\n','        type patch;');
fprintf(f1,'%s\n','        faces');
fprintf(f1,'%s\n','        (');
fprintf(f1,'%s\n','            (0 1 2 0)');
fprintf(f1,'%s\n','        );');
fprintf(f1,'%s\n','    }');
fprintf(f1,'%s\n','    outlet');
fprintf(f1,'%s\n','    {');
fprintf(f1,'%s\n','        type patch;');
fprintf(f1,'%s\n','        faces;');
fprintf(f1,'%s\n','        (');
fprintf(f1,'%s\n','            (3 5 4 3)');
fprintf(f1,'%s\n','        );');
fprintf(f1,'%s\n','    }');
fprintf(f1,'%s\n','    frontwedge');
fprintf(f1,'%s\n','    {');
fprintf(f1,'%s\n','        type wedge;');
fprintf(f1,'%s\n','        faces');
fprintf(f1,'%s\n','        (');
fprintf(f1,'%s\n','            (1 0 3 4)');
fprintf(f1,'%s\n','        );');
fprintf(f1,'%s\n','    }');
fprintf(f1,'%s\n','    backwedge');
fprintf(f1,'%s\n','    {');
fprintf(f1,'%s\n','        type wedge;');
fprintf(f1,'%s\n','        faces');
fprintf(f1,'%s\n','        (');
fprintf(f1,'%s\n','            (0 2 5 3)');
fprintf(f1,'%s\n','        );');
fprintf(f1,'%s\n','    }');
fprintf(f1,'%s\n','    topwall');
fprintf(f1,'%s\n','    {');
fprintf(f1,'%s\n','        type wall;');
fprintf(f1,'%s\n','        faces');
fprintf(f1,'%s\n','        (');
fprintf(f1,'%s\n','            (1 4 5 2)');
fprintf(f1,'%s\n','        );');
fprintf(f1,'%s\n','    }');
fprintf(f1,'%s\n','    bottomwall');
fprintf(f1,'%s\n','    {');
fprintf(f1,'%s\n','        type empty;');
fprintf(f1,'%s\n','        faces');
fprintf(f1,'%s\n','        (');
fprintf(f1,'%s\n','            (0 3 3 0)');
fprintf(f1,'%s\n','        );');
fprintf(f1,'%s\n','    }');
fprintf(f1,'%s\n',');');
fprintf(f1,'%s\n','');
fprintf(f1,'%s\n','mergePatchPairs');
fprintf(f1,'%s\n','(');
fprintf(f1,'%s\n',');');
fprintf(f1,'%s\n','// ************************************************************************* //');

fclose(f1);

Mesh:

BlockMeshDict:

/*--------------------------------*- 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) //V0
    (0 2.44074e-3 5.41099e-4) //V1
    (0 2.44074e-3 -5.41099e-4) //V2
    (1 0 0) //V3
    (1 2.44074e-3 5.41099e-4) //V4
    (1 2.44074e-3 -5.41099e-4) //V5
);
blocks
(
    hex (0 0 2 1 3 3 5 4) (5 20 200) simpleGrading (1 0.2 1)
);
edges
(
   arc 2 1 (0 2.5e-3 0) 
   arc 5 4 (1 2.5e-3 0)
);
boundary
(
   inlet
    {
        type patch;
        faces
        (
            (0 1 2 0)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 5 4 3)
        );
    }
    front
    {
        type symmetry;
        faces
        (
            (1 0 3 4)
        );
    }
    back
    {
        type symmetry;
        faces
        (
            (0 2 5 3)
        );
    }
    topwall
    {
        type wall;
        faces
        (
            (1 4 5 2)
        );
    }
    bottomwall
    {
        type empty;
        faces
        (
            (0 3 3 0)
        );
    }
);

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

ControlDict:

/*--------------------------------*- 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.001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure:

/*--------------------------------*- 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;   
    }
    front
    {
        type            symmetry;
    }
    back
    {
        type            symmetry;
    }
    topwall
    {
        type            zeroGradient;          
    }
    bottomwall
    {
        type            empty;
    }
}

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

Volume:

/*--------------------------------*- 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.33642 0 0);
    } 
    outlet
    {
        type            zeroGradient;   
    }
    front
    {
        type            symmetry;
    }
    back
    {
        type            symmetry;
    }
    topwall
    {
        type            noSlip;          
    }
    bottomwall
    {
        type            empty;
    }
}

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

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] 0.801e-6;


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

Results:

The angle at 10 degrees:

The angle at 25 degrees:

The angle at 45 degrees:

Plots:

Result:

The volume remains constant for all the 3 different wedge angles.

U = 0.667452 m/s.

And the analytical velocity = 0.33642 m/s.

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.