/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.C

https://gitlab.com/johnvarv/OpenFOAM-3.0.x · C · 105 lines · 53 code · 22 blank · 30 comment · 0 complexity · 1ce2d14fc50b44b6563c0814ec397cc3 MD5 · raw file

  1. /*---------------------------------------------------------------------------*\
  2. ========= |
  3. \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
  4. \\ / O peration |
  5. \\ / A nd | Copyright (C) 2011-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 "rotatingMotion.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(rotatingMotion, 0);
  31. addToRunTimeSelectionTable
  32. (
  33. solidBodyMotionFunction,
  34. rotatingMotion,
  35. dictionary
  36. );
  37. }
  38. }
  39. // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
  40. Foam::solidBodyMotionFunctions::rotatingMotion::rotatingMotion
  41. (
  42. const dictionary& SBMFCoeffs,
  43. const Time& runTime
  44. )
  45. :
  46. solidBodyMotionFunction(SBMFCoeffs, runTime),
  47. origin_(SBMFCoeffs_.lookup("origin")),
  48. axis_(SBMFCoeffs_.lookup("axis")),
  49. omega_(DataEntry<scalar>::New("omega", SBMFCoeffs_))
  50. {}
  51. // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
  52. Foam::solidBodyMotionFunctions::rotatingMotion::~rotatingMotion()
  53. {}
  54. // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
  55. Foam::septernion
  56. Foam::solidBodyMotionFunctions::rotatingMotion::transformation() const
  57. {
  58. scalar t = time_.value();
  59. // Rotation around axis
  60. scalar angle = omega_->integrate(0, t);
  61. quaternion R(axis_, angle);
  62. septernion TR(septernion(origin_)*R*septernion(-origin_));
  63. Info<< "solidBodyMotionFunctions::rotatingMotion::transformation(): "
  64. << "Time = " << t << " transformation: " << TR << endl;
  65. return TR;
  66. }
  67. bool Foam::solidBodyMotionFunctions::rotatingMotion::read
  68. (
  69. const dictionary& SBMFCoeffs
  70. )
  71. {
  72. solidBodyMotionFunction::read(SBMFCoeffs);
  73. omega_.reset
  74. (
  75. DataEntry<scalar>::New("omega", SBMFCoeffs_).ptr()
  76. );
  77. return true;
  78. }
  79. // ************************************************************************* //