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/)
-   -   [Gmsh] gmshToFOAM: Found undefined faces in mesh (https://www.cfd-online.com/Forums/openfoam-meshing/145192-gmshtofoam-found-undefined-faces-mesh.html)

sisi November 30, 2014 17:32

gmshToFOAM: Found undefined faces in mesh
 
I am having some trouble with gmshToFOAM. So far the OpenFOAM "cavity" tutorial with the blockMesh utility works fine. Now I would like to solve the "cavity" problem using an unstructured mesh created by Gmesh:

Code:

lc = 0.01;
tc = 0.001; // top corners
bc = 0.0025; // bottom corners
 
Point(1) = { 0, 0, 0, lc };
Point(2) = { 0.05, 0, 0, lc };
Point(3) = { 0.1, 0, 0, lc };
Point(4) = { 0.1, 0.05, 0, lc };
Point(5) = { 0.1, 0.1, 0, tc };
Point(6) = { 0.05, 0.1, 0, lc };
Point(7) = { 0, 0.1, 0, tc };
Point(8) = { 0, 0.05, 0, lc };
 
Line(1) = {1,2}; 
Line(2) = {2,3}; 
Line(3) = {3,4}; 
Line(4) = {4,5}; 
Line(5) = {5,6}; 
Line(6) = {6,7}; 
Line(7) = {7,8}; 
Line(8) = {8,1}; 
 
Line Loop (9) = {1:8}; 
 
Plane Surface(1) = {9}; 
 
Extrude {0, 0, 0.1} {
Surface{1};
Layers{1};
Recombine;
}
 
Physical Surface("front") = {46,50};
Physical Surface("back") = {34,30};
Physical Surface("bottom") = {22,26};
Physical Surface("left") = {1};
Physical Surface("top") = {42,38};
Physical Surface("right") = {51};
 
Physical Volume("internal") = {1};
 
Mesh 3;
Save "cavity.msh";

I am getting the following terminal outputs:

Code:

$ gmshToFoam cavity.msh

...

Create time

Starting to read mesh format at line 2
Read format version 2.2  ascii 0

Starting to read physical names at line 5
Physical names:7
    Surface 1    front
    Surface 2    back
    Surface 3    bottom
    Surface 4    left
    Surface 5    top
    Surface 6    right
    Volume 7    internal

Starting to read points at line 15
Vertices to be read:652
Vertices read:652

Starting to read cells at line 670
Cells to be read:1806

Mapping region 4 to Foam patch 0
Mapping region 6 to Foam patch 1
Mapping region 3 to Foam patch 2
Mapping region 2 to Foam patch 3
Mapping region 5 to Foam patch 4
Mapping region 1 to Foam patch 5
Mapping region 7 to Foam cellZone 0
Cells:
    total:578
    hex  :0
    prism:578
    pyr  :0
    tet  :0

CellZones:
Zone    Size
    0    578

Skipping tag  at line 2479
Patch 0 gets name left
Patch 1 gets name right
Patch 2 gets name bottom
Patch 3 gets name back
Patch 4 gets name top
Patch 5 gets name front

--> FOAM Warning :
    From function polyMesh::polyMesh(... construct from shapes...)
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 627
    Found 1228 undefined faces in mesh; adding to default patch.
Finding faces of patch 0
Finding faces of patch 1
Finding faces of patch 2
Finding faces of patch 3
Finding faces of patch 4
Finding faces of patch 5

FaceZones:
Zone    Size

Writing zone 0 to cellZone internal and cellSet
End

and

Code:

$ icoFoam

Create time

Create mesh for time = 0

Reading transportProperties

Reading field p



--> FOAM FATAL IO ERROR:
Cannot find patchField entry for left

file: ~/.../run/tutorials/incompressible/icoFoam/cavity/0/p.boundaryField from line 25 to line 35.

    From function GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField::readField(const DimensionedField<Type, GeoMesh>&, const dictionary&)
    in file ~/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/GeometricBoundaryField.C at line 209.

FOAM exiting

Any ideas how to solve this problem?

alexeym December 1, 2014 02:10

Hi,

This

Code:

--> FOAM Warning :
    From function polyMesh::polyMesh(... construct from shapes...)
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 627
    Found 1228 undefined faces in mesh; adding to default patch.

can be ignored. As gmshToFoam first adds all boundary faces to defaultFaces patch and then move faces to patches defined in MSH file. IIRC I've already posted explanation on the forum, or you can take a look at sources of gmshToFoam.

Second error: add left patch description to p file in 0 folder. Here's the names of the patches in the cavity tutorial:

Code:

boundaryField
{
    movingWall
    {
        type            zeroGradient;
    }

    fixedWalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

either you change names of physical groups in your mesh, or you change names of the patches in 0 folder (p and U) files according to your mesh.

sisi December 1, 2014 07:00

1 Attachment(s)
Thanks for your quick reply! I made the following changes to the cavity.geo file but icoFOAM still not working :confused:

Code:

Physical Surface("fixedWalls") = {46, 50, 22, 26, 30, 34};
Physical Surface("frontAndBack") = {51, 1};
Physical Surface("movingWall") = {42, 38};

Running gmshToFoam

Code:

$ gmshToFoam cavity.msh

...

Create time

Starting to read mesh format at line 2
Read format version 2.2  ascii 0

Starting to read physical names at line 5
Physical names:4
    Surface 1    fixedWalls
    Surface 2    frontAndBack
    Surface 3    movingWall
    Volume 4    internal

Starting to read points at line 12
Vertices to be read:826
Vertices read:826

Starting to read cells at line 841
Cells to be read:2288

Mapping region 2 to Foam patch 0
Mapping region 1 to Foam patch 1
Mapping region 3 to Foam patch 2
Mapping region 4 to Foam cellZone 0
Cells:
    total:732
    hex  :0
    prism:732
    pyr  :0
    tet  :0

CellZones:
Zone    Size
    0    732

Skipping tag  at line 3132
Patch 0 gets name frontAndBack
Patch 1 gets name fixedWalls
Patch 2 gets name movingWall

--> FOAM Warning :
    From function polyMesh::polyMesh(... construct from shapes...)
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 627
    Found 1556 undefined faces in mesh; adding to default patch.
Finding faces of patch 0
Finding faces of patch 1
Finding faces of patch 2

FaceZones:
Zone    Size

Writing zone 0 to cellZone internal and cellSet
End

and finally icoFoam leads to

Code:

Create time

Create mesh for time = 0

Reading transportProperties

Reading field p



--> FOAM FATAL IO ERROR:

    patch type 'patch' not constraint type 'empty'
    for patch frontAndBack of field p in file "...cavity/gmsh/0/p"

file: ~/.../cavity/gmsh/0/p.boundaryField.frontAndBack from line 35 to line 35.

    From function emptyFvPatchField<Type>::emptyFvPatchField
(
    const fvPatch& p,
    const Field<Type>& field,
    const dictionary& dict
)

    in file fields/fvPatchFields/constraint/empty/emptyFvPatchField.C at line 100.

FOAM exiting

What does it mean?

alexeym December 1, 2014 07:16

Hi,

Gmsh doesn't store boundary type information in mesh file, all boundaries has type 'patch' (in OpenFOAM's terminology) after conversion.

Cavity tutorial is 2D, frontAndBack boundary should have 'empty' type, fixedWalls and movingWall should have 'wall' type (though for cavity tutorial this is not so important). You should edit constant/polyMesh/boundary file and set correct types. Either by hand, or with changeDictionary utility.

sisi December 1, 2014 09:07

1 Attachment(s)
I tried to follow your instructions. The attached file is the modified boundary file. I still getting an error message:

Code:

Create time

Create mesh for time = 0



--> FOAM FATAL IO ERROR:
wrong token type - expected word, found on line 23 the label 1

file: .frontAndBack.physicalType at line 23.

    From function operator>>(Istream&, word&)
    in file primitives/strings/word/wordIO.C at line 74.

FOAM exiting


alexeym December 1, 2014 09:27

Well,

As it said, it expects word (empty), while you've put list there (1(empty)).

If you take a look at patchIdentifier.H:122, you'll see that physicalType of the patch is word.

I.e. this

Code:

    frontAndBack
    {
        type            empty;
        physicalType    1(empty);
        nFaces          1464;
        startFace      1052;
    }

in fact should be

Code:

    frontAndBack
    {
        type            empty;
        physicalType    empty;
        nFaces          1464;
        startFace      1052;
    }

or even

Code:

    frontAndBack
    {
        type            empty;
        nFaces          1464;
        startFace      1052;
    }

as physical type of the patch is optional thing.

The same with other patches.

sisi December 1, 2014 11:08

Sorry! So the boundary file should look like this?

Code:

frontAndBack
    {
        type            empty;
        physicalType    empty;
        nFaces          1464;
        startFace      1052;
    }
    fixedWalls
    {
        type            wall;
        physicalType    empty;
        nFaces          60;
        startFace      2516;
    }
    movingWall
    {
        type            wall;
        physicalType    empty;
        nFaces          32;
        startFace      2576;
    }

Why am I still getting an error message?

Code:

Create time



--> FOAM FATAL IO ERROR:
cannot find file

file: ~/..../tutorials/incompressible/icoFoam/cavity/gmsh/constant/polyMesh/system/controlDict at line 0.

    From function regIOobject::readStream()
    in file db/regIOobject/regIOobjectRead.C at line 73.

FOAM exiting


alexeym December 1, 2014 11:11

It's worth reading the error (and trying to understand it) before posting message here. You're trying to run a case in constant/polyMesh folder instead of case folder.

sisi December 1, 2014 11:54

Thanks for helping me and being so patient :rolleyes: Works now!

Quote:

Originally Posted by alexeym (Post 521869)
Well,

If you take a look at patchIdentifier.H:122, you'll see that physicalType of the patch is word.

Link not working. Please fix...

alexeym December 1, 2014 11:59

Hm, that's right, posted a link to a local copy of documentation instead of sourceforge. Fixed.

sisi December 2, 2014 11:39

Thank you again for all your assistance! :)

