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.

DCSurvey.h 8.8KB

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