/* Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
 * All rights reserved.
 * Use of this source code is governed by a MIT-style
 * license that can be found in the LICENSE file.    */
#ifndef __SOLVER_H_
#define __SOLVER_H_
#include "parameter.h"
#include <mpi.h>
typedef enum {
    NB     = 0b0000,
    LEFT   = 0b0001,
    RIGHT  = 0b0010,
    TOP    = 0b0100,
    BOTTOM = 0b1000,
    LFTO   = LEFT + TOP,
    LFBO   = LEFT + BOTTOM,
    RITO   = RIGHT + TOP,
    ROBO   = RIGHT + BOTTOM
} boundary_t;

typedef struct {

    double dx, dy;
    int imax, jmax;
    int limax, ljmax;
    int i_start, j_start;
    double *p, *rhs;
    double eps, omega, rho;
    int itermax;
    MPI_Comm cart_comm;
    MPI_Datatype types[4];
    MPI_Aint rcv_displacements[4];
    MPI_Aint snd_displacements[4];
    int coords[2];
    int dims[2];
    int rank, size;
    boundary_t boundary;

} Solver;

extern void initSolver(Solver*, Parameter*, int problem);
extern void writeResult(Solver*, char*);
extern void solveRB(Solver*);
#endif
