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] Converting a 2Dmesh to axisymmetric (https://www.cfd-online.com/Forums/openfoam-meshing/61473-converting-2dmesh-axisymmetric.html)

wenxu January 10, 2016 01:31

Dear Davi Barreira,

Quote:

I tried using collapseEdges, but I just couldnt get it to work. So I decided to use my mesh with symmetryPlane in the face that was supposed to be the axis (dont know how correct this is, but the results are looking correct when compared to some 3D simulations I ran).

The patch type I had to change manually in my blockMeshDict file.

I played around with MakeAxialMesh for a while and I really think it has some compatibility error with OpenFOAM 2.3, because the errors occur even in really simple meshes.
I also encounter the same problem when I run collapseEdges, it does not work for me. The boundary type stays symmetryplane (with faces but area equal to zero) unchanged. However, which type should be axis. Have you solved your problem? Or do you just use the SymmetryPlane type for your simulation?

Best regards,
Wen

luonghungtruyen April 17, 2018 01:27

makeAxialMesh problem
 
Quote:

Originally Posted by zhixuan (Post 506286)
hi, all foamers,

I came across problems when using makeAxisMesh in OF2.3.0. Here are steps I went through:
1. run blockMesh, where axis_plane has been set as planar type
2. run makeAxialMesh -axis axis_plane -wedge frontAndback

however, it says
HTML Code:

Symmetry plane 'axis_plane' is not planar.
At local face at (0 -0.075565 0.0025) the normal (0 0 0) differs from the average normal (0.438889 0 0) by 0.192623
Either split the patch into planar parts or use the symmetry patch type

I changed the "axis_plane" to be "symmetric", it still cannot work.

Then I changed the coordinates, such as switching X axis and Y axis, it works somehow with a new error:
HTML Code:

--> FOAM FATAL ERROR:
wedge frontAndback_pos plane aligns with a coordinate plane.
    The wedge plane should make a small angle (~2.5deg) with the coordinate plane
    and the the pair of wedge planes should be symmetric about the coordinate plane.
    Normal of face 0 is (-1 0 0) , implied coordinate plane direction is (-1 0 0)

    From function wedgePolyPatch::initTransforms()
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 78.

FOAM exiting

I tired several times rotating the coordinator. But still, nothing improved. So I'm wondering if anyone can provide hints on this issue.

I also enclosed my blockMeshDict for your reference.

Thank you in advance.


I met the same problem. I found out the solution that we should specify "the offset"

I solved the problem by adding "the offset" example: "makeAxialMesh -axis axisPatchName -wedge wedgePatchName -offset 5"

here is the reference: https://openfoamwiki.net/index.php/M...s/AxiSymmetric

zhangyan June 22, 2018 04:48

The Warning occurred during collapseEdges can be solved by change writeFormat from ascii to binary in controlDict.
Code:

--> FOAM Warning :
    From function wedgePolyPatch::calcGeometry(PstreamBuffers&)
    in file meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C at line 72
    Wedge patch 'frontAndBack_pos' is not planar.
At local face at (0.003875 0.067375 0.000169026) the normal (-0.0435786 -1.65279e-18 0.99
905) differs from the average normal (-0.0435779 -4.96938e-20 0.99905) by 4.36392e-13Either correct the patch or split it into planar parts


kishpishar August 23, 2018 14:58

makeAxialMesh for OF-5.0
 
1 Attachment(s)
I was trying to compile this utility for OpenFOAM 5.0 and had to make a couple of tiny changes to get rid of some issues during compilation and usage. In case someone is interested:

(1) In function ChangeTypes(polyMesh &mesh, word wedge, word axis, bool hasOffset), axis patches are changed to symmetry patches (instead of symmetryPlane) in the corresponding constructor. I think that with the old symmetryPlane bc, the normals of the patch should be perfectly aligned and in many cases this may not be possible due to round-off errors and OF throws warning/error messages. The symmetry bc is less strict and does away with these.

(2) Included "IOdictionary.H" for handling the rotationDict object.

Tested with OpenFOAM 5.0. Thanks Bernhard for such a useful utility.

NBad March 15, 2020 13:43

Modification to the code
 
Dear Bernard,



First of all thanks for this utility, I was going crazy and you saved me from descending into a well of desperation!!


Second thing, I found some problems while compiling your application, but solved them doing the following changes:



Into the file makeAxialMesh.C I added the preprocessor line:
#include "IOdictionary.h"
into the file options I substituted the lines
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude\ -I$(LIB_SRC)/cfdTools/lnInclude\
with
-I$(LIB_SRC)/finiteVolume/lnInclude\


This was necessary to achieve compilation on my machine with Openfoam7 (version 20190902 100).


Hope this will be helpful to anyone is having trouble compiling!



I am new to this this forum and to forums in general, so I hope I have done something good by posting this!

gschaider March 15, 2020 17:13

Quote:

Originally Posted by NBad (Post 761657)
Dear Bernard,



First of all thanks for this utility, I was going crazy and you saved me from descending into a well of desperation!!


Second thing, I found some problems while compiling your application, but solved them doing the following changes:



Into the file makeAxialMesh.C I added the preprocessor line:
#include "IOdictionary.h"
into the file options I substituted the lines
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude\ -I$(LIB_SRC)/cfdTools/lnInclude\
with
-I$(LIB_SRC)/finiteVolume/lnInclude\


This was necessary to achieve compilation on my machine with Openfoam7 (version 20190902 100).


Hope this will be helpful to anyone is having trouble compiling!



I am new to this this forum and to forums in general, so I hope I have done something good by posting this!


Thank you very much.


I haven't used the utility for quite some time (not because I don't like it but because I didn't have the need for it) so I didn't stumble on it

I7aniel June 8, 2020 11:34

Hey Guys,

I have a question, i used the Make Axial Mesh funtion to create axissymetric mesh, the axis is type symmetry, is this correct?

According to the openfoam user guide (4.3.3) this should be empty i think.

For my special case my simulation does only run 0.4 seconds if axisymetric with symetric boundary condition at the axis.

Any suggestions?

Kind regards

Daniel

NBad June 13, 2020 15:31

Hi I7aniel,

so I understood some things in the meanwhile: if you have a patch where you should have the symmetry axis, then your mesh is terribly wrong!

If the generation of the axysimmetric mesh generation was successful, you would end with only the front and back patches that are of type wedge, and no patches where the axis of symmetry is, because there any face present should have been collapsed to an edge and the resulting empty patch removed.

My suggestion to build an axysimmetric mesh is to do that by using the extrudeMesh utility and the extrudeMeshDict to revolve the front patch of your mesh. You can find a template here: https://github.com/OpenFOAM/OpenFOAM...xtrudeMeshDict

If you're trying to import the mesh from another software, the situation is a little bit more complicated because the front and back plane of your flat mesh are fused in a single patch and you need to split them, I can explain you how.

chw68014 October 10, 2021 14:58

Patch Error
 
Hello, I was also getting the error after running blockMesh and running makeAxialMesh:

"--> FOAM FATAL ERROR:
Symmetry plane 'center' is not planar.
At local face at (0 1.333333333e-05 1e-05) the normal (-1 0 0) differs from the average normal (-0.352 0 0) by 0.419904
Either split the patch into planar parts or use the symmetry patch type

From function virtual void Foam::symmetryPlanePolyPatch::calcGeometry(Foam::P streamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C at line 66."

One of the posts here said to apply an offset to get around the issue but offsetting puts a hole in the domain and I don't want to do that. Has there been any further discussion here about how to solve this issue without needing to offset? Thank you.

My blockMesh is as shown below:

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

vertices
(
(0 0 0) //0
(0.001 0 0) //1
(0.001 0 0.00002) //2
(0 0 0.00002) //3
(0 0.002 0) //4
(0.001 0.002 0) //5
(0.001 0.002 0.00002)//6
(0 0.002 0.00002) //7
(0 0.0025 0) //8
(0.001 0.0025 0) //9
(0.001 0.0025 0.00002) //10
(0 0.0025 0.00002) //11
);

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

edges
(
);

boundary
(

center
{
type symmetryPlane;
faces
(
(0 3 7 4)
(4 7 11 8)
);
}

rightWall
{
type wall;
faces
(
(1 2 6 5)
(5 6 10 9)
);
}

bottomWall
{
type wall;
faces
(
(0 1 2 3)
);
}

atmosphere
{
type patch;
faces
(
(8 9 10 11)
);
}

frontAndBackPlanes
{
type patch;
faces
(
(0 1 5 4)
(4 5 9 8)
(3 2 6 7)
(7 6 10 11)
);
}
);

mergePatchPairs
(
);

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

NBad October 11, 2021 04:05

Revolving mesh method
 
1 Attachment(s)
Quote:

Originally Posted by chw68014 (Post 813982)
Hello, I was also getting the error after running blockMesh and running makeAxialMesh:

"--> FOAM FATAL ERROR:
Symmetry plane 'center' is not planar.
At local face at (0 1.333333333e-05 1e-05) the normal (-1 0 0) differs from the average normal (-0.352 0 0) by 0.419904
Either split the patch into planar parts or use the symmetry patch type

From function virtual void Foam::symmetryPlanePolyPatch::calcGeometry(Foam::P streamBuffers&)
in file meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C at line 66."

One of the posts here said to apply an offset to get around the issue but offsetting puts a hole in the domain and I don't want to do that. Has there been any further discussion here about how to solve this issue without needing to offset? Thank you.

My blockMesh is as shown below:

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

vertices
(
(0 0 0) //0
(0.001 0 0) //1
(0.001 0 0.00002) //2
(0 0 0.00002) //3
(0 0.002 0) //4
(0.001 0.002 0) //5
(0.001 0.002 0.00002)//6
(0 0.002 0.00002) //7
(0 0.0025 0) //8
(0.001 0.0025 0) //9
(0.001 0.0025 0.00002) //10
(0 0.0025 0.00002) //11
);

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

edges
(
);

boundary
(

center
{
type symmetryPlane;
faces
(
(0 3 7 4)
(4 7 11 8)
);
}

rightWall
{
type wall;
faces
(
(1 2 6 5)
(5 6 10 9)
);
}

bottomWall
{
type wall;
faces
(
(0 1 2 3)
);
}

atmosphere
{
type patch;
faces
(
(8 9 10 11)
);
}

frontAndBackPlanes
{
type patch;
faces
(
(0 1 5 4)
(4 5 9 8)
(3 2 6 7)
(7 6 10 11)
);
}
);

mergePatchPairs
(
);

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


I think that you are chosing a wrong symmetry plane.. The plane you use for revolving the mesh and creating a fully axial mesh should lie in the x-y plane..



The method that I'm using now to create axial meshes is the following:

  1. I create a mesh using blockMesh or I import it using fluent2DMeshToFoam
  2. I create one planar patch that I want to revolve, this step is different according to your situation but it should be something like:
    1. If you use blockMesh to create your base mesh, be sure that the patch you want to revolve around the axis lies in the x-y plane
    2. If you are importing the mesh, use topoSet and createPatch utilities to split the frontAndBackPlanes into two different patches, and use translateMesh to ensure that the patch you want to extrude lies in the x-y plane
  3. Use extrudeMesh utility with the following setup in the extrudeMeshDict:
  • constructFrom patch;
  • sourceCase ".";
  • sourcePatches ([name of the patch that lies on the x-y plane]);
  • exposedPatchName [name of your choice]; // this is used to create the patch at the end of the revolution if less of 360°
  • flipNormals true; //or false, try until you get it
  • estrudeModel sector; //sector if you want to extrude more than one layer or wedge if you want to extrude only one layer
  • mergeFaces false; //or true if you extrude 360°
I attached to this answer a test case in which the procedure I just described is implemented starting from your mesh.


I hope I helped you! :D

chw68014 October 13, 2021 01:10

Quote:

Originally Posted by NBad (Post 814006)
I think that you are chosing a wrong symmetry plane.. The plane you use for revolving the mesh and creating a fully axial mesh should lie in the x-y plane..



The method that I'm using now to create axial meshes is the following:

  1. I create a mesh using blockMesh or I import it using fluent2DMeshToFoam
  2. I create one planar patch that I want to revolve, this step is different according to your situation but it should be something like:
    1. If you use blockMesh to create your base mesh, be sure that the patch you want to revolve around the axis lies in the x-y plane
    2. If you are importing the mesh, use topoSet and createPatch utilities to split the frontAndBackPlanes into two different patches, and use translateMesh to ensure that the patch you want to extrude lies in the x-y plane
  3. Use extrudeMesh utility with the following setup in the extrudeMeshDict:
  • constructFrom patch;
  • sourceCase ".";
  • sourcePatches ([name of the patch that lies on the x-y plane]);
  • exposedPatchName [name of your choice]; // this is used to create the patch at the end of the revolution if less of 360°
  • flipNormals true; //or false, try until you get it
  • estrudeModel sector; //sector if you want to extrude more than one layer or wedge if you want to extrude only one layer
  • mergeFaces false; //or true if you extrude 360°
I attached to this answer a test case in which the procedure I just described is implemented starting from your mesh.


I hope I helped you! :D

Thank you so much for the feedback. The frontAndBackPlanes patch consists of two surfaces, both of which are parallel to the xy plane. One is on the xy plane and the other is offset from the xy plane by 1 cell (0.00002 m). I want to revolve around the y axis completely (360 degrees). The y axis is at the left edge of the domain with how I set it up. I have some other questions regarding your instructions:

1) "If you are importing the mesh, use topoSet and createPatch utilities to split the frontAndBackPlanes into two different patches, and use translateMesh to ensure that the patch you want to extrude lies in the x-y plane." Are you saying that, if I use blockMesh to create my mesh and not by importing it, I don't need to use topoSet and createPatch? Or do I need to use them regardless? It seems that way from your Allmesh file.

2) From your instructions, it sounds like I need one patch in the xy plane. As I previously stated, my frontAndBackPlanes patch includes one surface that is offset from but parallel to the xy plane. Is this a problem? If so, how do I fix it?

