Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
AMReX_SPACE.H
Go to the documentation of this file.
1
6#ifndef AMREX_SPACE_H
7#define AMREX_SPACE_H
8#include <AMReX_Config.H>
9
10/* for backward compatibility */
11#if defined(BL_SPACEDIM) && !defined(AMREX_SPACEDIM)
12#define AMREX_SPACEDIM BL_SPACEDIM
13#endif
14#if !defined(BL_SPACEDIM)
15#define BL_SPACEDIM AMREX_SPACEDIM
16#endif
17
18/*
19 * \def AMREX_SPACEDIM
20 *
21 * The AMREX_SPACEDIM macro specifies the dimension of the AMReX library
22 * to be built. Acceptable values are either 1, 2, or 3. This macro
23 * must be set for every compilation as many of the data structures of
24 * AMReX rely on it being set.
25 *
26 * Code that depends on the dimensionality of the problem that you're
27 * trying to solve should be cast in terms of this macro.
28 */
29
30#if !defined(AMREX_SPACEDIM)
31#error AMREX_SPACEDIM must be defined
32#endif
33
34#if (AMREX_SPACEDIM != 1 && AMREX_SPACEDIM !=2 && AMREX_SPACEDIM != 3)
35#error AMREX_SPACEDIM must be either 1, 2, or 3
36#endif
37
38/*
39 The SpaceDim C++ integer constant specifies the dimension of the
40 AMReX library to be built. It is initialized to the value of
41 the macro AMREX_SPACEDIM. Hence it will have one of the values 1, 2, or 3.
42
43 C++ code that depends on the dimensionality of the problem that
44 you're trying to solve should be cast in terms of this constant,
45 instead of the AMREX_SPACEDIM macro, if possible, as constants are
46 visible to debuggers while macros are not.
47*/
48#ifdef __cplusplus
49namespace amrex
50{
51 constexpr int SpaceDim = AMREX_SPACEDIM;
52}
53#endif
54
55
56#if AMREX_SPACEDIM==1
57
81# define AMREX_D_EXPR(a,b,c) ((void)((a),0))
82
104# define AMREX_D_DECL(a,b,c) a
105
129# define AMREX_D_TERM(a,b,c) a
130
151# define AMREX_D_PICK(a,b,c) a
152#elif AMREX_SPACEDIM==2
153# define AMREX_D_EXPR(a,b,c) ((void)((a),(b),0))
154# define AMREX_D_DECL(a,b,c) a,b
155# define AMREX_D_TERM(a,b,c) a b
156# define AMREX_D_PICK(a,b,c) b
157#elif AMREX_SPACEDIM==3
158# define AMREX_D_EXPR(a,b,c) ((void)((a),(b),(c),0))
159# define AMREX_D_DECL(a,b,c) a,b,c
160# define AMREX_D_TERM(a,b,c) a b c
161# define AMREX_D_PICK(a,b,c) c
162#endif
163
164#if (AMREX_SPACEDIM == 1)
165# define AMREX_1D_ONLY(a) a
166# define AMREX_2D_ONLY(a) ((void)0)
167# define AMREX_3D_ONLY(a) ((void)0)
168#elif (AMREX_SPACEDIM == 2)
169# define AMREX_1D_ONLY(a) ((void)0)
170# define AMREX_2D_ONLY(a) a
171# define AMREX_3D_ONLY(a) ((void)0)
172#elif (AMREX_SPACEDIM == 3)
173# define AMREX_1D_ONLY(a) ((void)0)
174# define AMREX_2D_ONLY(a) ((void)0)
175# define AMREX_3D_ONLY(a) a
176#endif
177
178#ifdef __cplusplus
179
180#if (AMREX_SPACEDIM == 1)
181#define AMREX_1D_ONLY_ARGS(...) __VA_ARGS__ ,
182#else
183#define AMREX_1D_ONLY_ARGS(...)
184#endif
185
186#if (AMREX_SPACEDIM == 2)
187#define AMREX_2D_ONLY_ARGS(...) __VA_ARGS__ ,
188#else
189#define AMREX_2D_ONLY_ARGS(...)
190#endif
191
192#if (AMREX_SPACEDIM == 3)
193#define AMREX_3D_ONLY_ARGS(...) __VA_ARGS__ ,
194#else
195#define AMREX_3D_ONLY_ARGS(...)
196#endif
197
198#endif
199
200#endif /*AMREX_SPACE_H*/
Definition AMReX_Amr.cpp:49