CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [blockMesh] mergePatchPairs with blockMesh (https://www.cfd-online.com/Forums/openfoam-meshing/90357-mergepatchpairs-blockmesh.html)

Ivanet July 7, 2011 13:23

mergePatchPairs with blockMesh
 
1 Attachment(s)
Dear Foamers,
I have done a mesh with blockMesh consisting of 6 blocks. Now I want to merge all the blocks and I am using for it mergePatchPairs. It works for some patches but not for all of them. I have attached my blockMeshDict so that you can check it.
Any idea or suggestion will be highly appreciated.
Thanks a lot in advance
Ivan

Ivanet July 8, 2011 11:35

Problem solved
 
I have just solved the problem using face matching instead of face merging!
I guess it must work also with face merging, but I am happy so far with the mentioned solution.
Many greetings
Ivan

hei@ge November 24, 2011 23:51

mergePatchPairs with blockMesh
 
can you tell me how to edit mergepatchpairs?My case is cut the windfarm into two blocks.Thaks a lots.

Ivanet November 25, 2011 03:05

Hi hei@ge
at the end of your blockMeshDict there is a mergePatchPairs entry. You only have to write there which patch pairs you want to merge.
If you have 2 different meshes that you want to merge, you can use the utility mergeMeshes for that.
I hope this helps...
Ivan

hei@ge November 26, 2011 21:34

Hi,thread,thank you for your reply.but i can not solve my problem.please see my blockmeshdict for me.
vertices
(
( 581321 4.78537e+06 930)
( 582290 4.78537e+06 930)
( 582290 4.78624e+06 930)
( 581321 4.78624e+06 930)
( 581321 4.78537e+06 1030)
( 582290 4.78537e+06 1030)
( 582290 4.78624e+06 1030)
( 581321 4.78624e+06 1030)
( 581321 4.78537e+06 2000)
( 582290 4.78537e+06 2000)
( 582290 4.78624e+06 2000)
( 581321 4.78624e+06 2000)

);

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

edges
(
);

patches
(
patch outlet
(
(2 6 5 1)
(6 10 9 5)

)
patch sides
(
(1 5 4 0)
(5 9 8 4)
(3 7 6 2)
(7 11 10 6)
)
patch inlet
(
(0 4 7 3)
(4 8 11 7)
)
wall ground
(
(0 3 2 1)
)
patch top
(
(8 9 10 11)
)
patch interface1
(
(4 5 6 7)
)
patch interface2
(
(4 7 6 5)
)
);

mergePatchPairs
(
(<interface1> <interface2>)
);
my model is a Hex,i turn it into 2 blocks in the near bottom.

aeroGeek December 20, 2011 00:22

Hi hei@ge,

You've probably figured it out by now, but just in case (and because unanswered threads bug me), here's your answer:

Internal faces between blocks (which won't be receiving boundary conditions) don't get assigned as patches - they are simply ignored, and OpenFoam will recognize them as simply being an interface between two blocks.

The exception is when the two blocks use separate vertices to define overlapping faces - say, if you were to copy vertices 4, 5, 6, & 7 to vertices 12, 13, 14, & 15. THEN you would use mergePatchPairs to merge the faces (4 5 6 7) and (15 14 13 12)

Hope this helps someone!

Regards,
Jacob

fakekarma January 16, 2012 09:57

@ Hei@ge,

I don't if it is just a mistake in copy and paste but you should in matchPatchPairs write

(interface1 interface2)

instead of

(<interface1> <interface2>)

Cheers,

Elia

ziemowitzima November 19, 2015 11:22

Hi,
Do you know how to specify BC at the interface patches ?
thx
ZMM

marv91 June 27, 2017 12:47

hey

in case I can't connect my blocks because they don't have the same vertices at their interface how should I proceed. As aeroGeek described I need to define two patches and merge them with mergePatchPairs. The problem is than that I need boundaries in the 0 directory for the two new internal patches.
Or are these two patches automatically formed to an internal face?

Thanks a lot!

Marvin

jiahui_93 January 17, 2018 22:02

Hi, I am a totally newbie in CFD. I am facing the problem that openfoam doesnt accept the block with internal faces. But i need that to build a hollow cavity within the center of a rectangular box. What should I do? i hope can get some advice and will be very grateful on that. thanks

Creating topology blocks
--> FOAM Warning :
From function Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList<Foam::Vector<double> >&) const
in file meshes/meshShapes/cellModel/cellModel.C at line 70
zero or negative pyramid volume: -10.12 for face 0
--> FOAM Warning :
From function Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList<Foam::Vector<double> >&) const
in file meshes/meshShapes/cellModel/cellModel.C at line 70
zero or negative pyramid volume: -10.12 for face 1
--> FOAM Warning :
From function Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList<Foam::Vector<double> >&) const
in file meshes/meshShapes/cellModel/cellModel.C at line 70
zero or negative pyramid volume: -23.76 for face 3
--> FOAM Warning :
From function Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList<Foam::Vector<double> >&) const
in file meshes/meshShapes/cellModel/cellModel.C at line 70
zero or negative pyramid volume: -10.12 for face 4
--> FOAM Warning :
From function Foam::vector Foam::cellModel::centre(const labelList&, const Foam::UList<Foam::Vector<double> >&) const
in file meshes/meshShapes/cellModel/cellModel.C at line 70
zero or negative pyramid volume: -10.12 for face 5