3) "flipNormals true; //or false, try until you get it" I dont know what you mean by "try until you get it".

4) "estrudeModel sector; //sector if you want to extrude more than one layer or wedge if you want to extrude only one layer" So for a 360 degree revolution about the y axis, would i pick wedge or sector?

Thank you so much for the help.

Chris W

NBad October 13, 2021 01:39

1 Attachment(s)
Quote:

Originally Posted by chw68014 (Post 814150)
Thank you so much for the feedback. The frontAndBackPlanes patch consists of two surfaces, both of which are parallel to the xy plane. One is on the xy plane and the other is offset from the xy plane by 1 cell (0.00002 m). I want to revolve around the y axis completely (360 degrees). The y axis is at the left edge of the domain with how I set it up. I have some other questions regarding your instructions:

1) "If you are importing the mesh, use topoSet and createPatch utilities to split the frontAndBackPlanes into two different patches, and use translateMesh to ensure that the patch you want to extrude lies in the x-y plane." Are you saying that, if I use blockMesh to create my mesh and not by importing it, I don't need to use topoSet and createPatch? Or do I need to use them regardless? It seems that way from your Allmesh file.

2) From your instructions, it sounds like I need one patch in the xy plane. As I previously stated, my frontAndBackPlanes patch includes one surface that is offset from but parallel to the xy plane. Is this a problem? If so, how do I fix it?

