| 1 | /*
|
|---|
| 2 | A simple 2D hydro code
|
|---|
| 3 | (C) Romain Teyssier : CEA/IRFU -- original F90 code
|
|---|
| 4 | (C) Pierre-Francois Lavallee : IDRIS -- original F90 code
|
|---|
| 5 | (C) Guillaume Colin de Verdiere : CEA/DAM -- for the C version
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 |
|
|---|
| 10 | This software is governed by the CeCILL license under French law and
|
|---|
| 11 | abiding by the rules of distribution of free software. You can use,
|
|---|
| 12 | modify and/ or redistribute the software under the terms of the CeCILL
|
|---|
| 13 | license as circulated by CEA, CNRS and INRIA at the following URL
|
|---|
| 14 | "http://www.cecill.info".
|
|---|
| 15 |
|
|---|
| 16 | As a counterpart to the access to the source code and rights to copy,
|
|---|
| 17 | modify and redistribute granted by the license, users are provided only
|
|---|
| 18 | with a limited warranty and the software's author, the holder of the
|
|---|
| 19 | economic rights, and the successive licensors have only limited
|
|---|
| 20 | liability.
|
|---|
| 21 |
|
|---|
| 22 | In this respect, the user's attention is drawn to the risks associated
|
|---|
| 23 | with loading, using, modifying and/or developing or reproducing the
|
|---|
| 24 | software by the user in light of its specific status of free software,
|
|---|
| 25 | that may mean that it is complicated to manipulate, and that also
|
|---|
| 26 | therefore means that it is reserved for developers and experienced
|
|---|
| 27 | professionals having in-depth computer knowledge. Users are therefore
|
|---|
| 28 | encouraged to load and test the software's suitability as regards their
|
|---|
| 29 | requirements in conditions enabling the security of their systems and/or
|
|---|
| 30 | data to be ensured and, more generally, to use and operate it in the
|
|---|
| 31 | same conditions as regards security.
|
|---|
| 32 |
|
|---|
| 33 | The fact that you are presently reading this means that you have had
|
|---|
| 34 | knowledge of the CeCILL license and that you accept its terms.
|
|---|
| 35 |
|
|---|
| 36 | */
|
|---|
| 37 | #ifndef PARAMETRES_H_INCLUDED
|
|---|
| 38 | #define PARAMETRES_H_INCLUDED
|
|---|
| 39 | extern unsigned long flops;
|
|---|
| 40 |
|
|---|
| 41 | #ifndef PREC_SP
|
|---|
| 42 | typedef double real_t;
|
|---|
| 43 | #else
|
|---|
| 44 | typedef float real_t;
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | typedef enum {
|
|---|
| 48 | XMIN_BOX, XMAX_BOX,
|
|---|
| 49 | YMIN_BOX, YMAX_BOX,
|
|---|
| 50 | UP_BOX, DOWN_BOX,
|
|---|
| 51 | LEFT_BOX, RIGHT_BOX,
|
|---|
| 52 | MAX_BOX
|
|---|
| 53 | } Box_t;
|
|---|
| 54 |
|
|---|
| 55 | typedef struct _hydroparam {
|
|---|
| 56 | int prt;
|
|---|
| 57 |
|
|---|
| 58 | // time control
|
|---|
| 59 | real_t t, tend;
|
|---|
| 60 | int nstep, nstepmax;
|
|---|
| 61 | int noutput;
|
|---|
| 62 | real_t dtoutput;
|
|---|
| 63 |
|
|---|
| 64 | // dimensions
|
|---|
| 65 | int imin, imax, jmin, jmax, nx, ny, nxt, nyt, nxyt, nxystep;
|
|---|
| 66 |
|
|---|
| 67 | /*
|
|---|
| 68 | nx, ny: real useful size of the domain
|
|---|
| 69 | i/j min, max: the total domain index range
|
|---|
| 70 | nxt, nyt: the total domain size (includes 2 extra layers around the domain)
|
|---|
| 71 | nxyt: maximum of nxt and nyt to minimize allocations
|
|---|
| 72 | */
|
|---|
| 73 | int nproc, mype; // MPI version
|
|---|
| 74 | int globnx, globny; // global size of the problem
|
|---|
| 75 | int box[MAX_BOX]; // our domain size and its position relative to the others
|
|---|
| 76 |
|
|---|
| 77 | // physics
|
|---|
| 78 | int nvar;
|
|---|
| 79 | real_t dx;
|
|---|
| 80 | real_t gamma;
|
|---|
| 81 | real_t courant_factor;
|
|---|
| 82 | real_t smallc, smallr;
|
|---|
| 83 |
|
|---|
| 84 | // numerical scheme
|
|---|
| 85 | int niter_riemann;
|
|---|
| 86 | int iorder;
|
|---|
| 87 | real_t slope_type;
|
|---|
| 88 |
|
|---|
| 89 | // char scheme[20];
|
|---|
| 90 | int scheme;
|
|---|
| 91 | int boundary_right, boundary_left, boundary_down, boundary_up;
|
|---|
| 92 |
|
|---|
| 93 | // test case
|
|---|
| 94 | int testCase;
|
|---|
| 95 | } hydroparam_t;
|
|---|
| 96 |
|
|---|
| 97 | #define HSCHEME_MUSCL 1
|
|---|
| 98 | #define HSCHEME_PLMDE 2
|
|---|
| 99 | #define HSCHEME_COLLELA 3
|
|---|
| 100 |
|
|---|
| 101 | // Hydrovar holds the whole 2D problem for all variables
|
|---|
| 102 | typedef struct _hydrovar {
|
|---|
| 103 | real_t *uold; // nxt, nyt, nvar allocated as (nxt * nyt), nvar
|
|---|
| 104 | } hydrovar_t; // 1:nvar
|
|---|
| 105 | #ifndef IHv
|
|---|
| 106 | // #define IHv(i,j,v) ((i) + (j) * H.nxt + (H.nxt * H.nyt) * (v))
|
|---|
| 107 | #define IHv(i,j,v) ((i) + (H.nxt * (H.nyt * (v)+ (j))))
|
|---|
| 108 | #define IHvP(i,j,v) ((i) + (j) * H->nxt + (H->nxt * H->nyt) * (v))
|
|---|
| 109 | #endif /* */
|
|---|
| 110 |
|
|---|
| 111 | // work arrays along one direction for all variables
|
|---|
| 112 | typedef struct _hydrovarwork {
|
|---|
| 113 | real_t *u, *q, *qxm, *qxp, *dq; // (nxt or nyt), nvar
|
|---|
| 114 | real_t *qleft, *qright, *qgdnv, *flux; // (nx+1 or ny+1), nvar
|
|---|
| 115 | } hydrovarwork_t; // 1:nvar
|
|---|
| 116 | #ifndef IHvw
|
|---|
| 117 | // #define IHvw(i,v) ((i) + (v) * H.nxyt)
|
|---|
| 118 | // #define IHvwP(i,v) ((i) + (v) * H->nxyt)
|
|---|
| 119 | #endif /* */
|
|---|
| 120 |
|
|---|
| 121 | // works arrays along one direction
|
|---|
| 122 | typedef struct _hydrowork {
|
|---|
| 123 | real_t *c; // nxt or nyt
|
|---|
| 124 | real_t *e; // nxt or nyt
|
|---|
| 125 | real_t *tmpm1, *tmpm2; // for the reduction
|
|---|
| 126 | // all others nx+1 or ny+1
|
|---|
| 127 | real_t *rl, *ul, *pl, *cl, *wl;
|
|---|
| 128 | real_t *rr, *ur, *pr, *cr, *wr;
|
|---|
| 129 | real_t *ro, *uo, *po, *co, *wo;
|
|---|
| 130 | real_t *rstar, *ustar, *pstar, *cstar;
|
|---|
| 131 | real_t *spin, *spout, *ushock;
|
|---|
| 132 | int *sgnm;
|
|---|
| 133 | int *goon; // convergence indicator for riemann
|
|---|
| 134 | real_t *frac, *scr, *delp, *pold;
|
|---|
| 135 | int *ind, *ind2;
|
|---|
| 136 | } hydrowork_t;
|
|---|
| 137 |
|
|---|
| 138 | // All variables are grouped in structs for clarity sake.
|
|---|
| 139 | /*
|
|---|
| 140 | Warning : no global variables are declared.
|
|---|
| 141 | They are passed as arguments.
|
|---|
| 142 | */
|
|---|
| 143 |
|
|---|
| 144 | // useful constants to force double promotion
|
|---|
| 145 | #ifdef ALWAYS // HMPP
|
|---|
| 146 | static const real_t zero = (real_t) 0.0;
|
|---|
| 147 | static const real_t one = (real_t) 1.0;
|
|---|
| 148 | static const real_t two = (real_t) 2.0;
|
|---|
| 149 | static const real_t three = (real_t) 3.0;
|
|---|
| 150 | static const real_t hundred = (real_t) 100.0;
|
|---|
| 151 | static const real_t two3rd = (real_t) 2.0 / (real_t) 3.0;
|
|---|
| 152 | static const real_t half = (real_t) 1.0 / (real_t) 2.0;
|
|---|
| 153 | static const real_t third = (real_t) 1.0 / (real_t) 3.0;
|
|---|
| 154 | static const real_t forth = (real_t) 1.0 / (real_t) 4.0;
|
|---|
| 155 | static const real_t sixth = (real_t) 1.0 / (real_t) 6.0;
|
|---|
| 156 |
|
|---|
| 157 | // conservative variables with C indexing
|
|---|
| 158 | static const int ID = 1 - 1;
|
|---|
| 159 | static const int IU = 2 - 1;
|
|---|
| 160 | static const int IV = 3 - 1;
|
|---|
| 161 | static const int IP = 4 - 1;
|
|---|
| 162 |
|
|---|
| 163 | // The current scheme ahs two extra layers around the domain.
|
|---|
| 164 | static const int ExtraLayer = 2;
|
|---|
| 165 | static const int ExtraLayerTot = 2 * 2;
|
|---|
| 166 |
|
|---|
| 167 | #else /* */
|
|---|
| 168 | #define zero ((real_t) 0.0)
|
|---|
| 169 | #define one ((real_t) 1.0)
|
|---|
| 170 | #define two ((real_t) 2.0)
|
|---|
| 171 | #define three ((real_t) 3.0)
|
|---|
| 172 | #define hundred ((real_t) 100.0)
|
|---|
| 173 | #define two3rd ((real_t) 2.0 / (real_t) 3.0)
|
|---|
| 174 | #define half ((real_t) 1.0 / (real_t) 2.0)
|
|---|
| 175 | #define third ((real_t) 1.0 / (real_t) 3.0)
|
|---|
| 176 | #define forth ((real_t) 1.0 / (real_t) 4.0)
|
|---|
| 177 | #define sixth ((real_t) 1.0 / (real_t) 6.0)
|
|---|
| 178 | #define ID (0)
|
|---|
| 179 | #define IU (1)
|
|---|
| 180 | #define IV (2)
|
|---|
| 181 | #define IP (3)
|
|---|
| 182 | #define ExtraLayer (2)
|
|---|
| 183 | #define ExtraLayerTot (2 * 2)
|
|---|
| 184 | #endif /* */
|
|---|
| 185 | void process_args(int argc, char **argv, hydroparam_t * H);
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | typedef enum {
|
|---|
| 189 | TIM_GATCON,
|
|---|
| 190 | TIM_CONPRI,
|
|---|
| 191 | TIM_EOS,
|
|---|
| 192 | TIM_SLOPE,
|
|---|
| 193 | TIM_TRACE,
|
|---|
| 194 | TIM_QLEFTR,
|
|---|
| 195 | TIM_RIEMAN,
|
|---|
| 196 | TIM_CMPFLX,
|
|---|
| 197 | TIM_UPDCON,
|
|---|
| 198 | TIM_COMPDT,
|
|---|
| 199 | TIM_MAKBOU,
|
|---|
| 200 | TIM_ALLRED,
|
|---|
| 201 | TIM_END
|
|---|
| 202 | } Timers_t;
|
|---|
| 203 |
|
|---|
| 204 | extern double functim[TIM_END];
|
|---|
| 205 |
|
|---|
| 206 | #endif // PARAMETRES_H_INCLUDED
|
|---|
| 207 | //EOF
|
|---|