source: CIVL/examples/omp/HydroC/constoprim.c@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 3.0 KB
Line 
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
9This software is governed by the CeCILL license under French law and
10abiding by the rules of distribution of free software. You can use,
11modify and/ or redistribute the software under the terms of the CeCILL
12license as circulated by CEA, CNRS and INRIA at the following URL
13"http://www.cecill.info".
14
15As a counterpart to the access to the source code and rights to copy,
16modify and redistribute granted by the license, users are provided only
17with a limited warranty and the software's author, the holder of the
18economic rights, and the successive licensors have only limited
19liability.
20
21In this respect, the user's attention is drawn to the risks associated
22with loading, using, modifying and/or developing or reproducing the
23software by the user in light of its specific status of free software,
24that may mean that it is complicated to manipulate, and that also
25therefore means that it is reserved for developers and experienced
26professionals having in-depth computer knowledge. Users are therefore
27encouraged to load and test the software's suitability as regards their
28requirements in conditions enabling the security of their systems and/or
29data to be ensured and, more generally, to use and operate it in the
30same conditions as regards security.
31
32The fact that you are presently reading this means that you have had
33knowledge 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
48void
49constoprim(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
Note: See TracBrowser for help on using the repository browser.