3) "flipNormals true; //or false, try until you get it" I dont know what you mean by "try until you get it".

4) "estrudeModel sector; //sector if you want to extrude more than one layer or wedge if you want to extrude only one layer" So for a 360 degree revolution about the y axis, would i pick wedge or sector?

Thank you so much for the help.

Chris W




Hi Chris,



1) yes, if you use blockmesh, instead of creating a patch with two faces (front and back) you can directly create two split patches and extrude the one that lies in the x-y plane skipping the topoSet and createPatch passages. In fact what these two commands do is to split the frontAndBack patch that you have in your mesh into two (that I called front_cyc and back_cyc) so you can extrude only one.



2) The fact that your frontAndBack include two surfaces (and one of them does not lie in the x-y plane) is a problem, since with my script you take the patch and revolve it around the axis. Thus you are revolving the whole patch, which is composed of two surfaces, and the software doesn't understand what's happening.



3) so flipNormals tells the software to change the orientation of the patch that is created at the end of the estrusion. If that's true or false it depends on the other parameter exposedPatchName. I never remember which value (True or False) it is right, try it, if you get the right one the software will say nothing, otherwise it will return an error or complain in general


4) For 360° extrusion you need to pick sector, set the angle parameter to 360° and the mergeFaces parameter to true. This will glue together the patches ypu used for the extrusion once the 360° revolution is complete. I attached the mesh I generated using the case I sent you last time by omitting mergeFaces, and you can see it has an internal patch which is the one used for the extrusion that must be removed.



