helpers.problem_helper module¶
- get_1d_grid(size, bc, left_boundary=0.0, right_boundary=1.0)[source]¶
Generate a grid in one dimension and obtain mesh spacing for finite difference discretization.
- Parameters:
size (int) – Number of degrees of freedom per dimension
bc (str) – Boundary conditions for both sides
left_boundary (float) – x value at the left boundary
right_boundary (float) – x value at the right boundary
- Returns:
mesh spacing numpy.ndarray: 1d mesh
- Return type:
float
- get_finite_difference_matrix(derivative, order, stencil_type=None, steps=None, dx=None, size=None, dim=None, bc=None, cupy=False, bc_params=None)[source]¶
Build FD matrix from stencils, with boundary conditions. Keep in mind that the boundary conditions may require further modification of the right hand side.
- Parameters:
derivative (int) – Order of the spatial derivative
order (int) – Order of accuracy
stencil_type (str) – Type of stencil
steps (list) – Provide specific steps, overrides stencil_type
dx (float) – Mesh width
size (int) – Number of degrees of freedom per dimension
dim (int) – Number of dimensions
bc (str) – Boundary conditions for both sides
cupy (bool) – Construct a GPU ready matrix if yes
- Returns:
Finite difference matrix numpy.ndarray: Vector containing information about the boundary conditions
- Return type:
Sparse matrix
- get_finite_difference_stencil(derivative, order=None, stencil_type=None, steps=None)[source]¶
Derive general finite difference stencils from Taylor expansions
- Parameters:
derivative (int) – Order of the derivative
order (int) – Order of accuracy
stencil_type (str) – Type of the stencil
steps (list) – Provide specific steps, overrides stencil_type
- Returns:
The weights of the stencil numpy.ndarray: The offsets for the stencil
- Return type:
numpy.ndarray
- get_steps(derivative, order, stencil_type)[source]¶
Get the offsets for the FD stencil.
- Parameters:
derivative (int) – Order of the derivative
order (int) – Order of accuracy
stencil_type (str) – Type of the stencil
steps (list) – Provide specific steps, overrides stencil_type
- Returns:
The number of elements in the stencil numpy.ndarray: The offsets for the stencil
- Return type:
int