File Util_CPU.h
FileList > src > Util_CPU.h
Go to the source code of this file
#include "General.h"#include "Param.h"
Namespaces
| Type | Name |
|---|---|
| namespace | utils |
Public Functions
| Type | Name |
|---|---|
| __host__ __device__ T | BarycentricInterpolation (T q1, T x1, T y1, T q2, T x2, T y2, T q3, T x3, T y3, T x, T y) Barycentric interpolation within a triangle. Barycentric interpolation within a triangle defined by the vertices (x1, y1), (x2, y2), and (x3, y3). The values at the vertices are q1, q2, and q3. The function returns the interpolated value at the point (x, y). |
| __host__ __device__ T | BilinearInterpolation (T q11, T q12, T q21, T q22, T x1, T x2, T y1, T y2, T x, T y) Bilinear interpolation within a rectangle. Bilinear interpolation within a rectangle defined by (x1, y1) and (x2, y2). The values at the corners of the rectangle are q11, q12, q21, and q22. The function returns the interpolated value at the point (x, y). __ |
| __host__ __device__ bool | OBBdetect (T Axmin, T Axmax, T Aymin, T Aymax, T Bxmin, T Bxmax, T Bymin, T Bymax) Overlapping Bounding Box detection. Overlapping Bounding Box detection to determine if two axis-aligned bounding boxes overlap. The function takes the minimum and maximum coordinates of two bounding boxes (A and B). It returns true if the bounding boxes overlap, and false otherwise. |
| __host__ __device__ T | calcres (T dx, int level) Calculate the grid resolution at a given refinement level. Calculate the grid resolution at a given refinement level. If level is negative, the resolution is coarsened (doubled for each level). If level is positive, the resolution is refined (halved for each level). |
| int | ftoi (T value) Converts a floating-point number to the nearest integer. Converts a floating-point number to the nearest integer. The function rounds the value to the nearest integer, rounding halfway cases away from zero. |
| double | interptime (double next, double prev, double timenext, double time) Linear interpolation between two values. |
| __host__ __device__ T | minmod2 (T theta, T s0, T s1, T s2) Minmod limiter function for slope limiting in numerical schemes. Minmod limiter function for slope limiting in numerical schemes. The function takes a parameter theta and three slope values (s0, s1, s2). Theta is used to tune the limiting (theta=1 gives minmod, the most dissipative limiter, and theta=2 gives superbee, the least dissipative). The function returns the limited slope value based on the input slopes and theta. Usual value : float theta = 1.3f;. |
| unsigned int | nextPow2 (unsigned int x) Computes the next power of two greater than or equal to x. Computes the next power of two greater than or equal to x. |
| __host__ __device__ T | signof (T a) Returns the sign of a number. Returns the sign of a number. |
Public Functions Documentation
function BarycentricInterpolation
Barycentric interpolation within a triangle. Barycentric interpolation within a triangle defined by the vertices (x1, y1), (x2, y2), and (x3, y3). The values at the vertices are q1, q2, and q3. The function returns the interpolated value at the point (x, y).
template<class T>
__host__ __device__ T BarycentricInterpolation (
T q1,
T x1,
T y1,
T q2,
T x2,
T y2,
T q3,
T x3,
T y3,
T x,
T y
)
Parameters:
q1Value at (x1, y1)x1x-coordinate of the first vertexy1y-coordinate of the first vertexq2Value at (x2, y2)x2x-coordinate of the second vertexy2y-coordinate of the second vertexq3Value at (x3, y3)x3x-coordinate of the third vertexy3y-coordinate of the third vertexxx-coordinate of the point to interpolateyy-coordinate of the point to interpolate
Returns:
Interpolated value at (x, y)
function BilinearInterpolation
Bilinear interpolation within a rectangle. Bilinear interpolation within a rectangle defined by (x1, y1) and (x2, y2). The values at the corners of the rectangle are q11, q12, q21, and q22. The function returns the interpolated value at the point (x, y). __
template<class T>
__host__ __device__ T BilinearInterpolation (
T q11,
T q12,
T q21,
T q22,
T x1,
T x2,
T y1,
T y2,
T x,
T y
)
Parameters:
q11Value at (x1, y1)q12Value at (x1, y2)q21Value at (x2, y1)q22Value at (x2, y2)x1x-coordinate of the bottom-left cornerx2x-coordinate of the top-right cornery1y-coordinate of the bottom-left cornery2y-coordinate of the top-right cornerxx-coordinate of the point to interpolateyy-coordinate of the point to interpolate
function OBBdetect
Overlapping Bounding Box detection. Overlapping Bounding Box detection to determine if two axis-aligned bounding boxes overlap. The function takes the minimum and maximum coordinates of two bounding boxes (A and B). It returns true if the bounding boxes overlap, and false otherwise.
template<class T>
__host__ __device__ bool OBBdetect (
T Axmin,
T Axmax,
T Aymin,
T Aymax,
T Bxmin,
T Bxmax,
T Bymin,
T Bymax
)
Parameters:
AxminMinimum x-coordinate of bounding box A.AxmaxMaximum x-coordinate of bounding box A.AyminMinimum y-coordinate of bounding box A.AymaxMaximum y-coordinate of bounding box A.BxminMinimum x-coordinate of bounding box B.BxmaxMaximum x-coordinate of bounding box B.ByminMinimum y-coordinate of bounding box B.BymaxMaximum y-coordinate of bounding box B.
Returns:
True if the bounding boxes overlap, false otherwise.
Overlaping Bounding Box to detect which cell river falls into. It is the simplest version of the algorythm where the bounding box are paralle;l to the axis
function calcres
Calculate the grid resolution at a given refinement level. Calculate the grid resolution at a given refinement level. If level is negative, the resolution is coarsened (doubled for each level). If level is positive, the resolution is refined (halved for each level).
Parameters:
dxThe base grid resolution.levelThe refinement level (negative for coarsening, positive for refining).
Returns:
The calculated grid resolution at the specified level.
function ftoi
Converts a floating-point number to the nearest integer. Converts a floating-point number to the nearest integer. The function rounds the value to the nearest integer, rounding halfway cases away from zero.
Parameters:
valueThe floating-point number to convert.
Returns:
The nearest integer.
function interptime
Linear interpolation between two values.
function minmod2
Minmod limiter function for slope limiting in numerical schemes. Minmod limiter function for slope limiting in numerical schemes. The function takes a parameter theta and three slope values (s0, s1, s2). Theta is used to tune the limiting (theta=1 gives minmod, the most dissipative limiter, and theta=2 gives superbee, the least dissipative). The function returns the limited slope value based on the input slopes and theta. Usual value : float theta = 1.3f;.
Parameters:
thetaThe tuning parameter for the limiter (between 1 and 2).s0The slope value at the left cell.s1The slope value at the center cell.s2The slope value at the right cell.
Returns:
The limited slope value.
function nextPow2
Computes the next power of two greater than or equal to x. Computes the next power of two greater than or equal to x.
function signof
Returns the sign of a number. Returns the sign of a number.
The documentation for this class was generated from the following file src/Util_CPU.h