CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Meshing of a circular cross-section

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By piotr.mecht
  • 1 Post By piotr.mecht

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 23, 2019, 09:51
Default Meshing of a circular cross-section
  #1
New Member
 
Join Date: Sep 2019
Posts: 8
Rep Power: 6
Mi95 is on a distinguished road
Dear all,

this is my first contribution to this forum and as im fairly new to OpenFoam, my question might have a trivial answer.

Im trying to mesh a geometry that that can be described as a U-pipe with a circular cross section, experiencing an internal-fluid flow.

I know that i have to differentiate between inlet, outlet and wall geometry in the blockMeshDict. My question now is, how can i describe and insert those boundary patches in the Blockmeshdict correctly?

is it enough to create STL-files in ASCII-format of each geometry-patch and simply copy-paste the patch'es code in the blockMeshDicht-file?

best regards
Mi95 is offline   Reply With Quote

Old   September 23, 2019, 19:26
Default
  #2
Senior Member
 
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 16
peterhess is on a distinguished road
Hello!
I am not sure to understand the question right, anyway but the blockMeshDict I uploaded here and see the result in paraFoam...

blockMesh is meshing the pipe and defines the boundaries.

Regards

Peter
Attached Files
File Type: gz blockMeshDict.tar.gz (911 Bytes, 55 views)
peterhess is offline   Reply With Quote

Old   September 24, 2019, 04:29
Default
  #3
Senior Member
 
Join Date: Jun 2012
Location: Germany, Bochum
Posts: 230
Rep Power: 15
Bazinga is on a distinguished road
Quote:
Originally Posted by Mi95 View Post
Dear all,

this is my first contribution to this forum and as im fairly new to OpenFoam, my question might have a trivial answer.

Im trying to mesh a geometry that that can be described as a U-pipe with a circular cross section, experiencing an internal-fluid flow.

I know that i have to differentiate between inlet, outlet and wall geometry in the blockMeshDict. My question now is, how can i describe and insert those boundary patches in the Blockmeshdict correctly?

is it enough to create STL-files in ASCII-format of each geometry-patch and simply copy-paste the patch'es code in the blockMeshDicht-file?

best regards
Check out the user guide of OpenFOAM. There are tutorials which explain the basics of blockMesh as well as a documentation with more details later.

AFAIK you can not use stl files with blockMesh. You could do that with snappyHexMesh (unstructured meshes)
Bazinga is offline   Reply With Quote

Old   September 24, 2019, 06:01
Default
  #4
Member
 
Piotr Ładyński
Join Date: Apr 2017
Posts: 55
Rep Power: 8
piotr.mecht is on a distinguished road
Quote:
Originally Posted by Bazinga View Post
AFAIK you can not use stl files with blockMesh. You could do that with snappyHexMesh (unstructured meshes)
You can use stl in Geometry field, to project points, edges and faces on this stl, it can be sometimes pretty useful


Code:
geometry
{
   myShape
   {

      type triSurfaceMesh;

      file  "myGeometry.stl" //must be in [constant/geometry] directory
   }

}
then you can for example:
Code:
//vertices...
name myVertex01 project (0 0 0) (myShape) 

//edges...
 project myVertex01 myVertex02 (myShape)


 //faces...
project (myVertex01 myVertex02 myVertex03 myVertex04) myShape
There is a cool tutorial in $FOAM_TUTORIALS/mesh/blockMesh/pipe that shows how to project vertices/edges/faces on any geometry

Quote:
Originally Posted by Mi95 View Post
My question now is, how can i describe and insert those boundary patches in the Blockmeshdict correctly?

You should look at basic meshing tutorials:
Code:
    boundary               // keyword 
    ( 
        inlet              // patch name 
        { 
            type patch;    // patch type for patch 0 
            faces 
            ( 
                (0 4 7 3)  // block face in this patch 
            ); 
        }                  // end of 0th patch definition  
        outlet             // patch name 
        { 
            type patch;    // patch type for patch 1 
            faces 
            ( 
                (1 2 6 5) 
            ); 
        }  
        walls 
        { 
            type wall; 
            faces 
            ( 
                (0 1 5 4) 
                (0 3 2 1) 
                (3 7 6 2) 
                (4 5 6 7) 
            ); 
        } 
    );
it is useful to use names instead of vertex number, so it is better to specify vertex like:
name myVertexName (0 0 0)
and then:
Code:
inlet
{ 
    type patch;
    faces 
    ( 
       (myVertex00 myVertex01 myVertex02 myVertex03)   
    ); 
}
Mi95 likes this.

Last edited by piotr.mecht; September 28, 2019 at 04:51.
piotr.mecht is offline   Reply With Quote

Old   September 24, 2019, 06:11
Default
  #5
Senior Member
 