Maimouna March 14, 2016 10:50

Hi Alexey,

I need your help please. I'm doing fsi case about beam in cross flow attached to the square cylinder. I generated mesh using Gmsh.
Quote:

cl1 = 0.5;
cl2 = 0.2;

Point(1) = {0, 0, 0, cl1};

Point(2) = {20, 0, 0, cl1};
//
Point(3) = {0, 11, 0, cl1};

Point(4) = {20, 11, 0, cl1};

Point(11) = {0, 0, 11, cl1};
Point(12) = {20, 0, 11, cl1};
Point(13) = {0, 11, 11, cl1};
Point(14) = {20, 11, 11, cl1};

Line(1) = {1, 11};
Line(2) = {11, 12};
Line(3) = {12, 2};
Line(4) = {2, 1};
Line(5) = {13, 14};
Line(6) = {14, 4};
Line(7) = {4, 3};
Line(8) = {3, 13};
Line(9) = {11, 13};
Line(10) = {12, 14};
Line(11) = {2, 4};
Line(12) = {1, 3};
Line Loop(13) = {1, 2, 3, 4};
Plane Surface(14) = {13};
Line Loop(15) = {8, 5, 6, 7};
Plane Surface(16) = {15};
Line Loop(17) = {1, 9, -8, -12};
Plane Surface(18) = {17};
Line Loop(19) = {3, 11, -6, -10};
Plane Surface(20) = {19};
Line Loop(21) = {2, 10, -5, -9};
Plane Surface(22) = {21};
Line Loop(23) = {4, 12, -7, -11};
Plane Surface(24) = {23};

