Main Lemma Repository
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.

LayeredEarth.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 06/24/2009
  9. @version 0.0
  10. **/
  11. #ifndef __LAYEREDEARTH_H
  12. #define __LAYEREDEARTH_H
  13. #include "EarthModel.h"
  14. namespace Lemma {
  15. const int MAXLAYERS = 10;
  16. // =======================================================================
  17. // Class: LayeredEarth
  18. /// \ingroup LemmaCore
  19. /// \brief Abstract 1D layered earth.
  20. // =======================================================================
  21. class LayeredEarth : public EarthModel {
  22. friend class LayeredEarthEM;
  23. public:
  24. // ==================== FRIENDS ===========================
  25. /** Recursively prints out information about this class
  26. */
  27. friend std::ostream &operator<<(std::ostream &stream,
  28. const LayeredEarth &ob);
  29. // ==================== LIFECYCLE ===========================
  30. // ==================== OPERATORS ===========================
  31. // ==================== OPERATIONS ===========================
  32. // ==================== ACCESS ===========================
  33. /** Sets the number of layers and resizes all model parameters to
  34. * be the correct size, finally initialises all values to free
  35. * space.
  36. */
  37. virtual void SetNumberOfLayers(const int& nlay)=0;
  38. /** Sets the thickness of the layers
  39. */
  40. void SetLayerThickness(const VectorXr &thick);
  41. // ==================== INQUIRY ===========================
  42. /** Returns the number of layers in the model */
  43. int GetNumberOfLayers( );
  44. /** Returns the number of layers in the model, excluding the air
  45. * layer
  46. */
  47. int GetNumberOfNonAirLayers( );
  48. /** Returns the layer that a depth is in.
  49. * @param[in] depth is the depth you desire to know the layer of
  50. * @return the indice of the layer that depth is in.
  51. */
  52. int GetLayerAtThisDepth(const Real& depth);
  53. /** Returns the thickness of a layer
  54. * @param[in] lay is the layer indice
  55. * @return the thickness of a layer
  56. */
  57. Real GetLayerThickness(const int & lay);
  58. /** Returns the depth of the bottom interface of a layer
  59. * @param[in] lay is the layer indice
  60. * @return the depth of the bottom interface of a layer
  61. */
  62. Real GetLayerDepth(const int & lay);
  63. /** YAML Serializing method
  64. */
  65. YAML::Node Serialize() const;
  66. /** Returns the name of the underlying class, similiar to Python's type */
  67. virtual inline std::string GetName() const {
  68. return this->CName;
  69. }
  70. protected:
  71. // ==================== LIFECYCLE ===========================
  72. /** Default protected constructor. */
  73. LayeredEarth ( );
  74. /** Default protected constructor. */
  75. LayeredEarth (const YAML::Node& node);
  76. /** Default protected constructor. */
  77. ~LayeredEarth ();
  78. // ==================== DATA MEMBERS ===========================
  79. private:
  80. /** ASCII string representation of the class name */
  81. static constexpr auto CName = "LayeredEarth";
  82. /** no copy */
  83. LayeredEarth ( const LayeredEarth& ) = delete;
  84. /** Number of layers in the model, including the air layer,
  85. * and counting from 0
  86. */
  87. int NumberOfLayers;
  88. /** Number of interfaces in the model. Equal to NumberOfLayers - 1
  89. */
  90. int NumberOfInterfaces;
  91. /** Vector of layer thicknesses */
  92. VectorXr LayerThickness;
  93. }; // ----- end of class LayeredEarth -----
  94. ///////////////////////////////////////////////////////////////////
  95. // Error classes
  96. /** If a model with less than two layers is specified, throw error. Not set up
  97. * for whole space solutions.
  98. */
  99. class EarthModelWithLessThanTwoLayers : public std::runtime_error {
  100. public:
  101. EarthModelWithLessThanTwoLayers( );
  102. };
  103. /** If a solver has a max number of layers, and this is exceeded, throw this
  104. * error.
  105. */
  106. class EarthModelWithMoreThanMaxLayers : public std::runtime_error {
  107. public:
  108. /** Thrown when an Earth model with more than the maximum number of
  109. * Layers is given
  110. */
  111. EarthModelWithMoreThanMaxLayers( );
  112. };
  113. /** If the model parameters have different lengths than the earth model, throw
  114. * this error.
  115. */
  116. class EarthModelParametersDoNotMatchNumberOfLayers : public std::runtime_error {
  117. public:
  118. /** Thrown when the parameters do not match the number of Layers
  119. */
  120. EarthModelParametersDoNotMatchNumberOfLayers ( );
  121. };
  122. /** If a request if made for a non-valid earth model parameter, throw this
  123. * error.
  124. */
  125. class RequestForNonValidEarthModelParameter : public std::runtime_error {
  126. public:
  127. /** Thrown when a request is made for a non-valid earth parameter
  128. */
  129. RequestForNonValidEarthModelParameter ( );
  130. };
  131. } // namespace Lemma
  132. #endif // __LAYEREDEARTH_H