CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[blockMesh] about Hex at blockMeshDict

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By aow
  • 1 Post By aow

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 7, 2018, 20:33
Default about Hex at blockMeshDict
  #1
New Member
 
Arisna Fauzia
Join Date: Feb 2018
Location: Aceh, Indonesia
Posts: 3
Rep Power: 8
arisna is on a distinguished road
Hello everyone,
Could you explain to me about hex ?
for instance :
blocks
(
hex (0 1 5 4 12 13 17 16) (23 8 1) simpleGrading (1 1 1)
hex (2 3 7 6 14 15 19 18) (19 8 1) simpleGrading (1 1 1)
...
I dont know about (23 8 1), do you know?
please tell me,
thank you!
arisna is offline   Reply With Quote

Old   March 7, 2018, 21:40
Default
  #2
Senior Member
 
Join Date: Aug 2013
Posts: 407
Rep Power: 15
Antimony is on a distinguished road
Hi,

(23 8 1) in this case means 23 cells in the first direction (x or x1, however you want to call it), 8 cells in the second direction (y or x2) and 1 cell in the third direction (z or x3)

You can find the details here: https://cfd.direct/openfoam/user-guide/blockmesh/

Cheers,
Antimony
Antimony is offline   Reply With Quote

Old   March 8, 2018, 05:48
Default
  #3
New Member
 
Arisna Fauzia
Join Date: Feb 2018
Location: Aceh, Indonesia
Posts: 3
Rep Power: 8
arisna is on a distinguished road
Thank you for your explain.
oh i see, that is to get the grid in 1 box or 1 volume ?

best,
arisna

Quote:
Originally Posted by Antimony View Post
Hi,

(23 8 1) in this case means 23 cells in the first direction (x or x1, however you want to call it), 8 cells in the second direction (y or x2) and 1 cell in the third direction (z or x3)

You can find the details here: https://cfd.direct/openfoam/user-guide/blockmesh/

Cheers,
Antimony
arisna is offline   Reply With Quote

Old   May 31, 2018, 22:36
Default
  #4
aow
Member
 
Andrew O. Winter
Join Date: Aug 2015
Location: Seattle, WA, USA
Posts: 78
Rep Power: 10
aow is on a distinguished road
Those 3 numbers of cells in the x, y, and z directions only apply to a single hex. In your example, you have 2 hexes with each one having the same numbers of cells in the y and z directions, but different numbers of cells in the x direction. You would want the y and z cell numbers to be the same if you intended to connect the two hexes as a single mesh object. This approach is called face matching with the alternative being face merging; however, without seeing the rest of your blockMeshDict it is impossible to tell if this is the case. If you have more questions, you should post the entire blockMeshDict in a code block so it's easy to read.
aero.rajat likes this.
aow is offline   Reply With Quote

Old   August 31, 2018, 02:41
Question flow on the sharp crested triangle weir
  #5
New Member
 
ceren's Avatar
 
ceren cilavdaroğlu
Join Date: Aug 2018
Location: Turkey
Posts: 6
Rep Power: 7
ceren is on a distinguished road
i have a triangle weir. i am trying execute blockmeshdict. this is 3D. i cant do that unfortunately.
have you done it before or like this?

i need guidance..

https://swmm5.org/2016/09/04/weir-background-equations-for-swmm5-and-infoswmm/

Last edited by ceren; September 1, 2018 at 04:18. Reason: i tried edding picture
ceren is offline   Reply With Quote

Old   August 31, 2018, 15:03
Default
  #6
aow
Member
 
Andrew O. Winter
Join Date: Aug 2015
Location: Seattle, WA, USA
Posts: 78
Rep Power: 10
aow is on a distinguished road
Hi Ceren,

Can you post the details of your geometry and the blockMeshDict that you attempted to use? Then I can try to help you.

As an initial suggestion though, if you want to make a triangular shaped hex region, you need to collapse nodes on top of each other so that 2 pairs of nodes overlap. This is demonstrated in the OpenFOAM User Guide (see image below).



Your blockMeshDict entries for such a hex would be something like...

hex (0 1 2 3 4 5 5 4)

and the "collapsed" patch has an area of zero, which means you should give it the empty boundary condition for files in your 0 directory. The patches describing the hex faces should be something like...

(0 1 2 3)
(1 2 5 5)
(0 3 4 4)
(0 1 5 4)
(2 5 4 3)
(4 5 5 4)

A more complete description can be found at...

https://cfd.direct/openfoam/user-guide/v6-blockmesh/

...and looking at section 5.3.5 Creating blocks with fewer than 8 vertices.

Best,

Andrew
aow is offline   Reply With Quote

Old   August 31, 2018, 15:18
Default
  #7
aow
Member
 
Andrew O. Winter
Join Date: Aug 2015
Location: Seattle, WA, USA
Posts: 78
Rep Power: 10
aow is on a distinguished road
Also, it might make some sense to just make a large rectangular channel using blockMesh and then import an .stl surface file that has your weir geometry using snappyHexMesh. I had forgotten what a triangle weir looks like and it might be a bit annoying to do using blockMesh alone.

You can make a 3D solid in a program like Autodesk's Inventor and then export it as an .stl file (stereolithography file, which makes a surface out of triangles using unit normal vectors and the coordinates of the triangle corner points). However, before using snappyHexMesh, you would need to extract data from the .stl file using the surfaceFeatureExtract command. Also, your .stl file would need to be placed in <yourCaseDirectory>/constant/trisurface and then you need surfaceFeatureExtractDict in <yourCaseDirectory>/system along with all of the other necessary files.

Then you can build the case with the following commands...

blockMesh
surfaceFeatureExtract
snappyHexMesh
setFields

If your model is very complex in terms of the amount cells you want to use or you want to refine certain regions a lot, then you can run snappyHexMesh in parallel as follows...

decomposePar -copyZero
mpirun -np <numberOfProcessors> snappyHexMesh -parallel
reconstructParMesh -mergeTol 1e-06 -time <lastestTime>
reconstructPar -time <latestTime>

In the above commands, "latestTime" = (number of snappyHexMesh operations)*(time step from controlDict). The 3 possible snappyHexMesh operations are "castellatedMesh", "snap", and "addLayers", which are specified to be either true or false at the beginning of snappyHexMeshDict. The number of these operations that are set to be true is the amount to use when determining "latestTime".

Good luck!
aow is offline   Reply With Quote

Old   September 1, 2018, 04:26
Default
  #8
New Member
 
ceren's Avatar
 
ceren cilavdaroğlu
Join Date: Aug 2018
Location: Turkey
Posts: 6
Rep Power: 7
ceren is on a distinguished road
https://swmm5.files.wordpress.com/2016/09/image0096.jpg


hi Andrew,



thank you for your answer. i tried adding picture. i am checking over your writing. I hope I can solve this problem.



thanks again.
ceren

Last edited by ceren; September 1, 2018 at 04:27. Reason: about picture
ceren is offline   Reply With Quote

Old   September 17, 2018, 21:00
Default Triangular Weir Example
  #9
aow
Member
 
Andrew O. Winter
Join Date: Aug 2015
Location: Seattle, WA, USA
Posts: 78
Rep Power: 10
aow is on a distinguished road
Hey Ceren,

I had a chance to look over the triangular weir problem a bit more and make a demonstration of how to execute the suggestions I gave in my previous post. I attached the case directory I created so you can directly see everything discussed below.

I used Autodesk's Inventor to draw the triangular weir shape with lines to create a closed shape outline and then extruded this shape as a 3D solid. Next I used the export option to save the model as an .stl file, which is how it should be saved for use with OpenFOAM. The image below illustrates the result of these steps.

Triangle Weir Outline with Extruded 3D Solid:



To create this example, the weirOverflow tutorial, for which the path should be something like ./OpenFOAM-x.x/tutorials/multiphase/interFoam/RAS/weirOverflow, where x.x is the version number, was copied and heavily modified to create what I hope is a reasonably straightforward example.

In the constant directory, a directory named triSurface was added. Then the weir .stl file, TriangleWeir.stl, was placed in the triSurface directory. Additionally, the gravity file g was adjusted to be (0 0 -9.81) so that the acceleration vector was acting in the negative z-axis direction instead of the negative y-axis direction. This was necessary based on the coordinate system I chose to draw the triangle weir in.

Next, the geometry and initial condition files were modified as described below. Note that the files decomposePar, meshQualityDict, surfaceFeatureExtractDict, and snappyHexMeshDict were added to the system directory of the tutorial. Also, the headers and all comments were omitted for each file in this post to save space, but they are included in the attached case files. Additionally, the domain was resized to be 2.0 m long (x-direction), 1.0 m wide (y-direction), and 1.0 m tall (z-direction) with the weir (25 mm thick in x-dir., 1.0 m wide in y-dir., 0.5 m tall in z-dir. with a 90 degree triangle that had its bottom 0.25 m above the bottom of the channel) placed in the middle of the channel.

In the system directory, the following files were modified or added:

blockMeshDict:
Code:
convertToMeters 1;

xI -1;
xJ 1;
yI -0.5;
yJ 0.5;
zI 0.0;
zJ 1.0;

vertices
(
    ($xI $yI $zI)
	($xJ $yI $zI)
	($xJ $yJ $zI)
	($xI $yJ $zI)
	($xI $yI $zJ)
	($xJ $yI $zJ)
	($xJ $yJ $zJ)
	($xI $yJ $zJ)
);

blocks          
(
    hex (0 1 2 3 4 5 6 7)  (100 50 50)  simpleGrading (1 1 1)
);

edges           
(
);

patches
(
	patch inlet
	(
		(0 4 7 3)
	)
	patch outlet
	(
		(1 2 6 5)
	)
	wall bottom
	(
		(0 3 2 1)
	)
	wall right
	(
		(0 1 5 4)
	)
	wall left
	(
		(3 7 6 2)
	)
	patch atmosphere
	(
		(4 5 6 7)
	)
);

mergePatchPairs
(
);
setFieldsDict:
Code:
defaultFieldValues
(
    volScalarFieldValue alpha.water 0
);

regions
(
    boxToCell
    {
        box (-1 -0.5 0) (0 0.5 0.2);

        fieldValues
        (
            volScalarFieldValue alpha.water 1
        );
    }
);
snappyHexMeshDict:
Code:
// Which of the steps to run
castellatedMesh true;
snap            true;
addLayers       false;

geometry
{
	TriangleWeir
	{
		type triSurfaceMesh;
		file "TriangleWeir.stl";
	}
};

castellatedMeshControls
{
    maxLocalCells 10000000;

    maxGlobalCells 200000000;

    minRefinementCells 0;

    nCellsBetweenLevels 3;

    features
    (
    );


    refinementSurfaces
    {
		TriangleWeir
        {
            level    (2  2);
            patchInfo
            {
                type wall;
            }
        }
    }

    // Resolve sharp angles
    resolveFeatureAngle 30;

    refinementRegions
    {
    }

    locationInMesh (0.314159 0.314159 0.314159);

    allowFreeStandingZoneFaces true;
}
    
snapControls
{
    nSmoothPatch 10; // or 15; 
	
    tolerance 4.0;  // or 0.1;
    
    nSolveIter 30;

    nRelaxIter 10;

        nFeatureSnapIter 20;

        implicitFeatureSnap false;

        explicitFeatureSnap true;

        multiRegionFeatureSnap false;
}

addLayersControls
{
    relativeSizes true;

    layers
    {
        suplat
        {
            nSurfaceLayers 2;
        }
    }

    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;
}

meshQualityControls
{
    #include "meshQualityDict"

    nSmoothScale 10;

    errorReduction 0.9;
}

mergeTolerance 1e-6;
meshQualityDict:
Code:
// Include defaults parameters from master dictionary
#includeEtc "caseDicts/meshQualityDict"

minFaceWeight 0.02;
surfaceFeatureExtractDict:
Code:
TriangleWeir.stl
{
    extractionMethod    extractFromSurface;

    extractFromSurfaceCoeffs
    {
        includedAngle   180;
    }

    subsetFeatures
    {
        nonManifoldEdges       no;

        openEdges       yes;
    }

        writeObj                yes;
}
decomposeParDict:
Code:
numberOfSubdomains 32;

method          scotch;

simpleCoeffs
{
    n               ( 4 2 2 );
    delta           0.001;
}

hierarchicalCoeffs
{
    n               ( 1 1 1 );
    delta           0.001;
    order           xyz;
}

metisCoeffs
{
    processorWeights ( 1 1 1 1 );
}

manualCoeffs
{
    dataFile        "";
}

distributed     no;

roots     ();
In the 0 directory, the following files were modified:

include/initialConditions:
Code:
inletFlowRate        0.02451;
pressure             0;
turbulentKE          4.14e-03;
turbulentEpsilon     4.39e-05;
Note that the above flow rate Q~(m^{3}/s) was calculated according to the equation given in the image shown below using H=0.2~m, g=9.81~m/s^{2}, and \theta=90 degrees. The coefficient C_{d} was taken to be 0.58 based on Figure 10.25 on page 599 of "Fundamentals of Fluid Mechanics, Fifth Edition" by Munson, Young, and Okiishi.



alpha.water:
Code:
#include        "include/initialConditions"

dimensions      [0 0 0 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            variableHeightFlowRate;
        lowerBound      0;
        upperBound      1;
        value           uniform 0;
    }

    outlet
    {
        type            zeroGradient;
    }

    bottom
    {
        type            zeroGradient;
    }
	
	left
	{
        type            zeroGradient;
    }
	
	right
	{
        type            zeroGradient;
    }

    atmosphere
    {
        type            inletOutlet;
        inletValue      uniform 0;
        value           uniform 0;
    }
	
	TriangleWeir
    {
        type            zeroGradient;
    }

    defaultFaces
    {
        type            empty;
    }
}
epsilon:
Code:
#include        "include/initialConditions"

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

