Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

LayeredEarth.h 5.5KB

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