Join Date: Jun 2012
Location: Germany, Bochum
Posts: 230
Rep Power: 15
Bazinga is on a distinguished road
thanks for the info. interesting!
Bazinga is offline   Reply With Quote

Old   September 24, 2019, 07:59
Default
  #6
New Member
 
Join Date: Sep 2019
Posts: 8
Rep Power: 6
Mi95 is on a distinguished road
Hey all,

thanks alot!

i looked at the code in the blockmesh tutorial for a pipe in open foam and still have a few questions:

how is it possible address the coordinates of the edges and how do you address the coordinates of the inlet outlet and walls?

are these informations written automatically in the blockmeshdict file when using snappy hex mesh or do i have to insert these informations manually?

i think i still dont get the point of defining the actual geometry of the pipe in the blockmeshdict, when the snappyhexmeshdict cuts out the stl geometries anyway?

best regards
Mi95 is offline   Reply With Quote

Old   September 24, 2019, 08:44
Default
  #7
Member
 
Piotr Ładyński
Join Date: Apr 2017
Posts: 55
Rep Power: 8
piotr.mecht is on a distinguished road
Quote:
Originally Posted by Mi95 View Post
(...)

If you are going to use snappyHexMesh anyway you need blockMesh only to provide background mesh (like simple domain-sized cuboid). You don't need to specify any patches in blockMeshDict in this case. You specify them in snappyHexMeshDict in geometry field:
Code:
geometry
{
    Geometry.stl
    {
        type triSurfaceMesh;
        name myGeometry;
        regions
        {
           region1   {name Inlet; }
           region2   {name Outlet; }
           regionbanana   {name Wall; }
        }
    }
}
But in order to distinguish region1 to name it Inlet you have to provide .STL file with specified regions. Example on how to do that is shown here:
https://www.youtube.com/watch?v=_Sak...oOzmG5T9dvasG6


==============


blockMesh wasn't designed to fit complex geometries, but it is often useful for the proof-of-concept things. It is posible to fit some faces, edges and vertices onto your geometry with projection capabilities.
Create some points with coordinates in proximity of place you want to fit (I don't remember wether you need to be exactly inside or outside this surface or if that matters), and project them onto your shape. You can project onto multiple surfaces (stl, box, cylinder, surface etc.) at once, so the vertex will fit a place, where your surfaces intersect (it is useful to add e.g. a plane to make sure your hex vertices fit your stl at certaint height/length).


==============
piotr.mecht is offline   Reply With Quote

Old   September 26, 2019, 12:09
Default
  #8
New Member
 
Join Date: Sep 2019
Posts: 8
Rep Power: 6
Mi95 is on a distinguished road
thanks for your reply, but i still havent fully solved the problem.

I run my case in the following order:
1. blockMesh
2. surfaceFeatureExtract
3. snappyHexMesh
4. icoFoam

I can see the meshing worked when i load it in paraView, but i still have some questions:

1. Is it correct that the programm writes out in two timesteps (0.01, 0.02) the meshing data?

2.is it possible to define initial and boundary conditions for the case even if the only appearence of the definition of the faces is in the SnappyHexMeshDict? i know only defined a Hexagonal cubemesh in the blockmeshdict, no specification of any surface in particular.

Looking forward to your answers.

best regards
Mi95 is offline   Reply With Quote

Old   September 26, 2019, 16:11
Default
  #9
Member
 
Piotr Ładyński
Join Date: Apr 2017
Posts: 55
Rep Power: 8
piotr.mecht is on a distinguished road
Quote:
Originally Posted by Mi95 View Post
1. Is it correct that the program writes out in two timesteps (0.01, 0.02) the meshing data?

snappyHexMesh has 3 stages:
castellated refinement, snappig to the surface and adding layers stage.
It returns separate "timesteps" (they are just labeled according to your timestep set in controlDict) for each stage executed, so you can check each stage result separately.
Each of this folder contains polyMesh folder, which you could copy to
constant/ directory to account as your new mesh.



In your case folder 0.01 probably contains castellated (minecraft-like) result and folder 0.02 is probably snapped mesh (without layers fitted to boundary).

you can skip this and make your final mesh stage directly into constant/polyMesh folder by calling:
Code:
snappyHexMesh -overwrite
Quote:
Originally Posted by Mi95 View Post
2.is it possible to define initial and boundary conditions for the case even if the only appearence of the definition of the faces is in the SnappyHexMeshDict? i know only defined a Hexagonal cubemesh in the blockmeshdict, no specification of any surface in particular.

I don't think I understand your question well. Your boundary (and initial) conditions are defined in 0/ directory for each of transported quantity. In case of icoFoam these are 0/p (which corresponds to kinematic pressure) and 0/U (which corresponds to velocity vector).


pressure file might look like this:

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

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    myInlet // name specified in snappyHexMeshDict
    {
        type            zeroGradient;
    }

    myOutlet
    {
        type            fixedValue;
        value           uniform 0;
    }

    myWall
    {
        type            zeroGradient;
    }
}