internalField   uniform $turbulentEpsilon;

boundaryField
{
    inlet
    {
        type            fixedValue;
        value           $internalField;
    }

    outlet
    {
        type			zeroGradient;
		//type            inletOutlet;
        //inletValue      $internalField;
        //value           $internalField;
    }

    bottom
    {
        type            epsilonWallFunction;
        value           $internalField;
    }
	
	left
    {
        type            epsilonWallFunction;
        value           $internalField;
    }
	
	right
    {
        type            epsilonWallFunction;
        value           $internalField;
    }

    atmosphere
    {
        type            inletOutlet;
        inletValue      $internalField;
        value           $internalField;
    }
	
	TriangleWeir
    {
        type            epsilonWallFunction;
        value           $internalField;
    }

    defaultFaces
    {
        type            empty;
    }
}
k:
Code:
#include        "include/initialConditions"

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

internalField   uniform $turbulentKE;

boundaryField
{
    inlet
    {
        type            fixedValue;
        value           $internalField;
    }

    outlet
    {
		type			zeroGradient;
        //type            inletOutlet;
        //inletValue      $internalField;
        //value           $internalField;
    }

    bottom
    {
        type            kqRWallFunction;
        value           $internalField;
    }
	
	left
	{
        type            kqRWallFunction;
        value           $internalField;
    }
	
	right
	{
        type            kqRWallFunction;
        value           $internalField;
    }

    atmosphere
    {
        type            inletOutlet;
        inletValue      $internalField;
        value           $internalField;
    }
	
	TriangleWeir
    {
        type            kqRWallFunction;
        value           $internalField;
    }

    defaultFaces
    {
        type            empty;
    }
}
nut:
Code:
dimensions      [0 2 -1 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            calculated;
        value           uniform 0;
    }
	
    outlet
    {
        type            calculated;
        value           uniform 0;
    }
	
    bottom
    {
        type            nutkWallFunction;
        value           uniform 0;
    }
	
	left
	{
        type            nutkWallFunction;
        value           uniform 0;
    }
	
	right
	{
        type            nutkWallFunction;
        value           uniform 0;
    }
	
    atmosphere
    {
        type            calculated;
        value           uniform 0;
    }
	
	TriangleWeir
    {
        type            nutkWallFunction;
        value           uniform 0;
    }
	
    defaultFaces
    {
        type            empty;
    }
}
p_rgh:
Code:
#include        "include/initialConditions"

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

