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

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