Peano
Loading...
Searching...
No Matches
kernel_hydro.h File Reference

Kernel functions for SPH (scalar and vector version). More...

#include <config.h>
#include <math.h>
#include "dimension.h"
#include "error.h"
#include "inline.h"
#include "minmax.h"
#include "vector.h"
Include dependency graph for kernel_hydro.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define kernel_gamma_inv   ((float)(1. / kernel_gamma))
 
#define kernel_gamma2   ((float)(kernel_gamma * kernel_gamma))
 
#define kernel_ivals_f   ((float)(kernel_ivals))
 
#define kernel_root
 
#define kernel_norm   ((float)(hydro_dimension_unit_sphere * kernel_gamma_dim))
 

Functions

 __attribute__ ((always_inline)) INLINE static void kernel_deval(float u
 Computes the kernel function and its derivative.
 
 for (int k=2;k<=kernel_degree;k++) = x * w + coeffs[k]
 
 for (int k=2;k< kernel_degree;k++) dw_dx
 
void hydro_kernel_dump (int N)
 Test the SPH kernel function by dumping it in the interval [0,1].
 

Variables

float *restrict W = w * kernel_constant * kernel_gamma_inv_dim
 
float *restrict float *restrict dW_dx
 
const int temp = (int)(x * kernel_ivals_f)
 
const int ind = temp > kernel_ivals ? kernel_ivals : temp
 
const float *const coeffs = &kernel_coeffs[ind * (kernel_degree + 1)]
 
float w = coeffs[0] * x + coeffs[1]
 
float dw_dx = coeffs[0]
 

Detailed Description

Kernel functions for SPH (scalar and vector version).

All constants and kernel coefficients are taken from table 1 of Dehnen & Aly, MNRAS, 425, pp. 1062-1082 (2012).

Definition in file kernel_hydro.h.

Macro Definition Documentation

◆ kernel_gamma2

#define kernel_gamma2   ((float)(kernel_gamma * kernel_gamma))

Definition at line 206 of file kernel_hydro.h.

◆ kernel_gamma_inv

#define kernel_gamma_inv   ((float)(1. / kernel_gamma))

Definition at line 205 of file kernel_hydro.h.

◆ kernel_ivals_f

#define kernel_ivals_f   ((float)(kernel_ivals))

Definition at line 233 of file kernel_hydro.h.

◆ kernel_norm

#define kernel_norm   ((float)(hydro_dimension_unit_sphere * kernel_gamma_dim))

Definition at line 241 of file kernel_hydro.h.

◆ kernel_root

#define kernel_root
Value:
((float)(kernel_coeffs[kernel_degree]) * kernel_constant * \
kernel_gamma_inv_dim)

Definition at line 236 of file kernel_hydro.h.

Function Documentation

◆ __attribute__()

__attribute__ ( (always_inline) )

Computes the kernel function and its derivative.

Computes the kernel function derivative.

Computes the kernel function in double precision.

Computes the kernel function.

The kernel function needs to be mutliplied by \(h^{-d}\) and the gradient by \(h^{-(d+1)}\), where \(d\) is the dimensionality of the problem.

Returns 0 if \(u > \gamma = H/h\).

Parameters
uThe ratio of the distance to the smoothing length \(u = x/h\).
W(return) The value of the kernel function \(W(x,h)\).
dW_dx(return) The norm of the gradient of \(|\nabla W(x,h)|\).

The kernel function needs to be mutliplied by \(h^{-d}\), where \(d\) is the dimensionality of the problem.

Returns 0 if \(u > \gamma = H/h\)

Parameters
uThe ratio of the distance to the smoothing length \(u = x/h\).
W(return) The value of the kernel function \(W(x,h)\).

Required for computing the projected kernel because rounding error causes problems for the GSL integration function if we evaluate in single precision.

The kernel function needs to be mutliplied by \(h^{-d}\), where \(d\) is the dimensionality of the problem.

Returns 0 if \(u > \gamma = H/h\)

Parameters
uThe ratio of the distance to the smoothing length \(u = x/h\).
W(return) The value of the kernel function \(W(x,h)\).

The kernel function needs to be mutliplied by \(h^{-d}\) and the gradient by \(h^{-(d+1)}\), where \(d\) is the dimensionality of the problem.

Returns 0 if \(u > \gamma = H/h\).

Parameters
uThe ratio of the distance to the smoothing length \(u = x/h\).
dW_dx(return) The norm of the gradient of \(|\nabla W(x,h)|\).

◆ for() [1/2]

for ( )

◆ for() [2/2]

for ( int k = 2;k<=kernel_degree;k++) = x * w + coeffs[k]

Definition at line 273 of file kernel_hydro.h.

References coeffs, dw_dx, and w.

◆ hydro_kernel_dump()

void hydro_kernel_dump ( int N)

Test the SPH kernel function by dumping it in the interval [0,1].

Parameters
Nnumber of intervals in [0,1].

Definition at line 31 of file kernel_hydro.c.

References dw_dx, kernel_deval(), and w.

Here is the call graph for this function:

Variable Documentation

◆ coeffs

const float *const coeffs = &kernel_coeffs[ind * (kernel_degree + 1)]

◆ dW_dx

* dW_dx
Initial value:
{
const float x = u * kernel_gamma_inv
float u
#define kernel_gamma_inv

Definition at line 258 of file kernel_hydro.h.

Referenced by swift2::kernels::legacy::kernelHydro::kernel_deval().

◆ dw_dx

float dw_dx = coeffs[0]

◆ ind

const int ind = temp > kernel_ivals ? kernel_ivals : temp

◆ temp

◆ W

* W = w * kernel_constant * kernel_gamma_inv_dim

◆ w