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.

DEMGrain.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 06/16/2016 02:10:28 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, Trevor Irons & Lemma Software, LLC
  16. */
  17. #ifndef DEMGRAIN_INC
  18. #define DEMGRAIN_INC
  19. #pragma once
  20. #include "DEMParticle.h"
  21. #include <random>
  22. #include <time.h>
  23. namespace Lemma {
  24. /**
  25. \brief
  26. \details
  27. */
  28. class DEMGrain : public DEMParticle {
  29. friend std::ostream &operator<<(std::ostream &stream, const DEMGrain &ob);
  30. public:
  31. // ==================== LIFECYCLE =======================
  32. /*
  33. * Factory method for generating concrete class.
  34. * @return a std::shared_ptr of type DEMGrain
  35. */
  36. static std::shared_ptr< DEMGrain > NewSP();
  37. /**
  38. * Uses YAML to serialize this object.
  39. * @return a YAML::Node
  40. * @see DEMGrain::DeSerialize
  41. */
  42. YAML::Node Serialize() const;
  43. /**
  44. * Constructs an DEMGrain object from a YAML::Node.
  45. * @see DEMGrain::Serialize
  46. */
  47. static std::shared_ptr<DEMGrain> DeSerialize(const YAML::Node& node);
  48. // ==================== OPERATORS =======================
  49. // ==================== OPERATIONS =======================
  50. /**
  51. * Constructs the DEMGrain with random angular points. The points
  52. * are called from normal distribution
  53. * @param[input] npoints the number points to build a grain out of
  54. * @param[input] sigma is the variance of the random distribution
  55. */
  56. void RandomPointCloud ( const int& npoints, const Real& sigma );
  57. // ==================== ACCESS =======================
  58. // ==================== INQUIRY =======================
  59. virtual inline std::string GetName () const {
  60. return std::string(this->CName);
  61. }
  62. protected:
  63. /**
  64. * Performs a convex hull on the point cloud, uses a brute force approach
  65. */
  66. void ConvexHull();
  67. // ==================== LIFECYCLE =======================
  68. /**
  69. * Default protected constructor, use NewSP methods to construct
  70. * @see DEMGrain::NewSP
  71. */
  72. DEMGrain ( );
  73. /**
  74. * Protected DeDerializing constructor, use factory DeSerialize method.
  75. * @see DEMGrain::DeSerialize
  76. */
  77. DEMGrain (const YAML::Node& node);
  78. /** Default protected destructor, use smart pointers (std::shared_ptr) */
  79. ~DEMGrain ();
  80. // ==================== DATA MEMBERS =========================
  81. private:
  82. static constexpr auto CName = "DEMGrain";
  83. /** The points defining the angular grain */
  84. Vector3Xr Points;
  85. /** The connections between the points */
  86. MatrixXi Connections;
  87. }; // ----- end of class DEMGrain -----
  88. } // ----- end of namespace Lemma ----
  89. /* vim: set tabstop=4 expandtab: */
  90. /* vim: set filetype=cpp: */
  91. #endif // ----- #ifndef DEMGRAIN_INC -----