CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [cfMesh] Problem CfMesh 2D Mesh (https://www.cfd-online.com/Forums/openfoam-community-contributions/159815-problem-cfmesh-2d-mesh.html)

Clmkite September 23, 2015 16:35

Problem CfMesh 2D Mesh
 
Hi,

I'm trying to mesh a car with cfMesh in 2D but I experience some problems.
Here is the geometry :

https://drive.google.com/file/d/0B0-...ew?usp=sharing
https://drive.google.com/file/d/0B0-...ew?usp=sharing

Here is my meshDict :

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM GUI Project: creativeFields          |
|  \\    /  O peration    | Version:  0.8.9.0                                  |
|  \\  /    A nd          | Web: www.c-fields.com                                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/

FoamFile
{
version    2;
format    ascii;
class    dictionary;
location    "system";
object    meshDict;
}

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

surfaceFile    "caronly3.ftr";

maxCellSize    100;
minCellSize    80;
//boundaryCellSize 200;

surfaceFile    "caronly3.ftr";


localRefinement
{
car
{
cellSize 50;
}
}

objectRefinements
{
box
{
type box;
cellsize 100;
centre (15000 3000 5);
lengthX 20000;
lengthY 5500;
lengthZ 10;
}
}


boundaryLayers
{
 patchboundaryLayers
 {
  car
  { 
    nLayers        10;
    thicknessRatio  1.2;
    maxFirstlayrThickness 0.01;
  }
 }
}

In fact I have 2 problems,
When the ratio between maxCellSize and minCellSize is too large I have the following error :

Code:

--> FOAM FATAL ERROR:
This cannot be a 2D mesh

    From function void polyMeshGen2DEngine::findZMinOffsetPoints()
    in file utilities/meshes/polyMeshGen2DEngine/polyMeshGen2DEngine.C at line 174.

FOAM exiting

When the ration between maxCellSize and boundaryCellSize is too big I have this one :
Code:

Octree nodes 37794
Resizing points!
Segmentation fault (core dumped)

And it seems quite important to have a big ratio to reduce the number of cells far from the car.

My second problem is that my localRefinement / objectRefinements / boundaryLayers are completely ignored by the program (cartesian2DMesh).

At this point I didn,t find my answers anywhere...

Thanks a lot

franjo_j September 27, 2015 10:29

1 Attachment(s)
Hello,

The case did not produce the expected results because of some incorrect settings (mainly typos), and the crash was due to some bugs in the 1.1 version. Please upgrade to the 1.1.1 version available at SourceForge. We have resolved some problems reported by the people using the 2D mesher.
Please check the attached case and please let me know if it generates the required result.
There are a few suggestions that I would like to point out:
1. When you generate the features via surfaceFeatureEdges and export the results into an stl or an ftr file, it changes the names of the patches in the surface mesh. You need to use the new names for meshing or simply use the regular expressions. A non-existent patch name in meshDict results in the region being ignored.
2. Please pay attention to use the correct keywords. The settings are case-sensitive so you cannot use cellsize, it has to be cellSize. The same problem is with patchboundaryLayers, it shall be patchBoundaryLayers. This has caused the problem that box refinement region was ignored, and there was only one boundary layer.

I hope that this helps you.

Regards,

Franjo

Clmkite September 28, 2015 11:17

2 Attachment(s)
Hi Franjo,

Thanks for your answer.
I did upgrade myversion and since I didn't encounter my first error.
And you were right about my typo because now it works much better ;)
It's not so long that I work in linux environnement and not used to take care so much of the typo !!!

Howevers I get a mesh loonking like I want (cf pictures).
My checkMesh is not really good and I don't really know how to play with parameters in order to get good quality mesh (I tried optimiseLayer but I didn't find may informations about it).

My MeshDict

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM GUI Project: creativeFields          |
|  \\    /  O peration    | Version:  0.8.9.0                                  |
|  \\  /    A nd          | Web: www.c-fields.com                                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/

FoamFile
{
version        2;
format        ascii;
class        dictionary;
location        "system";
object        meshDict;
}

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

surfaceFile        "caronly1.stl";


maxCellSize        600;
minCellSize    6;
boundaryCellSize 350;
boundaryCellSizeRefinementThickness 400;

