/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/linearMotion/linearMotion.C

https://gitlab.com/johnvarv/OpenFOAM-3.0.x · C · 98 lines · 47 code · 21 blank · 30 comment · 0 complexity · b814371f9d41d11eb2d1aa1b5604a3d5 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 "linearMotion.H"
  22. #include "addToRunTimeSelectionTable.H"
  23. // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
  24. namespace Foam
  25. {
  26. namespace solidBodyMotionFunctions
  27. {
  28. defineTypeNameAndDebug(linearMotion, 0);
  29. addToRunTimeSelectionTable
  30. (
  31. solidBodyMotionFunction,
  32. linearMotion,
  33. dictionary
  34. );
  35. }
  36. }
  37. // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
  38. Foam::solidBodyMotionFunctions::linearMotion::linearMotion
  39. (
  40. const dictionary& SBMFCoeffs,
  41. const Time& runTime
  42. )
  43. :
  44. solidBodyMotionFunction(SBMFCoeffs, runTime)
  45. {
  46. read(SBMFCoeffs);
  47. }
  48. // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
  49. Foam::solidBodyMotionFunctions::linearMotion::~linearMotion()
  50. {}
  51. // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
  52. Foam::septernion
  53. Foam::solidBodyMotionFunctions::linearMotion::transformation() const
  54. {
  55. scalar t = time_.value();
  56. // Translation of centre of gravity with constant velocity
  57. const vector displacement = velocity_*t;
  58. quaternion R(0, 0, 0);
  59. septernion TR(septernion(displacement)*R);
  60. Info<< "solidBodyMotionFunctions::linearMotion::transformation(): "
  61. << "Time = " << t << " transformation: " << TR << endl;
  62. return TR;
  63. }
  64. bool Foam::solidBodyMotionFunctions::linearMotion::read
  65. (
  66. const dictionary& SBMFCoeffs
  67. )
  68. {
  69. solidBodyMotionFunction::read(SBMFCoeffs);
  70. SBMFCoeffs_.lookup("velocity") >> velocity_;
  71. return true;
  72. }
  73. // ************************************************************************* //