PS: I noticed an error in the files I sent you, in the extrudeMeshDict you should change the initial part like this:




//constructFrom mesh;
constructFrom patch;
//constructFrom surface;

// If construct from patch/mesh:
sourceCase ".";
sourcePatches (back_cyc);

// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName front_cyc;

// If construct from surface:
//surface "movingWall.stl";

// Flip surface normals before usage. Valid only for extrude from surface or
// patch.
flipNormals true;


Hope this helps,

Nicolo.

chw68014 October 17, 2021 15:25

2 Attachment(s)
Quote:

Originally Posted by NBad (Post 814152)
Hi Chris,



1) yes, if you use blockmesh, instead of creating a patch with two faces (front and back) you can directly create two split patches and extrude the one that lies in the x-y plane skipping the topoSet and createPatch passages. In fact what these two commands do is to split the frontAndBack patch that you have in your mesh into two (that I called front_cyc and back_cyc) so you can extrude only one.



2) The fact that your frontAndBack include two surfaces (and one of them does not lie in the x-y plane) is a problem, since with my script you take the patch and revolve it around the axis. Thus you are revolving the whole patch, which is composed of two surfaces, and the software doesn't understand what's happening.



3) so flipNormals tells the software to change the orientation of the patch that is created at the end of the estrusion. If that's true or false it depends on the other parameter exposedPatchName. I never remember which value (True or False) it is right, try it, if you get the right one the software will say nothing, otherwise it will return an error or complain in general


