/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.C

https://github.com/bgschaid/OpenFOAM-2.0.x · C · 109 lines · 56 code · 23 blank · 30 comment · 0 complexity · 0690594c88f6cbf27181af7f182514db MD5 · raw file

  1. /*---------------------------------------------------------------------------*\
  2. ========= |
  3. \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
  4. \\ / O peration |
  5. \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
  6. \\/ M anipulation |
  7. -------------------------------------------------------------------------------
  8. License
  9. This file is part of OpenFOAM.
  10. OpenFOAM is free software: you can redistribute it and/or modify it
  11. under the terms of the GNU General Public License as published by
  12. the Free Software Foundation, either version 3 of the License, or
  13. (at your option) any later version.
  14. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
  15. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  17. for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
  20. \*---------------------------------------------------------------------------*/
  21. #include "oscillatingRotatingMotion.H"
  22. #include "addToRunTimeSelectionTable.H"
  23. #include "mathematicalConstants.H"
  24. using namespace Foam::constant::mathematical;
  25. // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
  26. namespace Foam
  27. {
  28. namespace solidBodyMotionFunctions
  29. {
  30. defineTypeNameAndDebug(oscillatingRotatingMotion, 0);
  31. addToRunTimeSelectionTable
  32. (
  33. solidBodyMotionFunction,
  34. oscillatingRotatingMotion,
  35. dictionary
  36. );
  37. }
  38. }
  39. // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
  40. Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::
  41. oscillatingRotatingMotion
  42. (
  43. const dictionary& SBMFCoeffs,
  44. const Time& runTime
  45. )
  46. :
  47. solidBodyMotionFunction(SBMFCoeffs, runTime)
  48. {
  49. read(SBMFCoeffs);
  50. }
  51. // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
  52. Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::
  53. ~oscillatingRotatingMotion()
  54. {}
  55. // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
  56. Foam::septernion
  57. Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::
  58. transformation() const
  59. {
  60. scalar t = time_.value();
  61. vector eulerAngles = amplitude_*sin(omega_*t);
  62. // Convert the rotational motion from deg to rad
  63. eulerAngles *= pi/180.0;
  64. quaternion R(eulerAngles.x(), eulerAngles.y(), eulerAngles.z());
  65. septernion TR(septernion(CofG_)*R*septernion(-CofG_));
  66. Info<< "solidBodyMotionFunctions::oscillatingRotatingMotion::"
  67. << "transformation(): "
  68. << "Time = " << t << " transformation: " << TR << endl;
  69. return TR;
  70. }
  71. bool Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::read
  72. (
  73. const dictionary& SBMFCoeffs
  74. )
  75. {
  76. solidBodyMotionFunction::read(SBMFCoeffs);
  77. SBMFCoeffs_.lookup("CofG") >> CofG_;
  78. SBMFCoeffs_.lookup("amplitude") >> amplitude_;
  79. SBMFCoeffs_.lookup("omega") >> omega_;
  80. return true;
  81. }
  82. // ************************************************************************* //