--> FOAM FATAL IO ERROR:
Block hex (37 38 46 45 53 54 62 61) (16 339 4) simpleGrading (1(1) 1(1) 1(1)) has inward-pointing faces
4(37 53 61 45) 4(38 46 62 54) 4(45 61 62 46) 4(37 45 46 38) 4(53 54 62 61)

file: /mnt/c/Users/User/OpenFOAM/jhTutorial/pimpleDyMfoam/elevator/system/blockMeshDict.blocks at line 91.

From function void Foam::blockDescriptor::check(const Foam::Istream&)
in file blockDescriptor/blockDescriptor.C at line 89.

FOAM exiting

anuragm February 23, 2018 09:42

Were you able to solve this problem? blockMesh does not like internal faces, but a cavity inside is not usually a problem because this is external to the mesh. If you post the geometry or blockMeshDict file, I can help you with it.

In any case, you can take a look at the createBaffles utility if you want internal walls.

jiahui_93 February 23, 2018 10:27

Quote:

Originally Posted by anuragm (Post 682684)
Were you able to solve this problem? blockMesh does not like internal faces, but a cavity inside is not usually a problem because this is external to the mesh. If you post the geometry or blockMeshDict file, I can help you with it.

In any case, you can take a look at the createBaffles utility if you want internal walls.

Thanks for your suggestion. I will try it now. Is it something like splitMeshRegions?

previously, by using setSet, I got my hollow box within the domain. But i faced another problem, the deleted cell zone left a hole there when it moved up. The mesh seems not replaced automatically.

I am trying the moving Cone topo method which is topo changer. As it seems limited, so i was trying to modify it to suit my case which has vertical translation motion.

thanks again for your help.

anuragm February 23, 2018 10:53

No, splitMeshRegions splits the mesh into different regions, which I achieve in my case through meticulous blocking and naming. createBaffles on the other hand is capable of generating internal walls using previously defined cell sets or regions. Here is an example image of my mesh with internal walls and cavity, note that I define internal walls explicitly in the blockMeshDict using duplicate vertices instead of using the createBaffles utility:

https://www.cfd-online.com/Forums/op...evolution.html

Again, it is difficult to say what exactly is the problem in your case without any details but it seems to me like you are trying to transform your mesh to create a cavity instead of deleting it. To me, this seems a little strange way to do things.

jiahui_93 February 23, 2018 11:16

Quote:

Originally Posted by anuragm (Post 682695)
No, splitMeshRegions splits the mesh into different regions, which I achieve in my case through meticulous blocking and naming. createBaffles on the other hand is capable of generating internal walls using previously defined cell sets or regions. Here is an example image of my mesh with internal walls and cavity, note that I define internal walls explicitly in the blockMeshDict using duplicate vertices instead of using the createBaffles utility:

https://www.cfd-online.com/Forums/op...evolution.html

Again, it is difficult to say what exactly is the problem in your case without any details but it seems to me like you are trying to transform your mesh to create a cavity instead of deleting it. To me, this seems a little strange way to do things.

Thanks for reply. Sry for not providing sufficient info. Here is my post with more details.
https://www.cfd-online.com/Forums/op...ide-fluid.html

