| 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 | This software is governed by the CeCILL license under French law and
|
|---|
| 10 | abiding by the rules of distribution of free software. You can use,
|
|---|
| 11 | modify and/ or redistribute the software under the terms of the CeCILL
|
|---|
| 12 | license as circulated by CEA, CNRS and INRIA at the following URL
|
|---|
| 13 | "http://www.cecill.info".
|
|---|
| 14 |
|
|---|
| 15 | As a counterpart to the access to the source code and rights to copy,
|
|---|
| 16 | modify and redistribute granted by the license, users are provided only
|
|---|
| 17 | with a limited warranty and the software's author, the holder of the
|
|---|
| 18 | economic rights, and the successive licensors have only limited
|
|---|
| 19 | liability.
|
|---|
| 20 |
|
|---|
| 21 | In this respect, the user's attention is drawn to the risks associated
|
|---|
| 22 | with loading, using, modifying and/or developing or reproducing the
|
|---|
| 23 | software by the user in light of its specific status of free software,
|
|---|
| 24 | that may mean that it is complicated to manipulate, and that also
|
|---|
| 25 | therefore means that it is reserved for developers and experienced
|
|---|
| 26 | professionals having in-depth computer knowledge. Users are therefore
|
|---|
| 27 | encouraged to load and test the software's suitability as regards their
|
|---|
| 28 | requirements in conditions enabling the security of their systems and/or
|
|---|
| 29 | data to be ensured and, more generally, to use and operate it in the
|
|---|
| 30 | same conditions as regards security.
|
|---|
| 31 |
|
|---|
| 32 | The fact that you are presently reading this means that you have had
|
|---|
| 33 | knowledge of the CeCILL license and that you accept its terms.
|
|---|
| 34 |
|
|---|
| 35 | */
|
|---|
| 36 |
|
|---|
| 37 | #include <math.h>
|
|---|
| 38 | #include <malloc.h>
|
|---|
| 39 | // #include <unistd.h>
|
|---|
| 40 | // #include <stdlib.h>
|
|---|
| 41 | #include <string.h>
|
|---|
| 42 | #include <stdio.h>
|
|---|
| 43 |
|
|---|
| 44 | #ifndef HMPP
|
|---|
| 45 | #include "parametres.h"
|
|---|
| 46 | #include "utils.h"
|
|---|
| 47 | #include "cmpflx.h"
|
|---|
| 48 | #include "perfcnt.h"
|
|---|
| 49 |
|
|---|
| 50 | void
|
|---|
| 51 | cmpflx(const int narray,
|
|---|
| 52 | const int Hnxyt,
|
|---|
| 53 | const int Hnvar,
|
|---|
| 54 | const real_t Hgamma,
|
|---|
| 55 | const int slices,
|
|---|
| 56 | const int Hstep,
|
|---|
| 57 | real_t qgdnv[Hnvar][Hstep][Hnxyt],
|
|---|
| 58 | real_t flux[Hnvar][Hstep][Hnxyt]) {
|
|---|
| 59 | int nface, i, IN;
|
|---|
| 60 | real_t entho, ekin, etot;
|
|---|
| 61 | WHERE("cmpflx");
|
|---|
| 62 | int s;
|
|---|
| 63 |
|
|---|
| 64 | nface = narray;
|
|---|
| 65 | entho = one / (Hgamma - one);
|
|---|
| 66 | FLOPS(1, 1, 0, 0);
|
|---|
| 67 |
|
|---|
| 68 | // Compute fluxes
|
|---|
| 69 | #pragma omp parallel for private(s, i, ekin, etot), shared(flux)
|
|---|
| 70 | for (s = 0; s < slices; s++) {
|
|---|
| 71 | for (i = 0; i < nface; i++) {
|
|---|
| 72 | real_t qgdnvID = qgdnv[ID][s][i];
|
|---|
| 73 | real_t qgdnvIU = qgdnv[IU][s][i];
|
|---|
| 74 | real_t qgdnvIP = qgdnv[IP][s][i];
|
|---|
| 75 | real_t qgdnvIV = qgdnv[IV][s][i];
|
|---|
| 76 |
|
|---|
| 77 | // Mass density
|
|---|
| 78 | real_t massDensity = qgdnvID * qgdnvIU;
|
|---|
| 79 | flux[ID][s][i] = massDensity;
|
|---|
| 80 |
|
|---|
| 81 | // Normal momentum
|
|---|
| 82 | flux[IU][s][i] = massDensity * qgdnvIU + qgdnvIP;
|
|---|
| 83 | // Transverse momentum 1
|
|---|
| 84 | flux[IV][s][i] = massDensity * qgdnvIV;
|
|---|
| 85 |
|
|---|
| 86 | // Total energy
|
|---|
| 87 | ekin = half * qgdnvID * (Square(qgdnvIU) + Square(qgdnvIV));
|
|---|
| 88 | etot = qgdnvIP * entho + ekin;
|
|---|
| 89 |
|
|---|
| 90 | flux[IP][s][i] = qgdnvIU * (etot + qgdnvIP);
|
|---|
| 91 | }
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | {
|
|---|
| 95 | int nops = slices * nface;
|
|---|
| 96 | FLOPS(13 * nops, 0 * nops, 0 * nops, 0 * nops);
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 | // Other advected quantities
|
|---|
| 101 | if (Hnvar > IP) {
|
|---|
| 102 | for (s = 0; s < slices; s++) {
|
|---|
| 103 | for (IN = IP + 1; IN < Hnvar; IN++) {
|
|---|
| 104 | for (i = 0; i < nface; i++) {
|
|---|
| 105 | flux[IN][s][i] = flux[IN][s][i] * qgdnv[IN][s][i];
|
|---|
| 106 | }
|
|---|
| 107 | }
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 | } // cmpflx
|
|---|
| 111 |
|
|---|
| 112 | #endif
|
|---|
| 113 |
|
|---|
| 114 | //EOF
|
|---|