Galerkin FEM for elliptic PDEs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

structuredgrid.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // ===========================================================================
  2. //
  3. // Filename: structuredgrid.h
  4. //
  5. // Description: Derived class for structured grids. Base class to
  6. // regular and rectilinear grids.
  7. //
  8. // Version: 0.0
  9. // Created: 09/12/2013 08:29:26 AM
  10. // Revision: none
  11. // Compiler: Tested with g++
  12. //
  13. // Author: M. Andy Kass (MAK)
  14. //
  15. // Organisation: US Geological Survey
  16. //
  17. //
  18. // Email: mkass@usgs.gov
  19. //
  20. // This program is free software: you can redistribute it and/or modify
  21. // it under the terms of the GNU General Public License as published by
  22. // the Free Software Foundation, either version 3 of the License, or
  23. // (at your option) any later version.
  24. //
  25. // This program is distributed in the hope that it will be useful,
  26. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. // GNU General Public License for more details.
  29. //
  30. // You should have received a copy of the GNU General Public License
  31. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  32. //
  33. // ===========================================================================
  34. #ifndef __STRUCTUREDGRID_H
  35. #define __STRUCTUREDGRID_H
  36. #include "formalhaut.h"
  37. #include "grid.h"
  38. #include "exceptions.h"
  39. #include "logging.h"
  40. namespace formalhaut {
  41. // ===================================================================
  42. // Class: StructuredGrid
  43. /// \brief
  44. /// \details
  45. // ===================================================================
  46. class StructuredGrid : public Grid {
  47. friend std::ostream &operator<<(std::ostream &stream,
  48. const StructuredGrid &ob);
  49. public:
  50. // ==================== LIFECYCLE =======================
  51. static StructuredGrid* New();
  52. void Delete();
  53. // ==================== OPERATORS =======================
  54. // ==================== OPERATIONS =======================
  55. /// Set the number of cells in each direction
  56. void SetNCells(const Eigen::Matrix<int,3,1>& ncells);
  57. /// Set origin (top south west)
  58. void SetOrigin(const Vector3r& origin);
  59. // ==================== ACCESS =======================
  60. /// Read mesh parameters from Meshtools format
  61. void ReadMeshtoolsGrid(const std::string& fname);
  62. /// Attach a log object for writing lines to log file
  63. void AttachLogObject(Logging* logobj);
  64. // ==================== INQUIRY =======================
  65. /// Given a cell count in each direction, return the position that
  66. /// cell has in the unwrapped vector. Indexed from zero.
  67. int GetVectorPosition(const Eigen::Matrix<int,3,1>& cellpos);
  68. /// Given a position in space, determine if the position exists
  69. /// within the model region and then if so, in what cell does that
  70. /// position exist.
  71. int QueryCellPosition(const Vector3r& cellpos);
  72. /// Return vector with the number of cells in each direction
  73. Eigen::Matrix<int,3,1> GetNCells();
  74. /// Return a vector of the origin
  75. Vector3r GetOrigin();
  76. /// Return the centroid matrix
  77. Vector3Xr GetCentroids();
  78. /// Return a particular centroid
  79. Vector3r GetCentroid(const int& vecpos);
  80. protected:
  81. // ==================== LIFECYCLE =======================
  82. /// Default protected constructor.
  83. StructuredGrid ();
  84. /// Default protected constructor.
  85. ~StructuredGrid ();
  86. // ==================== DATA MEMBERS =========================
  87. /// Number of cells in x,y,z
  88. Eigen::Matrix<int,3,1> Nx3;
  89. /// Cell spacings in each dimension (3 x n)
  90. Vector3Xr Dx3;
  91. /// Origin (3 x 1)
  92. Vector3r Origin;
  93. /// Vectorized edge coordinates
  94. MatrixXr VecEdgCoord;
  95. /// Vectorized centroid coordinates (3 x n)
  96. Vector3Xr VecCentroid;
  97. /// Log object
  98. Logging* LogObj;
  99. /// Vector of cell spacings in each dimension (3 x n)
  100. std::vector<VectorXr> Dx3v;
  101. private:
  102. }; // ----- end of class StructuredGrid -----
  103. } // end of namespace formalhaut
  104. #endif