internalField   uniform $pressure;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
		type            fixedValue;
        value           uniform 0;
        //type            zeroGradient;
    }

    bottom
    {
        type            fixedFluxPressure;
    }
	
	left
	{
        type            fixedFluxPressure;
    }
	
	right
	{
        type            fixedFluxPressure;
    }

    atmosphere
    {
        type            totalPressure;
        p0              uniform 0;
    }
	
	TriangleWeir
    {
        type            fixedFluxPressure;
    }

    defaultFaces
    {
        type            empty;
    }
}
U:
Code:
#include        "include/initialConditions"

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

internalField   uniform (0 0 0);

boundaryField
{
    inlet
    {
        type            variableHeightFlowRateInletVelocity;
        flowRate        $inletFlowRate;
        alpha           alpha.water;
        value           uniform (0 0 0);
    }

    outlet
    {
        type            zeroGradient;
    }

    bottom
    {
        type            noSlip;
    }
	
	left
	{
        type            noSlip;
    }
	
	right
	{
        type            noSlip;
    }

    atmosphere
    {
        type            pressureInletOutletVelocity;
        value           uniform (0 0 0);
    }
	
	TriangleWeir
    {
        type            noSlip;
    }

    defaultFaces
    {
        type            empty;
    }
}
After all the files were modified, the following series of commands was used to construct the case and then run it. Note that since I had access to 32 cores using two computers, I was able to execute the snappyHexMesh and interFoam commands using parallel processing. If you want to use a different amount, just change the 32s to whatever you're going to use and don't forget to also change the number in your decomposeParDict file too, or else OpenFOAM will give an error output.

