// =========================================================================== // // Filename: structuredgrid.h // // Description: Derived class for structured grids. Base class to // regular and rectilinear grids. // // Version: 0.0 // Created: 09/12/2013 08:29:26 AM // Revision: none // Compiler: Tested with g++ // // Author: M. Andy Kass (MAK) // // Organisation: US Geological Survey // // // Email: mkass@usgs.gov // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // =========================================================================== #ifndef __STRUCTUREDGRID_H #define __STRUCTUREDGRID_H #include "formalhaut.h" #include "grid.h" #include "exceptions.h" #include "logging.h" namespace formalhaut { // =================================================================== // Class: StructuredGrid /// \brief /// \details // =================================================================== class StructuredGrid : public Grid { friend std::ostream &operator<<(std::ostream &stream, const StructuredGrid &ob); public: // ==================== LIFECYCLE ======================= static StructuredGrid* New(); void Delete(); // ==================== OPERATORS ======================= // ==================== OPERATIONS ======================= /// Set the number of cells in each direction void SetNCells(const Eigen::Matrix& ncells); /// Set origin (top south west) void SetOrigin(const Vector3r& origin); // ==================== ACCESS ======================= /// Read mesh parameters from Meshtools format void ReadMeshtoolsGrid(const std::string& fname); /// Attach a log object for writing lines to log file void AttachLogObject(Logging* logobj); // ==================== INQUIRY ======================= /// Given a cell count in each direction, return the position that /// cell has in the unwrapped vector. Indexed from zero. int GetVectorPosition(const Eigen::Matrix& cellpos); /// Given a position in space, determine if the position exists /// within the model region and then if so, in what cell does that /// position exist. int QueryCellPosition(const Vector3r& cellpos); /// Return vector with the number of cells in each direction Eigen::Matrix GetNCells(); /// Return a vector of the origin Vector3r GetOrigin(); /// Return the centroid matrix Vector3Xr GetCentroids(); /// Return a particular centroid Vector3r GetCentroid(const int& vecpos); protected: // ==================== LIFECYCLE ======================= /// Default protected constructor. StructuredGrid (); /// Default protected constructor. ~StructuredGrid (); // ==================== DATA MEMBERS ========================= /// Number of cells in x,y,z Eigen::Matrix Nx3; /// Cell spacings in each dimension (3 x n) Vector3Xr Dx3; /// Origin (3 x 1) Vector3r Origin; /// Vectorized edge coordinates MatrixXr VecEdgCoord; /// Vectorized centroid coordinates (3 x n) Vector3Xr VecCentroid; /// Log object Logging* LogObj; /// Vector of cell spacings in each dimension (3 x n) std::vector Dx3v; private: }; // ----- end of class StructuredGrid ----- } // end of namespace formalhaut #endif