localRefinement
{
car {cellSize 30;refinementThickness 200;}
}

objectRefinements
{
becquet {type sphere;cellSize 0.5;centre (10013 1732 5);radius 6;}
box1 {type box;cellSize 80;centre (11000 1300 5);lengthX 12500;lengthY 2600;lengthZ 20;}
box2 {type box;cellSize 200;centre (15000 2200 5);lengthX 25000;lengthY 4400;lengthZ 20;}
box3 {type box;cellSize 400;centre (25000 2500 5);lengthX 45000;lengthY 5000;lengthZ 20;}
}

boundaryLayers
{
 patchBoundaryLayers
 {
  car {nLayers 30;thicknessRatio 1.2;maxFirstLayerThickness 0.01;}
 }

optimiseLayer 1; // activates layer optimisation

// optional parameters
optimisationParameters
{
// number of iterations in the procedure for reducing normal-variation
nSmoothNormals 30;

// max number of total iterations
maxNumIterations 50;

// feature size factor. Reasonable range <0.2, 0.5>
// lower values force thinner layers
featureSizeFactor 0.3;

// shall the normal vectors be recalculated
reCalculateNormals 1;

// relative thickess variation between two hair nSmoothNormals
// lower value produce thinner and more uniform layers
relThicknessTol 0.01;
}
}

chekcMesh results

Code:

/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.4.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.4.0-f0842aea0e77
Exec  : checkMesh
Date  : Sep 28 2015
Time  : 11:04:32
Host  : "clement-desktop"
PID    : 2742
Case  : /home/clement/OpenFOAM/clement-2.4.0/run/etude/caronly
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

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

Create polyMesh for time = 0

Time = 0

Mesh stats
    points:          244808
    internal points:  0
    faces:            479164
    internal faces:  237537
    cells:            118920
    faces per cell:  6.02675
    boundary patches: 7
    point zones:      0
    face zones:      0
    cell zones:      0

Overall number of cells of each type:
    hexahedra:    116196
    prisms:        0
    wedges:        0
    pyramids:      0
    tet wedges:    0
    tetrahedra:    0
    polyhedra:    2724
    Breakdown of polyhedra by number of faces:
        faces  number of cells
            7  2269
            8  453
            9  2

Checking topology...
    Boundary definition OK.
 ***Total number of faces on empty patches is not divisible by the number of cells in the mesh. Hence this mesh is not 1D or 2D.
    Cell to face addressing OK.
    Point usage OK.
    Upper triangular ordering OK.
    Face vertices OK.
    Number of regions: 1 (OK).

Checking patch topology for multiply connected surfaces...
                  Patch    Faces  Points                  Surface topology
                    car    2983    5966  ok (non-closed singly connected)
                  inlet      40      82  ok (non-closed singly connected)
                  ground      556    1114  ok (non-closed singly connected)
                    top      168      338  ok (non-closed singly connected)
                  outlet      40      82  ok (non-closed singly connected)
        bottomEmptyFaces  118920  122404  ok (non-closed singly connected)
          topEmptyFaces  118920  122404  ok (non-closed singly connected)

Checking geometry...
    Overall domain bounding box (0 0 0) (50000 12000 10)
    Mesh (non-empty, non-wedge) directions (0 0 0)
    Mesh (non-empty) directions (0 0 0)
 ***Number of edges not aligned with or perpendicular to non-empty directions: 291712
  <<Writing 212922 points on non-aligned edges to set nonAlignedEdges
    Boundary openness (3.33116e-20 4.09695e-20 4.28121e-14) OK.
 ***Open cells found, max cell openness: 1, number of open cells 1761
  <<Writing 1761 non closed cells to set nonClosedCells
 ***Zero or negative face area detected.  Minimum area: 0
  <<Writing 14895 zero area faces to set zeroAreaFaces
 ***Zero or negative cell volume detected.  Minimum negative volume: -0.0445, Number of negative volume cells: 4766
  <<Writing 4766 zero volume cells to set zeroVolumeCells
    Mesh non-orthogonality Max: 179.145 average: 34.9415
  *Number of severely non-orthogonal (> 70 degrees) faces: 26886.
 ***Number of non-orthogonality errors: 10474.
  <<Writing 37360 non-orthogonal faces to set nonOrthoFaces
 ***Error in face pyramids: 5229 faces are incorrectly oriented.
  <<Writing 4902 faces with incorrect orientation to set wrongOrientedFaces
 ***Max skewness = 8.75e+150, 6824 highly skew faces detected which may impair the quality of the results
  <<Writing 6824 skew faces to set skewFaces
    Coupled point location match (average 0) OK.

