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

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