Main Lemma Repository
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LayeredEarth.h 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. protected:
  66. // ==================== LIFECYCLE ===========================
  67. /** Default protected constructor. */
  68. LayeredEarth ( );
  69. /** Default protected constructor. */
  70. LayeredEarth (const YAML::Node& node);
  71. /** Default protected constructor. */
  72. ~LayeredEarth ();
  73. // ==================== DATA MEMBERS ===========================
  74. private:
  75. /** ASCII string representation of the class name */
  76. static constexpr auto CName = "LayeredEarth";
  77. /** Number of layers in the model, including the air layer,
  78. * and counting from 0
  79. */
  80. int NumberOfLayers;
  81. /** Number of interfaces in the model. Equal to NumberOfLayers - 1
  82. */
  83. int NumberOfInterfaces;
  84. /** Vector of layer thicknesses */
  85. VectorXr LayerThickness;
  86. }; // ----- end of class LayeredEarth -----
  87. ///////////////////////////////////////////////////////////////////
  88. // Error classes
  89. /** If a model with less than two layers is specified, throw error. Not set up
  90. * for whole space solutions.
  91. */
  92. class EarthModelWithLessThanTwoLayers : public std::runtime_error {
  93. public:
  94. EarthModelWithLessThanTwoLayers( );
  95. };
  96. /** If a solver has a max number of layers, and this is exceeded, throw this
  97. * error.
  98. */
  99. class EarthModelWithMoreThanMaxLayers : public std::runtime_error {
  100. public:
  101. /** Thrown when an Earth model with more than the maximum number of
  102. * Layers is given
  103. */
  104. EarthModelWithMoreThanMaxLayers( );
  105. };
  106. /** If the model parameters have different lengths than the earth model, throw
  107. * this error.
  108. */
  109. class EarthModelParametersDoNotMatchNumberOfLayers : public std::runtime_error {
  110. public:
  111. /** Thrown when the parameters do not match the number of Layers
  112. */
  113. EarthModelParametersDoNotMatchNumberOfLayers ( );
  114. };
  115. /** If a request if made for a non-valid earth model parameter, throw this
  116. * error.
  117. */
  118. class RequestForNonValidEarthModelParameter : public std::runtime_error {
  119. public:
  120. /** Thrown when a request is made for a non-valid earth parameter
  121. */
  122. RequestForNonValidEarthModelParameter ( );
  123. };
  124. } // namespace Lemma
  125. #endif // __LAYEREDEARTH_H