Lemma is an Electromagnetics API
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.5KB

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