| 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 |
|
|---|
| 42 | #ifndef HMPP
|
|---|
| 43 | #include "parametres.h"
|
|---|
| 44 | #include "constoprim.h"
|
|---|
| 45 | #include "perfcnt.h"
|
|---|
| 46 | #include "utils.h"
|
|---|
| 47 |
|
|---|
| 48 | void
|
|---|
| 49 | constoprim(const int n,
|
|---|
| 50 | const int Hnxyt,
|
|---|
| 51 | const int Hnvar,
|
|---|
| 52 | const real_t Hsmallr,
|
|---|
| 53 | const int slices, const int Hstep,
|
|---|
| 54 | real_t u[Hnvar][Hstep][Hnxyt], real_t q[Hnvar][Hstep][Hnxyt], real_t e[Hstep][Hnxyt]) {
|
|---|
| 55 | int ijmin, ijmax, IN, i, s;
|
|---|
| 56 | real_t eken;
|
|---|
| 57 | // const int nxyt = Hnxyt;
|
|---|
| 58 | WHERE("constoprim");
|
|---|
| 59 | ijmin = 0;
|
|---|
| 60 | ijmax = n;
|
|---|
| 61 |
|
|---|
| 62 | #pragma omp parallel for private(i, s, eken), shared(q,e) COLLAPSE
|
|---|
| 63 | for (s = 0; s < slices; s++) {
|
|---|
| 64 | for (i = ijmin; i < ijmax; i++) {
|
|---|
| 65 | real_t qid = MAX(u[ID][s][i], Hsmallr);
|
|---|
| 66 | q[ID][s][i] = qid;
|
|---|
| 67 |
|
|---|
| 68 | real_t qiu = u[IU][s][i] / qid;
|
|---|
| 69 | real_t qiv = u[IV][s][i] / qid;
|
|---|
| 70 | q[IU][s][i] = qiu;
|
|---|
| 71 | q[IV][s][i] = qiv;
|
|---|
| 72 |
|
|---|
| 73 | eken = half * (Square(qiu) + Square(qiv));
|
|---|
| 74 |
|
|---|
| 75 | real_t qip = u[IP][s][i] / qid - eken;
|
|---|
| 76 | q[IP][s][i] = qip;
|
|---|
| 77 | e[s][i] = qip;
|
|---|
| 78 | }
|
|---|
| 79 | }
|
|---|
| 80 | {
|
|---|
| 81 | int nops = slices * ((ijmax) - (ijmin));
|
|---|
| 82 | FLOPS(5 * nops, 3 * nops, 1 * nops, 0 * nops);
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | if (Hnvar > IP) {
|
|---|
| 86 | for (IN = IP + 1; IN < Hnvar; IN++) {
|
|---|
| 87 | for (s = 0; s < slices; s++) {
|
|---|
| 88 | for (i = ijmin; i < ijmax; i++) {
|
|---|
| 89 | q[IN][s][i] = u[IN][s][i] / q[IN][s][i];
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|
| 94 | } // constoprim
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | #undef IHVW
|
|---|
| 98 | #endif
|
|---|
| 99 | //EOF
|
|---|