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

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