OpenFOAM blockMesh

919 Views Asked by At

I am trying to simulate a water storage tank for a refrigeration system. I am new to OpenFOAM.

But, I tried to find related information on the internet, which turned out to be quite difficult as there is just sparse information about OpenFOAM and especially about my specific project.
The water tank will have one inlet and one outlet.
The written blockMesh file is:

FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale 0.1;

vertices
(
    (0 0 0)         //0
    (3.984 0 0)     //1
    (3.984 1.992 0)     //2
    (0 1.992 0)     //3
    (0 0 2.984)     //4
    (3.984 0 2.984)     //5
    (3.984 1.992 2.984) //6
    (0 1.992 2.984)     //7
    (0.147 0.197 2.984) //8
    (0.353 0.197 2.984) //9
    (0.147 0.313 2.984) //10
    (0.353 0.313 2.984) //11
    (0.147 1.679 2.984) //12
    (0.353 1.679 2.984) //13
    (0.353 1.885 2.984) //14
    (0.147 1.885 2.984) //15
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (4 2 3) simpleGrading (1 1 1)
    hex (8 9 10 11) (1 1 0) simpleGrading (1 1 1)
    hex (12 13 14 15) (1 1 0) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (8 9 10 11)
        );
    }  
    outlet
    {
        type patch;
        faces
        (
            (12 13 14 15)
        );
    }
    
    fixedWalls
    {
        type wall;
        faces
        (
            (0 4 7 3)
            (2 6 5 1)
            (1 5 4 0)
            (3 7 6 2)
            (0 3 2 1)
            (4 5 6 7)
        );
    }
);

//mergePatchPairs
(
);

Should the inlet and outlet be separate blocks or be combined with the rest of the tank in one hex-block?

There is no need to do all the work. I would appreciate just some helpful tips, to what I need to pay attention to. (I know that the order of the vertices is important, is this correct?)

This is the error-code I received, when I run the "blockMesh" Command in the terminal:

\*---------------------------------------------------------------------------*/
Build  : 8-1c9b5879390b
Exec   : blockMesh
Date   : May 27 2021
Time   : 11:03:25
Host   : "DESKTOP-DCDG4KB"
PID    : 600
I/O    : uncollated
Case   : /home/flaayor/OpenFOAM/flaayor-8/run/cavity
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Creating block mesh from
    "system/blockMeshDict"
Creating block edges
No non-planar block faces defined
Creating topology blocks
#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::Vector<double> Foam::face::centre<Foam::UIndirectList<Foam::Vector<double> > >(Foam::UIndirectList<Foam::Vector<double> > const&) at ??:?
#4  Foam::face::centre(Foam::Field<Foam::Vector<double> > const&) const at ??:?
#5  Foam::blockDescriptor::check(Foam::Istream const&) at ??:?
#6  Foam::blockDescriptor::blockDescriptor(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#7  Foam::block::block(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#8  Foam::block::New(Foam::dictionary const&, int, Foam::Field<Foam::Vector<double> > const&, Foam::PtrList<Foam::blockEdge> const&, Foam::PtrList<Foam::blockFace> const&, Foam::Istream&) at ??:?
#9  void Foam::PtrList<Foam::block>::read<Foam::block::iNew>(Foam::Istream&, Foam::block::iNew const&) at ??:?
#10  Foam::blockMesh::createTopology(Foam::IOdictionary const&, Foam::word const&) at ??:?
#11  Foam::blockMesh::blockMesh(Foam::IOdictionary const&, Foam::word const&) at ??:?
#12  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/blockMesh"
#13  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#14  ? in "/opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/blockMesh"
Segmentation fault (core dumped)
2

There are 2 best solutions below

0
On

There are many mistakes in your code. Your problem can be created with various methods e.g. blockMesh, codedFixedValue, snappyHexMesh, and ... . By blockMesh command it will need 15 separate blocks to define as it is shown in the following picture; it is in the Z-axis view.

enter image description here

But it can be very easier if you use codedFixedValue which help to specify inlet and outlet by only one block. In blockMesh, blocks must by hexagonal and define by 8 points in blocks section; some have 4 points in your code. Not complying the ordering of vertices in defining blocks and boundaries could confuse OpenFOAM and result in future solving problems and must be followed.
As it is asked in the question for blockMesh, I have created an example such your problem but with only 4 blocks. The blockMesh code is as follows, some explanations are written to the code:

FoamFile
{
    version         2.0;
    format          ascii;
    class           dictionary;
    object          blockMeshDict;
}

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

scale 0.1;

vertices
(
    (0.0  0.0  0.0)         //0
    (1.0  0.0  0.0)         //1
    (2.0  0.0  0.0)         //2
    (0.0  1.0  0.0)         //3
    (1.0  1.0  0.0)         //4
    (2.0  1.0  0.0)         //5
    (0.0  2.0  0.0)         //6
    (1.0  2.0  0.0)         //7
    (2.0  2.0  0.0)         //8

    (0.0  0.0  4.0)         //9
    (1.0  0.0  4.0)         //10
    (2.0  0.0  4.0)         //11
    (0.0  1.0  4.0)         //12
    (1.0  1.0  4.0)         //13
    (2.0  1.0  4.0)         //14
    (0.0  2.0  4.0)         //15
    (1.0  2.0  4.0)         //16
    (2.0  2.0  4.0)         //17
);

blocks      // Always hex; write as [(minX,minY,minZ) (maxX,minY,minZ) (maxX,maxY,minZ) (minX,maxY,minZ) (minX,minY,maxZ) (maxX,minY,maxZ) (maxX,maxY,maxZ) (minX,maxY,maxZ)]
(
    hex (0 1 4 3 9 10 13 12)  (2 4 8) simpleGrading (1 1 1)
    hex (1 2 5 4 10 11 14 13) (2 4 8) simpleGrading (1 1 1)
    hex (3 4 7 6 12 13 16 15) (2 4 8) simpleGrading (1 1 1)
    hex (4 5 8 7 13 14 17 16) (2 4 8) simpleGrading (1 1 1)
);

edges
(
);

boundary            // For each block's corresponding faces, order as how, using right-hand rule, the thumb of the right hand outwards the block
(
    inlet
    {
        type patch;
        faces
        (
            (12 13 16 15)
        );
    }  
    outlet
    {
        type patch;
        faces
        (
            (10 11 14 13)
        );
    }
    
    fixedWalls
    {
        type wall;
        faces
        (
            (0 9 12 3)
            (3 12 15 6)
            (6 15 16 7)
            (7 16 17 8)
            (8 17 14 5)
            (5 14 11 2)
            (2 11 10 1)
            (1 10 9 0)

            (0 3 4 1)
            (2 1 4 5)
            (3 6 7 4)
            (5 4 7 8)

            (13 14 17 16)
            (9 10 13 12)
        );
    }
);

mergePatchPairs
(
);

Which will be as:

enter image description here

You can use this example for your problem but with enough blocks.
In your problem and with using blockMesh, inlet and outlet must be specified on separate blocks; which can be specified on only one block when using codedFixedValue method.

Hope it can be helpful.

0
On

For some reason you have defined hex-blocks with 4 points - you definitely need 8 points per hex. If you have, for example, two hex-blocks joined together you will need to define 12 points, 4 of which will be common between the two blocks.