Semidiscretization

TrixiParticles.SemidiscretizationType
Semidiscretization(systems...;
                   neighborhood_search=GridNeighborhoodSearch{NDIMS}(),
                   neighborhood_search_handler=default_neighborhood_search_handler(neighborhood_search),
                   parallelization_backend=PolyesterBackend(),
                   interaction_matrix=nothing)

The semidiscretization couples the passed systems to one simulation.

Arguments

  • systems: Systems to be coupled in this semidiscretization. Any nothing entries are ignored.

Keywords

  • neighborhood_search=GridNeighborhoodSearch{NDIMS}(): The neighborhood search used in the simulation. Use nothing to loop over all particles without a neighborhood search. To use another neighborhood search implementation, pass a template of a neighborhood search. See copy_neighborhood_search and the examples below for more details. To use a periodic domain, pass a PeriodicBox to the neighborhood search.
  • neighborhood_search_handler: The handler type used to store and look up neighborhood searches internally. By default, SharedNHSHandler is used whenever possible and PairsNHSHandler otherwise. See neighborhood search handlers for more details.
  • parallelization_backend=PolyesterBackend(): Backend used for parallel loops. Pass SerialBackend() to disable parallelization. See GPU support for information on using GPU backends.
  • interaction_matrix=nothing: Matrix controlling ordered system-pair interactions after filtering out nothing systems. With n_systems remaining systems, nothing creates trues(n_systems, n_systems), enabling every interaction. Rows refer to the system being updated and columns to the neighbor system. interaction_matrix[i, j] == true uses the default interaction for computing forces on system i by particles of system j, while interaction_matrix[i, j] == false disables it. Set an entry to a callable with the signature interaction(dv, v_system, u_system, v_neighbor, u_neighbor, system, neighbor, semi; kwargs...) to use a custom interaction function. Disabled pairs are also skipped in auxiliary neighbor loops such as density summation, correction factors, surface normals, pressure extrapolation, and particle shifting. Disabled pairs remain available through the neighborhood search handler for APIs such as point interpolation, which use neighborhood searches independently of force interactions.

Examples

semi = Semidiscretization(fluid_system, boundary_system)

semi = Semidiscretization(fluid_system, boundary_system,
                          neighborhood_search=GridNeighborhoodSearch{2}(update_strategy=SerialUpdate()))

periodic_box = PeriodicBox(min_corner = [0.0, 0.0], max_corner = [1.0, 1.0])
semi = Semidiscretization(fluid_system, boundary_system,
                          neighborhood_search=GridNeighborhoodSearch{2}(; periodic_box))

semi = Semidiscretization(fluid_system, boundary_system,
                          neighborhood_search=PrecomputedNeighborhoodSearch{2}())

semi = Semidiscretization(fluid_system, boundary_system,
                          neighborhood_search=nothing)

interaction_matrix = trues(2, 2)
interaction_matrix[1, 2] = false # `fluid_system` skips interactions with `boundary_system`
semi = Semidiscretization(fluid_system, boundary_system;
                          neighborhood_search=nothing,
                          interaction_matrix=interaction_matrix)
source
TrixiParticles.SourceTermDampingType
SourceTermDamping(; damping_coefficient)

A source term to be used when a damping step is required before running a full simulation. The term $-c \cdot v_a$ is added to the acceleration $\frac{\mathrm{d}v_a}{\mathrm{d}t}$ of particle $a$, where $c$ is the damping coefficient and $v_a$ is the velocity of particle $a$.

Keywords

  • damping_coefficient: The coefficient $c$ above. A higher coefficient means more damping. A coefficient of 1e-4 is a good starting point for damping a fluid at rest.

Examples

source_terms = SourceTermDamping(; damping_coefficient=1e-4)
source
TrixiParticles.restart_with!Method
restart_with!(semi, sol; reset_threads=true)

Set the restartable state of all systems in semi to the final values in the solution sol. This includes coordinates and velocities as well as integrated state variables such as density or pressure where applicable. semidiscretize has to be called again afterwards, or another Semidiscretization can be created with the updated systems.

Arguments

  • semi: The semidiscretization to update.
  • sol: The ODESolution returned by solve from OrdinaryDiffEq.jl.

Keywords

  • reset_threads=true: Reset Polyester.jl threads before updating the systems. After an error within a threaded loop, threading might be disabled; resetting the threads ensures that threading is enabled again.
source
TrixiParticles.semidiscretizeMethod
semidiscretize(semi, tspan; reset_threads=true, restart_with=nothing)

Create an ODEProblem from the semidiscretization with the specified tspan.

Arguments

  • semi: A Semidiscretization holding the systems involved in the simulation.
  • tspan: The time span over which the simulation will be run.

Keywords

  • reset_threads=true: Reset Polyester.jl threads before the simulation. After an error within a threaded loop, threading might be disabled; resetting the threads ensures that threading is enabled again for the simulation. See also trixi-framework/Trixi.jl#1583.
  • restart_with=nothing: Restart the simulation from VTK solution files created by SolutionSavingCallback. This can be either nothing (default, no restart) or a tuple of filenames, one for each system in the Semidiscretization. The tuple order must match the system order. When restarting, semidiscretize replaces the initial time (tspan[1]) with the timestamp read from the VTK files. If the provided tspan[1] does not match the restart time, it is adjusted and an info message is logged. Timestamps in multiple files must match.

Returns

A DynamicalODEProblem (see the OrdinaryDiffEq.jl docs) to be integrated with OrdinaryDiffEq.jl. Note that this is not a true DynamicalODEProblem where the acceleration does not depend on the velocity. Therefore, not all integrators designed for DynamicalODEProblems will work properly. However, all integrators designed for ODEProblems can be used. See time integration for more details.

Examples

semi = Semidiscretization(fluid_system, boundary_system)
tspan = (0.0, 1.0)
ode_problem = semidiscretize(semi, tspan)
source