123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- /* This file is part of Lemma, a geophysical modelling and inversion API */
-
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
- /**
- @file
- @author Trevor Irons
- @date 10/28/2010
- @version $Id: rectilineargrid.h 193 2014-11-10 23:51:41Z tirons $
- **/
-
- #ifndef RECTILINEARGRID_INC
- #define RECTILINEARGRID_INC
-
- #include "Grid.h"
-
- namespace Lemma {
-
- /**
- * \ingroup LemmaCore
- * \brief Impliments a rectilinear grid.
- * \details A rectilinear grid can vary regularily in space but must be
- * constant variation across each dimension. In this way three
- * vectors can define the entire grid, and each cell is right
- * aligned with all its neighbours.
- */
- class RectilinearGrid : public Grid {
-
- friend std::ostream &operator<<(std::ostream &stream,
- const RectilinearGrid &ob);
-
- /*
- * This key is used to lock the constructors
- */
- struct ctor_key {};
-
- public:
-
- // ==================== LIFECYCLE =======================
-
- /**
- * DeSerializing constructor.
- * @note This method is locked, and cannot be called directly.
- * The reason that the method is public is to enable the use
- * of make_shared whilst enforcing the use of shared_ptr,
- * in c++-17, this curiosity may be resolved.
- * @see RectilinearGrid::NewSP
- */
- explicit RectilinearGrid ( const ctor_key& );
-
- /**
- * DeSerializing constructor.
- * @note This method is locked, and cannot be called directly.
- * The reason that the method is public is to enable the use
- * of make_shared whilst enforcing the use of shared_ptr,
- * in c++-17, this curiosity may be resolved.
- * @see DeSerialize
- */
- explicit RectilinearGrid (const YAML::Node& node, const ctor_key& );
-
- /** Default destructor.
- * @note This should never be called explicitly, use NewSP
- */
- virtual ~RectilinearGrid ();
-
- /**
- * Uses YAML to serialize this object.
- * @return a YAML::Node
- */
- virtual YAML::Node Serialize() const;
-
- /**
- * Factory method for generating concrete class.
- * @return a std::shared_ptr of type RectilinearGrid
- */
- static std::shared_ptr<RectilinearGrid> NewSP();
-
- /**
- * Constructs an object from a YAML::Node.
- */
- static std::shared_ptr< RectilinearGrid > DeSerialize(const YAML::Node& node);
-
- // ==================== OPERATORS =======================
-
- // ==================== OPERATIONS =======================
-
- /**
- * Sets the dimensions in x, y and z
- * @param[in] nx is the number of cells in x
- * @param[in] ny is the number of cells in y
- * @param[in] nz is the number of cells in z
- */
- void SetDimensions (const int &nx, const int &ny, const int &nz);
-
- /**
- * Sets the offset in x, y and z. This sets the corner position of the top SW corner.
- * @param[in] ox is the number of cells in x
- * @param[in] oy is the number of cells in y
- * @param[in] oz is the number of cells in z
- */
- void SetOffset (const Real &ox, const Real &oy, const Real &oz);
-
- /**
- * Sets the spacing in x, y and z
- * @param[in] dx is a Vector of cell spacing in x, must be same
- * size ad nx
- * @param[in] dy is a Vector of cell spacing in x, must be same
- * size ad ny
- * @param[in] dz is a Vector of cell spacing in x, must be same
- * size ad nz
- */
- void SetSpacing (const VectorXr &dx, const VectorXr &dy,
- const VectorXr &dz);
-
-
- // ==================== ACCESS =======================
-
- /** Returns the number of cells in x
- * @return number of cells in x
- */
- int GetNx();
-
- /** Returns the number of cells in y
- * @return number of cells in y
- */
- int GetNy();
-
- /** Returns the number of cells in z
- * @return number of cells in z
- */
- int GetNz();
-
- /** Returns the offset of cells in x
- * @return offset of cells in x
- */
- Real GetOx();
-
- /** Returns the number of cells in y
- * @return number of cells in y
- */
- Real GetOy();
-
- /** Returns the offset of cells in z
- * @return offset of cells in z
- */
- Real GetOz();
-
- /** Returns Spacing Vector
- * @return dx
- */
- VectorXr GetDx();
-
- /** Returns a spacing
- * @return dx[ix]
- */
- Real GetDx(const int& ix);
-
- /** Returns Spacing Vector
- * @return dy
- */
- VectorXr GetDy();
-
- /** Returns a spacing
- * @return dy[iy]
- */
- Real GetDy(const int& iy);
-
- /** Returns Spacing Vector
- * @return dz
- */
- VectorXr GetDz();
-
- /** Returns Spacing Vector
- * @return dz[iz]
- */
- Real GetDz(const int& iz);
-
- // ==================== INQUIRY =======================
-
- /** Returns the name of the underlying class, similiar to Python's type */
- virtual inline std::string GetName() const;
-
- protected:
-
- // ==================== LIFECYCLE =======================
-
- private:
-
- /** ASCII string representation of the class name */
- static constexpr auto CName = "RectilinearGrid";
-
- // ==================== DATA MEMBERS =========================
-
- /// Number of cells in the x dimension
- int nx;
-
- /// Number of cells in the y dimension
- int ny;
-
- /// Number of cells in the z dimension
- int nz;
-
- /// Grid offset in x dimension
- Real ox;
-
- /// Grid offset in y dimension
- Real oy;
-
- /// Grid offset in z dimension
- Real oz;
-
- /// Cell spacing in the x dimension
- VectorXr dx;
-
- /// Cell spacing in the y dimension
- VectorXr dy;
-
- /// Cell spacing in the z dimension
- VectorXr dz;
-
- }; // ----- end of class RectilinearGrid -----
-
- } // ----- end of Lemma name -----
-
- #endif // ----- #ifndef RECTILINEARGRID_INC -----
-
- /* vim: set tabstop=4 expandtab: */
- /* vim: set filetype=cpp syntax=cpp.doxygen: */
|