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