Main Lemma Repository
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

RectilinearGridReader.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. \brief
  24. \details
  25. */
  26. class RectilinearGridReader : public GridReader {
  27. friend std::ostream &operator<<(std::ostream &stream,
  28. const RectilinearGridReader &ob);
  29. public:
  30. // ==================== LIFECYCLE =======================
  31. /**
  32. * Factory method for generating concrete class.
  33. * @return a std::shared_ptr of type RectilinearGridReader
  34. */
  35. static std::shared_ptr< RectilinearGridReader > NewSP();
  36. // ==================== OPERATORS =======================
  37. // ==================== OPERATIONS =======================
  38. /**
  39. Reads a .mod file, a simple representation of the grid. These files
  40. have the following format:
  41. @verbatim
  42. nx ny nz // number of cells in x, y, and z
  43. ox oy oz // grid offset of top SW corner
  44. hx[0] hx[1] ... hx[nx-1] // grid cell spacing in x, from 0 to nx-1
  45. hy[0] hy[1] ... hy[ny-1] // grid cell spacing in y, from 0 to ny-1
  46. hz[0] hz[1] ... hz[nz-1] // grid cell spacing in z, from 0 to nz-1
  47. // c++ style (//) comments are allowed anywhere, c-style are not
  48. @endverbatim
  49. */
  50. void ReadASCIIGridFile( const std::string& name );
  51. // ==================== ACCESS =======================
  52. /**
  53. * Accessor method for the underlying RectilinearGrid class constructed
  54. * from the input file.
  55. */
  56. std::shared_ptr<Grid> GetGrid();
  57. // ==================== INQUIRY =======================
  58. /** Returns the name of the underlying class, similiar to Python's type */
  59. virtual inline std::string GetName() const {
  60. return this->CName;
  61. }
  62. protected:
  63. // ==================== LIFECYCLE =======================
  64. /** Default protected constructor, use New */
  65. RectilinearGridReader ( );
  66. /** Default protected constructor, use Delete */
  67. ~RectilinearGridReader ();
  68. private:
  69. // ==================== DATA MEMBERS =========================
  70. /** ASCII string representation of the class name */
  71. static constexpr auto CName = "RectilinearGridReader";
  72. /** Object holding constructed Grid */
  73. std::shared_ptr<RectilinearGrid> rGrid;
  74. /** Performs actual file parsing */
  75. std::shared_ptr<ASCIIParser> Parser;
  76. }; // ----- end of class RectilinearGridReader -----
  77. } // ----- end of Lemma name -----
  78. #endif // ----- #ifndef RECTILINEARGRIDREADER_INC -----