How to extract raw data from OpenFOAM using sampleDict

We often need to take the data on a specific point. In OpenFOAM we can use sampleDict utility.

In the sampleDict file, we can add the following line for extracting data on a set of specific points.

curve // name of the file (can be any name)
{
type cloud; //type cloud for arbitrary ponits
axis xyz; // the points are scattred in xyz direction
points // list of points
(
(3.93 0.28 0.7897)
(5.93 0.28 1.2)
(7.93 0.28 2.2)
);
}

SnappyHexMesh: How to get a smooth mesh

This post explains briefly how can we get a smooth mesh when using the snappyHexMesh in OpenFOAM 2.0.

The main ingredient is the ‘surfaceFeatureExtract’ utility.

Here are the steps:

1- blockMesh: the BCs can be defined here, example: inlet and outlet patches.

2- extract the surface edge from the .stl file, example: tank.stl
command : “surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/tank.stl features”

this utiliy will create .eMesh file in /constant/triSurface/ : example tank.eMesh

3- in the snappyHexMeshDict, edge refinement is made by referring the eMesh file name, example: tank.eMesh.

4- run the snappyHexmesh utility.

Enjoy!

yPlus

This post is about how to calculate yPlus in OpenFOAM.

For RANS
1) with wall function; simply type ‘yPlusRAS’
2) without wall function;
i- type wallShearStress
ii- calculate manually: y+ = sqrt(wallShearStress/rho) * y/nu
y = height of the cell near to the wall
nu = kinematic viscosity.

For LES
1_ simply type ‘yPlusLES’

enjoy!

transformPoints

This post is for OpenFOAM user.

Most of the times, we need to import CAD drawing to OpenFOAM, especially for the complex geomtery. The dimension in the drawing somehow may changes after we imported into OpenFOAM.

with ‘transformPoints’ utilitiy, we can manipulate the coordinate of the imported file to our requirement. Refer to this site for complete explanation:

https://openfoamwiki.net/index.php/TransformPoints

Example: if we want to scale the CAD drawing to a factor of 0.01 in x and y directions:

>> tranformPoints -scale ‘(0.01 0.01 1)’

if the surface is not smooth (due to the sudden change in geometry) use surfaceFeatureExtractDict, e.g.: tutorials/mesh/snappyHexMesh/flange

or snapEdgeDict http://openfoamwiki.net/index.php/Contrib_snapEdge

 

/*——————————–*- C++ -*———————————-*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.7                                   |
|   \\  /    A nd           | Web:      http://www.OpenFOAM.org               |
|    \\/     M anipulation  |                                                 |
\*—————————————————————————*/
FoamFile
{
version     2.0;
format      ascii;
class       dictionary;
location    “constant”;
object      snapEdgeDict;
}

snapEdgeDict
{

/*snapPatches
(
);

snapZones
(
);*/

stlFileNames
(
square.stl
);

// only move those points that are closer to the features than the tolerance*| edge length |
tolerance 1.9;

// 1.0 = move the points to the edge, 0 = dont move the point
// under-relaxation works better with many iterations to capture corners
relaxation 0.1;

// number of iterations to move points towards edge
nIterations 15;

// set to yes if edges inside a patch should be included
// set to no if only the edges of the patch should be moved
// in general: set this to no to get optimal mapping of inlet/outlet patches
// this ensures that wall-faces and inlet/outlet-faces are mapped to correct positions
includeInterior yes;

// resolve all features with greater angle than this
featureAngle 90.0;

// do not snap edges with an angle greater than this to the feature line
excludeEdgeAngle 60;

// used when selecting between multiple edges to map to the same position
// if the angle is above this value
//     the choice will be based on which edge has the smallest angle to feature line
// otherwise
//     the choice will be based on which edge is closest
parallelAngle 50.0;

// allow for small overlap when fitting the edges to feature lines
fitFactor 1.0e-2;

}

enjoy!

Extract data from log file OpenFOAM

OpenFOAM version 2.3.0 has a new feature for its sixDoFRigidBodyMotion solver. There is no celldisplacement field in the time steps so we cannot use probe to extract data of the mesh displacement. But, if we like to extract the data, we can use extractData command.

Example, In the ./case/extractData

grep “Centre of mass” $1 | cut -d “:” -f 2 | cut -d ” ” -f 3 | tr -d “)” > cM
grep “Linear velocity” $1 | cut -d “:” -f 2 | cut -d ” ” -f 4 | tr -d “)” > lV
grep -e “^Time = ” $1 | cut -d ” ” -f 3 > times

paste times cM > t_vs_cm
paste times lV > t_vs_lv

rm cM lV times

After run the case, example: >> mpirun -np 2 pimpleDyMFoam -parallel > log &
Then type >> ./extractData log

You can find new files are created that contain you needed data.

enjoy!

subset: a mesh manipulation in OpenFOAM

Example: flow over a cube

1) create a computational domain using blockMesh (Hexagonal)

2) using toposetDict, define the geometry of the cube:

actions
(

{
name blockFaces;
type cellSet;
action new;
source boxToCell;
sourceInfo
{
box (-2 -2 -2)(2 2 2);
}
}

{
name blockFaces;
type cellSet;
action invert;

}

);

3) run “toposet” in the terminal

4) run “subsetMesh -overwrite blockFaces -patch block” in the terminal

5) check your mesh using paraview

OpenFOAM Roadshow 01-2013

Thanks to Dr. Azli of UiTM for hosting the 1st OpenFOAM roadshow for Malaysia CFD community. It was a successful event with the spirit to spread the awareness and usage of Free and Open Source Software. Thanks also goes to the participants (uni. staff and industry) who have committed to form a strong OpenFOAM discussion group in Malaysia.

Let me know if you like to join our discussion group.

 

OpenFOAM Malaysia Discussion Group

OpenFOAM is a free CFD software package and it has large no. of users and it keeps growing. In Malaysia, OpenFOAM users are still small but there are many inquiries on how they can switch from commercial softwares to OpenFOAM.

Therefore, we would like to invite you to join an informal discussion on how can we fully utilise this free yet reliable CFD software package.

You present in the discussion is really appreciated. Looking forward to see you there.

Venue: OldTown White Coffee, 1st Ground Floor, Jalan Radin Annum, 57000 Kuala Lumpur

Time: 7 Sept 2013, Saturday, 11am – 1pm

Agenda: Informal discussion yet informative for CFD users to know about OpenFOAM. You can also propose to the group a suitable case study for us to develop our OpenFOAM skills.