/*
 * Copyright (C)  NHR@FAU, University Erlangen-Nuremberg.
 * All rights reserved. This file is part of nusif-solver.
 * Use of this source code is governed by a MIT style
 * license that can be found in the LICENSE file.
 */
#ifndef __DISCRETIZATION_H_
#define __DISCRETIZATION_H_
#include "comm.h"
#include "grid.h"
#include "parameter.h"
#include<unistd.h>

enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC };

enum OBJECTBOUNDARY {
    FLUID = 0,
    TOP,
    BOTTOM,
    LEFT,
    RIGHT,
    TOPLEFT,
    BOTTOMLEFT,
    TOPRIGHT,
    BOTTOMRIGHT,
    OBSTACLE
};

enum SHAPE { NOSHAPE = 0, RECT, CIRCLE };

typedef struct {
    /* geometry and grid information */
    Grid grid;
    /* arrays */
    double *p, *rhs;
    double *f, *g;
    double *u, *v;
    /* parameters */
    double re, tau, gamma;
    double gx, gy;
    /* time stepping */
    double dt, te;
    double dtBound;
    char* problem;

    double xLocal, yLocal, xOffset, yOffset, xOffsetEnd, yOffsetEnd;


    int bcLeft, bcRight, bcBottom, bcTop;
    /* communication */
    Comm comm;
} Discretization;

extern void initDiscretiztion(Discretization*, Parameter*);
extern void computeRHS(Discretization*);
extern void normalizePressure(Discretization*);
extern void computeTimestep(Discretization*);
extern void setBoundaryConditions(Discretization*);
extern void setSpecialBoundaryCondition(Discretization*);
extern void setObjectBoundaryCondition(Discretization*);
extern void computeFG(Discretization*);
extern void adaptUV(Discretization*);
extern void writeResult(Discretization* s, double* u, double* v, double* p);
extern double sumOffset(double* , int , int , int );
extern void print(Discretization* , double* );
#endif
