Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:17:12

0001 //
0002 // APFEL++ 2017
0003 //
0004 // Author: Valerio Bertone: valerio.bertone@cern.ch
0005 //
0006 
0007 #pragma once
0008 
0009 #include "apfel/subgrid.h"
0010 
0011 #include <memory>
0012 
0013 namespace apfel
0014 {
0015   /**
0016    * @brief The Grid class defines ab object that is essentially a
0017    * collection of "SubGrid" objects plus other global
0018    * parameters. This class also includes all the relevant methods for
0019    * the manipulation of the SubGrids.
0020    */
0021   class Grid
0022   {
0023   public:
0024     /**
0025      * @brief Structure for the subgrid parameters which encapsulates
0026      * lower value of the grid (xMin), density factor w.r.t. the
0027      * previous grid (density), and interpolation degree
0028      * (InterDegree).
0029      */
0030     struct SubGridPars
0031     {
0032       double xMin;
0033       int    density;
0034       int    InterDegree;
0035     };
0036 
0037     /**
0038      * @brief The Grid constructor.
0039      * @param grs: vector of subgrids
0040      */
0041     Grid(std::vector<SubGrid> const& grs);
0042 
0043     /**
0044      * @brief The Grid constructor.
0045      * @param mgr: main subgrid with the lowest xmin
0046      * @param sgpars: vector of subgrid parameters
0047      */
0048     Grid(SubGrid const& mgr, std::vector<SubGridPars> const& sgpars);
0049 
0050     /**
0051      * @name Getters
0052      */
0053     ///@{
0054     /**
0055      * @return The number of subgrids
0056      */
0057     int nGrids() const { return _GlobalGrid.size(); }
0058 
0059     /**
0060      * @return The map of indices from the joint grid to the subgrids
0061      */
0062     std::vector<std::pair<int, int>> const& SubToJointMap() const { return _SubToJointMap; }
0063 
0064     /**
0065      * @return The map of indices from the subgrids to the joint grid
0066      */
0067     std::vector<std::vector<int>> const& JointToSubMap() const { return _JointToSubMap; }
0068 
0069     /**
0070      * @return The vector of transition indices on the joint grid
0071      */
0072     std::vector<int> const& TransitionPoints() const { return _TransPoints; }
0073 
0074     /**
0075      * @return The vector of subgrids
0076      */
0077     std::vector<SubGrid> const& GetSubGrids() const { return _GlobalGrid; }
0078 
0079     /**
0080      * @return The ig-th SubGrid
0081      */
0082     SubGrid const& GetSubGrid(int ig) const { return _GlobalGrid[ig]; }
0083 
0084     /**
0085      * @return The joint SubGrid
0086      */
0087     SubGrid const& GetJointGrid() const { return *_JointGrid; }
0088 
0089     /**
0090      * @brief Print the Grid object
0091      */
0092     void Print() const { std::cout << *this << std::endl; }
0093     ///@}
0094 
0095     /**
0096      * @name Comparison operators
0097      * Collection of operators for comparing grid objects
0098      */
0099     ///@{
0100     bool operator == (Grid const& g) const;
0101     bool operator != (Grid const& g) const;
0102     ///@}
0103 
0104   private:
0105     /**
0106      * @brief Fill in the joint grid object with the appropriate grid
0107      * nodes.
0108      * @return the joint grid
0109      */
0110     SubGrid CreateJointGrid();
0111 
0112     /**
0113      * @brief Fill in the joint grid object with the appropriate grid
0114      * nodes.
0115      * @param mgr: main subgrid with the lowest xmin
0116      * @param sgpars: vector of subgrid parameters
0117      * @return a vector of sub grids (including the main one) already
0118      * locked and with the requested density factors.
0119      */
0120     std::vector<SubGrid> CreateSubGrids(SubGrid const& mgr, std::vector<SubGridPars> const& sgpars);
0121 
0122   private:
0123     std::vector<std::pair<int, int>> _SubToJointMap; //!< Vector of pairs corresponding to grid- and node-indices on the subgrids.
0124     std::vector<std::vector<int>>    _JointToSubMap; //!< Vector of indices from the subgrids to the joint grid
0125     std::vector<int>                 _TransPoints;   //!< Vector of indices corresponding to the transition from one subgrid to the other
0126     std::vector<SubGrid>             _GlobalGrid;    //!< Vector with sub-grids.
0127     std::unique_ptr<SubGrid>         _JointGrid;     //!< Container for the joint grid.
0128 
0129     friend std::ostream& operator << (std::ostream& os, Grid const& gr);
0130   };
0131 
0132   /**
0133    * @brief Overload the << operator to print the parameters of the
0134    * grid.
0135    */
0136   std::ostream& operator << (std::ostream& os, Grid const& gr);
0137 }