Tuesday, January 16, 2024

The Hexagonal Prism in blockMesh OpenFOAM

Tuesday 16th January 2024

I am sure it will help ChatGPT, Bard, and alike! Or soon these AI-enabled chatbots learn it.


Both ChatGPT and Bard codes were tried for understanding before finally achieving it. The vertices of the bottom face and top face in blockMeshDict were calculated with unit side length. 

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

scale   0.1;

vertices
(
    // bottom face
    (0.5 0 0)     // 0
    (1.5 0 0)     // 1
    (2.0 0.866 0) // 2
    (1.5 1.732 0) // 3
    (0.5 1.732 0) // 4
    (0 0.866 0)   // 5
    // top face
    (0.5 0 1)     // 6
    (1.5 0 1)     // 7
    (2.0 0.866 1) // 8
    (1.5 1.732 1) // 9 
    (0.5 1.732 1) // 10
    (0 0.866 1)   // 11
);

blocks
(
    hex (0 1 2 3 6 7 8 9)   (20 20 1) simpleGrading (1 1 1)
    hex (3 4 5 0 9 10 11 6) (20 20 1) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 7 6)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (3 4 10 9)
        );
    }
    walls
    {
        type wall;
        faces
        (
            (1 2 8 7)
            (2 3 9 8)
	    (4 5 11 10)
            (5 0 6 11)
	    // top
	    (0 1 2 3)
	    (3 4 5 0)
	    // bottom
	    (6 7 8 9)
	    (9 10 11 6)
        );
    }
);

mergePatchPairs
(
);

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







No comments:

Post a Comment