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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. struct ctor_key{};
  25. public:
  26. // ==================== FRIENDS ===========================
  27. /** Recursively prints out information about this class
  28. */
  29. friend std::ostream &operator<<(std::ostream &stream,
  30. const LayeredEarth &ob);
  31. // ==================== LIFECYCLE ===========================
  32. // ==================== OPERATORS ===========================
  33. // ==================== OPERATIONS ===========================
  34. // ==================== ACCESS ===========================
  35. /** Sets the number of layers and resizes all model parameters to
  36. * be the correct size, finally initialises all values to free
  37. * space.
  38. */
  39. virtual void SetNumberOfLayers(const int& nlay)=0;
  40. /** Sets the thickness of the layers
  41. */
  42. void SetLayerThickness(const VectorXr &thick);
  43. // ==================== INQUIRY ===========================
  44. /** Returns the number of layers in the model */
  45. int GetNumberOfLayers( );
  46. /** Returns the number of layers in the model, excluding the air
  47. * layer
  48. */
  49. int GetNumberOfNonAirLayers( );
  50. /** Returns the layer that a depth is in.
  51. * @param[in] depth is the depth you desire to know the layer of
  52. * @return the indice of the layer that depth is in.
  53. */
  54. int GetLayerAtThisDepth(const Real& depth);
  55. /** Returns the thickness of a layer
  56. * @param[in] lay is the layer indice
  57. * @return the thickness of a layer
  58. */
  59. Real GetLayerThickness(const int & lay);
  60. /** Returns the thickness of a layer
  61. * @param[in] lay is the layer indice
  62. * @return the thickness of all intermediary (non-infinite) layers
  63. */
  64. VectorXr GetLayerThickness( );
  65. /** Returns the depth of the bottom interface of a layer
  66. * @param[in] lay is the layer indice
  67. * @return the depth of the bottom interface of a layer
  68. */
  69. Real GetLayerDepth(const int & lay);
  70. /** YAML Serializing method
  71. */
  72. YAML::Node Serialize() const;
  73. /** Returns the name of the underlying class, similiar to Python's type */
  74. virtual std::string GetName() const;
  75. protected:
  76. // ==================== LIFECYCLE ===========================
  77. /** Default protected constructor. */
  78. LayeredEarth ( const ctor_key& );
  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