4) For 360° extrusion you need to pick sector, set the angle parameter to 360° and the mergeFaces parameter to true. This will glue together the patches ypu used for the extrusion once the 360° revolution is complete. I attached the mesh I generated using the case I sent you last time by omitting mergeFaces, and you can see it has an internal patch which is the one used for the extrusion that must be removed.



PS: I noticed an error in the files I sent you, in the extrudeMeshDict you should change the initial part like this:




//constructFrom mesh;
constructFrom patch;
//constructFrom surface;

// If construct from patch/mesh:
sourceCase ".";
sourcePatches (back_cyc);

// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName front_cyc;

// If construct from surface:
//surface "movingWall.stl";

// Flip surface normals before usage. Valid only for extrude from surface or
// patch.
flipNormals true;


Hope this helps,

Nicolo.

Hi Nicolo,

Ok, so I split up frontAndBackPlanes into two patches, one called front_cyc in the x-y plane and one called back_cyc, which was offset but parallels from the x-y plane.

The changes I made to extrudeMeshDict were to set sourcePatches to front_cyc (the patch in the x-y plane), set exposedPatchName to back_cyc (the offset patch), set mergeFaces to True, and set angle to 180 and nLayers to 1 because it said in the file that nLayers = 1 would provide symmetry.

I ran blockMesh, and then ran extrudeMesh and got the error, after some running, as follows:

"--> FOAM FATAL ERROR:
Points on patch sides do not match to within tolerance 2e-08

From function virtual void Foam::perfectInterface::setRefinement(const indirectPrimitivePatch&, const indirectPrimitivePatch&, Foam::polyTopoChange&) const
in file perfectInterface/perfectInterface.C at line 218.

FOAM exiting"

I attached blockMeshDict and extrudeMeshDict so you can see what may be wrong. Do you see anything obvious I did wrong? Thank you for the help.

Attachment 86690

Attachment 86691

NBad October 18, 2021 04:08

3 Attachment(s)
Quote:

Originally Posted by chw68014 (Post 814439)
Hi Nicolo,

Ok, so I split up frontAndBackPlanes into two patches, one called front_cyc in the x-y plane and one called back_cyc, which was offset but parallels from the x-y plane.

The changes I made to extrudeMeshDict were to set sourcePatches to front_cyc (the patch in the x-y plane), set exposedPatchName to back_cyc (the offset patch), set mergeFaces to True, and set angle to 180 and nLayers to 1 because it said in the file that nLayers = 1 would provide symmetry.

I ran blockMesh, and then ran extrudeMesh and got the error, after some running, as follows:

