WarpX
Toggle main menu visibility
Loading...
Searching...
No Matches
Source
ablastr
math
LinearInterpolation.H
Go to the documentation of this file.
1
/* Copyright 2022-2025 Luca Fedeli
2
*
3
* This file is part of WarpX.
4
*
5
* License: BSD-3-Clause-LBNL
6
*/
7
8
#ifndef ABLASTR_MATH_LINEAR_INTERPOLATION_H_
9
#define ABLASTR_MATH_LINEAR_INTERPOLATION_H_
10
11
#include <
AMReX_Extension.H
>
12
#include <
AMReX_GpuQualifiers.H
>
13
14
namespace
ablastr::math
15
{
21
template
<
typename
TCoord,
typename
TVal>
22
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
23
constexpr
auto
linear_interp
(
24
TCoord x0, TCoord x1,
25
TVal f0, TVal f1,
26
TCoord x)
27
{
28
return
((x1-x)*f0 + (x-x0)*f1)/(x1-x0);
29
}
30
36
template
<
typename
TCoord,
typename
TVal>
37
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
38
constexpr
auto
bilinear_interp
(
39
TCoord x0, TCoord x1, TCoord y0, TCoord y1,
40
TVal f00, TVal f01, TVal f10, TVal f11,
41
TCoord x, TCoord y)
42
{
43
const
auto
fx0 =
linear_interp
(x0, x1, f00, f10, x);
44
const
auto
fx1 =
linear_interp
(x0, x1, f01, f11, x);
45
return
linear_interp
(y0, y1, fx0, fx1, y);
46
}
47
54
template
<
typename
TCoord,
typename
TVal>
55
AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
56
constexpr
auto
trilinear_interp
(
57
TCoord x0, TCoord x1, TCoord y0, TCoord y1, TCoord z0, TCoord z1,
58
TVal f000, TVal f001, TVal f010, TVal f011, TVal f100, TVal f101, TVal f110, TVal f111,
59
TCoord x, TCoord y, TCoord z)
60
{
61
const
auto
fxy0 =
bilinear_interp
(
62
x0, x1, y0, y1, f000, f010, f100, f110, x, y);
63
const
auto
fxy1 =
bilinear_interp
(
64
x0, x1, y0, y1, f001, f011, f101, f111, x, y);
65
return
linear_interp
(z0, z1, fxy0, fxy1, z);
66
}
67
}
68
69
#endif
//ABLASTR_MATH_LINEAR_INTERPOLATION_H_
AMReX_Extension.H
AMREX_FORCE_INLINE
#define AMREX_FORCE_INLINE
AMReX_GpuQualifiers.H
AMREX_GPU_DEVICE
#define AMREX_GPU_DEVICE
ablastr::math
Definition
AnyFFT.H:41
ablastr::math::linear_interp
AMREX_GPU_DEVICE AMREX_FORCE_INLINE constexpr auto linear_interp(TCoord x0, TCoord x1, TVal f0, TVal f1, TCoord x)
Performs a linear interpolation.
Definition
LinearInterpolation.H:23
ablastr::math::bilinear_interp
AMREX_GPU_DEVICE AMREX_FORCE_INLINE constexpr auto bilinear_interp(TCoord x0, TCoord x1, TCoord y0, TCoord y1, TVal f00, TVal f01, TVal f10, TVal f11, TCoord x, TCoord y)
Performs a bilinear interpolation.
Definition
LinearInterpolation.H:38
ablastr::math::trilinear_interp
AMREX_GPU_DEVICE AMREX_FORCE_INLINE constexpr auto trilinear_interp(TCoord x0, TCoord x1, TCoord y0, TCoord y1, TCoord z0, TCoord z1, TVal f000, TVal f001, TVal f010, TVal f011, TVal f100, TVal f101, TVal f110, TVal f111, TCoord x, TCoord y, TCoord z)
Performs a trilinear interpolation.
Definition
LinearInterpolation.H:56
Generated by
1.17.0