12template <
class distributed_vector>
36 from_json (
const nlohmann::json &j, grid_properties_t &q) {
38 j.at (
"nx").get_to (q.numcols);
39 j.at (
"ny").get_to (q.numrows);
40 j.at (
"hx").get_to (q.hx);
41 j.at (
"hy").get_to (q.hy);
45 q.end_cell_row = q.numrows - 1;
47 q.end_cell_col = q.numcols - 1;
48 q.start_owned_nodes = 0;
49 q.num_owned_nodes = (q.numrows+1)*(q.numcols+1);
56 return (idx / numrows);
62 return (idx % numrows);
68 idx_t bottom_left = 0;
70 bottom_left = ridx + cidx * (numrows + 1);
76 return (bottom_left + 1);
79 return (bottom_left + (numrows + 1));
82 return (bottom_left + (numrows + 2));
115 bottom_left = colidx *
hx;
119 bottom_left = rowidx *
hy;
120 if (inode == 1 || inode == 3)
123 return (bottom_left);
133 return ((x -
p(0,0,c,r,
hx,
hy))/
hx * (y -
p(1,0,c,r,
hx,
hy))/
hy);
136 return ((x -
p(0,0,c,r,
hx,
hy))/
hx * (1. - (y -
p(1,0,c,r,
hx,
hy))/
hy));
139 return ((1. - (x -
p(0,0,c,r,
hx,
hy))/
hx) * (y -
p(1,0,c,r,
hx,
hy))/
hy);
142 return ((1. - (x -
p(0,0,c,r,
hx,
hy))/
hx) * (1. - (y -
p(1,0,c,r,
hx,
hy))/
hy));
157 return ((1. /
hx) * ((y -
p(1,0,c,r,
hx,
hy)) /
hy));
159 else if (idir == 1) {
160 return (((x -
p(0,0,c,r,
hx,
hy)) /
hx) * (1. /
hy));
165 return ((1. /
hx) * ((1. - (y -
p(1,0,c,r,
hx,
hy)) /
hy)));
167 else if (idir == 1) {
168 return (((x -
p(0,0,c,r,
hx,
hy)) /
hx) * (- 1. /
hy));
173 return ((- 1. /
hx) * ((y -
p(1,0,c,r,
hx,
hy)) /
hy));
175 else if (idir == 1) {
176 return ((1. - (x -
p(0,0,c,r,
hx,
hy)) /
hx) * (1. /
hy));
181 return ((- 1. /
hx) * (1. - (y -
p(1,0,c,r,
hx,
hy)) /
hy));
183 else if (idir == 1) {
184 return ((1. - (x -
p(0,0,c,r,
hx,
hy))/
hx) * (- 1. /
hy));
212 {
return *(this->
data); };
216 {
return *(this->
data); };
220 {
return this->
data; };
224 {
return this->
data; };
232 {
return ! ((*this) == other); }
454 const std::map<std::string,
455 distributed_vector> & f)
const;
459 const std::map<std::string,
460 distributed_vector> & f)
const;
cell_iterator(cell_t *_data=nullptr)
idx_t start_cell_row() const
idx_t end_cell_col() const
real_t shp_new(real_t x, real_t y, idx_t inode) const
idx_t sub2gind(idx_t r, idx_t c) const
static constexpr idx_t NOT_ON_BOUNDARY
real_t shg(real_t x, real_t y, idx_t idir, idx_t inode) const
static constexpr idx_t edges_per_cell
const neighbor_iterator begin_neighbor_sweep() const
const neighbor_iterator end_neighbor_sweep() const
cell_t(const grid_properties_t &_gp)
idx_t end_cell_row() const
idx_t get_global_cell_idx() const
const grid_properties_t & grid_properties
neighbor_iterator end_neighbor_sweep()
idx_t gind2col(idx_t idx) const
idx_t get_local_cell_idx() const
friend class cell_iterator
idx_t gind2row(idx_t idx) const
static constexpr idx_t nodes_per_cell
neighbor_iterator begin_neighbor_sweep()
idx_t start_cell_col() const
neighbor_iterator(cell_t *_data=nullptr, int _face_idx=-1)
cell_t * data
Face index in 0...3 (-1 if not defined).
const cell_t & operator[](idx_t tmp) const
idx_t sub2gind(idx_t r, idx_t c) const
idx_t gind2row(idx_t idx) const
idx_t num_local_cells() const
HOST static DEVICE idx_t gind2row(idx_t idx, idx_t numrows)
HOST static DEVICE real_t p(idx_t idir, idx_t inode, idx_t colidx, idx_t rowidx, real_t hx, real_t hy)
void vtk_export(const char *filename, const std::map< std::string, distributed_vector > &f) const
void set_sizes(idx_t numrows, idx_t numcols, real_t hx, real_t hy)
quadgrid_t & operator=(const quadgrid_t &)=delete
Delete assignment operator.
quadgrid_t(const quadgrid_t &)=delete
Delete copy constructor.
idx_t num_local_nodes() const
idx_t num_global_nodes() const
HOST static DEVICE idx_t sub2gind(idx_t r, idx_t c, idx_t nr)
const cell_iterator begin_cell_sweep() const
HOST static DEVICE real_t shp(real_t x, real_t y, idx_t inode, idx_t c, idx_t r, real_t hx, real_t hy)
HOST static DEVICE real_t shg(real_t x, real_t y, idx_t idir, idx_t inode, idx_t c, idx_t r, real_t hx, real_t hy)
HOST static DEVICE idx_t gt(idx_t inode, idx_t cidx, idx_t ridx, idx_t numrows)
HOST static DEVICE idx_t gind2col(idx_t idx, idx_t numrows)
cell_iterator begin_cell_sweep()
void octave_ascii_export(const char *filename, const std::map< std::string, distributed_vector > &f) const
void from_json(const nlohmann::json &j, grid_properties_t &q)
quadgrid_t(const nlohmann::json &j, MPI_Comm _comm=MPI_COMM_WORLD)
Ctor that reads grid properties from a json object.
const cell_iterator end_cell_sweep() const
grid_properties_t grid_properties
quadgrid_t(MPI_Comm _comm=MPI_COMM_WORLD)
Default constructor, set all pointers to nullptr.
cell_iterator end_cell_sweep()
~quadgrid_t()=default
Destructor.
idx_t gind2col(idx_t idx) const
idx_t num_global_cells() const
#define MPI_Comm_size(x, y)
#define MPI_Initialized(x)
#define MPI_Comm_rank(x, y)