Skip to content

salvus.mesh.algorithms.optimize_dt

salvus.mesh.algorithms.optimize_dt salvus mesh algorithms optimize_dt

A mesh smoother optimizing the miller estimate of the time step.

Functions

dgamma()

def dgamma(
    m: UnstructuredMesh,
    ij: npt.NDArray,
    rho: float = 1.0,
    weights: npt.NDArray | None = None,
) -> npt.NDArray: ...

Compute the derivative of gamma.

Parameters
  • m UnstructuredMesh — The unstructured mesh object.
  • ij npt.NDArray — ij
  • rho float = 1.0 — rho
  • weights npt.NDArray | None = None — Per-element weight of gamma, shape (nelem,). Used as given; see gamma. None weights every element equally.
Returns npt.NDArray

dgamma_h()

def dgamma_h(
    m: UnstructuredMesh,
    h_ek_ref: float | npt.NDArray,
    g_exponent: int = 3,
    rho: float = 35.0,
) -> npt.NDArray: ...

Compute d gamma h.

Parameters
  • m UnstructuredMesh — The mesh.
  • h_ek_ref float | npt.NDArray — h_ek_ref
  • g_exponent int = 3 — g_exponent
  • rho float = 35.0 — rho
Returns npt.NDArray

gamma()

def gamma(
    m: UnstructuredMesh,
    ij: npt.NDArray,
    rho: float = 1.0,
    return_gamma_max: bool = False,
    return_gamma_array: bool = False,
    weights: npt.NDArray | None = None,
) -> npt.NDArray | float: ...

Compute gamma.

Gamma is the reciprocal of the distance between two neighbouring GLL points, so the largest one in the mesh is what limits the time step of a simulation on a homogeneous medium. Weighting every element with its own wave speed turns that into the time step of a heterogeneous one, as the CFL bound is the distance over the velocity rather than the distance alone.

The weights are used exactly as given, so the objective they define carries their unit. Only their ratios matter to where the optimum is, and callers that mix gamma with another term are expected to scale them so both terms stay comparable.

Parameters
  • m UnstructuredMesh — The mesh.
  • ij npt.NDArray — ij
  • rho float = 1.0 — rho
  • return_gamma_max bool = False — Return the max gamma value.
  • return_gamma_array bool = False — Return the gamme array.
  • weights npt.NDArray | None = None — Per-element weight of gamma, shape (nelem,). None weights every element equally, which measures pure geometry.
Returns npt.NDArray | float

gamma_h()

def gamma_h(
    m: UnstructuredMesh,
    h_ek_ref: float | npt.NDArray,
    g_exponent: int = 3,
    rho: float = 35.0,
    return_gamma_h_max: bool = False,
) -> float | npt.NDArray: ...

Compute gamma h.

Parameters
  • m UnstructuredMesh — The mesh.
  • h_ek_ref float | npt.NDArray — h_ek_ref
  • g_exponent int = 3 — g_exponent
  • rho float = 35.0 — rho
  • return_gamma_h_max bool = False — Return the max value of gamma_h.
Returns float | npt.NDArray

optimize_dt()

def optimize_dt(
    m: UnstructuredMesh,
    fixed_side_sets: list[list[set[tuple[int, int]]]] | None = None,
    maxiter: int = 50,
    rho: float = 35.0,
    rho_h: float = 35.0,
    weight_h: float = 0.0,
    h_ek_ref: npt.NDArray | float = 0.0,
    g_exponent: int = 3,
    scale_mesh: bool = True,
    scale_factor: float = 10000.0,
    verbose: bool = False,
) -> UnstructuredMesh: ...

Optimize the time step for a mesh and return a better mesh.

Deprecated: use salvus.mesh.algorithms.improve and its optimize_time_step_globally function instead, which sets all tuning parameters to suitable defaults and identifies the fixed nodes by side-set name.

This optimizes the smallest distance between two GLL points anywhere in the mesh, i.e. pure geometry. Its successor additionally weights every element with its own wave speed, so it optimizes the time step of the medium the mesh carries.

Parameters
  • m UnstructuredMesh — The mesh to optimize.
  • fixed_side_sets list[list[set[tuple[int, int]]]] | None = None — Element and side ids of the fixed side sets.
  • maxiter int = 50 — Maximum number of iterations.
  • rho float = 35.0 — rho
  • rho_h float = 35.0 — rho_h
  • weight_h float = 0.0 — weight_h
  • h_ek_ref npt.NDArray | float = 0.0 — h_ek_ref
  • g_exponent int = 3 — g_exponent
  • scale_mesh bool = True — Scale the mesh.
  • scale_factor float = 10000.0 — Scaling factor.
  • verbose bool = False — Verbosity.
Returns UnstructuredMesh

optimize_dt_locally()

def optimize_dt_locally(
    m: UnstructuredMesh,
    fixed_side_set_names: list[list[str]],
    maxiter: int = 50,
    rho: float = 35.0,
    rho_h: float = 35.0,
    weight_h: float = 0.0,
    h_ek_ref: npt.NDArray[np.floating] | float = 0.0,
    g_exponent: int = 3,
    element_count_opt: int = 100,
    halo_width: int = 3,
    scale_factor: float = 10000.0,
    verbose: bool = False,
) -> UnstructuredMesh: ...

Locally optimize the time step of a mesh by finding the worst elements and only optimizing those.

Deprecated: use salvus.mesh.algorithms.improve and its optimize_time_step_locally function instead, which sets all tuning parameters to suitable defaults and always holds the boundary of the optimized region fixed.

This ranks and optimizes elements by the smallest distance between two GLL points, i.e. pure geometry. Its successor additionally weights every element with its own wave speed, so it works on the elements that limit the time step of the medium the mesh carries.

Parameters
  • m UnstructuredMesh — The mesh to optimize.
  • fixed_side_set_names list[list[str]] — Names of the fixed side sets.
  • maxiter int = 50 — Maximum number of iterations.
  • rho float = 35.0 — rho
  • rho_h float = 35.0 — rho_h
  • weight_h float = 0.0 — weight_h
  • h_ek_ref npt.NDArray[np.floating] | float = 0.0 — h_ek_ref
  • g_exponent int = 3 — g_exponent
  • element_count_opt int = 100 — Number of elements to optimize.
  • halo_width int = 3 — Halo width around the problematic elements.
  • scale_factor float = 10000.0 — Scaling factor.
  • verbose bool = False — Verbosity.
Returns UnstructuredMesh