Lemma is an Electromagnetics API
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 thickness of a layer
  59. * @param[in] lay is the layer indice
  60. * @return the thickness of all intermediary (non-infinite) layers
  61. */
  62. VectorXr GetLayerThickness( );
  63. /** Returns the depth of the bottom interface of a layer
  64. * @param[in] lay is the layer indice
  65. * @return the depth of the bottom interface of a layer
  66. */
  67. Real GetLayerDepth(const int & lay);
  68. /** YAML Serializing method
  69. */
  70. YAML::Node Serialize() const;
  71. /** Returns the name of the underlying class, similiar to Python's type */
  72. virtual std::string GetName() const;
  73. protected:
  74. // ==================== LIFECYCLE ===========================
  75. /** Default protected constructor. */
  76. LayeredEarth ( );
  77. /** Default protected constructor. */
  78. LayeredEarth (const YAML::Node& node);
  79. /** Default protected constructor. */
  80. ~LayeredEarth ();
  81. // ==================== DATA MEMBERS ===========================
  82. private:
  83. /** ASCII string representation of the class name */
  84. static constexpr auto CName = "LayeredEarth";
  85. /** no copy */
  86. LayeredEarth ( const LayeredEarth& ) = delete;
  87. /** Number of layers in the model, including the air layer,
  88. * and counting from 0
  89. */
  90. int NumberOfLayers;
  91. /** Number of interfaces in the model. Equal to NumberOfLayers - 1
  92. */
  93. int NumberOfInterfaces;
  94. /** Vector of layer thicknesses */
  95. VectorXr LayerThickness;
  96. }; // ----- end of class LayeredEarth -----
  97. ///////////////////////////////////////////////////////////////////
  98. // Error classes
  99. /** If a model with less than two layers is specified, throw error. Not set up
  100. * for whole space solutions.
  101. */
  102. class EarthModelWithLessThanTwoLayers : public std::runtime_error {
  103. public:
  104. EarthModelWithLessThanTwoLayers( );
  105. };
  106. /** If a solver has a max number of layers, and this is exceeded, throw this
  107. * error.
  108. */
  109. class EarthModelWithMoreThanMaxLayers : public std::runtime_error {
  110. public:
  111. /** Thrown when an Earth model with more than the maximum number of
  112. * Layers is given
  113. */
  114. EarthModelWithMoreThanMaxLayers( );
  115. };
  116. /** If the model parameters have different lengths than the earth model, throw
  117. * this error.
  118. */
  119. class EarthModelParametersDoNotMatchNumberOfLayers : public std::runtime_error {
  120. public:
  121. /** Thrown when the parameters do not match the number of Layers
  122. */
  123. EarthModelParametersDoNotMatchNumberOfLayers ( );
  124. };
  125. /** If a request if made for a non-valid earth model parameter, throw this
  126. * error.
  127. */
  128. class RequestForNonValidEarthModelParameter : public std::runtime_error {
  129. public:
  130. /** Thrown when a request is made for a non-valid earth parameter
  131. */
  132. RequestForNonValidEarthModelParameter ( );
  133. };
  134. } // namespace Lemma
  135. #endif // __LAYEREDEARTH_H