| [70c4392] | 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 <stdlib.h>
|
|---|
| 38 | // #include <unistd.h>
|
|---|
| 39 | #include <math.h>
|
|---|
| 40 | #include <stdio.h>
|
|---|
| 41 | #ifdef _OPENMP
|
|---|
| 42 | #include <omp.h>
|
|---|
| 43 | #endif
|
|---|
| 44 | #ifndef HMPP
|
|---|
| 45 | #include "equation_of_state.h"
|
|---|
| 46 | #include "parametres.h"
|
|---|
| 47 | #include "perfcnt.h"
|
|---|
| 48 | #include "utils.h"
|
|---|
| 49 |
|
|---|
| 50 | void
|
|---|
| 51 | equation_of_state(int imin,
|
|---|
| 52 | int imax,
|
|---|
| 53 | const int Hnxyt,
|
|---|
| 54 | const int Hnvar,
|
|---|
| 55 | const real_t Hsmallc,
|
|---|
| 56 | const real_t Hgamma,
|
|---|
| 57 | const int slices, const int Hstep,
|
|---|
| 58 | real_t eint[Hstep][Hnxyt], real_t q[Hnvar][Hstep][Hnxyt], real_t c[Hstep][Hnxyt]) {
|
|---|
| 59 | int k, s;
|
|---|
| 60 | int inpar = 0;
|
|---|
| 61 | real_t smallp;
|
|---|
| 62 |
|
|---|
| 63 | WHERE("equation_of_state");
|
|---|
| 64 | smallp = Square(Hsmallc) / Hgamma;
|
|---|
| 65 | FLOPS(1, 1, 0, 0);
|
|---|
| 66 |
|
|---|
| 67 | // printf("EOS: %d %d %d %d %g %g %d %d\n", imin, imax, Hnxyt, Hnvar, Hsmallc, Hgamma, slices, Hstep);
|
|---|
| 68 | #ifdef _OPENMP
|
|---|
| 69 | inpar = omp_in_parallel();
|
|---|
| 70 | //#pragma omp parallel for if (!inpar) schedule(auto) private(s,k), shared(c,q), collapse(2)
|
|---|
| 71 | #pragma omp parallel for private(s,k), shared(c,q) COLLAPSE
|
|---|
| 72 | #endif
|
|---|
| 73 | for (s = 0; s < slices; s++) {
|
|---|
| 74 | for (k = imin; k < imax; k++) {
|
|---|
| 75 | register real_t rhok = q[ID][s][k];
|
|---|
| 76 | register real_t base = (Hgamma - one) * rhok * eint[s][k];
|
|---|
| 77 | base = MAX(base, (real_t) (rhok * smallp));
|
|---|
| 78 |
|
|---|
| 79 | q[IP][s][k] = base;
|
|---|
| 80 | c[s][k] = sqrt(Hgamma * base / rhok);
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|
| 83 | {
|
|---|
| 84 | int nops = slices * (imax - imin);
|
|---|
| 85 | FLOPS(5 * nops, 2 * nops, 1 * nops, 0 * nops);
|
|---|
| 86 | }
|
|---|
| 87 | } // equation_of_state
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | #endif
|
|---|
| 91 | // EOF
|
|---|