// ************************************************************************* //
velocity file might look like this:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1906                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (10 0 0);

boundaryField
{
    myInlet
    {
        type            fixedValue;
        value           uniform (10 0 0);
    }

    myOutlet
    {
        type            zeroGradient;
    }

    myWall
    {
        type            noSlip;
        
    }

}

// ************************************************************************* //
Please look at tutorial cases in your tutorial folder. It is easier to copy the cases that work and change them to fit your needs.


To find tutorials directory type:
Code:
echo $FOAM_TUTORIALS
in the terminal.
piotr.mecht is offline   Reply With Quote

Old   September 27, 2019, 18:22
Default
  #10
New Member
 
Join Date: Sep 2019
Posts: 8
Rep Power: 6
Mi95 is on a distinguished road
Hello guys,


i again have one question regarding the snappyHexMesh dict.


I already looked at several complete files, like the flange tutorial mesh or the one with the motorbike.


Based on that i modelled my file for the internal pipe flow.


The only main thing i removed is the refinement surface part and the refinement region part. Do i have to have these parts in my code do properly run the hexmesh command?


my snappyhexmeshdict file looks like this


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


castellatedMesh true;
snap true;
addLayers false;

geometry
{
inlet { type triSurfaceMesh; file "inletm.stl"; }
outlet { type triSurfaceMesh; file "outletm.stl"; }
wand { type triSurfaceMesh; file "wandm.stl"; }
};

castellatedMeshControls
{
maxLocalCells 100000;
maxGlobalCells 2000000;
minRefinementCells 10;
maxLoadUnbalance 0.10;
nCellsBetweenLevels 3;

features

(
{file "inletm.eMesh";level 6;}
{file "outletm.eMesh";level 6;}
{file "wandm.eMesh";level 6;}

);
resolveFeatureAngle 30;
locationInMesh (0.05 -0.04 0);
allowFreeStandingZoneFaces true;
}

snapControls
{
nSmoothPatch 3;
tolerance 2.0;
nSolveIter 30;
nRelaxIter 5;
nFeatureSnapIter 10;
implicitFeatureSnap false;
explicitFeatureSnap true;
multiRegionFeatureSnap false;
}