Code:
rm -r 0
cp -r 0.org 0
blockMesh > log.blockMesh
surfaceFeatureExtract > log.surfFeatExt
decomposePar -copyZero > log.decompPar_sHM
mpirun -np 32 snappyHexMesh -parallel > log.sHM
reconstructParMesh -mergeTol 1e-06 -time '0.002' > log.sHMreconParMesh
reconstructPar -time '0.002' > log.reconPar_sHM
cp -r ./0.002/polyMesh/* ./constant/polyMesh
rm -r ./0.002
rm -r processor*
setFields > log.setFields
decomposePar > log.decompPar_run
mpirun -np 32 interFoam -parallel > log.interFoam 2>&1
The mesh created by snappyHexMesh is shown below. Here you can see the 2 levels of refinement with 3 cells between each level, which were specified in the snappyHexMeshDict file.



Finally, a pretty result image! This image was generated for the system state at 9 seconds of simulated time (I changed the writeInterval parameter in ./system/controlDict to be 1 instead of 2). Also, the surface was shaded according to the velocity magnitude.

Attached Files
File Type: zip weirOverflow-Modified.zip (15.9 KB, 20 views)
music_of_emotion likes this.
aow is offline   Reply With Quote

Reply


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
[blockMesh] --> FOAM FATAL ERROR: Trying to specify a boundary face A.A. OpenFOAM Meshing & Mesh Conversion 41 June 26, 2020 07:06
[blockMesh] Openfoam: Meshing, where do my defaultFaces come from syntex OpenFOAM Meshing & Mesh Conversion 19 December 10, 2018 07:21
[Other] mergeMatchPairs with arcs vainilreb OpenFOAM Meshing & Mesh Conversion 1 August 5, 2013 08:11
[blockMesh] apparently the mesh doesn't want to be created in one direction Maxime Thomas OpenFOAM Meshing & Mesh Conversion 1 August 18, 2012 06:05
CheckMeshbs errors ivanyao OpenFOAM Running, Solving & CFD 2 March 11, 2009 02:34


All times are GMT -4. The time now is 10:28.