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.

RectilinearGridReader.h 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. /**
  7. @file
  8. @date 09/23/2013 11:05:11 AM
  9. @version $Id$
  10. @author Trevor Irons (ti)
  11. @email Trevor.Irons@xri-geo.com
  12. @copyright Copyright (c) 2013, XRI Geophysics, LLC
  13. @copyright Copyright (c) 2013, Trevor Irons
  14. **/
  15. #ifndef RECTILINEARGRIDREADER_INC
  16. #define RECTILINEARGRIDREADER_INC
  17. #include "GridReader.h"
  18. #include "RectilinearGrid.h"
  19. #include "ASCIIParser.h"
  20. namespace Lemma {
  21. /**
  22. @class
  23. \ingroup LemmaCore
  24. \brief Base Class for rectilinear grid reader data files
  25. \details
  26. \todo this set of classes is deprecated, use serialize methods!
  27. */
  28. class RectilinearGridReader : public GridReader {
  29. friend std::ostream &operator<<(std::ostream &stream,
  30. const RectilinearGridReader &ob);
  31. /*
  32. * This key is used to lock the constructors
  33. */
  34. struct ctor_key {};
  35. public:
  36. // ==================== LIFECYCLE =======================
  37. /** Default constructor
  38. * @note This method is locked
  39. * @see NewSP
  40. */
  41. explicit RectilinearGridReader ( const ctor_key& );
  42. /**
  43. * DeSerializing constructor.
  44. * @note This method is locked, and cannot be called directly.
  45. * The reason that the method is public is to enable the use
  46. * of make_shared whilst enforcing the use of shared_ptr,
  47. * in c++-17, this curiosity may be resolved.
  48. * @see DeSerialize
  49. */
  50. explicit RectilinearGridReader ( const YAML::Node& node, const ctor_key& );
  51. /** Default destructor.
  52. * @note This should never be called explicitly, use NewSP
  53. */
  54. ~RectilinearGridReader ( );
  55. /**
  56. * Factory method for generating concrete class.
  57. * @return a std::shared_ptr of type RectilinearGridReader
  58. */
  59. static std::shared_ptr< RectilinearGridReader > NewSP();
  60. /**
  61. * Constructs an object from a YAML serialization
  62. * @return a std::shared_ptr of type RectilinearGridReader
  63. */
  64. static std::shared_ptr< RectilinearGridReader > DeSerialize( const YAML::Node& node );
  65. /**
  66. * Uses YAML to serialize this object.
  67. * @return a YAML::Node
  68. */
  69. virtual YAML::Node Serialize() const;
  70. // ==================== OPERATORS =======================
  71. // ==================== OPERATIONS =======================
  72. /**
  73. Reads a .mod file, a simple representation of the grid. These files
  74. have the following format:
  75. @verbatim
  76. nx ny nz // number of cells in x, y, and z
  77. ox oy oz // grid offset of top SW corner
  78. hx[0] hx[1] ... hx[nx-1] // grid cell spacing in x, from 0 to nx-1
  79. hy[0] hy[1] ... hy[ny-1] // grid cell spacing in y, from 0 to ny-1
  80. hz[0] hz[1] ... hz[nz-1] // grid cell spacing in z, from 0 to nz-1
  81. // c++ style (//) comments are allowed anywhere, c-style are not
  82. @endverbatim
  83. */
  84. void ReadASCIIGridFile( const std::string& name );
  85. // ==================== ACCESS =======================
  86. /**
  87. * Accessor method for the underlying RectilinearGrid class constructed
  88. * from the input file.
  89. */
  90. std::shared_ptr<Grid> GetGrid();
  91. // ==================== INQUIRY =======================
  92. /** Returns the name of the underlying class, similiar to Python's type */
  93. virtual inline std::string GetName() const {
  94. return this->CName;
  95. }
  96. protected:
  97. // ==================== LIFECYCLE =======================
  98. private:
  99. // ==================== DATA MEMBERS =========================
  100. /** ASCII string representation of the class name */
  101. static constexpr auto CName = "RectilinearGridReader";
  102. /** Object holding constructed Grid */
  103. std::shared_ptr<RectilinearGrid> rGrid;
  104. /** Performs actual file parsing */
  105. std::shared_ptr<ASCIIParser> Parser;
  106. }; // ----- end of class RectilinearGridReader -----
  107. } // ----- end of Lemma name -----
  108. #endif // ----- #ifndef RECTILINEARGRIDREADER_INC -----
  109. /* vim: set tabstop=4 expandtab: */
  110. /* vim: set filetype=cpp syntax=cpp.doxygen: */