ENH: codedMotionSolver: motion solver with user-supplied coding

This commit is contained in:
mattijs
2018-05-21 08:59:01 +01:00
parent 5474d161f2
commit 977a9894b4
12 changed files with 942 additions and 0 deletions

View File

@ -0,0 +1,77 @@
/*--------------------------------*- 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 dynamicMotionSolverFvMesh;
motionSolver coded;
name myMotion;
codeInclude
#{
#include "transformField.H"
#};
localCode
#{
// Generate new set of points
tmp<pointField> twistColumn
(
const scalar& maxRotAngle,
const pointField& points
)
{
tmp<pointField> tnewPoints(new pointField(points));
pointField& newPoints = tnewPoints.ref();
const boundBox bb(points, true);
const scalar zMin = bb.min()[vector::Z];
const scalar zSpan = bb.span()[vector::Z];
forAll(points, pointI)
{
const scalar x = points[pointI].component(0);
const scalar y = points[pointI].component(1);
const scalar z = points[pointI].component(2);
// Scale the angle by height
const scalar localAngle = maxRotAngle*(z-zMin)/zSpan;
const scalar xr = x*cos(localAngle)-y*sin(localAngle);
const scalar yr = x*sin(localAngle)+y*cos(localAngle);
newPoints[pointI] = vector(xr, yr, z);
}
return tnewPoints;
}
#};
code
#{
const Time& tm = mesh().time();
const pointField& p0 = points0();
// Max twist pi at t=10
const scalar maxRotAngle =
constant::mathematical::pi*Foam::sin(degToRad(90.0/10.0*tm.value()));
tmp<pointField> tnewPoints(twistColumn(maxRotAngle, p0));
return tnewPoints;
#};
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- 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 transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu 1.5e-05;
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*--------------------------------*- 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 blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(-0.5 -0.5 0)
(0.5 -0.5 0)
(0.5 0.5 0)
(-0.5 0.5 0)
(-0.5 -0.5 8)
(0.5 -0.5 8)
(0.5 0.5 8)
(-0.5 0.5 8)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (2 2 8) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
sides
{
type patch;
faces
(
(2 6 5 1)
(0 4 7 3)
(3 7 6 2)
(1 5 4 0)
);
}
floor
{
type wall;
faces
(
(0 3 2 1)
);
}
top
{
type patch;
faces
(
(4 5 6 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- 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 controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application moveDynamicMesh;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 40;
deltaT 1;
writeControl timeStep;
writeInterval 1;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //

View File

@ -0,0 +1,24 @@
/*--------------------------------*- 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;
note "mesh decomposition control dictionary";
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- The total number of domains (mandatory)
numberOfSubdomains 3;
//- The decomposition method (mandatory)
method random;
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- 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 fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,56 @@
/*--------------------------------*- 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 fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0;
}
U
{
solver PBiCGStab;
preconditioner DILU;
tolerance 1e-05;
relTol 0;
}
"cellDisplacement.*"
{
solver GAMG;
tolerance 1e-08;
relTol 0;
smoother GaussSeidel;
}
"(cellMotionU|cellMotionUz)"
{
$p;
tolerance 1e-08;
relTol 0;
}
}
PIMPLE
{}
// ************************************************************************* //