Wednesday, July 15, 2015
Calculate inlet conditions for k-epsilon
How to estimate k and epsilon for inlet
k=1.5*(I*U)^2where I is turbulence intensity and U is velocity, k is turbulent kinetic energy
epsilon=C_mu^0.75*k^1.5/L
where C_mu=0.09, epsilon is dissipation rate, L is the mixing length
for OpenFOAM easy conditions to specify are
turbulentIntensityKineticEnergyInlet for k
inlet{
type turbulentIntensityKineticEnergyInlet;
intensity 0.05 ;
value uniform .05; //dummy value
}
turbulentMixingLengthDissipationRateInlet for epsilon
inlet{
type turbulentMixingLengthDissipationRateInlet;
mixingLength 0.01; //m
value uniform 0.01; // dummy
}
see description by ESI
or https://en.wikipedia.org/wiki/Turbulence_kinetic_energy
http://www.cfd-online.com/
Friday, July 10, 2015
How to use topoSet to generate a circular inlet patch with OpenFOAM
Allrun script
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
rm log.*
rm 0 -r
cp 0.org 0 -r
# And execute
runApplication blockMesh
runApplication topoSet
runApplication createPatch -overwrite
runApplication decomposePar -force
runParallel `getApplication` 4
runApplication reconstructPar
# ----------------------------------------------------------------- end-of-file
topoSetDict
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name jetCells;
type cellSet;
action new;
source cylinderToCell;
sourceInfo
{
p1 (0 0 0); // start point on cylinder axis
p2 (0 .051 0); // end point on cylinder axis
radius .008;
}
}
{
name f0;
type faceSet;
action new;
source cellToFace;
sourceInfo
{
set jetCells;
option all;
}
}
{
name f0;
type faceSet;
action subset;
source boxToFace;
sourceInfo
{
box (-.1 0.024 -.1) (.1 .026 .1);
//boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
}
}
);
// ************************************************************************* //
createPatchDict
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
// a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
// is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.
// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
// and centre to make matching easier
// - always create both halves in one invocation with correct 'neighbourPatch'
// setting.
// - optionally pointSync true to guarantee points to line up.
// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
// "face 0 area does not match neighbour 2 by 0.0100005%"
// " -- possible face ordering problem."
// - in polyMesh/boundary file:
// - loosen matchTolerance of all cyclics to get case to load
// - or change patch type from 'cyclic' to 'patch'
// and regenerate cyclic as above
// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
// with transformations (i.e. cyclics).
pointSync false;
// Patches to create.
patches
(
{
// Name of new patch
name inlet;
// Type of new patch
patchInfo
{
type patch;
}
// How to construct: either from 'patches' or 'set'
constructFrom set;
// If constructFrom = patches : names of patches. Wildcards allowed.
patches ("periodic.*");
// If constructFrom = set : name of faceSet
set f0;
}
);
// ************************************************************************* //
How to automate renaming of STL patches without Salome using only OpenFOAM surface utilities and a script
This describes how to automate naming of patches of the stl file without using Salome or other software but with native OpenFOAM tools and a bash script. This is for use with cfMesh but a similar approach could be used with snappyHexMesh.
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
rm log.*
rm -r input
rm -r output
mkdir input
mkdir output
# split stl into inlet and walls
runApplication surfaceSubset system/surfaceSubsetDictInlet constant/triSurface/input.stl input/inlet.stl
mv log.surfaceSubset log.surfaceSubsetInlet
runApplication surfaceSubset system/surfaceSubsetDictRInlet constant/triSurface/input.stl input/walls.stl
mv log.surfaceSubset log.surfaceSubsetInletR
# split walls into outlet and walls
runApplication surfaceSubset system/surfaceSubsetDictOutlet input/walls.stl input/outlet.stl
mv log.surfaceSubset log.surfaceSubsetInletROutlet
runApplication surfaceSubset system/surfaceSubsetDictROutlet input/walls.stl input/walls.stl
mv log.surfaceSubset log.surfaceSubsetInletROutletR
# combine files
../../scripts/./stlCombine input output
#generate fms file with edges but retaining patches
runApplication surfaceFeatureEdges output/mergedStl.stl output/elbow.fms -angle 45
#generate mesh
runApplication cartesianMesh
#change definitions of patches
runApplication changeDictionary
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object surfaceSubsetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Select triangles by label
faces ();//#include "badFaces";
// Select triangles using given points (local point numbering)
localPoints ( );
// Select triangles using given edges
edges ();
// Select triangles (with face centre) inside box
zone
(
(.507 .25 -.101)
(.509 .36 .101)
);
// Select triangles (with face centre) inside or outside of another surface.
// (always selects triangles that are 'on' other surface)
/*
surface
{
name "sphere.stl";
outside yes;
}
// Select triangles on plane
plane
{
planeType embeddedPoints;
embeddedPointsDict
{
//point1 (-937.259845440205 160.865349115986 240.738791238078);
//point2 (-934.767379895778 9.63875523747379 14.412359671298);
//point3 (44.4744688899417 121.852927962709 182.352485273106);
point1 (-957.895294591874 242.865936478961 162.286611511875);
point2 (-961.43140327772 4.53895551562943 3.04159982093444);
point3 (91.2414146173805 72.1504381996692 48.2181961945329);
}
// Distance from plane
distance 0.1;
// Normal difference to plane
cosAngle 0.99;
}
*/
// Extend selection with edge neighbours
addFaceNeighbours no;
// Invert selection
invertSelection false;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | cfMesh: A library for mesh generation |
| \\ / O peration | |
| \\ / A nd | Author: Franjo Juretic |
| \\/ M anipulation | E-mail: franjo.juretic@c-fields.com |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object meshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
surfaceFile "output/elbow.fms";
maxCellSize .05;
boundaryCellSize .0049;
minCellSize .0049;
localRefinement
{
walls
{
cellSize 0.0025;
}
}
boundaryLayers
{
nLayers 1;
thicknessRatio 1.1;
maxFirstLayerThickness 0.003;
patchBoundaryLayers
{
"walls.*"
{
nLayers 3;
thicknessRatio 1.2;
maxFirstLayerThickness .005;
allowDiscontinuity 0;
}
}
}
/*
renameBoundary
{
defaultName junk;
defaultType wall;
newPatchNames
{
"inl.*"
{
newName testo;
newType patch;
}
}
}*/
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object changeDictionaryDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary
{
"inlet"
{
type patch;
}
"outlet"
{
type patch;
}
"walls"
{
name walls;
type wall;
}
}
}
// ************************************************************************* //
Allmesh Script
#!/bin/shcd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
rm log.*
rm -r input
rm -r output
mkdir input
mkdir output
# split stl into inlet and walls
runApplication surfaceSubset system/surfaceSubsetDictInlet constant/triSurface/input.stl input/inlet.stl
mv log.surfaceSubset log.surfaceSubsetInlet
runApplication surfaceSubset system/surfaceSubsetDictRInlet constant/triSurface/input.stl input/walls.stl
mv log.surfaceSubset log.surfaceSubsetInletR
# split walls into outlet and walls
runApplication surfaceSubset system/surfaceSubsetDictOutlet input/walls.stl input/outlet.stl
mv log.surfaceSubset log.surfaceSubsetInletROutlet
runApplication surfaceSubset system/surfaceSubsetDictROutlet input/walls.stl input/walls.stl
mv log.surfaceSubset log.surfaceSubsetInletROutletR
# combine files
../../scripts/./stlCombine input output
#generate fms file with edges but retaining patches
runApplication surfaceFeatureEdges output/mergedStl.stl output/elbow.fms -angle 45
#generate mesh
runApplication cartesianMesh
#change definitions of patches
runApplication changeDictionary
surfaceSubsetDictInlet file
/*--------------------------------*- C++ -*----------------------------------*\| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object surfaceSubsetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Select triangles by label
faces ();//#include "badFaces";
// Select triangles using given points (local point numbering)
localPoints ( );
// Select triangles using given edges
edges ();
// Select triangles (with face centre) inside box
zone
(
(.507 .25 -.101)
(.509 .36 .101)
);
// Select triangles (with face centre) inside or outside of another surface.
// (always selects triangles that are 'on' other surface)
/*
surface
{
name "sphere.stl";
outside yes;
}
// Select triangles on plane
plane
{
planeType embeddedPoints;
embeddedPointsDict
{
//point1 (-937.259845440205 160.865349115986 240.738791238078);
//point2 (-934.767379895778 9.63875523747379 14.412359671298);
//point3 (44.4744688899417 121.852927962709 182.352485273106);
point1 (-957.895294591874 242.865936478961 162.286611511875);
point2 (-961.43140327772 4.53895551562943 3.04159982093444);
point3 (91.2414146173805 72.1504381996692 48.2181961945329);
}
// Distance from plane
distance 0.1;
// Normal difference to plane
cosAngle 0.99;
}
*/
// Extend selection with edge neighbours
addFaceNeighbours no;
// Invert selection
invertSelection false;
// ************************************************************************* //
surfaceSubsetDictInletR change invertSelection true;
surfaceSubsetDictOutlet change coordinates of
box;surfaceSubsetDictOutletR change invertSelection true;
stlCombine code from Kruno at
https://openfoamwiki.net/index.php/Thread:Talk:Sig_Numerical_Optimization/Salome_and_cfMesh_parametrizationmeshDict for cfMesh
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | cfMesh: A library for mesh generation |
| \\ / O peration | |
| \\ / A nd | Author: Franjo Juretic |
| \\/ M anipulation | E-mail: franjo.juretic@c-fields.com |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object meshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
surfaceFile "output/elbow.fms";
maxCellSize .05;
boundaryCellSize .0049;
minCellSize .0049;
localRefinement
{
walls
{
cellSize 0.0025;
}
}
boundaryLayers
{
nLayers 1;
thicknessRatio 1.1;
maxFirstLayerThickness 0.003;
patchBoundaryLayers
{
"walls.*"
{
nLayers 3;
thicknessRatio 1.2;
maxFirstLayerThickness .005;
allowDiscontinuity 0;
}
}
}
/*
renameBoundary
{
defaultName junk;
defaultType wall;
newPatchNames
{
"inl.*"
{
newName testo;
newType patch;
}
}
}*/
// ************************************************************************* //
changeDictionaryDict
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object changeDictionaryDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
boundary
{
"inlet"
{
type patch;
}
"outlet"
{
type patch;
}
"walls"
{
name walls;
type wall;
}
}
}
// ************************************************************************* //
Wednesday, July 8, 2015
Saturday, March 22, 2014
Saturday, March 1, 2014
Side view of air jet from converging nozzle into a bucket of water
This is the same as the jet from the converging nozzle but is viewed from the side. I cut out part of the bucket and replaced it with polycarbonate. It is played back in full in real time and then 32 times slower for the first part of the video.
Subscribe to:
Posts (Atom)
