Block-Structured AMR Software Framework
 
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
84# define AMREX_D_EXPR(a,b,c) ((void)((a),0))
85
110# define AMREX_D_DECL(a,b,c) a
111
138# define AMREX_D_TERM(a,b,c) a
139
163# define AMREX_D_PICK(a,b,c) a
164#elif AMREX_SPACEDIM==2
165# define AMREX_D_EXPR(a,b,c) ((void)((a),(b),0))
166# define AMREX_D_DECL(a,b,c) a,b
167# define AMREX_D_TERM(a,b,c) a b
168# define AMREX_D_PICK(a,b,c) b
169#elif AMREX_SPACEDIM==3
170# define AMREX_D_EXPR(a,b,c) ((void)((a),(b),(c),0))
171# define AMREX_D_DECL(a,b,c) a,b,c
172# define AMREX_D_TERM(a,b,c) a b c
173# define AMREX_D_PICK(a,b,c) c
174#endif
175
176#if (AMREX_SPACEDIM == 1)
177# define AMREX_1D_ONLY(a) a
178# define AMREX_2D_ONLY(a) ((void)0)
179# define AMREX_3D_ONLY(a) ((void)0)
180#elif (AMREX_SPACEDIM == 2)
181# define AMREX_1D_ONLY(a) ((void)0)
182# define AMREX_2D_ONLY(a) a
183# define AMREX_3D_ONLY(a) ((void)0)
184#elif (AMREX_SPACEDIM == 3)
185# define AMREX_1D_ONLY(a) ((void)0)
186# define AMREX_2D_ONLY(a) ((void)0)
187# define AMREX_3D_ONLY(a) a
188#endif
189
190#ifdef __cplusplus
191
192#if (AMREX_SPACEDIM == 1)
193#define AMREX_1D_ONLY_ARGS(...) __VA_ARGS__ ,
194#else
195#define AMREX_1D_ONLY_ARGS(...)
196#endif
197
198#if (AMREX_SPACEDIM == 2)
199#define AMREX_2D_ONLY_ARGS(...) __VA_ARGS__ ,
200#else
201#define AMREX_2D_ONLY_ARGS(...)
202#endif
203
204#if (AMREX_SPACEDIM == 3)
205#define AMREX_3D_ONLY_ARGS(...) __VA_ARGS__ ,
206#else
207#define AMREX_3D_ONLY_ARGS(...)
208#endif
209
210#endif
211
212#endif /*AMREX_SPACE_H*/
Definition AMReX_Amr.cpp:49
constexpr int SpaceDim
Definition AMReX_SPACE.H:51