Actually i am trying to build a 3D hollow box moving in a rectangular tube (domain), and i aim to mesh the space btwn hollow box and rectangular tube to study the external airflow and pressure and turbulence parameters. This is my starting step to learn the simulation of aerodynamic outside a vehicles or body within a domain. Is it correct for me to delete the cells within the box to make it hollow? i am sry for my dummy questions. Thanks a lot :)

anuragm February 23, 2018 14:23

Quote:

Originally Posted by jiahui_93 (Post 682699)
Thanks for reply. Sry for not providing sufficient info. Here is my post with more details.
https://www.cfd-online.com/Forums/op...ide-fluid.html

Actually i am trying to build a 3D hollow box moving in a rectangular tube (domain), and i aim to mesh the space btwn hollow box and rectangular tube to study the external airflow and pressure and turbulence parameters. This is my starting step to learn the simulation of aerodynamic outside a vehicles or body within a domain. Is it correct for me to delete the cells within the box to make it hollow? i am sry for my dummy questions. Thanks a lot :)

I read your post now, and I want to make it clear that I do not have extensive experience with moving meshes. I took the movingCone case and modified it a little to get something similar to what you want. But first, I would like to say a couple of things:

  1. In case you are only working with simple shapes like block or cylinder, blockMesh is a perfectly capable tool. However, it is very difficult to work with if you are working with a complex geometry (a car or motorbike, for example)
  2. In complex cases, snappyHexMesh is good but it has some problems with boundary layers. There is another open-source tool called cfMesh which supposedly gives better results as compared to snappyHexMesh
  3. In case you are working with blockMesh, then just be careful when defining blocks and faces. Keep in mind that you can assign a boundary condition to a block face and not to part of it (unless you make use of an additional utility).
Anyway, here is an example blockMeshDict that you can adapt for your case. I have made it based on the movingCone case so you can test this case with pimpleDymFoam (remember to change the boundary conditions from wedge to empty):
Code:

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

convertToMeters 0.001;

vertices
(
    (-7.5 0 0)    //0
    (-7 0 0)      //1
    (-3.5 0 0)    //2
    (0 0 0)        //3
    (-7.5 1.75 0)  //4
    (-7 1.75 0)    //5
    (-3.5 2 0)    //6
    (0 2 0)        //7
    (-7.5 2.5 0)  //8
    (-7 2.5 0)    //9
    (-3.5 2.5 0)  //10
    (0 2.5 0)      //11
    (-7.5 1.75 1)  //12
    (-7 1.75 1)    //13
    (-3.5 2 1)    //14
    (0 2 1)        //15
    (-7.5 2.5 1)  //16
    (-7 2.5 1)    //17
    (-3.5 2.5 1)  //18
    (0 2.5 1)      //19
    (-7.5 0 1)    //20
    (-7 0 1)      //21
    (-3.5 0 1)    //22
    (0 0 1)        //23
    (-7 0.75 0)    //24
    (-7 0.75 1)    //25
    (-3.5 0.75 0)  //26
    (-3.5 0.75 1)  //27
    (-7.5 0.75 0)  //28
    (-7.5 0.75 1)  //29
    (0 0.75 0)    //30
    (0 0.75 1)    //31
);

blocks
(
    hex (0 1 24 28 20 21 25 29) (15 20 1) simpleGrading (2 0.25 1)
    hex (28 24 5 4 29 25 13 12) (15 20 1) simpleGrading (2 0.25 1)
    hex (2 3 30 26 22 23 31 27) (20 20 1) simpleGrading (2 0.25 1)
    hex (26 30 7 6 27 31 15 14) (20 20 1) simpleGrading (2 0.25 1)
    hex (4 5 9 8 12 13 17 16) (15 20 1) simpleGrading (2 0.25 1)
    hex (5 6 10 9 13 14 18 17) (50 20 1) simpleGrading (2 0.25 1)
    hex (6 7 11 10 14 15 19 18) (20 20 1) simpleGrading (2 0.25 1)
    hex (1 2 26 24 21 22 27 25) (50 20 1) simpleGrading (2 0.25 1)
);

edges
(
);

