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()
dgamma()def dgamma(
m: UnstructuredMesh,
ij: npt.NDArray,
rho: float = 1.0,
weights: npt.NDArray | None = None,
) -> npt.NDArray: ...Compute the derivative of gamma.
mUnstructuredMesh — The unstructured mesh object.ijnpt.NDArray — ijrhofloat =1.0— rhoweightsnpt.NDArray | None =None— Per-element weight of gamma, shape(nelem,). Used as given; seegamma.Noneweights every element equally.
dgamma_h()
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.
mUnstructuredMesh — The mesh.h_ek_reffloat | npt.NDArray — h_ek_refg_exponentint =3— g_exponentrhofloat =35.0— rho
gamma()
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.
mUnstructuredMesh — The mesh.ijnpt.NDArray — ijrhofloat =1.0— rhoreturn_gamma_maxbool =False— Return the max gamma value.return_gamma_arraybool =False— Return the gamme array.weightsnpt.NDArray | None =None— Per-element weight of gamma, shape(nelem,).Noneweights every element equally, which measures pure geometry.
gamma_h()
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.
mUnstructuredMesh — The mesh.h_ek_reffloat | npt.NDArray — h_ek_refg_exponentint =3— g_exponentrhofloat =35.0— rhoreturn_gamma_h_maxbool =False— Return the max value of gamma_h.
optimize_dt()
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.
mUnstructuredMesh — The mesh to optimize.fixed_side_setslist[list[set[tuple[int, int]]]] | None =None— Element and side ids of the fixed side sets.maxiterint =50— Maximum number of iterations.rhofloat =35.0— rhorho_hfloat =35.0— rho_hweight_hfloat =0.0— weight_hh_ek_refnpt.NDArray | float =0.0— h_ek_refg_exponentint =3— g_exponentscale_meshbool =True— Scale the mesh.scale_factorfloat =10000.0— Scaling factor.verbosebool =False— Verbosity.
optimize_dt_locally()
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.
mUnstructuredMesh — The mesh to optimize.fixed_side_set_nameslist[list[str]] — Names of the fixed side sets.maxiterint =50— Maximum number of iterations.rhofloat =35.0— rhorho_hfloat =35.0— rho_hweight_hfloat =0.0— weight_hh_ek_refnpt.NDArray[np.floating] | float =0.0— h_ek_refg_exponentint =3— g_exponentelement_count_optint =100— Number of elements to optimize.halo_widthint =3— Halo width around the problematic elements.scale_factorfloat =10000.0— Scaling factor.verbosebool =False— Verbosity.