"--> FOAM FATAL ERROR:
Points on patch sides do not match to within tolerance 2e-08

From function virtual void Foam::perfectInterface::setRefinement(const indirectPrimitivePatch&, const indirectPrimitivePatch&, Foam::polyTopoChange&) const
in file perfectInterface/perfectInterface.C at line 218.

FOAM exiting"

I attached blockMeshDict and extrudeMeshDict so you can see what may be wrong. Do you see anything obvious I did wrong? Thank you for the help.

Attachment 86690

Attachment 86691


OK so there are two ways of providing cyclic symmetry in OpenFOAM:
  1. You extrude your mesh by a small angle (<4°) and set the front_cyc and back_cyc to wedge patch type. To do this you must set your extrudeMeshDict with the following:
    1. extrudeModel wedge;
    2. nLayers 1;
    3. angle 4;
    4. mergeFaces false; //True ONLY if angle = 360°!!
The resulting mesh should look like the one in the first attached image named mesh_wedge.
Attachment 86695
This is equivalent to doing a 2D simulation but with cylindrical symmetry.
NB now the boundary conditions on your front_cyc and back_cyc must be set as "type wedge;" for every field you use.
2. You extrude your mesh by 360°. In this case the configuration is:
  1. extrudeModel sector;
  2. nLayers 360; //or as you whish, the higher the better the angle discretization
  3. angle 360; //full revolve extrusion
  4. mergeFaces true;
and by doing this you obtain a full 360° extrusion, like the second attached image. Attachment 86696

The error you are getting is because you set the angle at 180° and the front_cyc and back_cyc do not overlap! mergeFaces tryes to stitch them together but since they're distant it can't and throws an error. Also you can't extrude single layers more than few degrees otherwise you get triangles, you lose precision and get highly skewed mesh like the one of the third image in which I extruded 120° with only one layer (nLayer 1; angle 120;)! Attachment 86697


BTW I highly suggest you use ParaFoam or ParaView to look at your mesh and try varying the parameters in the files to understand how they affect the mesh cereation.


Hope this is clear,

Nicoḷ.

chw68014 October 19, 2021 15:00

It worked!
 
3 Attachment(s)
Quote:

Originally Posted by NBad (Post 814456)
OK so there are two ways of providing cyclic symmetry in OpenFOAM:
  1. You extrude your mesh by a small angle (<4°) and set the front_cyc and back_cyc to wedge patch type. To do this you must set your extrudeMeshDict with the following:
    1. extrudeModel wedge;
    2. nLayers 1;
    3. angle 4;
    4. mergeFaces false; //True ONLY if angle = 360°!!
The resulting mesh should look like the one in the first attached image named mesh_wedge.
Attachment 86695
This is equivalent to doing a 2D simulation but with cylindrical symmetry.
NB now the boundary conditions on your front_cyc and back_cyc must be set as "type wedge;" for every field you use.
2. You extrude your mesh by 360°. In this case the configuration is:
  1. extrudeModel sector;
  2. nLayers 360; //or as you whish, the higher the better the angle discretization
  3. angle 360; //full revolve extrusion
  4. mergeFaces true;
and by doing this you obtain a full 360° extrusion, like the second attached image. Attachment 86696

The error you are getting is because you set the angle at 180° and the front_cyc and back_cyc do not overlap! mergeFaces tryes to stitch them together but since they're distant it can't and throws an error. Also you can't extrude single layers more than few degrees otherwise you get triangles, you lose precision and get highly skewed mesh like the one of the third image in which I extruded 120° with only one layer (nLayer 1; angle 120;)! Attachment 86697


BTW I highly suggest you use ParaFoam or ParaView to look at your mesh and try varying the parameters in the files to understand how they affect the mesh cereation.


Hope this is clear,

Nicoḷ.

Thank you so much! It worked! Attachment 86724

My next difficulty is setting the initial conditions for the domain using setFields. I have a setFieldsDict set up right now to have a default oil volume fraction of 0, an oil volume fraction of 1 for a portion of the domain using cellToCylinder (full domain radius up to a height of 0.002 m which is 0.0005 m away from the domain top), and a sphereToCell at a specific point to create a single gas bubble (I think I need to make this a cylinderToCell approximation because of my cylindrical domain now). I tried using setFields out right after creating the domain but I get an error that says:

"--> FOAM FATAL IO ERROR:
size 62500 is not equal to the given value of 2250000

file: /storage/home/chw119/scratch/TEST/Axisymm/Base_help/0/alpha.oil

From function Foam::Field<Type>::Field(const Foam::word&, const Foam::dictionary&, Foam::label) [with Type = double; Foam::label = int]
in file /storage/work/asr20/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/Field.C at line 222.

FOAM exiting"

I'm assuming setFields is not reading my current mesh correctly and needs me to manipulate the initial condition files in the '0' folder and maybe even setFieldsDict to read the mesh properly. Do you have any examples on how to go about this? I attached one of current files in the 0 folder and my setFieldsDict file to show you what I have right now. Thank you.

Chris W

Attachment 86726
Attachment 86727

NBad October 20, 2021 03:15

1 Attachment(s)
Quote:

Originally Posted by chw68014 (Post 814609)
Thank you so much! It worked! Attachment 86724

My next difficulty is setting the initial conditions for the domain using setFields. I have a setFieldsDict set up right now to have a default oil volume fraction of 0, an oil volume fraction of 1 for a portion of the domain using cellToCylinder (full domain radius up to a height of 0.002 m which is 0.0005 m away from the domain top), and a sphereToCell at a specific point to create a single gas bubble (I think I need to make this a cylinderToCell approximation because of my cylindrical domain now). I tried using setFields out right after creating the domain but I get an error that says:

"--> FOAM FATAL IO ERROR:
size 62500 is not equal to the given value of 2250000

file: /storage/home/chw119/scratch/TEST/Axisymm/Base_help/0/alpha.oil

From function Foam::Field<Type>::Field(const Foam::word&, const Foam::dictionary&, Foam::label) [with Type = double; Foam::label = int]
in file /storage/work/asr20/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/Field.C at line 222.

FOAM exiting"

I'm assuming setFields is not reading my current mesh correctly and needs me to manipulate the initial condition files in the '0' folder and maybe even setFieldsDict to read the mesh properly. Do you have any examples on how to go about this? I attached one of current files in the 0 folder and my setFieldsDict file to show you what I have right now. Thank you.

Chris W

Attachment 86726
Attachment 86727


Dear Chris,


I'm happy I could help :)!
However, I never used the setFields utility, so I can't help you with this new issue. I suggest you look on the internet for the error and try to work out the issue from that.

But if I understood correctly your problem, I would suggest you to use the wedge method to build your mesh to reduce the computational effort needed.

NB: run checkMesh to check if everything is ok with the mesh!!! I think you might want to change the flipNormals in extrudeMeshDict to false.
NNB: you might want to add a second createPatchDict with no patches in it and run the createPatch utility after the extrusion to remove empty patches left from the previous meshing steps, like I did here: Attachment 86740


Sincerely,

Nicolo.

chw68014 October 28, 2021 23:45

Quote:

Originally Posted by NBad (Post 814635)
Dear Chris,


I'm happy I could help :)!
However, I never used the setFields utility, so I can't help you with this new issue. I suggest you look on the internet for the error and try to work out the issue from that.

But if I understood correctly your problem, I would suggest you to use the wedge method to build your mesh to reduce the computational effort needed.

NB: run checkMesh to check if everything is ok with the mesh!!! I think you might want to change the flipNormals in extrudeMeshDict to false.
NNB: you might want to add a second createPatchDict with no patches in it and run the createPatch utility after the extrusion to remove empty patches left from the previous meshing steps, like I did here: Attachment 86740


Sincerely,

Nicolo.

Hello Nicolo,

Thank you for the feedback. I ran createPatch using the createPatchDict you attached and it wrote a new 'polyMesh' folder with the mesh files without the empty center patch included within a new folder called '1e-07'. Should I take the polyDict files in that folder and overwrite the polyDict files in the 'constant' folder? I want to make sure the right mesh files are read when the simulation is run. Regarding my earlier mention of setFields, I essentially want to establish an initial condition of half a circular bubble at the rotational axis by setting the void fraction to 0 for a circular region. Would I need to do that prior to running extrudeMesh or do you know of a way to do that after extruding the mesh and removing the empty patches? Thank you for everything.

Chris W


All times are GMT -4. The time now is 08:00.