Program Listing for File grid.hpp

Return to documentation for file (grid.hpp)

// ***********************************************************************************
// Idefix MHD astrophysical code
// Copyright(C) 2020-2022 Geoffroy R. J. Lesur <geoffroy.lesur@univ-grenoble-alpes.fr>
// and other code contributors
// Licensed under CeCILL 2.1 License, see COPYING for more information
// ***********************************************************************************

#ifndef GRID_HPP_
#define GRID_HPP_
#include <vector>
#include "idefix.hpp"
#include "input.hpp"


class Grid {
 public:
  std::vector<IdefixArray1D<real>> x;
  std::vector<IdefixArray1D<real>> xr;
  std::vector<IdefixArray1D<real>> xl;
  std::vector<IdefixArray1D<real>> dx;

  std::vector<real> xbeg;
  std::vector<real> xend;

  std::vector<int> np_tot;
  std::vector<int> np_int;

  std::vector<int> nghost;
  std::vector<BoundaryType> lbound;
  std::vector<BoundaryType> rbound;

  bool haveAxis{false};


  GridCoarsening haveGridCoarsening{GridCoarsening::disabled};
  std::vector<bool> coarseningDirection;

  // MPI data
  std::vector<int> nproc;
  std::vector<int> xproc;

  #ifdef WITH_MPI
  MPI_Comm CartComm;
  MPI_Comm AxisComm;
  #endif

  // Constructor
  explicit Grid(Input &);
  void ShowConfig();

  Grid() = default;

 private:
  // Check if number is a power of 2
  bool isPow2(int);
  void makeDomainDecomposition();
};

#endif // GRID_HPP_