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/)
-   -   [mesh manipulation] Refine a 3D-Mesh resulting in pure hex-mesh (https://www.cfd-online.com/Forums/openfoam-meshing/148175-refine-3d-mesh-resulting-pure-hex-mesh.html)

smoerebroet February 5, 2015 14:30

Refine a 3D-Mesh resulting in pure hex-mesh
 
Hi FOAMers!

I tried to use refineMesh to refine some regions of my mesh. Unfortunately, it produces polyhedral-cells, which are unacceptable for our purposes. Does anyone of you have any idea how to refine those cells while not producing non-hexa-cells. Hanging nodes are not a problem. Normally it should be possible to split every convex hexa cell in eight smaller hexas, by simply splitting the edges in half and adding 7 additional vertices, or am I mistaken? If it is possible, do you know if there is a tool, which does exactly that?

Thank you very much in advance!!

Thomas

smoerebroet February 6, 2015 10:34

It would even be helpful, if somebody knew that its not possible in openFoam! Or even better would know a tool which can refine keeping up the hexa-structure of mesh.

Thanks alot!

mturcios777 February 6, 2015 12:02

The answer depends on a few parameters:

1) Is your original mesh hexahedral only?
2) What coordinate system and directions are your refining your region in?

A visual example and your refineMeshDict would be helpful.

smoerebroet February 9, 2015 19:00

4 Attachment(s)
Hi Marco!

Thanks alot for your reply! I hope you had a nice weekend. Sorry for answering late. I didnt find the time to write earlier. Regarding your questions:

Quote:

Originally Posted by mturcios777 (Post 530756)
1) Is your original mesh hexahedral only?

Yes, it is.

Quote:

Originally Posted by mturcios777 (Post 530756)
2) What coordinate system and directions are your refining your region in?

A visual example and your refineMeshDict would be helpful.

I am refining in all three directions. Unfortunately, the geometry is quite complicated. A refinement in less than one direction therefore is not adequate. As you can see in pics attached, I try to mesh a complex shaped room. For the visual exaples, I cut the geometry vertically in the first two pictures and horizontaly in the last two pictures. In the centre there is a circular area, where eight pipes are arranged in radial direction. Each of the pipes is intersecting a wall, where there is a gap between the wall and the pipe. Since this gap is quite small compared to our mesh size we would like to locally refine it. As I said the hexaedral mesh is essential for our solver. However, when refining in the intersection area between the refined cells and the non-refined cells polyhedrical cells are emerging.

My refineMeshDict:

Quote:

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

set toBeRefined;

coordinateSystem global;

globalCoeffs
{
tan1 ( 1 0 0 );
tan2 ( 0 1 0 );
tan3 ( 0 0 1 );
}

directions (tan1, tan2, normal);

useHexTopology yes;

geometricCut no;

writeMesh no;

// ************************************************** *********************** //
Thanks very much for your reply. I am thankful for any thought you or someone else might have!

Thomas

vatavuk February 10, 2015 04:16

Hi,
Are you sure that the resulting mesh has polyhedral cells? Sometimes Paraview produces artifacts in the image showing some edges that are not really in the model. I've seen a thread about this some time ago, but I wasn't able to locate it. Does checkmesh report polyhedral cells?
Best Regards,
Paulo

smoerebroet February 10, 2015 07:38

Hi Paulo,

thank you for your relpy. Indeed checkMesh reports polyhedral cells. And as I said it seems as though they are located at the interface between the refined and the non-refined cells.

Best regards,

Thomas

Phicau February 10, 2015 11:04

Hi Thomas,

this is totally normal, so don't worry, if they were hexahedral cells initially that has not changed with the refinement. See this example of a general (level 0) hex next to a refined one:

Code:

·----·----·--------·
|    |    |        |
·----·----·        |
|    |    |        |
·----·----·--------·

You can note that one of the faces of the level 0 hex has been splitted into 4 (in 3D), so that the cell does no longer have 6 faces, but 9. Therefore, it is no longer a hex for OpenFOAM although it really is.

Also don't pay attention on how paraview splits the cells, it is just a visualization artifact.

Best,

Pablo

vatavuk February 10, 2015 12:47

Hi Thomas,
Pablo is correct; you always will have polyhedral cells in the interface, and Paraview divides polyhedral cells in tetrahedra before visualization.
The only remaining question is: Do you need to be completely sure that there are only hexahedra in your mesh?
I found the thread about the visualization artifacts:
http://www.cfd-online.com/Forums/ope...-parafoam.html
Best Regards,
Paulo

mturcios777 February 10, 2015 14:54

Excellent response from Vatatuk. There is another thing you should be aware of. When you refine in the global direction, things get weird when your faces are not aligned with major coordinate sections. Think of refining a cube rotated 45 degrees on the z axis. If you refine in x and y, you will need to cut the cell into triangles (cutting from corner to corner) so you get the same number of cells in x as in y, something like this: http://www.mathematische-basteleien....0of%20a%20Cube

If you want the division to be aligned with the local coordinate system, you will need to use the patchLocal coordinate system, and only refine a subset where a patch normal can be aligned to one of the local coordinate systems.

smoerebroet February 10, 2015 15:33

Thank you Pablo and Paulo for your replies. It fells like I am one step closer to the solution, if there is any.

Ok, so what you are saying, Pablo is that at the interface of refined to non refined cells the faces get split. Therefore, the unrefined cell at the interface has no more six faces but nine, since one of the former six faces got split into four new faces. Each of the for new faces should then have four vertices. However, in the faces-file there are faces with five and six vertices. Is there a contradiction to your post Pablo, or did I understand something wrong?

We in deed need a perfectly hexaedral mesh, Paulo. We want to use adaptive Mesh refinement, and our in-house code uses isotropic mesh refinement based on a hexadrical mesh.

