Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_Dim3.H
Go to the documentation of this file.
1#ifndef AMREX_DIM3_H_
2#define AMREX_DIM3_H_
3#include <AMReX_Config.H>
4
10#include <AMReX_REAL.H>
11#include <AMReX_GpuQualifiers.H>
12
13#include <concepts>
14#include <iostream>
15
16namespace amrex {
17
24struct Dim3 { int x; int y; int z; };
25
32struct XDim3 { Real x; Real y; Real z; };
33
40Real dot_product (XDim3 const& a, XDim3 const& b)
41{
42 return a.x*b.x + a.y*b.y + a.z*b.z;
43}
44
51XDim3 cross_product (XDim3 const& a, XDim3 const& b)
52{
53 return XDim3{.x = a.y*b.z-a.z*b.y, .y = a.z*b.x-a.x*b.z, .z = a.x*b.y-a.y*b.x};
54}
55
62XDim3 operator+ (XDim3 const& a, XDim3 const& b)
63{
64 return XDim3{.x = a.x + b.x, .y = a.y + b.y, .z = a.z + b.z};
65}
66
73XDim3 operator- (XDim3 const& a, XDim3 const& b)
74{
75 return XDim3{.x = a.x - b.x, .y = a.y - b.y, .z = a.z - b.z};
76}
77
83template <typename T>
84requires (std::same_as<T, Dim3> || std::same_as<T, XDim3>)
85std::ostream& operator<< (std::ostream& os, const T& d)
86{
87 os << '(' << d.x << ',' << d.y << ',' << d.z << ')';
88 return os;
89}
90
91}
92
93#endif
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
Definition AMReX_Amr.cpp:50
__host__ __device__ Real dot_product(XDim3 const &a, XDim3 const &b)
Return the dot product of two XDim3 structs.
Definition AMReX_Dim3.H:40
__host__ __device__ XDim3 cross_product(XDim3 const &a, XDim3 const &b)
Return the cross product of two XDim3 structs.
Definition AMReX_Dim3.H:51
__host__ __device__ XDim3 operator-(XDim3 const &a, XDim3 const &b)
Component-wise subtraction of two XDim3 structs.
Definition AMReX_Dim3.H:73
__host__ __device__ XDim3 operator+(XDim3 const &a, XDim3 const &b)
Component-wise addition of two XDim3 structs.
Definition AMReX_Dim3.H:62
A simple struct holding 3 int values for a 3D index.
Definition AMReX_Dim3.H:24
int x
Definition AMReX_Dim3.H:24
int z
Definition AMReX_Dim3.H:24
int y
Definition AMReX_Dim3.H:24
A simple struct holding 3 Real values for a 3D coordinate.
Definition AMReX_Dim3.H:32
Real x
Definition AMReX_Dim3.H:32
Real z
Definition AMReX_Dim3.H:32
Real y
Definition AMReX_Dim3.H:32