Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_REAL.H
Go to the documentation of this file.
1#ifndef AMREX_REAL_H_
2#define AMREX_REAL_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_Extension.H>
6
7#ifdef BL_USE_FLOAT
8# undef BL_USE_DOUBLE
9# undef BL_USE_FLOAT
10/*
11 The macro BL_USE_FLOAT indicates that C++ floating-point calculations should
12 use "float" variables and Fortran floating-point calculations should use
13 "real*4" variables. One of BL_USE_FLOAT or BL_USE_DOUBLE must always be
14 defined when compiling and using AMReX.
15*/
16# define BL_USE_FLOAT 1
17#else
18# undef BL_USE_FLOAT
19# undef BL_USE_DOUBLE
20/*
21 The macro BL_USE_DOUBLE indicates that C++ floating-point calculations
22 should use "double" variables and Fortran floating-point calculations
23 should use "real*8" variables. One of BL_USE_FLOAT or BL_USE_DOUBLE must
24 always be defined when compiling and using AMReX.
25*/
26# define BL_USE_DOUBLE 1
27#endif
28
29#if !defined(BL_LANG_FORT)
30#ifdef __cplusplus
31#include <cfloat>
32#else
33#include <float.h>
34#endif
35
36/*
37 Real is a typedef specifying the precision of the floating-point
38 calculations in C++ code. It will be either float or double
39 depending upon which of the macros BL_USE_FLOAT or
40 BL_USE_DOUBLE, respectively, is defined during compilations. For
41 portability, you should write floating-point code in terms of this
42 typedef, instead of using float or double directly.
43
44 Note that exactly one of these macros must be defined
45 when compiling any module that uses floating-point.
46*/
47
48#ifdef BL_USE_FLOAT
49typedef float amrex_real; // NOLINT(modernize-use-using)
50// We need to define these to get around a CUDA 9.2 bug that breaks std::numeric_limits
51#define AMREX_REAL_MIN FLT_MIN
52#define AMREX_REAL_MAX FLT_MAX
53#define AMREX_REAL_LOWEST (-FLT_MAX)
54#else
55typedef double amrex_real; // NOLINT(modernize-use-using)
56#define AMREX_REAL_MIN DBL_MIN
57#define AMREX_REAL_MAX DBL_MAX
58#define AMREX_REAL_LOWEST (-DBL_MAX)
59#endif
60
61#ifdef AMREX_SINGLE_PRECISION_PARTICLES
62typedef float amrex_particle_real; // NOLINT(modernize-use-using)
63#else
64typedef double amrex_particle_real; // NOLINT(modernize-use-using)
65#endif
66
67#ifdef __cplusplus
68namespace amrex {
69
80
91
96inline namespace literals {
97
107 constexpr Real
108 operator""_rt( long double x )
109 {
110 return Real( x );
111 }
112
113 constexpr Real
114 operator""_rt( unsigned long long int x )
115 {
116 return Real( x );
117 }
118
119 constexpr ParticleReal
120 operator""_prt( long double x )
121 {
122 return ParticleReal( x );
123 }
124
125 constexpr ParticleReal
126 operator""_prt( unsigned long long int x )
127 {
128 return ParticleReal( x );
129 }
131} // namespace literals
132} // namespace amrex
133#endif
134
135#endif /* !BL_LANG_FORT */
136
137#endif /*BL_REAL_H*/
double amrex_real
Definition AMReX_REAL.H:55
double amrex_particle_real
Definition AMReX_REAL.H:64
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
amrex_particle_real ParticleReal
Floating Point Type for Particles.
Definition AMReX_REAL.H:90
Definition AMReX_Amr.cpp:49