1#ifndef AMREX_GEOMETRY_H_
2#define AMREX_GEOMETRY_H_
3#include <AMReX_Config.H>
113 int const* is_per =
nullptr);
138 .prob_domain = prob_domain,
141 .is_periodic = {
AMREX_D_DECL(is_periodic[0], is_periodic[1], is_periodic[2])},
142 .coord =
static_cast<int>(
c_sys)
164 static void Setup (
const RealBox* rb =
nullptr,
int coord = -1,
int const* isper =
nullptr);
185 void define (
const Box& dom,
const RealBox* rb =
nullptr,
int coord = -1,
int const* is_per =
nullptr);
210 [[nodiscard]]
const Real*
ProbLo () const noexcept {
return prob_domain.lo(); }
212 [[nodiscard]]
const Real*
ProbHi () const noexcept {
return prob_domain.hi(); }
214 [[nodiscard]]
Real ProbLo (
int dir)
const noexcept {
return prob_domain.lo(dir); }
216 [[nodiscard]]
Real ProbHi (
int dir)
const noexcept {
return prob_domain.hi(dir); }
220 return {{
AMREX_D_DECL(prob_domain.lo(0),prob_domain.lo(1),prob_domain.lo(2))}};
225 return {{
AMREX_D_DECL(prob_domain.hi(0),prob_domain.hi(1),prob_domain.hi(2))}};
241 return AMREX_D_TERM(prob_domain.length(0),*prob_domain.length(1),*prob_domain.length(2));
244 [[nodiscard]]
Real ProbLength (
int dir)
const noexcept {
return prob_domain.length(dir); }
246 [[nodiscard]]
const Box&
Domain () const noexcept {
return domain; }
283#if AMREX_SPACEDIM == 1
285 auto coord = geomdata.
Coord();
298 constexpr Real pi = std::numbers::pi_v<Real>;
299 vol = pi * (rl + rr) *
dx[0];
307 constexpr Real pi = std::numbers::pi_v<Real>;
308 vol = (4.0_rt / 3.0_rt) * pi *
dx[0] * (rl * rl + rl * rr + rr * rr);
311#elif AMREX_SPACEDIM == 2
313 auto coord = geomdata.
Coord();
326 constexpr Real pi = std::numbers::pi_v<Real>;
327 vol = pi * (r_l + r_r) *
dx[0] *
dx[1];
336 Real theta_r = geomdata.
ProbLo()[1] +
static_cast<Real>(point[1]+1) *
dx[1];
338 constexpr Real twoThirdsPi =
static_cast<Real>((2.0 / 3.0) * std::numbers::pi_v<Real>);
339 vol = twoThirdsPi * (std::cos(theta_l) - std::cos(theta_r)) *
dx[0] *
340 (r_r*r_r + r_r*r_l + r_l*r_l);
349 vol =
dx[0] *
dx[1] *
dx[2];
399 [[nodiscard]]
bool isPeriodic (
int dir)
const noexcept {
return is_periodic[dir]; }
413 static_cast<int>(is_periodic[1]),
414 static_cast<int>(is_periodic[2]))}};
419 static_cast<int>(is_periodic[1]),
420 static_cast<int>(is_periodic[2]))}};
423 [[nodiscard]]
int period (
int dir)
const noexcept {
BL_ASSERT(is_periodic[dir]);
return domain.length(dir); }
428 domain.length(1) * is_periodic[1],
429 domain.length(2) * is_periodic[2])));
436 b.length(1) * is_periodic[1],
437 b.length(2) * is_periodic[2])));
477 is_periodic[1] =
period[1];,
478 is_periodic[2] =
period[2];);
490 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
504 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
541 bool is_periodic[AMREX_SPACEDIM] = {
AMREX_D_DECL(
false,
false,
false)};
548 GpuArray<ParticleReal , AMREX_SPACEDIM> roundoff_lo, roundoff_hi;
623template <std::
floating_po
int T>
627 return std::fma(T(i), dx, problo);
Fixed-size array types for use on GPU and CPU.
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
Coordinate system that maps between physical space and index space.
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_INLINE
Definition AMReX_Extension.H:132
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Geometry * getDefaultGeometry() noexcept
Geometry owned by this context (constructed with the AMReX object).
Definition AMReX.H:548
static AMReX * top() noexcept
Pointer to the most recently pushed instance.
Definition AMReX.H:530
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
__host__ __device__ bool cellCentered() const noexcept
Return true if BoxND is cell-centered in all indexing directions.
Definition AMReX_Box.H:356
Coordinate system; provides mapping between physical space and index space.
Definition AMReX_CoordSys.H:31
Real inv_dx[3]
Definition AMReX_CoordSys.H:322
CoordType c_sys
Definition AMReX_CoordSys.H:317
Real dx[3]
Definition AMReX_CoordSys.H:320
@ RZ
Definition AMReX_CoordSys.H:35
@ cartesian
Definition AMReX_CoordSys.H:35
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:51
A Fortran Array of REALs.
Definition AMReX_FArrayBox.H:237
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:87
Geometry(Geometry &&rhs) noexcept=default
Real ProbLo(int dir) const noexcept
Returns the lo end of the problem domain in specified direction.
Definition AMReX_Geometry.H:214
GpuArray< ParticleReal, 3 > ProbLoArrayInParticleReal() const noexcept
Return the lo end of the roundoff domain in ParticleReal precision.
Definition AMReX_Geometry.H:229
void ProbDomain(const RealBox &rb)
Sets the problem domain.
Definition AMReX_Geometry.H:204
bool outsideRoundoffDomain(ParticleReal x, ParticleReal y, ParticleReal z) const
Returns true if a point is outside the roundoff domain. All particles with positions inside the round...
Definition AMReX_Geometry.cpp:709
void GetVolume(MultiFab &vol, const BoxArray &grds, const DistributionMapping &dm, int grow) const
Define vol on grds with dm and fill it with cell volumes.
Definition AMReX_Geometry.cpp:208
void refine(IntVect const &rr)
Refine the Geometry by rr.
Definition AMReX_Geometry.H:502
void coarsen(IntVect const &rr)
Coarsen the Geometry by rr.
Definition AMReX_Geometry.H:488
GpuArray< ParticleReal, 3 > ProbHiArrayInParticleReal() const noexcept
Return the hi end of the roundoff domain in ParticleReal precision.
Definition AMReX_Geometry.H:234
const Real * ProbHi() const noexcept
Returns the hi end of the problem domain in each dimension.
Definition AMReX_Geometry.H:212
__host__ static __device__ Real Volume(const IntVect &point, const GeometryData &geomdata)
Return the volume of the specified cell.
Definition AMReX_Geometry.H:277
bool isAnyPeriodic() const noexcept
Is domain periodic in any direction?
Definition AMReX_Geometry.H:401
Array< int, 3 > setPeriodicity(Array< int, 3 > const &period) noexcept
Set the periodicity flags and return the old flags.
Definition AMReX_Geometry.H:472
static void ResetDefaultProbDomain(const RealBox &rb) noexcept
Set the problem domain of the default Geometry to rb.
Definition AMReX_Geometry.cpp:184
void GetFaceArea(MultiFab &area, const BoxArray &grds, const DistributionMapping &dm, int dir, int grow) const
Define area on the faces of grds normal to dir, using dm, and fill it with face areas.
Definition AMReX_Geometry.cpp:303
Real ProbHi(int dir) const noexcept
Returns the hi end of the problem domain in specified direction.
Definition AMReX_Geometry.H:216
Geometry(const Geometry &rhs)=default
int period(int dir) const noexcept
What's period in specified direction?
Definition AMReX_Geometry.H:423
Geometry & operator=(const Geometry &rhs)=default
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:246
void Domain(const Box &bx)
Sets our rectangular domain.
Definition AMReX_Geometry.H:248
static void Setup(const RealBox *rb=nullptr, int coord=-1, int const *isper=nullptr)
Set up the default Geometry, unless it has already been set up.
Definition AMReX_Geometry.cpp:108
GpuArray< int, 3 > isPeriodicArray() const noexcept
Return the periodicity flags in a GpuArray for device code.
Definition AMReX_Geometry.H:417
const RealBox & ProbDomain() const noexcept
Returns the problem domain.
Definition AMReX_Geometry.H:202
Periodicity periodicity() const noexcept
Return the Periodicity based on the length of the domain.
Definition AMReX_Geometry.H:426
Array< int, 3 > isPeriodic() const noexcept
Return the periodicity flags for all directions as an Array.
Definition AMReX_Geometry.H:411
void GetDLogA(MultiFab &dloga, const BoxArray &grds, const DistributionMapping &dm, int dir, int grow) const
Define dloga on grds with dm and fill it with d(log(A))/dr at cell centers.
Box growNonPeriodicDomain(IntVect const &ngrow) const noexcept
Return domain box with non-periodic directions grown by ngrow.
Definition AMReX_Geometry.cpp:486
void periodicShift(const Box &target, const Box &src, Vector< IntVect > &out) const noexcept
Compute Array of shifts which will translate src so that it will intersect target with non-zero inter...
Definition AMReX_Geometry.cpp:376
Real ProbLength(int dir) const noexcept
Returns length of problem domain in specified dimension.
Definition AMReX_Geometry.H:244
void computeRoundoffDomain()
Compute the roundoff domain.
Definition AMReX_Geometry.cpp:522
const Real * ProbLo() const noexcept
Returns the lo end of the problem domain in each dimension.
Definition AMReX_Geometry.H:210
GeometryData data() const noexcept
Return a GPU-safe snapshot of the Geometry data.
Definition AMReX_Geometry.H:136
Geometry() noexcept
Construct a copy of the default Geometry, if one is available.
Definition AMReX_Geometry.cpp:45
GpuArray< Real, 3 > ProbHiArray() const noexcept
Return the hi end of the problem domain in a GpuArray for device code.
Definition AMReX_Geometry.H:224
Box growPeriodicDomain(IntVect const &ngrow) const noexcept
Return domain box with periodic directions grown by ngrow.
Definition AMReX_Geometry.cpp:498
Real ProbSize() const noexcept
Returns the overall size of the domain by multiplying the ProbLength's together.
Definition AMReX_Geometry.H:239
bool insideRoundoffDomain(ParticleReal x, ParticleReal y, ParticleReal z) const
Returns true if a point is inside the roundoff domain. All particles with positions inside the roundo...
Definition AMReX_Geometry.cpp:721
GpuArray< Real, 3 > ProbLoArray() const noexcept
Return the lo end of the problem domain in a GpuArray for device code.
Definition AMReX_Geometry.H:219
bool isAllPeriodic() const noexcept
Is domain periodic in all directions?
Definition AMReX_Geometry.H:406
bool isPeriodic(int dir) const noexcept
Is the domain periodic in the specified direction?
Definition AMReX_Geometry.H:399
static void ResetDefaultPeriodicity(const Array< int, 3 > &is_per) noexcept
Set the periodicity flags of the default Geometry to is_per.
Definition AMReX_Geometry.cpp:193
GpuArray< ParticleReal, 3 > const & RoundOffLo() const
Returns roundoff domain's lower end.
Definition AMReX_Geometry.H:531
friend std::istream & operator>>(std::istream &, Geometry &)
Read a Geometry from an input stream in ASCII format.
Definition AMReX_Geometry.cpp:25
static void ResetDefaultCoord(int coord) noexcept
Set the coordinate-system type of the default Geometry to coord.
Definition AMReX_Geometry.cpp:200
void define(const Box &dom, const RealBox *rb=nullptr, int coord=-1, int const *is_per=nullptr)
Define this Geometry for the specified index-space domain.
Definition AMReX_Geometry.cpp:70
GpuArray< ParticleReal, 3 > const & RoundOffHi() const
Returns roundoff domain's higher end.
Definition AMReX_Geometry.H:535
Periodicity periodicity(const Box &b) const noexcept
Return the Periodicity based on the length of the cell-centered box b.
Definition AMReX_Geometry.H:433
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition AMReX_Periodicity.H:17
A Box with real dimensions.
Definition AMReX_RealBox.H:28
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
amrex_particle_real ParticleReal
Floating Point Type for Particles.
Definition AMReX_REAL.H:91
__host__ __device__ BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b coarsened by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1471
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1328
__host__ __device__ BoxND< dim > refine(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b refined by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1512
std::array< T, N > Array
Definition AMReX_Array.H:31
__host__ __device__ T node_coord(T problo, int i, T dx) noexcept
Coordinate of node i: problo + i*dx.
Definition AMReX_Geometry.H:625
const Geometry & DefaultGeometry()
Return the default Geometry held by the top-level AMReX instance.
Definition AMReX_Geometry.H:636
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
@ y
Definition AMReX_Orientation.H:14
@ x
Definition AMReX_Orientation.H:14
@ z
Definition AMReX_Orientation.H:14
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
std::istream & operator>>(std::istream &is, BoxND< dim > &bx)
Read a BoxND from is.
Definition AMReX_Box.H:1967
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Stream helper; forwards to the friend declared inside AmrMesh.
Definition AMReX_AmrMesh.cpp:1372
GPU-safe snapshot of Geometry data suitable for capture in GPU kernels.
Definition AMReX_Geometry.H:38
Box domain
Cell-centered index-space domain.
Definition AMReX_Geometry.H:69
__host__ __device__ Real ProbLo(int dir) const noexcept
Returns the lo end of the problem domain in direction dir.
Definition AMReX_Geometry.H:50
__host__ __device__ Real CellSize(int dir) const noexcept
Returns the cellsize for direction dir.
Definition AMReX_Geometry.H:44
__host__ __device__ int Coord() const noexcept
Coordinates type.
Definition AMReX_Geometry.H:65
__host__ __device__ const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:59
Real dx[3]
Cell size in each dimension.
Definition AMReX_Geometry.H:70
__host__ __device__ Real ProbHi(int dir) const noexcept
Returns the hi end of the problem domain in direction dir.
Definition AMReX_Geometry.H:56
__host__ __device__ const Real * CellSize() const noexcept
Returns the cellsize for each coordinate direction.
Definition AMReX_Geometry.H:41
int coord
Coordinate-system type: 0 for Cartesian, 1 for RZ, and 2 for spherical.
Definition AMReX_Geometry.H:72
__host__ __device__ int isPeriodic(const int i) const noexcept
Returns whether the domain is periodic in the given direction.
Definition AMReX_Geometry.H:62
int is_periodic[3]
For each dimension, 0 if the domain is non-periodic and 1 if it is.
Definition AMReX_Geometry.H:71
__host__ __device__ const Real * ProbLo() const noexcept
Returns the lo end of the problem domain in each dimension.
Definition AMReX_Geometry.H:47
RealBox prob_domain
Physical bounds of the problem domain.
Definition AMReX_Geometry.H:68
__host__ __device__ const Real * ProbHi() const noexcept
Returns the hi end of the problem domain in each dimension.
Definition AMReX_Geometry.H:53
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:52