PageRenderTime 24ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.C

https://gitlab.com/johnvarv/OpenFOAM-3.0.x
C | 108 lines | 56 code | 22 blank | 30 comment | 0 complexity | 2c1e59450af6dc42676afba49f1314c8 MD5 | raw file
  1. /*---------------------------------------------------------------------------*\
  2. ========= |
  3. \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
  4. \\ / O peration |
  5. \\ / A nd | Copyright (C) 2012-2015 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 "axisRotationMotion.H"
  22. #include "addToRunTimeSelectionTable.H"
  23. #include "unitConversion.H"
  24. using namespace Foam::constant::mathematical;
  25. // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
  26. namespace Foam
  27. {
  28. namespace solidBodyMotionFunctions
  29. {
  30. defineTypeNameAndDebug(axisRotationMotion, 0);
  31. addToRunTimeSelectionTable
  32. (
  33. solidBodyMotionFunction,
  34. axisRotationMotion,
  35. dictionary
  36. );
  37. }
  38. }
  39. // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
  40. Foam::solidBodyMotionFunctions::axisRotationMotion::axisRotationMotion
  41. (
  42. const dictionary& SBMFCoeffs,
  43. const Time& runTime
  44. )
  45. :
  46. solidBodyMotionFunction(SBMFCoeffs, runTime)
  47. {
  48. read(SBMFCoeffs);
  49. }
  50. // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
  51. Foam::solidBodyMotionFunctions::axisRotationMotion::~axisRotationMotion()
  52. {}
  53. // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
  54. Foam::septernion
  55. Foam::solidBodyMotionFunctions::axisRotationMotion::transformation() const
  56. {
  57. scalar t = time_.value();
  58. // Rotation origin (in radians)
  59. vector omega
  60. (
  61. t*degToRad(radialVelocity_.x()),
  62. t*degToRad(radialVelocity_.y()),
  63. t*degToRad(radialVelocity_.z())
  64. );
  65. scalar magOmega = mag(omega);
  66. quaternion R(omega/magOmega, magOmega);
  67. septernion TR(septernion(origin_)*R*septernion(-origin_));
  68. Info<< "solidBodyMotionFunctions::axisRotationMotion::transformation(): "
  69. << "Time = " << t << " transformation: " << TR << endl;
  70. return TR;
  71. }
  72. bool Foam::solidBodyMotionFunctions::axisRotationMotion::read
  73. (
  74. const dictionary& SBMFCoeffs
  75. )
  76. {
  77. solidBodyMotionFunction::read(SBMFCoeffs);
  78. SBMFCoeffs_.lookup("origin") >> origin_;
  79. SBMFCoeffs_.lookup("radialVelocity") >> radialVelocity_;
  80. return true;
  81. }
  82. // ************************************************************************* //