Discrete Element Methods (Alpha)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DEMParticle.cpp 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 05/31/2016 12:27:31 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email tirons@egi.utah.edu
  14. * @copyright Copyright (c) 2016, University of Utah
  15. * @copyright Copyright (c) 2016, Lemma Software, LLC
  16. */
  17. #include "DEMParticle.h"
  18. namespace Lemma {
  19. // ==================== FRIEND METHODS =====================
  20. std::ostream &operator << (std::ostream &stream, const DEMParticle &ob) {
  21. stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
  22. return stream;
  23. }
  24. // ==================== LIFECYCLE =======================
  25. //--------------------------------------------------------------------------------------
  26. // Class: DEMParticle
  27. // Method: DEMParticle
  28. // Description: constructor (protected)
  29. //--------------------------------------------------------------------------------------
  30. DEMParticle::DEMParticle ( ) : LemmaObject( ) {
  31. } // ----- end of method DEMParticle::DEMParticle (constructor) -----
  32. //--------------------------------------------------------------------------------------
  33. // Class: DEMParticle
  34. // Method: DEMParticle
  35. // Description: DeSerializing constructor (protected)
  36. //--------------------------------------------------------------------------------------
  37. DEMParticle::DEMParticle (const YAML::Node& node) : LemmaObject(node) {
  38. this->centreMass = node["centreMass"].as<Vector3r>();
  39. } // ----- end of method DEMParticle::DEMParticle (constructor) -----
  40. //--------------------------------------------------------------------------------------
  41. // Class: DEMParticle
  42. // Method: NewSP()
  43. // Description: public constructor
  44. //--------------------------------------------------------------------------------------
  45. std::shared_ptr< DEMParticle > DEMParticle::NewSP() {
  46. std::shared_ptr<DEMParticle> sp(new DEMParticle( ), LemmaObjectDeleter() );
  47. return sp;
  48. }
  49. //--------------------------------------------------------------------------------------
  50. // Class: DEMParticle
  51. // Method: ~DEMParticle
  52. // Description: destructor (protected)
  53. //--------------------------------------------------------------------------------------
  54. DEMParticle::~DEMParticle () {
  55. } // ----- end of method DEMParticle::~DEMParticle (destructor) -----
  56. //--------------------------------------------------------------------------------------
  57. // Class: DEMParticle
  58. // Method: Serialize
  59. //--------------------------------------------------------------------------------------
  60. YAML::Node DEMParticle::Serialize ( ) const {
  61. YAML::Node node = LemmaObject::Serialize();;
  62. node.SetTag( GetName() );
  63. // FILL IN CLASS SPECIFICS HERE
  64. node["centreMass"] = centreMass;
  65. return node;
  66. } // ----- end of method DEMParticle::Serialize -----
  67. //--------------------------------------------------------------------------------------
  68. // Class: DEMParticle
  69. // Method: DeSerialize
  70. //--------------------------------------------------------------------------------------
  71. std::shared_ptr<DEMParticle> DEMParticle::DeSerialize ( const YAML::Node& node ) {
  72. if (node.Tag() != "DEMParticle") {
  73. throw DeSerializeTypeMismatch( "DEMParticle", node.Tag());
  74. }
  75. std::shared_ptr<DEMParticle> Object(new DEMParticle(node), LemmaObjectDeleter() );
  76. return Object ;
  77. } // ----- end of method DEMParticle::DeSerialize -----
  78. //--------------------------------------------------------------------------------------
  79. // Class: DEMParticle
  80. // Method: GetCentreMass
  81. //--------------------------------------------------------------------------------------
  82. Vector3r DEMParticle::GetCentreMass ( ) {
  83. return centreMass;
  84. } // ----- end of method DEMParticle::get_CentreMass -----
  85. //--------------------------------------------------------------------------------------
  86. // Class: DEMParticle
  87. // Method: GetCentreMass
  88. //--------------------------------------------------------------------------------------
  89. Real DEMParticle::GetCentreMass ( const int& icoord ) {
  90. return centreMass(icoord);
  91. } // ----- end of method DEMParticle::get_CentreMass -----
  92. //--------------------------------------------------------------------------------------
  93. // Class: DEMParticle
  94. // Method: SetCentreMass
  95. //--------------------------------------------------------------------------------------
  96. void DEMParticle::SetCentreMass ( const Vector3r& pos ) {
  97. centreMass = pos;
  98. return ;
  99. } // ----- end of method DEMParticle::set_CentreMass -----
  100. } // ----- end of Lemma name -----
  101. /* vim: set tabstop=4 expandtab: */
  102. /* vim: set filetype=cpp: */