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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. /// Abstract 1D layered earth.
  19. // =======================================================================
  20. class LayeredEarth : public EarthModel {
  21. public:
  22. // ==================== FRIENDS ===========================
  23. /** Recursively prints out information about this class
  24. */
  25. friend std::ostream &operator<<(std::ostream &stream,
  26. const LayeredEarth &ob);
  27. // ==================== LIFECYCLE ===========================
  28. // ==================== OPERATORS ===========================
  29. // ==================== OPERATIONS ===========================
  30. // ==================== ACCESS ===========================
  31. /** Sets the number of layers and resizes all model parameters to
  32. * be the correct size, finally initialises all values to free
  33. * space.
  34. */
  35. virtual void SetNumberOfLayers(const int& nlay)=0;
  36. /** Sets the thickness of the layers
  37. */
  38. void SetLayerThickness(const VectorXr &thick);
  39. // ==================== INQUIRY ===========================
  40. /** Returns the number of layers in the model */
  41. int GetNumberOfLayers( );
  42. /** Returns the number of layers in the model, excluding the air
  43. * layer
  44. */
  45. int GetNumberOfNonAirLayers( );
  46. /** Returns the layer that a depth is in.
  47. * @param[in] depth is the depth you desire to know the layer of
  48. * @return the indice of the layer that depth is in.
  49. */
  50. int GetLayerAtThisDepth(const Real& depth);
  51. /** Returns the thickness of a layer
  52. * @param[in] lay is the layer indice
  53. * @return the thickness of a layer
  54. */
  55. Real GetLayerThickness(const int & lay);
  56. /** Returns the depth of the bottom interface of a layer
  57. * @param[in] lay is the layer indice
  58. * @return the depth of the bottom interface of a layer
  59. */
  60. Real GetLayerDepth(const int & lay);
  61. /** YAML Serializing method
  62. */
  63. YAML::Node Serialize() const;
  64. //static LayeredEarth* DeSerialize(const YAML::Node& node);
  65. /** Returns the name of the underlying class, similiar to Python's type */
  66. virtual inline std::string GetName() const {
  67. return this->CName;
  68. }
  69. protected:
  70. // ==================== LIFECYCLE ===========================
  71. /** Default protected constructor. */
  72. LayeredEarth ( );
  73. /** Default protected constructor. */
  74. LayeredEarth (const YAML::Node& node);
  75. /** Default protected constructor. */
  76. ~LayeredEarth ();
  77. // ==================== DATA MEMBERS ===========================
  78. private:
  79. /** ASCII string representation of the class name */
  80. static constexpr auto CName = "LayeredEarth";
  81. /** Number of layers in the model, including the air layer,
  82. * and counting from 0
  83. */
  84. int NumberOfLayers;
  85. /** Number of interfaces in the model. Equal to NumberOfLayers - 1
  86. */
  87. int NumberOfInterfaces;
  88. /** Vector of layer thicknesses */
  89. VectorXr LayerThickness;
  90. }; // ----- end of class LayeredEarth -----
  91. ///////////////////////////////////////////////////////////////////
  92. // Error classes
  93. /** If a model with less than two layers is specified, throw error. Not set up
  94. * for whole space solutions.
  95. */
  96. class EarthModelWithLessThanTwoLayers : public std::runtime_error {
  97. public:
  98. EarthModelWithLessThanTwoLayers( );
  99. };
  100. /** If a solver has a max number of layers, and this is exceeded, throw this
  101. * error.
  102. */
  103. class EarthModelWithMoreThanMaxLayers : public std::runtime_error {
  104. public:
  105. /** Thrown when an Earth model with more than the maximum number of
  106. * Layers is given
  107. */
  108. EarthModelWithMoreThanMaxLayers( );
  109. };
  110. /** If the model parameters have different lengths than the earth model, throw
  111. * this error.
  112. */
  113. class EarthModelParametersDoNotMatchNumberOfLayers : public std::runtime_error {
  114. public:
  115. /** Thrown when the parameters do not match the number of Layers
  116. */
  117. EarthModelParametersDoNotMatchNumberOfLayers ( );
  118. };
  119. /** If a request if made for a non-valid earth model parameter, throw this
  120. * error.
  121. */
  122. class RequestForNonValidEarthModelParameter : public std::runtime_error {
  123. public:
  124. /** Thrown when a request is made for a non-valid earth parameter
  125. */
  126. RequestForNonValidEarthModelParameter ( );
  127. };
  128. } // namespace Lemma
  129. #endif // __LAYEREDEARTH_H