Point(101) = {5, 5, 4, cl2};
Point(102) = {6, 5, 4, cl2};
//thickness of plate is 0.1
Point(103) = {6, 5+0.45, 4, cl2};
Point(104) = {6, 5+0.55, 4, cl2};
Point(105) = {6, 6, 4, cl2};
Point(106) = {5, 6, 4, cl2};
For i In {1:5}
Line(100+i) = {100+i, 100+i+1};
EndFor
Line(106) = {106, 101};
Line Loop(111) = {101, 102, 103, 104, 105, 106};
Plane Surface(111) = {111};

Point(113) = {6+4, 5+0.45, 4, cl2};
Point(114) = {6+4, 5+0.55, 4, cl2};
Line(113) = {103, 113};
Line(114) = {104, 114};
Line(115) = {113, 114};
Line Loop(116) = {103, 114, -115, -113};
Plane Surface(117) = {116};
vo1[]={Extrude {0, 0, 3} {Surface{111, 117};} };

Surface Loop(172) = {18, 14, 22, 20, 24, 16};
Surface Loop(173) = {170, 117, 162, 166, 171, 148, 111, 128, 132, 149, 140, 144};
Volume(174) = {172, 173};

Physical Surface("inlet") = {18};
Physical Surface("outlet") = {20};
Physical Surface("top") = {16};
Physical Surface("bottom") = {14};
Physical Surface("front") = {22};
Physical Surface("back") = {24};
Physical Surface("cylinder") = {128, 148, 111, 149, 144, 132};
Physical Surface("plate") = {166, 140, 117, 162, 170, 171};

