Semidiscretization
TrixiParticles.Semidiscretization — Type
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. Anynothingentries are ignored.
Keywords
neighborhood_search=GridNeighborhoodSearch{NDIMS}(): The neighborhood search used in the simulation. Usenothingto loop over all particles without a neighborhood search. To use another neighborhood search implementation, pass a template of a neighborhood search. Seecopy_neighborhood_searchand the examples below for more details. To use a periodic domain, pass aPeriodicBoxto the neighborhood search.neighborhood_search_handler: The handler type used to store and look up neighborhood searches internally. By default,SharedNHSHandleris used whenever possible andPairsNHSHandlerotherwise. See neighborhood search handlers for more details.parallelization_backend=PolyesterBackend(): Backend used for parallel loops. PassSerialBackend()to disable parallelization. See GPU support for information on using GPU backends.interaction_matrix=nothing: Matrix controlling ordered system-pair interactions after filtering outnothingsystems. Withn_systemsremaining systems,nothingcreatestrues(n_systems, n_systems), enabling every interaction. Rows refer to the system being updated and columns to the neighbor system.interaction_matrix[i, j] == trueuses the default interaction for computing forces on systemiby particles of systemj, whileinteraction_matrix[i, j] == falsedisables it. Set an entry to a callable with the signatureinteraction(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)TrixiParticles.SourceTermDamping — Type
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 of1e-4is a good starting point for damping a fluid at rest.
Examples
source_terms = SourceTermDamping(; damping_coefficient=1e-4)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: TheODESolutionreturned bysolvefrom 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.
TrixiParticles.semidiscretize — Method
semidiscretize(semi, tspan; reset_threads=true, restart_with=nothing)Create an ODEProblem from the semidiscretization with the specified tspan.
Arguments
semi: ASemidiscretizationholding 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 bySolutionSavingCallback. This can be eithernothing(default, no restart) or a tuple of filenames, one for each system in theSemidiscretization. The tuple order must match the system order. When restarting,semidiscretizereplaces the initial time (tspan[1]) with the timestamp read from the VTK files. If the providedtspan[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)