Best regards,

Thomas

smoerebroet February 10, 2015 16:08

Hey Marco,

thank you too!

I changed to local refinement, but the result is exactly the same. However, you are right of course I will keep the local coordinate setting, just in case.

Therefore, an update on my refineMeshDict:
Quote:

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

set toBeRefined;

coordinateSystem patchLocal;
/*
globalCoeffs
{
tan1 ( 1 0 0 );
tan2 ( 0 1 0 );
tan3 ( 0 0 1 );
}
*/
patchLocalCoeffs
{
// Normal direction is face normal of zero'th face of patch
patch outside;
tan1 ( 1 0 0 );
tan2 ( 0 1 0 );
tan3 ( 0 0 1 );
}


directions (tan1 tan3 normal);

useHexTopology yes;

geometricCut no;

writeMesh no;

// ************************************************** *********************** //
Regards

Thomas

mturcios777 February 10, 2015 17:19

I've been using refineMesh in 2.3.x, so the entries might be different. The most important entry is patch, which defines the normal direction, and the other direction tan1. The local coordinate system is such that tan1 X tan2 = normal.

If you wanted to refine a purely cylindrical mesh, the patch I would select the outer surface of the cylinder (to get the radial direction), and set tan1 as the axial direction, so that tan2 is the azimuthal direction.

Judging from your mesh, you won't be able to do this on all cells at once, so you should select subsets of the mesh using topoSet.

One last thing; when refineMesh is run without arguments, global refinement happens in all directions no matter what. At least it does in 2.3.x. You need to use -dict as an option to specify you want to use the dictionary.

Phicau February 11, 2015 06:42

Quote:

Originally Posted by smoerebroet (Post 531285)
Thank you Pablo and Paulo for your replies. It fells like I am one step closer to the solution, if there is any.

Ok, so what you are saying, Pablo is that at the interface of refined to non refined cells the faces get split. Therefore, the unrefined cell at the interface has no more six faces but nine, since one of the former six faces got split into four new faces. Each of the for new faces should then have four vertices. However, in the faces-file there are faces with five and six vertices. Is there a contradiction to your post Pablo, or did I understand something wrong?

We in deed need a perfectly hexaedral mesh, Paulo. We want to use adaptive Mesh refinement, and our in-house code uses isotropic mesh refinement based on a hexadrical mesh.

Best regards,

Thomas

Hi Thomas,

this probably has to do with the issue that Marco pointed out and I had not noticed before: some of your cells are not aligned with the global XYZ axes. Since you have already tried the local directions, I don't know how to correct this issue.

Best,

Pablo

smoerebroet February 11, 2015 07:06

Sounds reasonable, thanks a lot guys!

Howard May 5, 2015 11:14

Quote:

Originally Posted by smoerebroet (Post 531166)
Hi Marco!

Thanks alot for your reply! I hope you had a nice weekend. Sorry for answering late. I didnt find the time to write earlier. Regarding your questions:



Yes, it is.



I am refining in all three directions. Unfortunately, the geometry is quite complicated. A refinement in less than one direction therefore is not adequate. As you can see in pics attached, I try to mesh a complex shaped room. For the visual exaples, I cut the geometry vertically in the first two pictures and horizontaly in the last two pictures. In the centre there is a circular area, where eight pipes are arranged in radial direction. Each of the pipes is intersecting a wall, where there is a gap between the wall and the pipe. Since this gap is quite small compared to our mesh size we would like to locally refine it. As I said the hexaedral mesh is essential for our solver. However, when refining in the intersection area between the refined cells and the non-refined cells polyhedrical cells are emerging.

My refineMeshDict:

Thanks very much for your reply. I am thankful for any thought you or someone else might have!

Thomas

Hi, friends could I ask how you do this hex mesh? because I also have a complex geometry to mesh which contains many small cylinders on surface.

mturcios777 May 5, 2015 12:25

Either make the mesh in blockmesh and enforce hexahedral cells everywhere, or use snappyHexMesh and adjust the settings as best you can.

lukasf October 31, 2018 09:56

Quote:

Originally Posted by smoerebroet (Post 531166)
Hi Marco!

Thanks alot for your reply! I hope you had a nice weekend. Sorry for answering late. I didnt find the time to write earlier. Regarding your questions:



Yes, it is.



I am refining in all three directions. Unfortunately, the geometry is quite complicated. A refinement in less than one direction therefore is not adequate. As you can see in pics attached, I try to mesh a complex shaped room. For the visual exaples, I cut the geometry vertically in the first two pictures and horizontaly in the last two pictures. In the centre there is a circular area, where eight pipes are arranged in radial direction. Each of the pipes is intersecting a wall, where there is a gap between the wall and the pipe. Since this gap is quite small compared to our mesh size we would like to locally refine it. As I said the hexaedral mesh is essential for our solver. However, when refining in the intersection area between the refined cells and the non-refined cells polyhedrical cells are emerging.

My refineMeshDict:

Thanks very much for your reply. I am thankful for any thought you or someone else might have!

Thomas



Do not write:

Code:

directions      (tan1, tan2, normal);
instead write:

Code:

directions      (tan1 tan2 normal);
without the commas!


Using the commas can result in problems in my experience if several overlapping topoSets are used to be refined.


In my test cases ( see my post at https://www.cfd-online.com/Forums/op...ere-added.html ) you would not be able to do the Allrun_wrong_command_order with the case "0_understandRefineMesh" and you could not run Allrun with the case "1_understandRefineMesh".


The error message would be something like

Code:

could not find direction "tan1,";

As long as your topoSets do not overlap with already refined topoSets you can use the comma without issues.


All times are GMT -4. The time now is 09:27.