92 lines
2.3 KiB
C
92 lines
2.3 KiB
C
/*
|
|
* Copyright (C) 2022 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 __SOLVER_H_
|
|
#define __SOLVER_H_
|
|
#include "parameter.h"
|
|
|
|
#include <mpi.h>
|
|
|
|
#define NDIMS 2
|
|
|
|
enum OBJECTBOUNDARY {
|
|
NONE = 0,
|
|
TOP,
|
|
BOTTOM,
|
|
LEFT,
|
|
RIGHT,
|
|
TOPLEFT,
|
|
BOTTOMLEFT,
|
|
TOPRIGHT,
|
|
BOTTOMRIGHT,
|
|
LOCAL
|
|
};
|
|
enum BC { NOSLIP = 1, SLIP, OUTFLOW, PERIODIC };
|
|
/// @brief
|
|
enum SHAPE { NOSHAPE = 0, RECT, CIRCLE };
|
|
|
|
typedef struct {
|
|
/* geometry and grid information */
|
|
double dx, dy;
|
|
int imax, jmax;
|
|
double xlength, ylength;
|
|
/* arrays */
|
|
double *p, *rhs, **r, **e;
|
|
;
|
|
double *f, *g;
|
|
double *u, *v;
|
|
int* s;
|
|
|
|
/* parameters */
|
|
double eps, omega, rho;
|
|
double re, tau, gamma;
|
|
double gx, gy;
|
|
/* time stepping */
|
|
int itermax, levels, currentlevel;
|
|
double dt, te;
|
|
double dtBound;
|
|
char* problem;
|
|
int bcLeft, bcRight, bcBottom, bcTop;
|
|
/* mpi */
|
|
int rank;
|
|
int size;
|
|
MPI_Comm comm;
|
|
MPI_Datatype bufferTypes[NDIMS * 2];
|
|
MPI_Aint sdispls[NDIMS * 2], rdispls[NDIMS * 2];
|
|
|
|
MPI_Datatype bufferIntTypes[NDIMS * 2];
|
|
MPI_Aint sdisplsInt[NDIMS * 2], rdisplsInt[NDIMS * 2];
|
|
int iNeighbours[NDIMS], jNeighbours[NDIMS];
|
|
int coords[NDIMS], dims[NDIMS];
|
|
int imaxLocal, jmaxLocal;
|
|
|
|
double xLocal, yLocal, xOffset, yOffset, xOffsetEnd, yOffsetEnd;
|
|
|
|
} Solver;
|
|
|
|
extern void initSolver(Solver*, Parameter*);
|
|
extern void computeRHS(Solver*);
|
|
extern double smoothRB(Solver*);
|
|
extern void restrictMG(Solver*);
|
|
extern void prolongate(Solver*);
|
|
extern void correct(Solver*);
|
|
extern Solver copySolver(Solver*);
|
|
extern void multiGrid(Solver*);
|
|
extern void computeTimestep(Solver*);
|
|
extern void setBoundaryConditions(Solver*);
|
|
extern void setSpecialBoundaryCondition(Solver*);
|
|
extern void setObjectBoundaryCondition(Solver*);
|
|
extern void setPressureBoundaryCondition(Solver*);
|
|
extern void computeFG(Solver*);
|
|
extern void adaptUV(Solver*);
|
|
extern void collectResult(Solver*);
|
|
extern void writeResult(Solver*, double*, double*, double*);
|
|
extern void debugExchange(Solver*, double*);
|
|
extern void print(Solver*, double*);
|
|
extern void printInt(Solver*, int*);
|
|
|
|
#endif
|