sixDoFRigidBodyMotion: Update code and tutorial cases to use new explicit motion

simpleHarmonicMotion case removed temporarily pending the introduction of a suitable motion solver
This commit is contained in:
Henry
2014-01-23 11:24:50 +00:00
parent 7e7e47942f
commit 36f3e513ea
19 changed files with 92 additions and 642 deletions

View File

@ -80,7 +80,7 @@ void Foam::sixDoFRigidBodyMotionConstraints::axis::constrainRotation
pointConstraint& pc
) const
{
pc.combine(pointConstraint(Tuple2<label, vector>(2, vector(0,1,0))));
pc.combine(pointConstraint(Tuple2<label, vector>(2, axis_)));
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -60,14 +60,8 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
os.writeKeyword("sixDoFRigidBodyMotionRestraint")
<< restraintType << token::END_STATEMENT << nl;
os.writeKeyword(word(restraintType + "Coeffs")) << nl;
os << indent << token::BEGIN_BLOCK << nl << incrIndent;
restraints_[rI].write(os);
os << decrIndent << indent << token::END_BLOCK << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
}
@ -91,14 +85,8 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
os.writeKeyword(word(constraintType + "Coeffs")) << nl;
os << indent << token::BEGIN_BLOCK << nl << incrIndent;
constraints_[rI].write(os);
os << decrIndent << indent << token::END_BLOCK << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
}

View File

@ -105,7 +105,7 @@ Foam::sixDoFRigidBodyMotionSolver::sixDoFRigidBodyMotionSolver
{
if (rhoName_ == "rhoInf")
{
rhoInf_ = readScalar(dict.lookup("rhoInf"));
rhoInf_ = readScalar(coeffDict().lookup("rhoInf"));
}
// Calculate scaling factor everywhere
@ -202,8 +202,16 @@ void Foam::sixDoFRigidBodyMotionSolver::solve()
f.calcForcesMoment();
uniformDimensionedVectorField g =
db().lookupObject<uniformDimensionedVectorField>("g");
dimensionedVector g("g", dimAcceleration, vector::zero);
if (db().foundObject<uniformDimensionedVectorField>("g"))
{
g = db().lookupObject<uniformDimensionedVectorField>("g");
}
else if (coeffDict().found("g"))
{
coeffDict().lookup("g") >> g;
}
// scalar ramp = min(max((this->db().time().value() - 5)/10, 0), 1);
scalar ramp = 1.0;

View File

@ -23,79 +23,7 @@ boundaryField
{
wing
{
type sixDoFRigidBodyDisplacement;
mass 22.9;
centreOfMass (0.4974612746 -0.01671895744 0.125);
momentOfInertia (1.958864357 3.920839234 2.057121362);
orientation
(
0.9953705935 0.09611129781 0
-0.09611129781 0.9953705935 0
0 0 1
);
velocity (0 0 0);
acceleration (0 0 0);
angularMomentum (0 0 -2.0);
torque (0 0 0);
rhoName rhoInf;
rhoInf 1;
g (0 -9.81 0);
report on;
constraints
{
maxIterations 500;
yLine
{
sixDoFRigidBodyMotionConstraint line;
lineCoeffs
{
refPoint (0.25 0.007 0.125);
direction (0 1 0);
}
tolerance 1e-9;
relaxationFactor 0.7;
}
zAxis
{
sixDoFRigidBodyMotionConstraint axis;
axisCoeffs
{
axis (0 0 1);
}
tolerance 1e-06;
relaxationFactor 0.7;
}
}
restraints
{
verticalSpring
{
sixDoFRigidBodyMotionRestraint linearSpring;
linearSpringCoeffs
{
anchor (0.25 0.007 0.125);
refAttachmentPt (0.25 0.007 0.125);
stiffness 4000;
damping 2;
restLength 0;
}
}
axialSpring
{
sixDoFRigidBodyMotionRestraint linearAxialAngularSpring;
linearAxialAngularSpringCoeffs
{
axis (0 0 1);
stiffness 700;
damping 0.5;
referenceOrientation $orientation;
}
}
}
type calculated;
value uniform (0 0 0);
}

View File

@ -10,19 +10,75 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object motionProperties;
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicMotionSolverFvMesh;
motionSolverLibs ("libfvMotionSolvers.so" "libsixDoFRigidBodyMotion.so");
motionSolverLibs ("libsixDoFRigidBodyMotion.so");
solver displacementLaplacian;
solver sixDoFRigidBodyMotion;
displacementLaplacianCoeffs
sixDoFRigidBodyMotionCoeffs
{
diffusivity inverseDistance (wing);
patches (wing);
innerDistance 0.3;
outerDistance 1;
mass 22.9;
centreOfMass (0.4974612746 -0.01671895744 0.125);
momentOfInertia (1.958864357 3.920839234 2.057121362);
orientation
(
0.9953705935 0.09611129781 0
-0.09611129781 0.9953705935 0
0 0 1
);
angularMomentum (0 0 -2);
g (0 -9.81 0);
rhoName rhoInf;
rhoInf 1;
report on;
constraints
{
yLine
{
sixDoFRigidBodyMotionConstraint line;
direction (0 1 0);
}
zAxis
{
sixDoFRigidBodyMotionConstraint axis;
axis (0 0 1);
}
}
restraints
{
verticalSpring
{
sixDoFRigidBodyMotionRestraint linearSpring;
anchor (0.25 0.007 0.125);
refAttachmentPt (0.25 0.007 0.125);
stiffness 4000;
damping 2;
restLength 0;
}
axialSpring
{
sixDoFRigidBodyMotionRestraint linearAxialAngularSpring;
axis (0 0 1);
stiffness 700;
damping 0.5;
referenceOrientation $orientation;
}
}
}

View File

@ -21,40 +21,40 @@ FoamFile
{
type patch;
nFaces 72;
startFace 22911;
startFace 25179;
}
inlet
{
type patch;
nFaces 40;
startFace 22983;
startFace 25251;
}
outlet
{
type patch;
nFaces 62;
startFace 23023;
startFace 25291;
}
front
{
type empty;
inGroups 1(empty);
nFaces 11431;
startFace 23085;
nFaces 12565;
startFace 25353;
}
back
{
type empty;
inGroups 1(empty);
nFaces 11431;
startFace 34516;
nFaces 12565;
startFace 37918;
}
wing
{
type wall;
inGroups 1(wall);
nFaces 378;
startFace 45947;
startFace 50483;
}
)

View File

@ -17,7 +17,7 @@ FoamFile
application pimpleDyMFoam;
startFrom latestTime;
startFrom startTime;
startTime 0;
@ -49,28 +49,4 @@ adjustTimeStep yes;
maxCo 0.9;
libs
(
"libOpenFOAM.so"
"libforces.so"
);
functions
{
forces
{
type forces;
functionObjectLibs ("libforces.so");
outputControl timeStep;
outputInterval 10;
patches (wing);
pName p;
UName U;
rhoName rhoInf;
log true;
rhoInf 1;
CofR (0.25 0.007 0.125);
}
}
// ************************************************************************* //

View File

@ -21,40 +21,40 @@ FoamFile
{
type patch;
nFaces 72;
startFace 22911;
startFace 25179;
}
inlet
{
type patch;
nFaces 40;
startFace 22983;
startFace 25251;
}
outlet
{
type patch;
nFaces 62;
startFace 23023;
startFace 25291;
}
front
{
type empty;
inGroups 1(empty);
nFaces 11431;
startFace 23085;
nFaces 12565;
startFace 25353;
}
back
{
type empty;
inGroups 1(empty);
nFaces 11431;
startFace 34516;
nFaces 12565;
startFace 37918;
}
wing
{
type wall;
inGroups 1(wall);
nFaces 378;
startFace 45947;
startFace 50483;
}
)

View File

@ -1,80 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class pointVectorField;
location "0.01";
object pointDisplacement;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 0 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
stationaryWalls
{
type fixedValue;
value uniform (0 0 0);
}
movingBlock
{
type uncoupledSixDoFRigidBodyDisplacement;
centreOfMass (0.5 0.5 0.5);
momentOfInertia (0.1052 0.1052 0.1778);
mass 9.6;
velocity (0 0 0);
acceleration (0 0 0);
angularMomentum (0 0 0);
torque (0 0 0);
gravity (0 0 0);
rhoInf 1;
report on;
restraints
{
topSpring
{
sixDoFRigidBodyMotionRestraint linearSpring;
linearSpringCoeffs
{
anchor (0.5 0.5 1);
refAttachmentPt $centreOfMass;
stiffness 5000;
damping 50;
restLength 0.4;
}
}
}
constraints
{
fixedOrientation
{
sixDoFRigidBodyMotionConstraint orientation;
}
zLine
{
sixDoFRigidBodyMotionConstraint line;
lineCoeffs
{
direction (0 0 1);
}
}
}
value uniform (0 0 0);
}
}
// ************************************************************************* //