boundary
(
    movingWall
    {
        type wall;
        faces
        (
            (24 5 13 25)
            (5 6 14 13)
            (26 6 14 27)
            (24 26 27 25)
        );
    }
    farFieldMoving
    {
        type patch;
        faces
        (
            (9 17 18 10)
            (1 21 22 2)
        );
    }
    fixedWall
    {
        type wall;
        faces
        (
            (3 30 31 23)
            (30 7 15 31)
            (7 11 19 15)
        );
    }
    axis
    {
        type empty;
        faces
        (
            //(0 1 1 0)
            //(2 3 3 2)
        );
    }
    left
    {
        type patch;
        faces
        (
            (0 20 29 28)
            (28 29 12 4)
            (4 12 16 8)
        );
    }
    farField
    {
        type patch;
        faces
        (
            (8 16 17 9)
            (0 20 21 1)
            (10 18 19 11)
            (2 22 23 3)
        );
    }
    back
    {
        type empty;
        faces
        (
            (0 28 24 1)
            (28 4 5 24)
            (2 26 30 3)
            (26 6 7 30)
            (4 8 9 5)
            (5 9 10 6)
            (6 10 11 7)
        );
    }
    front
    {
        type empty;
        faces
        (
            (20 21 25 29)
            (29 25 13 12)
            (22 23 31 27)
            (27 31 15 14)
            (12 13 17 16)
            (13 14 18 17)
            (14 15 19 18)
        );
    }
);

mergePatchPairs
(
);

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


jiahui_93 February 23, 2018 20:21

Quote:

Originally Posted by anuragm (Post 682710)
I read your post now, and I want to make it clear that I do not have extensive experience with moving meshes. I took the movingCone case and modified it a little to get something similar to what you want. But first, I would like to say a couple of things:

  1. In case you are only working with simple shapes like block or cylinder, blockMesh is a perfectly capable tool. However, it is very difficult to work with if you are working with a complex geometry (a car or motorbike, for example)
  2. In complex cases, snappyHexMesh is good but it has some problems with boundary layers. There is another open-source tool called cfMesh which supposedly gives better results as compared to snappyHexMesh
  3. In case you are working with blockMesh, then just be careful when defining blocks and faces. Keep in mind that you can assign a boundary condition to a block face and not to part of it (unless you make use of an additional utility).
Anyway, here is an example blockMeshDict that you can adapt for your case. I have made it based on the movingCone case so you can test this case with pimpleDymFoam (remember to change the boundary conditions from wedge to empty):
Code:

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

convertToMeters 0.001;

vertices
(
    (-7.5 0 0)    //0
    (-7 0 0)      //1
    (-3.5 0 0)    //2
    (0 0 0)        //3
    (-7.5 1.75 0)  //4
    (-7 1.75 0)    //5
    (-3.5 2 0)    //6
    (0 2 0)        //7
    (-7.5 2.5 0)  //8
    (-7 2.5 0)    //9
    (-3.5 2.5 0)  //10
    (0 2.5 0)      //11
    (-7.5 1.75 1)  //12
    (-7 1.75 1)    //13
    (-3.5 2 1)    //14
    (0 2 1)        //15
    (-7.5 2.5 1)  //16
    (-7 2.5 1)    //17
    (-3.5 2.5 1)  //18
    (0 2.5 1)      //19
    (-7.5 0 1)    //20
    (-7 0 1)      //21
    (-3.5 0 1)    //22
    (0 0 1)        //23
    (-7 0.75 0)    //24
    (-7 0.75 1)    //25
    (-3.5 0.75 0)  //26
    (-3.5 0.75 1)  //27
    (-7.5 0.75 0)  //28
    (-7.5 0.75 1)  //29
    (0 0.75 0)    //30
    (0 0.75 1)    //31
);

blocks
(
    hex (0 1 24 28 20 21 25 29) (15 20 1) simpleGrading (2 0.25 1)
    hex (28 24 5 4 29 25 13 12) (15 20 1) simpleGrading (2 0.25 1)
    hex (2 3 30 26 22 23 31 27) (20 20 1) simpleGrading (2 0.25 1)
    hex (26 30 7 6 27 31 15 14) (20 20 1) simpleGrading (2 0.25 1)
    hex (4 5 9 8 12 13 17 16) (15 20 1) simpleGrading (2 0.25 1)
    hex (5 6 10 9 13 14 18 17) (50 20 1) simpleGrading (2 0.25 1)
    hex (6 7 11 10 14 15 19 18) (20 20 1) simpleGrading (2 0.25 1)
    hex (1 2 26 24 21 22 27 25) (50 20 1) simpleGrading (2 0.25 1)
);

