Skip to content
Snippets Groups Projects
Commit 33f2559a authored by mattijs's avatar mattijs
Browse files

ENH: relativeMotion: new tutorial demonstrating relative motion

parent 0211b0a4
Branches
Tags
No related merge requests found
Showing
with 927 additions and 0 deletions
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
(
cd box_snappyHexMesh || exit 1
cleanCase
)
(
cd box2D_moveDynamicMesh || exit 1
cleanCase
rm -rf 0
)
#------------------------------------------------------------------------------
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
# Make 3D mesh in slab of cells.
(
cd box_snappyHexMesh || exit 1
runApplication blockMesh
runApplication snappyHexMesh -overwrite
runApplication renumberMesh -overwrite
runApplication createPatch -overwrite
)
# Make a 2D mesh by extruding a patch and solve to steady state.
(
cd box2D_moveDynamicMesh || exit 1
runApplication extrudeMesh
restore0Dir
runApplication moveDynamicMesh -checkAMI
)
#------------------------------------------------------------------------------
Testcase demonstrating combining solid body motion solver
with a Laplacian mesh distortion solver.
There is a outer cylinder, spinning with a constant rpm. Inside
this a smaller cylinder counter-spins (so with constant but opposite
rpm). Finally inside this smaller cylinder there is relative motion
between two blocks (using boundary conditions and a mesh distortion solver).
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus-overset |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0.034";
object cellDisplacement;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
sides
{
type uniformFixedValue;
uniformValue (0 0 0);
}
inlet
{
type uniformFixedValue;
uniformValue (0 0 0);
}
outlet
{
type uniformFixedValue;
uniformValue (0 0 0);
}
"wing.*"
{
type cellMotion;
value uniform (0 0 0);
}
AMI_dualWing
{
patchType cyclicAMI;
type cellMotion;
value uniform (0 0 0);
}
AMI_dualWing_slave
{
patchType cyclicAMI;
type cellMotion;
value uniform (0 0 0);
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class pointVectorField;
location "0";
object pointMotionU;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
inlet
{
type fixedValue;
value $internalField;
}
outlet
{
type fixedValue;
value $internalField;
}
sides
{
type fixedValue;
value $internalField;
}
wing1
{
type fixedValue;
value $internalField;
}
wing2
{
// Make wing2 rotate around its centre
type solidBodyMotionDisplacement;
solidBodyMotionFunction oscillatingRotatingMotion;
oscillatingRotatingMotionCoeffs
{
origin (-0.41 0 0);
axis (0 0 1);
omega 10; // rad/s, 1rad/s=9.5rpm
amplitude (0 0 10); // max amplitude (degrees)
}
}
AMI_dualWing
{
patchType cyclicAMI;
type fixedValue;
value $internalField;
}
AMI_dualWing_slave
{
patchType cyclicAMI;
type fixedValue;
value $internalField;
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicMultiMotionSolverFvMesh; //dynamicMotionSolverFvMesh;
// Specification of rotation around centre
rotation1
{
solidBodyMotionFunction rotatingMotion;
rotatingMotionCoeffs
{
origin (0 0 0);
axis (0 0 1);
omega 10; // rad/s, 1rad/s=9.5rpm
}
}
dynamicMultiMotionSolverFvMeshCoeffs
{
rotor1
{
solver solidBody;
cellZone rotor;
solidBodyCoeffs
{
$rotation1;
}
}
dualWing1
{
cellZone dualWing;
// Solve displacement on top of solid-body rotation
solver solidBodyDisplacementLaplacian;
solidBodyDisplacementLaplacianCoeffs
{
solidBodyMotionFunction multiMotion;
multiMotionCoeffs
{
rotation_1
{
$rotation1;
}
rotation_2
{
// Apply counter rotation to keep dualWing aligned
solidBodyMotionFunction rotatingMotion;
rotatingMotionCoeffs
{
origin (-0.43 0 0);
axis (0 0 1);
omega -10; // rad/s, 1rad/s=9.5rpm
}
}
}
diffusivity quadratic inverseDistance (wing2);
}
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-6;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
RAS
{
RASModel kEpsilon;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
libs ("libfvMotionSolvers.so");
application moveDynamicMesh;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.5;
deltaT 0.002;
writeControl timeStep;
writeInterval 5;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 0.4;
maxDeltaT 1;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method hierarchical;
hierarchicalCoeffs
{
n (2 2 1);
delta 0.001;
order xyz;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object extrudeMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// What to extrude:
// patch : from patch of another case ('sourceCase')
// mesh : as above but with original case included
// surface : from externally read surface
constructFrom patch;
sourceCase "../box_snappyHexMesh";
sourcePatches (ZMin);
// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName ZMax;
// Flip surface normals before usage. Valid only for extrude from surface or
// patch.
flipNormals true;
//- Linear extrusion in point-normal direction
extrudeModel linearNormal;
nLayers 1;
expansionRatio 1.0;
linearNormalCoeffs
{
thickness 0.1;
}
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces false; //true;
// Merge small edges. Fraction of bounding box.
mergeTol 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
grad(U) cellLimited Gauss linear 1;
}
divSchemes
{
default none;
// div(phi,U) Gauss upwind;
div(phi,U) Gauss linearUpwind grad(U);
div(phi,k) Gauss upwind;
div(phi,epsilon) Gauss upwind;
div((nuEff*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear limited corrected 0.33;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default limited corrected 0.33;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"cellDisplacement.*"
{
solver GAMG;
tolerance 1e-8;
relTol 0;
smoother GaussSeidel;
cacheAgglomeration true;
nCellsInCoarsestLevel 10;
agglomerator faceAreaPair;
mergeLevels 1;
}
}
PIMPLE
{
correctPhi no;
nOuterCorrectors 1;
nCorrectors 2;
nNonOrthogonalCorrectors 0;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-6;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
RAS
{
RASModel kEpsilon;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(-1 -1 0)
( 1 -1 0)
( 1 1 0)
(-1 1 0)
(-1 -1 0.1)
( 1 -1 0.1)
( 1 1 0.1)
(-1 1 0.1)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (250 250 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
sides
{
type patch;
faces
(
(0 1 4 5)
(2 3 6 7)
);
}
inlet
{
type patch;
faces
(
(0 3 4 7)
);
}
outlet
{
type patch;
faces
(
(1 2 5 6)
);
}
ZMax
{
type empty;
faces
(
(4 5 6 7)
);
}
ZMin
{
type empty;
faces
(
(0 1 2 3)
);
}
);
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: plus |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
libs ("libfvMotionSolvers.so");
application moveDynamicMesh;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.5;
deltaT 0.002;
writeControl timeStep;
writeInterval 5;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 0.4;
maxDeltaT 1;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// 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
(
{
//- Master side patch
name AMI_rotor;
patchInfo
{
type cyclicAMI;
matchTolerance 0.0001;
neighbourPatch AMI_rotor_slave;
transform noOrdering;
}
constructFrom patches;
patches (v_rotor);
}
{
//- Slave side patch
name AMI_rotor_slave;
patchInfo
{
type cyclicAMI;
matchTolerance 0.0001;
neighbourPatch AMI_rotor;
transform noOrdering;
}
constructFrom patches;
patches (v_rotor_slave);
}
{
//- Master side patch
name AMI_dualWing;
patchInfo
{
type cyclicAMI;
matchTolerance 0.0001;
neighbourPatch AMI_dualWing_slave;
transform noOrdering;
}
constructFrom patches;
patches (v_dualWing);
}
{
//- Slave side patch
name AMI_dualWing_slave;
patchInfo
{
type cyclicAMI;
matchTolerance 0.0001;
neighbourPatch AMI_dualWing;
transform noOrdering;
}
constructFrom patches;
patches (v_dualWing_slave);
}
);
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method hierarchical;
hierarchicalCoeffs
{
n (2 2 1);
delta 0.001;
order xyz;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1606+ |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
grad(U) cellLimited Gauss linear 1;
}
divSchemes
{
default none;
// div(phi,U) Gauss upwind;
div(phi,U) Gauss linearUpwind grad(U);
div(phi,k) Gauss upwind;
div(phi,epsilon) Gauss upwind;
div((nuEff*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear limited corrected 0.33;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default limited corrected 0.33;
}
// ************************************************************************* //
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment