mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature-oscillatingLinearMotion' into 'develop'
ENH: oscillatingLinearMotion: add optional phase- and vertical-shift entries See merge request Development/openfoam!553
This commit is contained in:
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -53,7 +54,29 @@ Foam::solidBodyMotionFunctions::oscillatingLinearMotion::oscillatingLinearMotion
|
|||||||
const Time& runTime
|
const Time& runTime
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
solidBodyMotionFunction(SBMFCoeffs, runTime)
|
solidBodyMotionFunction(SBMFCoeffs, runTime),
|
||||||
|
omegaPtr_(Function1<scalar>::New("omega", SBMFCoeffs_, &runTime)),
|
||||||
|
phaseShiftPtr_
|
||||||
|
(
|
||||||
|
Function1<scalar>::NewIfPresent
|
||||||
|
(
|
||||||
|
"phaseShift",
|
||||||
|
SBMFCoeffs_,
|
||||||
|
word::null,
|
||||||
|
&runTime
|
||||||
|
)
|
||||||
|
),
|
||||||
|
amplitudePtr_(Function1<vector>::New("amplitude", SBMFCoeffs_, &runTime)),
|
||||||
|
verticalShiftPtr_
|
||||||
|
(
|
||||||
|
Function1<vector>::NewIfPresent
|
||||||
|
(
|
||||||
|
"verticalShift",
|
||||||
|
SBMFCoeffs_,
|
||||||
|
word::null,
|
||||||
|
&runTime
|
||||||
|
)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
read(SBMFCoeffs);
|
read(SBMFCoeffs);
|
||||||
}
|
}
|
||||||
@ -64,9 +87,27 @@ Foam::solidBodyMotionFunctions::oscillatingLinearMotion::oscillatingLinearMotion
|
|||||||
Foam::septernion
|
Foam::septernion
|
||||||
Foam::solidBodyMotionFunctions::oscillatingLinearMotion::transformation() const
|
Foam::solidBodyMotionFunctions::oscillatingLinearMotion::transformation() const
|
||||||
{
|
{
|
||||||
scalar t = time_.value();
|
const scalar t = time_.value();
|
||||||
|
|
||||||
const vector displacement = amplitude_*sin(omega_*t);
|
const vector amplitude(amplitudePtr_->value(t));
|
||||||
|
const scalar omega = omegaPtr_->value(t);
|
||||||
|
|
||||||
|
scalar phaseShift = 0;
|
||||||
|
if (phaseShiftPtr_)
|
||||||
|
{
|
||||||
|
phaseShift = phaseShiftPtr_->value(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector verticalShift(Zero);
|
||||||
|
if (verticalShiftPtr_)
|
||||||
|
{
|
||||||
|
verticalShift = verticalShiftPtr_->value(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
const vector displacement
|
||||||
|
(
|
||||||
|
amplitude*sin(omega*(t + phaseShift)) + verticalShift
|
||||||
|
);
|
||||||
|
|
||||||
quaternion R(1);
|
quaternion R(1);
|
||||||
septernion TR(septernion(-displacement)*R);
|
septernion TR(septernion(-displacement)*R);
|
||||||
@ -82,10 +123,42 @@ bool Foam::solidBodyMotionFunctions::oscillatingLinearMotion::read
|
|||||||
const dictionary& SBMFCoeffs
|
const dictionary& SBMFCoeffs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
solidBodyMotionFunction::read(SBMFCoeffs);
|
if (!solidBodyMotionFunction::read(SBMFCoeffs))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
SBMFCoeffs_.readEntry("amplitude", amplitude_);
|
omegaPtr_.reset
|
||||||
SBMFCoeffs_.readEntry("omega", omega_);
|
(
|
||||||
|
Function1<scalar>::New("omega", SBMFCoeffs_, &time_)
|
||||||
|
);
|
||||||
|
|
||||||
|
phaseShiftPtr_.reset
|
||||||
|
(
|
||||||
|
Function1<scalar>::NewIfPresent
|
||||||
|
(
|
||||||
|
"phaseShift",
|
||||||
|
SBMFCoeffs_,
|
||||||
|
word::null,
|
||||||
|
&time_
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
amplitudePtr_.reset
|
||||||
|
(
|
||||||
|
Function1<vector>::New("amplitude", SBMFCoeffs_, &time_)
|
||||||
|
);
|
||||||
|
|
||||||
|
verticalShiftPtr_.reset
|
||||||
|
(
|
||||||
|
Function1<vector>::NewIfPresent
|
||||||
|
(
|
||||||
|
"verticalShift",
|
||||||
|
SBMFCoeffs_,
|
||||||
|
word::null,
|
||||||
|
&time_
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -30,17 +30,64 @@ Class
|
|||||||
Description
|
Description
|
||||||
SolidBodyMotionFvMesh 6DoF motion function. Oscillating displacement.
|
SolidBodyMotionFvMesh 6DoF motion function. Oscillating displacement.
|
||||||
|
|
||||||
|
The governing equation for the displacement is given by:
|
||||||
|
\f[
|
||||||
|
y = A*\sin(B*(t + C)) + D
|
||||||
|
\f]
|
||||||
|
|
||||||
|
where:
|
||||||
|
\vartable
|
||||||
|
y | Displacement [m] (vector)
|
||||||
|
A | Amplitude [m] (vector)
|
||||||
|
B | Radial velocity [rad/s] (scalar)
|
||||||
|
C | Phase-shift to left [s] (scalar)
|
||||||
|
D | Vertical shift [m] (vector)
|
||||||
|
\endvartable
|
||||||
|
|
||||||
|
Usage
|
||||||
|
Minimal example by using \c constant/fvOptions:
|
||||||
|
\verbatim
|
||||||
|
oscillation
|
||||||
|
{
|
||||||
|
// Mandatory entries
|
||||||
|
solidBodyMotionFunction oscillatingLinearMotion;
|
||||||
|
|
||||||
|
oscillatingLinearMotionCoeffs
|
||||||
|
{
|
||||||
|
// Mandatory entries
|
||||||
|
amplitude <Function1<vector>>;
|
||||||
|
omega <Function1<scalar>>;
|
||||||
|
|
||||||
|
// Optional entries
|
||||||
|
phaseShift <Function1<scalar>>;
|
||||||
|
verticalShift <Function1<vector>>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
where the entries mean:
|
||||||
|
\table
|
||||||
|
Property | Description | Type | Reqd | Deflt
|
||||||
|
solidBodyMotionFunction | Type name: oscillatingLinearMotion <!--
|
||||||
|
--> | word | yes | -
|
||||||
|
amplitude | Amplitude | Function1\<vector\> | yes | -
|
||||||
|
omega | Radial velocity | Function1\<scalar\> | yes | -
|
||||||
|
phaseShift | Phase-shift to left | Function1\<scalar\> | no | -
|
||||||
|
verticalShift | Vertical shift | Function1\<vector\> | no | -
|
||||||
|
\endtable
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
oscillatingLinearMotion.C
|
oscillatingLinearMotion.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef oscillatingLinearMotion_H
|
#ifndef Foam_solidBodyMotionFunctions_oscillatingLinearMotion_H
|
||||||
#define oscillatingLinearMotion_H
|
#define Foam_solidBodyMotionFunctions_oscillatingLinearMotion_H
|
||||||
|
|
||||||
#include "solidBodyMotionFunction.H"
|
#include "solidBodyMotionFunction.H"
|
||||||
#include "primitiveFields.H"
|
#include "primitiveFields.H"
|
||||||
#include "point.H"
|
#include "point.H"
|
||||||
|
#include "Function1.H"
|
||||||
|
#include "autoPtr.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -50,7 +97,7 @@ namespace solidBodyMotionFunctions
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class oscillatingLinearMotion Declaration
|
Class oscillatingLinearMotion Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class oscillatingLinearMotion
|
class oscillatingLinearMotion
|
||||||
@ -59,11 +106,17 @@ class oscillatingLinearMotion
|
|||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- Amplitude
|
|
||||||
vector amplitude_;
|
|
||||||
|
|
||||||
//- Radial velocity
|
//- Radial velocity
|
||||||
scalar omega_;
|
autoPtr<Function1<scalar>> omegaPtr_;
|
||||||
|
|
||||||
|
//- Phase shift
|
||||||
|
autoPtr<Function1<scalar>> phaseShiftPtr_;
|
||||||
|
|
||||||
|
//- Amplitude
|
||||||
|
autoPtr<Function1<vector>> amplitudePtr_;
|
||||||
|
|
||||||
|
//- Vertical shift
|
||||||
|
autoPtr<Function1<vector>> verticalShiftPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|||||||
@ -7,5 +7,6 @@ cleanCase0
|
|||||||
|
|
||||||
rm -rf constant/triSurface
|
rm -rf constant/triSurface
|
||||||
rm -rf constant/extendedFeatureEdgeMesh
|
rm -rf constant/extendedFeatureEdgeMesh
|
||||||
|
rm -rf oldProcessors
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -3,19 +3,7 @@ cd "${0%/*}" || exit # Run from this directory
|
|||||||
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
mkdir -p constant/triSurface
|
./Allrun.pre
|
||||||
|
|
||||||
cp -f \
|
|
||||||
"$FOAM_TUTORIALS"/resources/geometry/sloshingCylinder.obj.gz \
|
|
||||||
constant/triSurface/
|
|
||||||
|
|
||||||
restore0Dir
|
|
||||||
|
|
||||||
runApplication blockMesh
|
|
||||||
|
|
||||||
runApplication snappyHexMesh -overwrite
|
|
||||||
|
|
||||||
runApplication setFields
|
|
||||||
|
|
||||||
runApplication $(getApplication)
|
runApplication $(getApplication)
|
||||||
|
|
||||||
|
|||||||
29
tutorials/multiphase/interFoam/laminar/sloshingCylinder/Allrun-parallel
Executable file
29
tutorials/multiphase/interFoam/laminar/sloshingCylinder/Allrun-parallel
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd "${0%/*}" || exit # Run from this directory
|
||||||
|
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
./Allrun.pre
|
||||||
|
|
||||||
|
runApplication decomposePar
|
||||||
|
|
||||||
|
runParallel $(getApplication)
|
||||||
|
|
||||||
|
runApplication reconstructPar
|
||||||
|
|
||||||
|
|
||||||
|
latestTime=$(foamListTimes -latestTime)
|
||||||
|
|
||||||
|
mv -f "$latestTime" "$latestTime".bak
|
||||||
|
|
||||||
|
mkdir oldProcessors
|
||||||
|
|
||||||
|
mv -f processor* oldProcessors
|
||||||
|
|
||||||
|
runParallel -s "decompose" redistributePar -decompose -latestTime
|
||||||
|
|
||||||
|
runParallel -s "restart" $(getApplication)
|
||||||
|
|
||||||
|
runParallel -s "reconstruct" redistributePar -reconstruct -latestTime
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
20
tutorials/multiphase/interFoam/laminar/sloshingCylinder/Allrun.pre
Executable file
20
tutorials/multiphase/interFoam/laminar/sloshingCylinder/Allrun.pre
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd "${0%/*}" || exit # Run from this directory
|
||||||
|
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
mkdir -p constant/triSurface
|
||||||
|
|
||||||
|
cp -f \
|
||||||
|
"$FOAM_TUTORIALS"/resources/geometry/sloshingCylinder.obj.gz \
|
||||||
|
constant/triSurface/
|
||||||
|
|
||||||
|
restore0Dir
|
||||||
|
|
||||||
|
runApplication blockMesh
|
||||||
|
|
||||||
|
runApplication snappyHexMesh -overwrite
|
||||||
|
|
||||||
|
runApplication setFields
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -27,6 +27,9 @@ oscillation
|
|||||||
{
|
{
|
||||||
amplitude (0.1 0 0);
|
amplitude (0.1 0 0);
|
||||||
omega 18.8945578;
|
omega 18.8945578;
|
||||||
|
|
||||||
|
phaseShift 0.01;
|
||||||
|
verticalShift (0.05 0 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2206 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object decomposeParDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
numberOfSubdomains 4;
|
||||||
|
|
||||||
|
method hierarchical;
|
||||||
|
|
||||||
|
coeffs
|
||||||
|
{
|
||||||
|
n ( 2 2 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user