Coherence;
I saved .geo and .msh files in my case and then gmshToFoam fluid.msh, I got the following
Quote:

/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 3.1-f61aab88e799
Exec : gmshToFoam fluid.msh
Date : Mar 14 2016
Time : 15:33:51
Host : owner-HP-Pavilion-Sleekbook-15-PC
PID : 5319
CtrlDict : /home/owner/foam/foam-extend-3.1/etc/controlDict
Case : /home/owner/foam/owner-3.1/FluidStructureInteraction/run/fsiFoam/beamInCrossFlowAttachedCylinder/fluid
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

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

Found $MeshFormat tag; assuming version 2 file format.
Starting to read physical names at line 5
Physical names:8
Surface 1 inlet
Surface 2 outlet
Surface 3 top
Surface 4 bottom
Surface 5 front
Surface 6 back
Surface 7 cylinder
Surface 8 plate

Starting to read points at line 16
Vertices to be read:7216
Vertices read:7216

Starting to read cells at line 7235
Cells to be read:14424

Mapping region 4 to Foam patch 0
Mapping region 3 to Foam patch 1
Mapping region 1 to Foam patch 2
Mapping region 2 to Foam patch 3
Mapping region 5 to Foam patch 4
Mapping region 6 to Foam patch 5
Mapping region 7 to Foam patch 6
Mapping region 8 to Foam patch 7
Cells:
total:0
hex :0
prism:0
pyr :0
tet :0



--> FOAM FATAL ERROR:
No cells read from file "fluid.msh"
Does your file specify any 3D elements (hex=5, prism=6, pyramid=7, tet=4)?
Perhaps you have not exported the 3D elements?

From function readCells(..)
in file gmshToFoam.C at line 690.

FOAM exiting
My second trying was saving that two files in constant/polyMesh folder as you recommended sisi in post #8, but I got same as sisi error
Quote:

Create time --> FOAM FATAL IO ERROR: cannot find file file: ~/..../tutorials/incompressible/icoFoam/cavity/gmsh/constant/polyMesh/system/controlDict at line 0. From function regIOobject::readStream() in file db/regIOobject/regIOobjectRead.C at line 73. FOAM exiting
How could solve that? What's the problem.

My boundary file is
Quote:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

8
(
top
{
type patch;
nFaces 1600;
startFace 314900;
}
bottom
{
type patch;
nFaces 1600;
startFace 316500;
}
outlet
{
type patch;
nFaces 1500;
startFace 318100;
}
inlet
{
type patch;
nFaces 1200;
startFace 319600;
}
cylinder
{
type wall;
nFaces 1200;
startFace 320800;
}
interface
{
type wall;
nFaces 600;
startFace 322000;
}
front
{
type wall;
nFaces 4500;
startFace 322600;
}
back
{
type wall;
nFaces 4500;
startFace 327100;
}

)

// ************************************************** *********************** //
Many thanks in advanced.

Maimouna

alexeym March 14, 2016 11:24

Hi,

You do not have Physical Volume definition in your mesh.

For example if you take this simple GEO:

Code:

Point(1) = {0, 0, 0};
Point(2) = {1, 0, 0};
Point(3) = {1, 1, 0};
Point(4) = {0, 1, 0};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {4, 1, 2, 3};
Plane Surface(6) = {5};
Extrude {0, 0, 1} {
  Surface{6};
  Layers{10};
  Recombine;
}

Transfinite Line {1, 2, 3, 4} = 11;
Transfinite Surface "*";
Recombine Surface "*";

Physical Surface("walls") = {28, 15, 27, 23, 6, 19};
Physical Volume("cube") = {1};  // *

Mesh 3;
Save "test.msh";

and try running it though Gmsh; without Physical Volume definition (comment out line marked with *), you get the following element list in msh-file:

Code:

$Elements
600
1 3 2 1 6 4 36 117 35
2 3 2 1 6 35 117 118 34
...
600 3 2 1 28 602 62 7 63
$EndElements

i.e. mesh does not contain any 3D elements; with Physical Volume definition:

Code:

$Elements
1600
1 3 2 1 6 4 36 117 35
2 3 2 1 6 35 117 118 34
...
601 5 2 2 1 4 36 117 35 81 198 603 513
...
1600 5 2 2 1 1331 359 107 368 602 62 7 63
$EndElements


Maimouna March 14, 2016 12:18

1 Attachment(s)
Hi Alexey,

