Main Lemma Repository
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 10/08/2014 01:51:50 PM
  11. * @author Trevor Irons (ti)
  12. * @email Trevor.Irons@lemmasoftware.org
  13. * @copyright Copyright (c) 2014, 2018 Trevor Irons
  14. */
  15. #ifndef DCSURVEY
  16. #define DCSURVEY
  17. #include "LemmaObject.h"
  18. #include "DCIPElectrode.h"
  19. #ifdef LEMMAUSEVTK
  20. #include <vtkDataSet.h>
  21. #endif
  22. namespace Lemma {
  23. #define EINFINITY -9999
  24. /**
  25. \brief Describes a DC survey.
  26. \details This class aims to encapulate any type of DC survey.
  27. */
  28. class DCSurvey : public LemmaObject {
  29. friend std::ostream &operator<<(std::ostream &stream,
  30. const DCSurvey &ob);
  31. public:
  32. // ==================== LIFECYCLE =======================
  33. /**
  34. * \brief Returns new shared pointer to DCIP object.
  35. * \details Use this method, as the default constructor is locked.
  36. */
  37. static std::shared_ptr<DCSurvey> NewSP();
  38. /**
  39. * Uses YAML to serialize this object.
  40. * @return a YAML::Node
  41. */
  42. YAML::Node Serialize() const;
  43. /**
  44. * Constructs an object from a YAML::Node.
  45. */
  46. static std::shared_ptr<DCSurvey> DeSerialize(const YAML::Node& node);
  47. /** Default protected constructor, use New */
  48. explicit DCSurvey (const ctor_key& key);
  49. /** Default protected constructor, use New */
  50. DCSurvey (const YAML::Node& node, const ctor_key& key);
  51. /** Default protected destructor, use Delete */
  52. virtual ~DCSurvey ();
  53. // ==================== OPERATORS =======================
  54. // ==================== OPERATIONS =======================
  55. /**
  56. * Adds new electrode to the survey.
  57. * @param[in] Electrode `Pounds' a new Electrode into place.
  58. * @return integer index to this electrode.
  59. * @note Single electrodes cannot be pulled once they are pounded. The reason for this is that
  60. * every index then would become invalid. Furthurmore these are stored in a std::vector and
  61. * removing arbitrary items is inefficient.
  62. * @see PullElectrodes
  63. * @param[in] label is an optional tag for electrode.
  64. * @param[in] nodeID is the optional node ID on a mesh
  65. */
  66. int PoundElectrode( std::shared_ptr<DCIPElectrode> Electrode, const std::string& label = "NULL", const int& nodeID=-1 );
  67. /** Alternative Factory method of setting electrodes. IN this manner all memoy management
  68. * is handled by DCSurvey.
  69. * @note there is no logic preventing one from pounding coincident electrodes. Don't do it.
  70. * @note Single electrodes cannot be pulled once they are pounded. The reason for this is that
  71. * every index then would become invalid. Furthurmore these are stored in a std::vector and
  72. * removing arbitrary items is inefficient.
  73. * @see PullElectrodes
  74. * @param[in] loc is the location of the electrode.
  75. * @param[in] label is an optional label for electrode.
  76. * @param[in] nodeID is the optional node ID on a mesh
  77. */
  78. std::shared_ptr<DCIPElectrode> PoundElectrode( const Vector3r& loc, const std::string& label = "NULL", const int& nodeID=-1 );
  79. #ifdef LEMMAUSEVTK
  80. std::shared_ptr<DCIPElectrode> PoundElectrode( const int& nodeID, vtkDataSet* Mesh, const std::string& label = "NULL" );
  81. #endif
  82. /**
  83. * Pulls all electrodes and removes connections.
  84. */
  85. void PullElectrodes();
  86. /**
  87. * Adds an injection point.
  88. * @param[in] A is the positive current electrode
  89. * @param[in] B is the negative current electrode
  90. * @param[in] J is the current intensity
  91. * @see AddInjection(const int& iA, const int& iB, const Real& J)
  92. * @see AddInjection(const int& iA, const Real& J)
  93. * @see AddInjection(std::shared_ptr<DCIPElectrode> A, const Real& J)
  94. */
  95. int AddInjection( std::shared_ptr<DCIPElectrode> A, std::shared_ptr<DCIPElectrode> B, const Real& J);
  96. /**
  97. * Adds an injection point.
  98. * @param[in] A is the positive current electrode.
  99. * @param[in] J is the current intensity.
  100. * B, the negative current electrode is taken to be infinity
  101. * @see AddInjection(const int& iA, const int& iB, const Real& J)
  102. * @see AddInjection(const int& iA, const Real& J)
  103. * @see AddInjection(std::shared_ptr<DCIPElectrode> A, std::shared_ptr<DCIPElectrode> B, const Real& J)
  104. */
  105. int AddInjection( std::shared_ptr<DCIPElectrode> A, const Real& J );
  106. /**
  107. * Adds an injection point.
  108. * @param[in] A is the positive current electrode index
  109. * @param[in] B is the negative current electrode index
  110. * @param[in] J is the current intensity
  111. * @see AddInjection(std::shared_ptr<DCIPElectrode> A, std::shared_ptr<DCIPElectrode> B, const Real& J)
  112. * @see AddInjection(std::shared_ptr<DCIPElectrode> A, const Real& J)
  113. * @see AddInjection(const int& iA, const Real& J)
  114. */
  115. int AddInjection( const int& iA, const int& iB, const Real& J );
  116. /**
  117. * Adds an injection point with the negative electrode at infinity.
  118. * @param[in] A is the positive current electrode index
  119. * @param[in] J is the current intensity
  120. * @see AddInjection(std::shared_ptr<DCIPElectrode> A, std::shared_ptr<DCIPElectrode> B, const Real& J)
  121. * @see AddInjection(std::shared_ptr<DCIPElectrode> A, const Real& J)
  122. * @see AddInjection(const int& iA, const int& iB, const Real& J)
  123. */
  124. int AddInjection( const int& iA, const Real& J );
  125. /** Adds a potential measurement via the electrode pair comparison \f$ M - N \f$.
  126. * @param[in] M is a pointer to the `positive' electrode
  127. * @param[in] N is a pointer to the `negative' electrode
  128. * @param[in] iJ is the current injection index to associate with this measurement
  129. */
  130. void AddMeasurement( const int& iJ, std::shared_ptr<DCIPElectrode> M, std::shared_ptr<DCIPElectrode> N );
  131. /** Adds a potential measurement via the electrode pair comparison \f$ M - N \f$.
  132. * @param[in] M is the `positive' electrode string label name
  133. * @param[in] N is the `negative' electrode string label name
  134. * @param[in] iJ is the current injection index to associate with this measurement
  135. * @see AddMeasurement( const int& iJ, std::shared_ptr<DCIPElectrode> M, std::shared_ptr<DCIPElectrode> N )
  136. */
  137. void AddMeasurement( const int& ij, const std::string& M, const std::string& N);
  138. /**
  139. * Used to probe for the index and current of an injection
  140. * @param[in] ij is the current injection indes
  141. * @param[out] ii is the node index
  142. * @param[out] jj is the current
  143. */
  144. void GetA( const int& ij, int& ii, Real& jj );
  145. /**
  146. * Used to probe for the index and current of an injection
  147. * @param[in] ij is the current injection indes
  148. * @param[out] ii is the node index
  149. * @param[out] jj is the current
  150. */
  151. void GetB( const int& ij, int& ii, Real& jj );
  152. // ==================== ACCESS =======================
  153. // ==================== INQUIRY =======================
  154. protected:
  155. // ==================== LIFECYCLE =======================
  156. private:
  157. // ==================== DATA MEMBERS =========================
  158. /** ASCII string representation of the class name */
  159. static constexpr auto CName = "DCSurvey";
  160. /** no copy */
  161. DCSurvey ( const DCSurvey& ) = delete;
  162. /** The electrodes */
  163. std::vector< std::shared_ptr<DCIPElectrode> > Electrodes;
  164. /** Tags for the electrodes, lines etc. Ordered with Electrodes std::vector */
  165. std::vector<std::string> OrderedElectrodeLabels;
  166. /** Map of tags for the electrodes, lines etc. */
  167. std::map<std::string, std::pair< std::shared_ptr<DCIPElectrode>, int> > ElectrodeLabelMap;
  168. /** The A Injection electrodes */
  169. std::vector<int> A_Electrodes;
  170. /** The A Injection electrodes */
  171. std::vector<int> B_Electrodes;
  172. /** The A Injection electrodes */
  173. std::vector<Real> J_Electrodes;
  174. /** First Potential electrodes */
  175. std::vector< std::vector<int> > M_Electrodes;
  176. /** Second Potential electrodes */
  177. std::vector< std::vector<int> > N_Electrodes;
  178. }; // ----- end of class DCSurvey -----
  179. } // ----- end of Lemma name -----
  180. #endif // ----- #ifndef DCSURVEY -----