Failed 7 mesh checks.

End

Thanks again because I try cfMesh and sHM and I was about giving up on cfMesh whereas now I found it powerful and very efficient (if I can fix quality).

Clmkite September 28, 2015 14:30

1 Attachment(s)
I found the utility improveMeshQuality
in the userguide but is it possible to constrain it with qulity criteria instead of numbers of iterations ?

Is it normal to get the kind of results I attached after using improveMeshQuality ?

Thx a lot

franjo_j September 28, 2015 17:14

Hi,

Can you please post the content of your controlDict? Do you save the mesh in the binary format? Can you please post the log of cartesian2DMesh?
It seems to me that the thickness of the first layer is smaller than the floating-point tolerance. Please increase the number of digits saved in a file or set the writeFormat to binary.

Quote:

Originally Posted by Clmkite (Post 565776)
I found the utility improveMeshQuality
in the userguide but is it possible to constrain it with qulity criteria instead of numbers of iterations ?

Not yet, we are working on that. It will be available in the next couple of days.

Quote:

Originally Posted by Clmkite (Post 565776)
Is it normal to get the kind of results I attached after using improveMeshQuality ?
Thx a lot

Your boundary layers are extremely thin and the algorithm is not designed to handle that.

Clmkite September 29, 2015 09:48

Hi Franjo,

Thanks for everything,
In fact I changed my wall function so I increase my first layer thickness and everything went well !
For next time I sill remember what you've said but how can I choose the writeFormat (just change ascii to binary in the header ?)

It's really great to have the support of the developer while discovering this great tool :)

franjo_j September 29, 2015 12:44

Quote:

Originally Posted by Clmkite (Post 565853)
Hi Franjo,

Thanks for everything,
In fact I changed my wall function so I increase my first layer thickness and everything went well !
For next time I sill remember what you've said but how can I choose the writeFormat (just change ascii to binary in the header ?)

Yes, all you need is:
writeFormat binary;

My suggestion is to use the binary format because it does not lose information, that is extremely important for very thin layers. In addition, it also saves disk space.

Quote:

Originally Posted by Clmkite (Post 565853)
It's really great to have the support of the developer while discovering this great tool :)

Thank you! Happy meshing :)!

ashkan February 1, 2018 01:37

1 Attachment(s)
Hi Franjo,
I am trying to create a 2D case for flow around a pipe using cfmesh and openfoam v1712. However, it seems that I cannot get it working with "cartesian2DMesh" at all. It seems that the issue is on the stl/fra file as it consider it 3D.

Basically, I created a cylinder and mesh it in salome then created boundying box for it using "surfaceGenerateBoundingBox" and use that in the meshDict. Attached please find my case file with the "Allrun" file showing the steps I have taken.

I would highly appreciate your input on how to get it to work.

many thanks
Ashkan

ashkan February 2, 2018 00:37

I managed to resolve my issues and generate the 2D mesh following the very helpful instructions given here

einstein_zee February 14, 2018 07:26

cfMesh different behaviour
 
Hi there foamers,

I didn't want to create a new thread cause the current name is good and applicable to my question as well. I just noticed that for the same geometry when I try to run cfMesh (I use cartesianMesh) for the first time it gave me 103 badCells. Then I just deleted the polymesh folder ($caseFile/constant/polymesh) and tried to run cfMesh for the second time and this time it gave me 64 badCells! this was weird for me and I tried for the third time and I got 115 badCells! I would appreciate if somebody can tell me why this happens? :confused:

I also tried to change the format of my original geometry (.stl file) to .fms (using surfaceToFMS). Guess what... after running cfMesh I got a different number of badCells. But at least for this one I can assume that there might be some slight changes during the conversion from one file format to another. However, for the first case all of the trials were completely identical (in .stl format). I'm using OF1712 and latest version of cfMesh, only if that matters!