I just added the following line for Physical surface to my previous geo file
Code:

Physical Volume(200) = {vo1[]};
and I got screen with full of warnings (attached). Why and how to solve?

With lots of thanks.

Maimouna

alexeym March 14, 2016 14:25

And why not

Code:

Physical Volume("mesh") = {174};
(you can use 200 instead of "mesh" if you like)?

Maimouna March 14, 2016 16:08

Ok dear. I got
Quote:

/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 3.1-f61aab88e799
Exec : gmshToFoam fluid.msh
Date : Mar 14 2016
Time : 21:03:41
Host : owner-HP-Pavilion-Sleekbook-15-PC
PID : 2486
CtrlDict : /home/owner/foam/foam-extend-3.1/etc/controlDict
Case : /home/owner/foam/owner-3.1/FluidStructureInteraction/run/fsiFoam/beamInCrossFlowAttachedCylinder/fluid
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

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

Found $MeshFormat tag; assuming version 2 file format.
Starting to read physical names at line 5
Physical names:9
Surface 1 inlet
Surface 2 outlet
Surface 3 top
Surface 4 bottom
Surface 5 front
Surface 6 back
Surface 7 cylinder
Surface 8 interface
Volume 9 mesh

Starting to read points at line 17
Vertices to be read:23732
Vertices read:23732

Starting to read cells at line 23752
Cells to be read:142726

Mapping region 4 to Foam patch 0
Mapping region 3 to Foam patch 1
Mapping region 1 to Foam patch 2
Mapping region 2 to Foam patch 3
Mapping region 5 to Foam patch 4
Mapping region 6 to Foam patch 5
Mapping region 7 to Foam patch 6
Mapping region 8 to Foam patch 7
Mapping region 9 to Foam cellZone 0
Cells:
total:128340
hex :0
prism:0
pyr :0
tet :128340

CellZones:
Zone Size
0 128340

Skipping tag at line 166481
Patch 0 gets name bottom
Patch 1 gets name top
Patch 2 gets name inlet
Patch 3 gets name outlet
Patch 4 gets name front
Patch 5 gets name back
Patch 6 gets name cylinder
Patch 7 gets name interface

--> FOAM Warning :
From function polyMesh::polyMesh(... construct from shapes...)
in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 626
Found 14386 undefined faces in mesh; adding to default patch.
Finding faces of patch 0
Finding faces of patch 1
Finding faces of patch 2
Finding faces of patch 3
Finding faces of patch 4
Finding faces of patch 5
Finding faces of patch 6
Finding faces of patch 7

FaceZones:
Zone Size


From function void polyMesh::initMesh()
in file meshes/polyMesh/polyMeshInitMesh.C at line 81
Truncating neighbour list at 249487 for backward compatibility
Writing zone 0 to cellZone mesh and cellSet
End
Again, what is the problem please?

alexeym March 15, 2016 03:01

Well, output depends on Gmsh version, mesh generation settings, and the state of gmshToFoam in foam-extend (last time I dealt with it, I had to implement removal of empty patches after conversion).

With 2.10.0, default mesh generation settings, and gmshToFoam from OpenFOAM 2.4.0 conversion went OK.

Maimouna March 15, 2016 05:16

Hi Alexey,

I'm using Gmsh 2.8.3 for foam-extend-3.1. What should do now? What are the next steps? Shall remove defaultFaces from the boundary file?

Regards

Maimouna

alexeym March 15, 2016 07:15

Dear Maimouna,

Quote:

Originally Posted by Maimouna (Post 589770)
I'm using Gmsh 2.8.3 for foam-extend-3.1. What should do now? What are the next steps? Shall remove defaultFaces from the boundary file?

Unfortunately I can not decide what YOU should do with YOUR simulation. You have foam-extend installed, check sources of gmshToFoam, learn the reason for

Code:

Truncating neighbor list at 249487 for backward compatibility
Are you sure FSI solvers capable of running on on tetrahedral meshes? Also your geometry is trivially meshed with hexahedra.

Maimouna March 15, 2016 08:39

Hi Alexey,

honestly, I'm not very sure if FSI solver would capable running on tetrahedral meshes, but suppose should be running for all mesh types regarding
HTML Code:

https://www.ricam.oeaw.ac.at/files/reports/12/rep12-11.pdf
So, in my case, what do you advice me to do? Shall I move to another solver? Guide me please.

Best regards

Maimouna


All times are GMT -4. The time now is 19:30.