View File

@ -1,11 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
rm -rf 0 t_vs_cm t_vs_lv shm.eps > /dev/null 2>&1
cleanCase
# ----------------------------------------------------------------- end-of-file

View File

@ -1,19 +0,0 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
# Set application name
application=`getApplication`
runApplication blockMesh
runApplication topoSet
runApplication subsetMesh -overwrite c0 -patch movingBlock
cp -r 0.org 0 > /dev/null 2>&1
runApplication $application
./extractData log.$application
gnuplot shm.gnuplot
# ----------------------------------------------------------------- end-of-file

View File

@ -1,29 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object motionProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicMotionSolverFvMesh;
motionSolverLibs ("libfvMotionSolvers.so" "libsixDoFRigidBodyMotion.so");
solver displacementLaplacian;
displacementLaplacianCoeffs
{
diffusivity inverseDistance (movingBlock);
}
// ************************************************************************* //

View File

@ -1,66 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(1 0 0)
(1 1 0)
(0 1 0)
(0 0 1)
(1 0 1)
(1 1 1)
(0 1 1)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (9 9 14) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
stationaryWalls
{
type patch;
faces
(
(0 3 2 1)
(2 6 5 1)
(1 5 4 0)
(3 7 6 2)
(0 4 7 3)
(4 5 6 7)
);
}
movingBlock
{
type patch;
faces ();
}
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -1,42 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# extractData
#
# Description
# Extracts motion data from a simple harmonic motion dynamicMesh case
#
#------------------------------------------------------------------------------
grep "Centre of mass" $1 | cut -d ":" -f 2 | cut -d " " -f 4 | 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
#------------------------------------------------------------------------------

View File

@ -1,76 +0,0 @@
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# shm.gnuplot
#
# Description
# Creates an .eps graph of OpenFOAM results vs analytical solution
# for a simple harmonic motion dynamicMesh case
#
#------------------------------------------------------------------------------
reset
set samples 2000
k = 5000.0
m = 9.6
c = 50.0
a = -0.1
omega = sqrt(k/m)
zeta = c/(2.0*m*omega)
phi = atan((sqrt(1.0 - zeta**2))/zeta)
A = a/sin(phi)
pos(A, t, omega, phi, zeta) = A*exp(-zeta*omega*t)*sin(sqrt(1-zeta**2)*omega*t + phi)
vel(A, t, omega, phi, zeta) = \
A*exp(-zeta*omega*t)*\
( \
sqrt(1-zeta**2)*omega*cos(sqrt(1-zeta**2)*omega*t + phi) \
- zeta*omega*sin(sqrt(1-zeta**2)*omega*t + phi) \
)
set xlabel "Time/[s]"
set ylabel "Position"
set ytics nomirror
set y2tics
set yrange [-0.1:0.1]
set y2range [-2:2]
set xzeroaxis
set terminal postscript eps color enhanced solid
set output "shm.eps"
plot \
"t_vs_cm" u 1:($2 - 0.6) w l t "Simulation, centre of mass relative to start", \
pos(A, x, omega, phi, zeta) w l t "Analytical solution, centre of mass", \
"t_vs_lv" u 1:2 w l axes x1y2 t "Simulation, vertical velocity", \
vel(A, x, omega, phi, zeta) w l axes x1y2 t "Analytical solution, vertical velocity"
#------------------------------------------------------------------------------

View File

@ -1,61 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application moveDynamicMesh;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 4;
deltaT 0.002;
writeControl adjustableRunTime;
writeInterval 0.25;
purgeWrite 0;
writeFormat ascii;
writePrecision 12;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 0.2;
maxDeltaT 0.025;
libs
(
"libOpenFOAM.so"
"libincompressibleRASModels.so"
"libforces.so"
);
// ************************************************************************* //

View File

@ -1,50 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
}
fluxRequired
{
}
// ************************************************************************* //

View File

@ -1,34 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
cellDisplacement
{
solver GAMG;
tolerance 1e-06;
relTol 0;
smoother GaussSeidel;
cacheAgglomeration true;
nCellsInCoarsestLevel 10;
agglomerator faceAreaPair;
mergeLevels 1;
}
}
// ************************************************************************* //

View File

@ -1,38 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object topoSetDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
actions
(
{
name c0;
type cellSet;
action new;
source boxToCell;
sourceInfo
{
box (0.35 0.35 0.44) (0.65 0.65 0.56);
}
}
{
name c0;
type cellSet;
action invert;
}
);
// ************************************************************************* //