addLayersControls
{
relativeSizes true;
layers
{
"(inlet)" {nSurfaceLayers 1;}
"(wall)" {nSurfaceLayers 1;}
"(outlet)" {nSurfaceLayers 1;}
expansionRatio 1.0;
finalLayerThickness 0.3;
minThickness 0.1;
nGrow 0;
featureAngle 60;
slipFeatureAngle 30;
nRelaxIter 3;
nSmoothSurfaceNormals 1;
nSmoothNormals 3;
nSmoothThickness 10;
maxFaceThicknessRatio 0.5;
maxThicknessToMedialRatio 0.3;
minMedianAxisAngle 90;
nBufferCellsNoExtrude 0;
nLayerIter 50;
nRelaxedIter 20;
}

meshQualityControls
{
#include "meshQualityDict"
relaxed
{
maxNonOrtho 75;
}
}
writeFlags
(
scalarLevels
layerSets
layerFields
);

mergeTolerance 1e-6;



after running snappyHexMesh it responds with that error:


--> FOAM FATAL IO ERROR:
keyword refinementSurfaces is undefined in dictionary "/home/mi/Schreibtisch/OF7/openfoam7/Test-Tutorials/incompressible/icoFoam/cavity/urohr/system/snappyHexMeshDict.castellatedMeshControls"

file: /snappyHexMeshDict.castellatedMeshControls from line 50 to line 149.

From function const Foam::dictionary& Foam::dictionary::subDict(const Foam::word&) const
in file db/dictionary/dictionary.C at line 708.

FOAM exiting


Do you have any idea why its not running?


best regards Mi
Mi95 is offline   Reply With Quote

Old   September 28, 2019, 04:43
Default
  #11
Member
 
Piotr Ładyński
Join Date: Apr 2017
Posts: 55
Rep Power: 8
piotr.mecht is on a distinguished road
Quote:
Originally Posted by Mi95 View Post
Do you have any idea why its not running?

--> FOAM FATAL IO ERROR:
keyword refinementSurfaces is undefined in dictionary "/home/mi/Schreibtisch/OF7/openfoam7/Test-Tutorials/incompressible/icoFoam/cavity/urohr/system/snappyHexMeshDict.castellatedMeshControls"

Read your error messeges. There is no refinementSurfaces in castellatedMeshControls subdictionary


Look at the Flange tutorial once again. This input tells us, that we want to refine our surface region (or not)

Code:
refinementSurfaces
    {
        flange
        {
            // Surface-wise min and max refinement level
            level (2 2); // level (0 0);
        }
    }
Second thing:
You're trying to provide multiple STLs insead of one STL with multiple regions. That might cause later issues, because sHM looks for one closed surface (not 4 separate ones)


each of your stls can look like:
Code:
solid regionName01
 facet normal -1.000000e+00  0.000000e+00  0.000000e+00
   outer loop
     vertex  0.000000e+00  0.000000e+00  0.000000e+00
     vertex  0.000000e+00  0.000000e+00  5.000000e-02
     vertex  0.000000e+00  5.000000e-02  0.000000e+00
   endloop
 endfacet
 [............. multiple face definitions .............]
 facet normal  0.000000e+00  0.000000e+00  1.000000e+00
   outer loop
     vertex  5.000000e-02  1.000000e-01  1.000000e-01
     vertex  0.000000e+00  5.000000e-02  1.000000e-01
     vertex  1.000000e-01  5.000000e-02  1.000000e-01
   endloop
 endfacet
endsolid regionName01
this regionName01 (e.g. wandm) names your region inside STL. There is often no name specified (software dependent thing), so you can add it manually.
To merge your stls into one stl with regions you can copypaste its contents to one file or use linux concatenation command in the terminal:
Code:
cat inletm.stl outletm.stl wandm.stl > myGeometry.stl
Your geometry field should look like this:
Code:
geometry
{
    myGeometry.stl
    {
        type triSurfaceMesh;
        name Geometry;
        regions
        {
           inletm    {name inlet;       }
           outletm     {name outlet;        }
           wandm     {name wand;       }
        }
    }    
}
And then you can specify refinementSurfaces entry like:
Code:
refinementSurfaces
    {
        Geometry
        {
        level (1 1); 
          
          regions
          {
             inletm     { level (0 1); patchInfo    { type patch;     }}
             outletm    { level (0 1); patchInfo    { type patch;     }}
             wandm        { level (1 2); patchInfo    { type wall;     }}
          }
        }
    }
this patchInfo might be important later, because different patch types allow different boundary conditions (like wall functions, symmetry or inlet/outlet specification)


There is also a bracket "}" missing in your layer specification, it will yield strange error messages.
piotr.mecht is offline   Reply With Quote

Old   September 30, 2019, 04:53
Default
  #12
New Member
 
Join Date: Sep 2019
Posts: 8
Rep Power: 6
Mi95 is on a distinguished road
Hey guys,

i fixed the problem with the meshing, running snappy hex mesh now works.

But when i run the icofoam solver i am not able to view the results in paraView.

After the simulation i inserted "paraFoam &" command to open up the results.

it loads in the geometry but when i try to look at the first timestep it closes down paraview with the error:

foam fatal error:
size 17532 is not equal to the given value of 6706

file:../0.005/ p from line 18 to 117613

i assume that it has something to do with addressing my "p" boundary file but i dont know how to fix it.

Do you have any ideas?

best regards
Mi95 is offline   Reply With Quote

Old   September 30, 2019, 14:50
Default
  #13
Member
 
Piotr Ładyński
Join Date: Apr 2017
Posts: 55
Rep Power: 8
piotr.mecht is on a distinguished road
If you used 'search' option you would find some threads with similiar issue, like:
Error size 400 is not equal to the given value of 1681


BUT


I have this strange feeling that there might be some different thing happening. If you played with snappyHexMesh without -overwrite option before, you might have left some leftover mesh file (polyMesh folder) e.g. from castelated stage in 0.005 directory. Paraview tries to display your result, but it tries to map them on different mesh (with different number of cells, locted in 0.005 folder maybe). If my suspicion is correct, you should delete any unnecessary polyMesh folder in every timestep. The only polyMesh folder you need in icoFoam should be located in constant directory.

It is possible in OpenFOAM to have separate meshes for each timestep in some solvers (with moving or adapting mesh) so Paraview interpretation is that you probably want to display your result that way.


If my suspicion wasn't correct, please use search option. Someone has probably encountered similiar issue before.
Mi95 likes this.
piotr.mecht is offline   Reply With Quote

Reply

Tags
meshing 3d, open foam, pre processing

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ansys Beginner, How to Make a cross section in a specific plane in design modeler arrman ANSYS 2 January 22, 2020 09:30
Meshing around a triangular cross section in ICEM ujjwalmohanty Mesh Generation & Pre-Processing 6 August 27, 2018 03:40
[Workbench] result in a cross section ssmnd ANSYS Meshing & Geometry 0 October 28, 2017 20:48
[Commercial meshers] converting Fluent mesh to openfoam standard mesh deepesh OpenFOAM Meshing & Mesh Conversion 31 March 29, 2017 06:59
+ shape circular pipe - meshing possible? Selina Tracy Main CFD Forum 2 January 16, 2003 14:31


All times are GMT -4. The time now is 18:32.