Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
AMReX_COORDSYS_1D_C.H
Go to the documentation of this file.
1#ifndef AMREX_COORDSYS_1D_C_H_
2#define AMREX_COORDSYS_1D_C_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_Gpu.H>
6#include <AMReX_Array.H>
7#include <AMReX_FArrayBox.H>
8#include <cmath>
9
10namespace amrex {
11
13inline
14void
15amrex_setvol (Box const& bx, Array4<Real> const& vol,
17 GpuArray<Real,1> const& dx, const int coord) noexcept
18{
19 const auto lo = amrex::lbound(bx);
20 const auto hi = amrex::ubound(bx);
21
22 if (coord == 0) // Cartesian
23 {
24 Real dv = dx[0];
26 for (int i = lo.x; i <= hi.x; ++i) {
27 vol(i,0,0) = dv;
28 }
29 }
30 else if (coord == 1)
31 {
32 const Real pi = Real(3.1415926535897932);
34 for (int i = lo.x; i <= hi.x; ++i) {
35 Real ri = offset[0] + dx[0]*i;
36 Real ro = ri + dx[0];
37 Real v = pi*(ro-ri)*(ro + ri);
38 vol(i,0,0) = std::abs(v);
39 }
40 }
41 else
42 {
43 const Real pi = Real(3.1415926535897932);
45 for (int i = lo.x; i <= hi.x; ++i) {
46 Real ri = offset[0] + dx[0]*i;
47 Real ro = ri + dx[0];
48 Real v = (Real(4./3.)*pi)*(ro-ri)*(ro*ro+ro*ri+ri*ri);
49 vol(i,0,0) = std::abs(v);
50 }
51 }
52}
53
55inline
56void
57amrex_setarea (Box const& bx, Array4<Real> const& area,
59 GpuArray<Real,1> const& dx, const int /*dir*/, const int coord) noexcept
60{
61 const auto lo = amrex::lbound(bx);
62 const auto hi = amrex::ubound(bx);
63
64 if (coord == 0)
65 {
67 for (int i = lo.x; i <= hi.x; ++i) {
68 area(i,0,0) = 1.0;
69 }
70 }
71 else if (coord == 1)
72 {
73 const Real pi = Real(3.1415926535897932);
75 for (int i = lo.x; i <= hi.x; ++i) {
76 Real ri = offset[0] + dx[0]*i;
77 Real a = (Real(2.)*pi)*ri;
78 area(i,0,0) = std::abs(a);
79 }
80 }
81 else
82 {
83 const Real pi = Real(3.1415926535897932);
85 for (int i = lo.x; i <= hi.x; ++i) {
86 Real ri = offset[0] + dx[0]*i;
87 Real a = (Real(4.0)*pi)*ri*ri;
88 area(i,0,0) = std::abs(a);
89 }
90 }
91}
92
94inline
95void
96amrex_setdloga (Box const& bx, Array4<Real> const& dloga,
98 GpuArray<Real,1> const& dx, const int /*dir*/, const int coord) noexcept
99{
100 const auto lo = amrex::lbound(bx);
101 const auto hi = amrex::ubound(bx);
102
103 if (coord == 0)
104 {
106 for (int i = lo.x; i <= hi.x; ++i) {
107 dloga(i,0,0) = 0.0;
108 }
109 }
110 else if (coord == 1)
111 {
113 for (int i = lo.x; i <= hi.x; ++i) {
114 Real rc = offset[0] + dx[0]*(i+Real(0.5));
115 dloga(i,0,0) = Real(1.0)/rc;
116 }
117 }
118 else
119 {
121 for (int i = lo.x; i <= hi.x; ++i) {
122 Real ri = offset[0] + dx[0]*(i+Real(0.5));
123 dloga(i,0,0) = Real(2.0)/ri;
124 }
125 }
126}
127
128}
129
130#endif
#define AMREX_PRAGMA_SIMD
Definition AMReX_Extension.H:80
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1089
Definition AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE void amrex_setvol(Box const &bx, Array4< Real > const &vol, GpuArray< Real, 1 > const &offset, GpuArray< Real, 1 > const &dx, const int coord) noexcept
Definition AMReX_COORDSYS_1D_C.H:15
AMREX_GPU_HOST_DEVICE void amrex_setarea(Box const &bx, Array4< Real > const &area, GpuArray< Real, 1 > const &offset, GpuArray< Real, 1 > const &dx, const int, const int coord) noexcept
Definition AMReX_COORDSYS_1D_C.H:57
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:308
AMREX_GPU_HOST_DEVICE void amrex_setdloga(Box const &bx, Array4< Real > const &dloga, GpuArray< Real, 1 > const &offset, GpuArray< Real, 1 > const &dx, const int, const int coord) noexcept
Definition AMReX_COORDSYS_1D_C.H:96
Definition AMReX_Array4.H:61
Definition AMReX_Array.H:34