jenna July 12, 2018 04:02

No cells in mesh / segmentation fault
 
Hi dear all,


I'm also having problems with the cartesian2D mesher.


The stl file (from Salome): https://drive.google.com/open?id=1X7...lLNXpFyP5PaS2p
The refined one: https://drive.google.com/open?id=1Yh...TCcGJ9QGa7UfAr


My meshDict only contains:



Code:

surfaceFile "Ham2D.stl";
maxCellSize 1;

I get the error:
Code:

--> FOAM FATAL ERROR:
There are no cells in the mesh!
The reasons for this can be fwofold:
1. Inadequate mesh resolution.
2. You maxCellSize is a multiplier of the domain length. This can be reolved by reducing the maxCellSize by a fraction.i.e. 2.49999 instead of 2.5.

I made sure that the geometry was completely closed, as hinted here: https://www.cfd-online.com/Forums/op...on-cfmesh.html. But this didn't help.


Then I tried refining the mesh, but still the same error. When I change the maxCellSize parameter to 0.5, it runs but crashes and then gives
Code:

segmentation fault

I also tried first converting to ftr with surfaceConvert, but this did not help either.


Any idea?

franjo_j July 12, 2018 05:00

Have a look at the hat case in the tutorial folder and prepare your geometry accordingly. In addition, you can find information about 2D geometries in the user guide.


You need to create a ribbon in order to use cartesian2DMesh.


It may help you to try keepCellsIntersectingBoundary 1 option.


However, it better to desing your geometry as a set of edges in the x-y plane and extrude it into a ribbon with the extrudeEdgesInto2DSurface utility.

jenna July 12, 2018 09:35

Hi franjo,


Thank you for the quick reply!
I exported only the edges from salome now, but extrudeEdgesInto2DSurface doesn't take it. Problem is that it is a vtk file, which contains VERTICES, causing the fatal error
Code:

Unsupported tag VERTICES
I tried to convert the vtk file to something foam-readable with vtkUnstructuredToFoam, but this gives the same error... Any ideas for this, or is it rather a salome thing?

franjo_j July 12, 2018 10:22

Can you visualize the vtk file in ParaView? Do you see edges, only?


Any edge mesh format readable by OpenFOAM shall suffice.


Which version of OF do you use?

jenna July 13, 2018 03:39

The openfoam version is 2.3.0, cfmesh v1.1.1.


When I visualise the vtk file (https://drive.google.com/open?id=1IK...czL6ccbY2IZuus), I see the edges, but also the vertices.

I tried with deleting the vertices part => this visualises in paraview as only edges. But then extrudeEdgesInto2DSurface gives:


Code:

--> FOAM FATAL ERROR:
bad size -2147483647


jenna August 13, 2018 11:07

Quote:

Originally Posted by franjo_j (Post 699030)
Can you visualize the vtk file in ParaView? Do you see edges, only?


Any edge mesh format readable by OpenFOAM shall suffice.


Which version of OF do you use?


Hi Franjo,


Still same trouble here... Maybe there is a problem with the edges file... Some details on what I'm trying to do: I have a closed PolyLine in Salome (which are the edges of my geometry), which I export in the Geometry module as a vtk file. However, this file cannot be read by extrudeEdgesInto2DSurface, as mentioned earlier. Can it be due to the type of element in Salome (PolyLine)? Is there a way to make Edges from a PolyLine? ...


Thanks,
Jenna

jenna August 23, 2018 03:27

Hi all,


To by-pass my problem with cartesian2DMesh, I changed the approach as follows:

instead of trying to read out edges from salome and later do extrudeEdgesInto2DSurface, I directly extruded the ribbon (in x-y plane) in the z-direction, within salome (for instance a polyline can be extruded with geompy.MakePrism).

Then I named the needed patches (geompy.CreateGroup) and also added them to the mesh after meshing (with GroupOnGeom).

Finally I exported the mesh as .fms by use of salomeTriSurf.py (notes on this also here).


And on this fms file, cartesian2DMesh works smoothly!


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