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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. #ifdef HAVE_YAMLCPP
  21. std::ostream &operator << (std::ostream &stream, const DEMParticle &ob) {
  22. stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
  23. return stream;
  24. }
  25. #else
  26. std::ostream &operator<<(std::ostream &stream, const DEMParticle& ob) {
  27. stream << *(LemmaObject*)(&ob);
  28. return stream;
  29. }
  30. #endif
  31. // ==================== LIFECYCLE =======================
  32. //--------------------------------------------------------------------------------------
  33. // Class: DEMParticle
  34. // Method: DEMParticle
  35. // Description: constructor (protected)
  36. //--------------------------------------------------------------------------------------
  37. DEMParticle::DEMParticle (const std::string& name) : LemmaObject(name) {
  38. } // ----- end of method DEMParticle::DEMParticle (constructor) -----
  39. #ifdef HAVE_YAMLCPP
  40. //--------------------------------------------------------------------------------------
  41. // Class: DEMParticle
  42. // Method: DEMParticle
  43. // Description: DeSerializing constructor (protected)
  44. //--------------------------------------------------------------------------------------
  45. DEMParticle::DEMParticle (const YAML::Node& node) : LemmaObject(node) {
  46. this->centreMass = node["centreMass"].as<Vector3r>();
  47. } // ----- end of method DEMParticle::DEMParticle (constructor) -----
  48. #endif
  49. //--------------------------------------------------------------------------------------
  50. // Class: DEMParticle
  51. // Method: NewSP()
  52. // Description: public constructor
  53. //--------------------------------------------------------------------------------------
  54. std::shared_ptr< DEMParticle > DEMParticle::NewSP() {
  55. std::shared_ptr<DEMParticle> sp(new DEMParticle("DEMParticle"), LemmaObjectDeleter() );
  56. return sp;
  57. }
  58. //--------------------------------------------------------------------------------------
  59. // Class: DEMParticle
  60. // Method: ~DEMParticle
  61. // Description: destructor (protected)
  62. //--------------------------------------------------------------------------------------
  63. DEMParticle::~DEMParticle () {
  64. } // ----- end of method DEMParticle::~DEMParticle (destructor) -----
  65. #ifdef HAVE_YAMLCPP
  66. //--------------------------------------------------------------------------------------
  67. // Class: DEMParticle
  68. // Method: Serialize
  69. //--------------------------------------------------------------------------------------
  70. YAML::Node DEMParticle::Serialize ( ) const {
  71. YAML::Node node = LemmaObject::Serialize();;
  72. node.SetTag( this->GetName() );
  73. // FILL IN CLASS SPECIFICS HERE
  74. node["centreMass"] = centreMass;
  75. return node;
  76. } // ----- end of method DEMParticle::Serialize -----
  77. //--------------------------------------------------------------------------------------
  78. // Class: DEMParticle
  79. // Method: DeSerialize
  80. //--------------------------------------------------------------------------------------
  81. std::shared_ptr<DEMParticle> DEMParticle::DeSerialize ( const YAML::Node& node ) {
  82. std::shared_ptr<DEMParticle> Object(new DEMParticle(node), LemmaObjectDeleter() );
  83. DESERIALIZECHECK( node, Object.get() )
  84. return Object ;
  85. } // ----- end of method DEMParticle::DeSerialize -----
  86. #endif
  87. //--------------------------------------------------------------------------------------
  88. // Class: DEMParticle
  89. // Method: GetCentreMass
  90. //--------------------------------------------------------------------------------------
  91. Vector3r DEMParticle::GetCentreMass ( ) {
  92. return centreMass;
  93. } // ----- end of method DEMParticle::get_CentreMass -----
  94. //--------------------------------------------------------------------------------------
  95. // Class: DEMParticle
  96. // Method: SetCentreMass
  97. //--------------------------------------------------------------------------------------
  98. void DEMParticle::SetCentreMass ( const Vector3r& pos ) {
  99. centreMass = pos;
  100. return ;
  101. } // ----- end of method DEMParticle::set_CentreMass -----
  102. } // ----- end of Lemma name -----