Lemma is an Electromagnetics API
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

RectilinearGridReader.h 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. virtual std::shared_ptr<Grid> GetGrid() const ;
  91. // ==================== INQUIRY =======================
  92. /** Returns the name of the underlying class, similiar to Python's type */
  93. virtual std::string GetName() const ;
  94. protected:
  95. // ==================== LIFECYCLE =======================
  96. private:
  97. // ==================== DATA MEMBERS =========================
  98. /** ASCII string representation of the class name */
  99. static constexpr auto CName = "RectilinearGridReader";
  100. /** Object holding constructed Grid */
  101. std::shared_ptr<RectilinearGrid> rGrid;
  102. /** Performs actual file parsing */
  103. std::shared_ptr<ASCIIParser> Parser;
  104. }; // ----- end of class RectilinearGridReader -----
  105. } // ----- end of Lemma name -----
  106. #endif // ----- #ifndef RECTILINEARGRIDREADER_INC -----
  107. /* vim: set tabstop=4 expandtab: */
  108. /* vim: set filetype=cpp syntax=cpp.doxygen: */