edges
(
);

boundary
(
    movingWall
    {
        type wall;
        faces
        (
            (24 5 13 25)
            (5 6 14 13)
            (26 6 14 27)
            (24 26 27 25)
        );
    }
    farFieldMoving
    {
        type patch;
        faces
        (
            (9 17 18 10)
            (1 21 22 2)
        );
    }
    fixedWall
    {
        type wall;
        faces
        (
            (3 30 31 23)
            (30 7 15 31)
            (7 11 19 15)
        );
    }
    axis
    {
        type empty;
        faces
        (
            //(0 1 1 0)
            //(2 3 3 2)
        );
    }
    left
    {
        type patch;
        faces
        (
            (0 20 29 28)
            (28 29 12 4)
            (4 12 16 8)
        );
    }
    farField
    {
        type patch;
        faces
        (
            (8 16 17 9)
            (0 20 21 1)
            (10 18 19 11)
            (2 22 23 3)
        );
    }
    back
    {
        type empty;
        faces
        (
            (0 28 24 1)
            (28 4 5 24)
            (2 26 30 3)
            (26 6 7 30)
            (4 8 9 5)
            (5 9 10 6)
            (6 10 11 7)
        );
    }
    front
    {
        type empty;
        faces
        (
            (20 21 25 29)
            (29 25 13 12)
            (22 23 31 27)
            (27 31 15 14)
            (12 13 17 16)
            (13 14 18 17)
            (14 15 19 18)
        );
    }
);

mergePatchPairs
(
);

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


I had tried snappyHexMesh, Salome, gmesh, etc.. and agree that blockMesh is the best for my simple geometry.
But i still cnt figure out if there's the function for me to choose where i wan to mesh, something like locationInMesh in snappyHexM. So that i can choose only to mesh the space between my hollow box and the rectangular domain. And most importantly, when the hollow car moved up, its original location won't left a hole there.

HTML Code:

Keep in mind that you can assign a boundary condition to a block face and not to part of it (unless you make use of an additional utility).
Yes, I use setSet, toposet and changeDictionary.

HTML Code:

here is an example blockMeshDict that you can adapt for your case. I have made it based on the movingCone case so you can test this case with pimpleDymFoam (remember to change the boundary conditions from wedge to empty)
I tried it before. It is very useful for me to understand pimpleDyM. Thanks for suggestion :)

Thanks again for your help. I very appreciate your help :)

Thanks

B_R_Khan May 4, 2021 06:48

Does anyone know how to give boundary condition to internal faces that you have merged through merge patch pairs? I had different size blocks and merged them through mergePatchPairs. Now it's giving me error that interface boundary condition is not defined in 0 folder.

jmt May 4, 2021 10:32

Quote:

Originally Posted by B_R_Khan (Post 803123)
Does anyone know how to give boundary condition to internal faces that you have merged through merge patch pairs? I had different size blocks and merged them through mergePatchPairs. Now it's giving me error that interface boundary condition is not defined in 0 folder.

I can speak for multi-region, conjugate heat transfer simulations in which the internal face is a fluid-solid interface. In this case, there is a mechanism in OpenFOAM for this type of internal face which is shared by two regions.

If you are not using multi-region CHT, I think you might need to create a baffle out of the internal face using createBafflesDict or something similar.

If you are using CHT, in your blockMeshDict, specify the two interface boundaries as type `patch` in the `boundary` group as shown below.

Code:

...
boundary
(
...
    bottomWall
    {
        type patch;
        faces
        (
            (12 13 15 14)
        );
    }
...
    solidInterface
    {
        type patch;
        faces
        (
            (16 18 19 17)
        );
    }
...
);

mergePatchPairs
(
    (bottomWall solidInterface)
);

Then when you split the blockMesh into multiple regions, OpenFOAM will automatically rename the interface boundary based on the fluid and solid region names. You can then specify boundary conditions for these on a per-region basis.


All times are GMT -4. The time now is 12:07.