Skip to content

List of all functions

Here an overview of all functions:

JustRelax.DYREL Type
julia
struct DYREL{T, F}

Structure containing parameters and arrays for the DYREL (Dynamic Relaxation) solver.

Fields

  • γ_eff: Effective penalty parameter.

  • Dx, Dy, Dz: Diagonal preconditioners for velocity updates in x, y, (and z) directions.

  • λmaxVx, λmaxVy, λmaxVz: Maximum eigenvalues for stability calculation.

  • dVxdτ, dVydτ, dVzdτ: Pseudo-time step related damping terms.

  • dτVx, dτVy, dτVz: Pseudo-time steps for velocity fields.

  • dVx, dVy, dVz: Velocity increments for the current iteration.

  • βVx, βVy, βVz: Damping coefficients for momentum equation.

  • cVx, cVy, cVz: Damping coefficients related to dynamic relaxation.

  • αVx, αVy, αVz: Scaling factors for damping.

  • ηb: Bulk viscosity field.

  • CFL: Courant-Friedrichs-Lewy number.

  • ϵ: General convergence tolerance.

  • ϵ_vel: Velocity convergence tolerance.

  • c_fact: Damping scaling factor.

source
JustRelax.Geometry Type
julia
struct Geometry{nDim,T}

A struct representing the geometry of a topological object in nDim dimensions.

Arguments

  • nDim: The number of dimensions of the topological object.

  • T: The type of the elements in the topological object.

source
JustRelax.RockRatio Type
julia
RockRatio{T, N} <: AbstractMask

A struct representing the rock ratio mask used in variational Stokes solvers. It contains arrays for center and vertex values, as well as velocity components and shear components.

source
JustRelax.velocity_grids Method
julia
velocity_grids(xci, xvi, di::NTuple{N,T}) where {N,T}

Compute the velocity grids for N dimensionional problems.

Arguments

  • xci: The x-coordinate of the cell centers.

  • xvi: The x-coordinate of the cell vertices.

  • di: A tuple containing the cell dimensions.

source
JustRelax.versioninfo Function
julia
versioninfo(io::IO=stdout; verbose::Bool=false)

Print information about the version of JustRelax in use. The output includes:

  • JustRelax version and installation method

  • Git commit information (if available)

  • Platform information

  • Julia version

  • Key dependencies (verbose mode)

  • Environment variables (verbose mode)

The output is controlled with boolean keyword arguments:

  • verbose: print all additional information including dependencies and environment

See also: Base.versioninfo().

source
JustRelax.JustRelax2D.DYREL! Method
julia
DYREL!(dyrel::JustRelax.DYREL, stokes::JustRelax.StokesArrays, rheology, phase_ratios, di, dt; CFL=0.99, γfact=20.0)

Updates the fields of the DYREL struct in-place for the current time step.

This function recomputes:

  • Bulk viscosity and penalty parameter γ_eff.

  • Gershgorin estimates for eigenvalues and preconditioners.

  • Damping coefficients.

Arguments

  • dyrel: JustRelax.DYREL struct to modify.

  • stokes: JustRelax.StokesArrays containing current simulation state.

  • rheology, phase_ratios: Material properties.

  • di: Grid spacing.

  • dt: Current time step.

  • CFL: Courant number (default: 0.99).

  • γfact: Penalty factor (default: 20.0).

Returns nothing.

source
JustRelax.JustRelax2D.DYREL Method
julia
DYREL(stokes, rheology, phase_ratios, di, dt; ϵ=1e-6, ϵ_vel=1e-6, CFL=0.99, c_fat=0.5, γfact=20.0)

Constructs and initializes a DYREL object based on existing Stokes fields.

This function:

  1. Allocates zero-initialized arrays using grid dimensions from stokes.

  2. Computes initial bulk viscosity and penalty parameters.

  3. Computes Gershgorin estimates for eigenvalues and preconditioners.

  4. Updates damping coefficients.

Arguments

  • stokes: JustRelax.StokesArrays struct.

  • rheology: Material properties.

  • phase_ratios: Phase fraction information.

  • di: Grid spacing tuple.

  • dt: Time step.

  • γfact: Factor for penalty parameter calculation (default: 20.0).

source
JustRelax.JustRelax2D.DYREL Method
julia
DYREL(ni::NTuple{N, Integer}; ϵ=1e-6, ϵ_vel=1e-6, CFL=0.99, c_fat=0.5) where N

Creates a new DYREL struct with fields initialized to zero.

Arguments

  • ni: Tuple containing the grid dimensions (nx, ny) for 2D or (nx, ny, nz) for 3D.

  • ϵ: General convergence tolerance.

  • ϵ_vel: Velocity convergence tolerance.

  • CFL: Courant-Friedrichs-Lewy number.

  • c_fat: Damping scaling factor.

source
JustRelax.JustRelax2D.Displacement Method
julia
Displacement(nx::Integer, ny::Integer, nz::Integer)

Create the displacement arrays for the Stokes solver in 3D.

Fields

  • Ux: Displacement in x direction at their staggered location

  • Uy: Displacement in y direction at their staggered location

  • Uz: Displacement in z direction at their staggered location

source
JustRelax.JustRelax2D.Displacement Method
julia
Displacement(nx::Integer, ny::Integer)

Create the displacement arrays for the Stokes solver in 2D.

Fields

  • Ux: Displacement in x direction at their staggered location

  • Uy: Displacement in y direction at their staggered location

source
JustRelax.JustRelax2D.PrincipalStress Method
julia
PrincipalStress(ni::NTuple{N, Integer}) where {N}

Create the principal stress arrays for the Stokes solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).

Fields

  • σ1: First principal stress

  • σ2: Second principal stress

  • σ3: Third principal stress (only in 3D). In 2D it is a placeholder array of size (2, 1, 1).

source
JustRelax.JustRelax2D.Residual Method
julia
Residual(nx::Integer, ny::Integer, nz::Integer)

Create the residual arrays for the Stokes solver in 3D.

Fields

  • Rx: Residual for the x-momentum equation

  • Ry: Residual for the y-momentum equation

  • Rz: Residual for the z-momentum equation

  • RP: Residual for the continuity equation

source
JustRelax.JustRelax2D.Residual Method
julia
Residual(nx::Integer, ny::Integer)

Create the residual arrays for the Stokes solver in 2D.

Fields

  • Rx: Residual for the x-momentum equation

  • Ry: Residual for the y-momentum equation

  • RP: Residual for the continuity equation

source
JustRelax.JustRelax2D.RockRatio Method
julia
RockRatio(nx, ny, nz)

Create a RockRatio object for a 3D grid with dimensions nx x ny x nz on a staggered grid.

source
JustRelax.JustRelax2D.RockRatio Method
julia
RockRatio(nx, ny)

Create a RockRatio object for a 2D grid with dimensions nx x ny on a staggered grid.

source
JustRelax.JustRelax2D.StokesArrays Method
julia
StokesArrays(ni::NTuple{N,Integer}) where {N}

Create the Stokes arrays object in 2D or 3D.

Fields

  • P: Pressure field

  • P0: Previous pressure field

  • ∇V: Velocity gradient

  • V: Velocity fields

  • Q: Volumetric source/sink term e.g. ΔV/V_tot [m³/m³]

  • U: Displacement fields

  • ω: Vorticity field

  • τ: Stress tensors

  • τ_o: Old stress tensors

  • ε: Strain rate tensors

  • ε_pl: Plastic strain rate tensors

  • EII_pl: Second invariant of the accumulated plastic strain

  • viscosity: Viscosity fields

  • R: Residual fields

  • Δε: Strain increment tensor

  • ∇U: Displacement gradient

  • λ : plastic multiplier @ centers

  • λv : plastic multiplier @ vertices

  • ΔPψ : pressure correction in dilatant case

source
JustRelax.JustRelax2D.SymmetricTensor Method
julia
SymmetricTensor(nx::Integer, ny::Integer, nz::Integer)

Create the symmetric tensor arrays for the Stokes solver in 3D.

Fields

  • xx: xx component of the tensor at cell centers

  • yy: yy component of the tensor at cell centers

  • zz: zz component of the tensor at cell centers

  • xx_v: xx component of the tensor at vertices

  • yy_v: yy component of the tensor at vertices

  • zz_v: zz component of the tensor at vertices

  • xy: xy component of the tensor at vertices

  • yz: yz component of the tensor at vertices

  • xz: xz component of the tensor at vertices

  • yz_c: yz component of the tensor at cell centers

  • xz_c: xz component of the tensor at cell centers

  • xy_c: xy component of the tensor at cell centers

  • II: second invariant of the tensor at cell centers

source
JustRelax.JustRelax2D.SymmetricTensor Method
julia
SymmetricTensor(nx::Integer, ny::Integer)

Create the symmetric tensor arrays for the Stokes solver in 2D.

Fields

  • xx: xx component of the tensor at cell centers

  • yy: yy component of the tensor at cell centers

  • xx_v: xx component of the tensor at vertices

  • yy_v: yy component of the tensor at vertices

  • xy: xy component of the tensor at vertices

  • xy_c: xy component of the tensor at cell centers

  • II: second invariant of the tensor at cell centers

source
JustRelax.JustRelax2D.ThermalArrays Method
julia
ThermalArrays(nx::Integer, ny::Integer, nz::Integer)

3D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx, ny and nz.

Fields

  • T: Temperature at stag. location WITHOUT ghost nodes (nx + 1, ny + 1, nz + 1)

  • Tc: Temperature at cell centers (nx, ny, nz)

  • Told: Temperature at previous time step at stag. location WITHOUT ghost nodes (nx + 1, ny + 1, nz + 1)

  • ΔT: Temperature change at stag. location WITHOUT ghost nodes (nx + 1, ny + 1, nz + 1)

  • ΔTc: Temperature change at cell centers (nx, ny, nz)

  • adiabatic: Adiabatic term α (u ⋅ ∇P) at their staggered location (nx - 1, ny - 1, nz - 1)

  • dT_dt: Time derivative of temperature at their staggered location (nx - 1, ny - 1, nz - 1)

  • qTx: Conductive heat flux in x direction at their staggered location (nx, ny - 1, nz - 1)

  • qTy: Conductive heat flux in y direction at their staggered location (nx - 1, ny, nz - 1)

  • qTz: Conductive heat flux in z direction at their staggered location (nx - 1, ny - 1, nz)

  • qTx2: Conductive heat flux in x direction at their staggered location for second order scheme (nx, ny - 1, nz - 1)

  • qTy2: Conductive heat flux in y direction at their staggered location for second order scheme (nx - 1, ny, nz - 1)

  • qTz2: Conductive heat flux in z direction at their staggered location for second order scheme (nx - 1, ny - 1, nz)

  • H: Source terms at cell centers (nx, ny, nz)

  • shear_heating: Shear heating terms at cell centers (nx, ny, nz)

  • ResT: Residual of the temperature equation at their staggered location (nx - 1, ny - 1, nz - 1)

source
JustRelax.JustRelax2D.ThermalArrays Method
julia
ThermalArrays(nx::Integer, ny::Integer)

2D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx and ny.

Fields

  • T: Temperature at stag. location with ghost nodes (nx + 3, ny + 1)

  • Tc: Temperature at cell centers (nx, ny)

  • Told: Temperature at previous time step at stag. location with ghost nodes (nx + 3, ny + 1)

  • ΔT: Temperature change at stag. location with ghost nodes (nx + 3, ny + 1)

  • ΔTc: Temperature change at cell centers (nx, ny)

  • adiabatic: Adiabatic term α (u ⋅ ∇P) at their staggered location (nx + 1, ny - 1)

  • dT_dt: Time derivative of temperature at their staggered location (nx + 1, ny - 1)

  • qTx: Conductive heat flux in x direction at their staggered location (nx + 2, ny - 1)

  • qTy: Conductive heat flux in y direction at their staggered location (nx + 1, ny)

  • qTx2: Conductive heat flux in x direction at their staggered location for second order scheme (nx + 2, ny - 1)

  • qTy2: Conductive heat flux in y direction at their staggered location for second order scheme (nx + 1, ny)

  • H: Source terms at cell centers (nx, ny)

  • shear_heating: Shear heating terms at cell centers (nx, ny)

  • ResT: Residual of the temperature equation at their staggered location (nx + 1, ny - 1)

source
JustRelax.JustRelax2D.ThermalArrays Method
julia
ThermalArrays(ni::NTuple{N, Integer}) where {N}

Create the thermal arrays for the heat diffusion solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).

source
JustRelax.JustRelax2D.ThermalArrays Method
julia
ThermalArrays(::Backend, ni::NTuple{N, Integer}) where {N}

Internal entry point function for the ThermalArrays constructor. This allows for dispatching on the backend type and then calling the main constructor with the dimensions.

source
JustRelax.JustRelax2D.Velocity Method
julia
Velocity(nx::Integer, ny::Integer, nz::Integer)

Create the velocity arrays for the Stokes solver in 3D.

Fields

  • Vx: Velocity in x direction (nx + 1, ny + 2, nz + 2)

  • Vy: Velocity in y direction (nx + 2, ny + 1, nz + 2)

  • Vz: Velocity in z direction (nx + 2, ny + 2, nz + 1)

source
JustRelax.JustRelax2D.Velocity Method
julia
Velocity(nx::Integer, ny::Integer)

Create the velocity arrays for the Stokes solver in 2D.

Fields

  • Vx: Velocity in x direction (nx + 1, ny + 2)

  • Vy: Velocity in y direction (nx + 2, ny + 1)

source
JustRelax.JustRelax2D.Viscosity Method
julia
Viscosity(ni::NTuple{N, Integer}) where {N}

Create the viscosity arrays for the Stokes solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).

Fields

  • η: Viscosity at cell centers

  • ηv: Viscosity at vertices

  • η_vep: Viscosity for visco-elastic-plastic rheology

  • ητ: Pseudo-transient viscosity for stress update

source
JustRelax.JustRelax2D.Vorticity Method
julia
Vorticity(nx::Integer, ny::Integer, nz::Integer)

Create the vorticity arrays for the Stokes solver in 3D.

Fields

  • yz: Vorticity component yz at their staggered location

  • xz: Vorticity component xz at their staggered location

  • xy: Vorticity component xy at their staggered location

source
JustRelax.JustRelax2D.Vorticity Method
julia
Vorticity(nx::Integer, ny::Integer)

Create the vorticity arrays for the Stokes solver in 2D.

Fields

  • xy: Vorticity component xy at vertices
source
JustRelax.JustRelax2D.WENO_advection! Method
julia
WENO_advection!(u, Vxi, weno, di, ni, dt)

Perform the advection step of the Weighted Essentially Non-Oscillatory (WENO) scheme for the solution of hyperbolic partial differential equations.

Arguments

  • u: field to be advected.

  • Vxi: velocity field.

  • weno: structure containing the WENO scheme parameters and temporary variables.

  • di: grid spacing.

  • ni: number of grid points.

  • dt: time step.

Description

The function approximates the advected fluxes using the WENO scheme and use a strong-stability preserving (SSP) Runge-Kutta method of order 3 for the time integration.

source
JustRelax.JustRelax2D._heatdiffusion_PT! Method
julia
heatdiffusion_PT!(thermal, pt_thermal, K, ρCp, dt, di; iterMax, nout, verbose)

Heat diffusion solver using Pseudo-Transient iterations. Both K and ρCp are n-dimensional arrays.

source
JustRelax.JustRelax2D._heatdiffusion_PT! Method
julia
heatdiffusion_PT!(thermal, pt_thermal, rheology, dt, di; iterMax, nout, verbose)

Heat diffusion solver using Pseudo-Transient iterations.

source
JustRelax.JustRelax2D._update_rock_ratio! Method
julia
_update_rock_ratio!(ϕ, ratio, air_phase)

Inner kernel of update_rock_ratio that clamps the computed rock ratio to the range [0, 1] for the given ratio and air_phase.

source
JustRelax.JustRelax2D.allzero Method
julia
allzero(x::Vararg{T,N}) where {T,N}

Check if all elements in x are zero.

Arguments

  • x::Vararg{T,N}: The input array.

Returns

  • Bool: true if all elements in x are zero, false otherwise.
source
JustRelax.JustRelax2D.assign! Method
julia
assign!(B::AbstractArray{T,N}, A::AbstractArray{T,N}) where {T,N}

Assigns the values of array A to array B in parallel.

Arguments

  • B::AbstractArray{T,N}: The destination array.

  • A::AbstractArray{T,N}: The source array.

source
JustRelax.JustRelax2D.compute_P! Method

compute_P!(P, P0, RP, ∇V, Q, ΔTc, η, rheology::NTuple{N,MaterialParams}, phase_ratio::C, dt, r, θ_dτ)

Compute the pressure field P and the residual RP for the compressible case. This function introduces thermal stresses after the implementation of Kiss et al. (2023).

Arguments

  • P: pressure field

  • RP: residual field

  • ∇V: divergence of the velocity field

  • Q: volumetric source/sink term which should have the properties of dV/V_tot [m³/m³] normalized per cell, default is zero.

  • ΔTc: temperature difference on the cell center, to account for thermal stresses. The thermal expansivity α is computed from the material parameters.

  • η: viscosity field

  • rheology: material parameters

  • phase_ratio: phase field

  • melt_fraction: melt fraction field, used for the thermal expansion coefficient if provided

  • dt: time step

  • r: relaxation parameter for the pressure update

  • θ_dτ: numerical parameter for the pressure update

source
JustRelax.JustRelax2D.compute_V! Method
julia
compute_V!(Vx, Vy, Vz, Rx, Ry, Rz, P, fx, fy, fz, τxx, τyy, τzz, τyz, τxz, τxy, ητ, ηdτ, ϕ, _dx, _dy, _dz)

Compute the 3D velocity field V from the pressure P, stress components τ, body forces f, and other parameters, with the rock ratio ϕ and grid spacing _dx, _dy, _dz.

source
JustRelax.JustRelax2D.compute_V! Method
julia
compute_V!(Vx, Vy, Rx, Ry, P, τxx, τyy, τxy, ηdτ, ρgx, ρgy, ητ, ϕ, _dx, _dy, dt)

Compute the velocity field V with the timestep dt from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ, grid spacing _dx, _dy, and time step dt.

source
JustRelax.JustRelax2D.compute_V! Method
julia
compute_V!(Vx, Vy, Rx, Ry, P, τxx, τyy, τxy, ηdτ, ρgx, ρgy, ητ, ϕ, _dx, _dy)

Compute the velocity field V from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ and grid spacing _dx, _dy.

source
JustRelax.JustRelax2D.compute_Vx! Method
julia
compute_Vx!(Vx, Rx, P, τxx, τxy, ηdτ, ρgx, ητ, ϕ, _dx, _dy)

Compute the x-component of the velocity field Vx from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ and grid spacing _dx, _dy.

source
JustRelax.JustRelax2D.compute_Vy! Method
julia
compute_Vy!(Vy, Vx_on_Vy, Ry, P, τyy, τxy, ηdτ, ρgy, ητ, ϕ, _dx, _dy, dt)

Compute the y-component of the velocity field Vy from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ, grid spacing _dx, _dy, and time step dt.

source
JustRelax.JustRelax2D.compute_air_ratio Method
julia
compute_air_ratio(phase_ratio, air_phase, inds...)

Compute the air ratio at the given indices based on the phase_ratio and air_phase.

source
JustRelax.JustRelax2D.compute_bulk_viscosity_and_penalty! Method
julia
compute_bulk_viscosity_and_penalty!(dyrel, stokes, rheology, phase_ratios, γfact, dt)

Computes the bulk viscosity ηb and the effective penalty parameter γ_eff.

  1. Bulk Viscosity (ηb): Computed based on the bulk modulus of the material phases.
  • If Kb is infinite (incompressible), ηb defaults to γfact * η_mean.

  • Otherwise ηb = Kb * dt.

  1. Penalty Parameter (γ_eff): A combination of numerical (γ_num) and physical (γ_phy) penalty terms.
  • γ_num = γfact * η_mean

  • γ_phy = Kb (or related term)

  • γ_eff = (γ_phy * γ_num) / (γ_phy + γ_num)

Arguments

  • dyrel: JustRelax.DYREL struct to update.

  • stokes: JustRelax.StokesArrays.

  • rheology: Material properties.

  • phase_ratios: Phase fraction information.

  • γfact: Numerical factor for penalty parameter (default: 20.0).

  • dt: Time step.

This function parallelizes the computation across grid cells.

source
JustRelax.JustRelax2D.compute_buoyancy Method
julia
compute_buoyancy(rheology, args, phase_ratios)

Compute the buoyancy forces based on the given rheology, arguments, and phase ratios.

Arguments

  • rheology: The rheology used to compute the buoyancy forces.

  • args: Additional arguments required by the rheology.

  • phase_ratios: The ratios of the different phases.

source
JustRelax.JustRelax2D.compute_buoyancy Method
julia
compute_buoyancy(rheology, args)

Compute the buoyancy forces based on the given rheology and arguments.

Arguments

  • rheology: The rheology used to compute the buoyancy forces.

  • args: Additional arguments required for the computation.

source
JustRelax.JustRelax2D.compute_buoyancy Method
julia
compute_buoyancy(rheology::MaterialParams, args, phase_ratios)

Compute the buoyancy forces for a given set of material parameters, arguments, and phase ratios.

Arguments

  • rheology: The material parameters.

  • args: The arguments.

  • phase_ratios: The phase ratios.

source
JustRelax.JustRelax2D.compute_buoyancy Method
julia
compute_buoyancy(rheology::MaterialParams, args)

Compute the buoyancy forces based on the given rheology parameters and arguments.

Arguments

  • rheology::MaterialParams: The material parameters for the rheology.

  • args: The arguments for the computation.

source
JustRelax.JustRelax2D.compute_dt Method
julia
compute_dt(S::JustRelax.StokesArrays, args...)

Compute the time step dt for the simulation.

source
JustRelax.JustRelax2D.compute_maxloc! Method
julia
compute_maxloc!(B, A; window)

Compute the maximum value of A in the window = (width_x, width_y, width_z) and store the result in B.

source
JustRelax.JustRelax2D.compute_rock_ratio Method
julia
compute_rock_ratio(phase_ratio, air_phase, inds...)

Compute the rock ratio at the given indices based on the phase_ratio and air_phase.

source
JustRelax.JustRelax2D.compute_shear_heating! Method
julia
compute_shear_heating!(thermal, stokes, rheology, dt)

Compute the shear heating term at cell centers for the thermal arrays thermal using the stress and strain rate from the Stokes arrays stokes and the rheology model rheology with a time step dt.

source
JustRelax.JustRelax2D.compute_strain_rate! Method
julia
compute_strain_rate!(εxx, εyy, εzz, εyz, εxz, εxy, ∇V, Vx, Vy, Vz, ϕ, _dx, _dy, _dz)

Compute the 3D components of the strain rate tensor ε from the velocity field V and its divergence ∇V, taking into account the rock ratio ϕ and grid spacing _dx, _dy, _dz.

source
JustRelax.JustRelax2D.compute_strain_rate! Method
julia
compute_strain_rate!(εxx, εyy, εxy, ∇V, Vx, Vy, ϕ, _dx, _dy)

Compute the components of the strain rate tensor ε from the velocity field V and its divergence ∇V, taking into account the rock ratio ϕ and grid spacing _dx, _dy.

source
JustRelax.JustRelax2D.compute_strain_rate_from_increment! Method
julia
compute_strain_rate_from_increment!(εxx, εyy, εxy, Δεxx, Δεyy, Δεxy, ϕ, _dt)

Compute the components of the strain rate tensor ε from the strain increments Δε, taking into account the rock ratio ϕ and time step _dt.

source
JustRelax.JustRelax2D.compute_ρg! Method
julia
compute_ρg!(ρg, rheology, args)

Calculate the buoyance forces ρg for the given GeoParams.jl rheology object and correspondent arguments args.

source
JustRelax.JustRelax2D.compute_ρg! Method
julia
compute_ρg!(ρg, phase_ratios, rheology, args)

Calculate the buoyance forces ρg for the given GeoParams.jl rheology object and correspondent arguments args. The phase_ratios are used to compute the density of the composite rheology.

source
JustRelax.JustRelax2D.compute_∇V! Method
julia
compute_∇V!(∇V, V, ϕ, _di)

Compute the divergence of the velocity field V and store it in ∇V, taking into account the rock ratio ϕ and grid spacing _di.

source
JustRelax.JustRelax2D.continuation_linear Method
julia
continuation_linear(x_new, x_old, ν)

Do a continuation step (1-ν)*x_old + ν*x_new with damping parameter ν

source
JustRelax.JustRelax2D.continuation_log Method
julia
continuation_log(x_new, x_old, ν)

Do a continuation step exp((1-ν)*log(x_old) + ν*log(x_new)) with damping parameter ν

source
JustRelax.JustRelax2D.flow_bcs! Method
julia
flow_bcs!(stokes, bcs::VelocityBoundaryConditions)

Apply the prescribed flow boundary conditions bc on the stokes

source
JustRelax.JustRelax2D.flow_bcs! Method
julia
flow_bcs!(stokes, bcs::DisplacementBoundaryConditions)

Apply the prescribed flow boundary conditions bc on the stokes

source
JustRelax.JustRelax2D.fn_ratio Method
julia
fn_ratio(fn::F, rheology::NTuple{N, AbstractMaterialParamsStruct}, ratio) where {N, F}

Average the function fn over the material phases in rheology using the phase ratios ratio.

source
JustRelax.JustRelax2D.interp_Vx_on_Vy! Method
julia
interp_Vx_on_Vy!(Vx_on_Vy, Vx)

Interpolates the values of Vx onto the grid points of Vy.

Arguments

  • Vx_on_Vy::AbstractArray: Vx at Vy grid points.

  • Vx::AbstractArray: Vx at its staggered grid points.

source
JustRelax.JustRelax2D.isvalid_c Method
julia
isvalid_v::JustRelax.RockRatio, inds...)

Check if ϕ.vertex[inds...] is a not a nullspace in 3D.

source
JustRelax.JustRelax2D.isvalid_c Method
julia
isvalid_c::JustRelax.RockRatio, inds...)

Check if ϕ.center[inds...] is a not a nullspace in 2D.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax2D.isvalid_v Method
julia
isvalid_v::JustRelax.RockRatio, inds...)

Check if ϕ.vertex[inds...] is a not a nullspace in 3D.

source
JustRelax.JustRelax2D.isvalid_v Method
julia
isvalid_v::JustRelax.RockRatio, inds...)

Check if ϕ.vertex[inds...] is a not a nullspace 2D.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax2D.isvalid_velocity Method
julia
isvalid_velocity::JustRelax.RockRatio, inds...)

Check if the velocity components at the given indices are not nullspaces in 3D.

source
JustRelax.JustRelax2D.isvalid_velocity Method
julia
isvalid_velocity::JustRelax.RockRatio, inds...)

Check if the velocity components at the given indices are not nullspaces in 2D.

source
JustRelax.JustRelax2D.isvalid_vx Method
julia
isvalid_vx::JustRelax.RockRatio, inds...)

Check if ϕ.Vx[inds...] is a not a nullspace.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax2D.isvalid_vz Method
julia
isvalid_vz::JustRelax.RockRatio, inds...)

Check if ϕ.Vz[inds...] is a not a nullspace.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax2D.isvalid_xy Method
julia
isvalid_xy(ϕ, inds...)

Check if the xy shear component at the given indices is not a nullspace.

source
JustRelax.JustRelax2D.isvalid_xz Method
julia
isvalid_xz(ϕ, inds...)

Check if the xz shear component at the given indices is not a nullspace.

source
JustRelax.JustRelax2D.isvalid_yz Method
julia
isvalid_yz(ϕ, inds...)

Check if the yz shear component at the given indices is not a nullspace.

source
JustRelax.JustRelax2D.maximum_mpi Method
julia
maximum_mpi(A)

Compute the maximum value of array A across all MPI processes.

source
JustRelax.JustRelax2D.mean_mpi Method
julia
mean_mpi(A)

Compute the mean of array A across all MPI processes.

source
JustRelax.JustRelax2D.minimum_mpi Method
julia
minimum_mpi(A)

Compute the minimum value of array A across all MPI processes.

source
JustRelax.JustRelax2D.multi_copy! Method
julia
multi_copy!(dst::NTuple{N, T}, src::NTuple{N, T}) where {N, T}

Copy data from the tuple of arrays src into the tuple of arrays dst in parallel.

source
JustRelax.JustRelax2D.norm_mpi Method
julia
norm_mpi(A)

Compute the L2 norm of array A across all MPI processes.

source
JustRelax.JustRelax2D.solve_DYREL! Method
julia
solve_DYREL!(stokes::JustRelax.StokesArrays, args...; kwargs)

Internal solver implementation for the 2D DYREL method on the CPU.

Arguments (in the following order)

  • stokes: JustRelax.StokesArrays containing the simulation fields.

  • ρg: buoyancy forces arrays.

  • dyrel: DYREL-specific parameters and fields.

  • flow_bcs: AbstractFlowBoundaryConditions defining velocity boundary conditions.

  • phase_ratios: JustPIC.PhaseRatios for material phase tracking.

  • rheology: Material properties and rheological laws.

  • args: Tuple of additional arguments needed to update viscosity, stress, and buoyancy forces.

  • di: Grid spacing tuple (dx, dy).

  • dt: Time step.

  • igg: IGG object for global grid information (MPI).

Keyword Arguments

  • viscosity_cutoff: Limits for viscosity (min, max). Default: (-Inf, Inf).

  • viscosity_relaxation: Relaxation factor for viscosity updates. Default: 1.0e-2.

  • λ_relaxation_DR: Relaxation factor for dynamic relaxation. Default: 1.

  • λ_relaxation_PH: Relaxation factor for Powell-Hestenes iterations. Default: 1.

  • iterMax: Maximum number of iterations. Default: 50.0e3.

  • nout: Output frequency for residuals. Default: 100.

  • rel_drop: Relative residual drop tolerance. Default: 1.0e-2.

  • verbose_PH: Print Powell-Hestenes iteration info. Default: true.

  • verbose_DR: Print Dynamic Relaxation iteration info. Default: true.

  • linear_viscosity: Whether to use linear viscosity. Default: false.

source
JustRelax.JustRelax2D.solve_VariationalStokes! Method
julia
solve_VariationalStokes!(backend::BackendTrait, stokes::JustRelax.StokesArrays, args...; kwargs)

Stokes solver entry point for variational Stokes solvers. This function dispatches to the appropriate implementation based on the backend provided in the function call.

source
JustRelax.JustRelax2D.solve_VariationalStokes! Method
julia
solve_VariationalStokes!(stokes::JustRelax.StokesArrays, args...; kwargs)

Stokes solver entry point for variational Stokes solvers. This function dispatches to the appropriate implementation based on the arguments given in the function call.

source
JustRelax.JustRelax2D.sum_mpi Method
julia
sum_mpi(A)

Compute the sum of array A across all MPI processes.

source
JustRelax.JustRelax2D.take Method
julia
take(fldr::String)

Create folder fldr if it does not exist.

source
JustRelax.JustRelax2D.tensor_invariant! Method
julia
tensor_invariant!(A::JustRelax.SymmetricTensor)

Compute the tensor invariant of the given symmetric tensor A.

Arguments

  • A::JustRelax.SymmetricTensor: The input symmetric tensor.
source
JustRelax.JustRelax2D.thermal_bcs! Method
julia
thermal_bcs!(T, bcs::TemperatureBoundaryConditions)

Apply the prescribed heat boundary conditions bc on the T

source
JustRelax.JustRelax2D.unpack Method
julia
unpack(x::T)

Generated function to unpack the fields of the struct x into a tuple.

source
JustRelax.JustRelax2D.update_dτV_α_β! Method
julia
update_dτV_α_β!(dτV, βV, αV, cV, λmaxV, CFL_v)

Generic N-dimensional version (2D and 3D) for updating pseudo-time step and acceleration parameters.

Computes the pseudo-time step dτV from the maximum eigenvalue estimate λmaxV and CFL number, then updates the damping parameters βV and acceleration parameters αV accordingly.

Arguments

  • dτV::NTuple{N, AbstractArray{T, N}}: Tuple of pseudo-time steps for each velocity component

  • βV::NTuple{N, AbstractArray{T, N}}: Tuple of damping parameters β for each velocity component

  • αV::NTuple{N, AbstractArray{T, N}}: Tuple of acceleration parameters α for each velocity component

  • cV::NTuple{N, AbstractArray{T, N}}: Tuple of preconditioner diagonal entries for each velocity component

  • λmaxV::NTuple{N, AbstractArray{T, N}}: Tuple of maximum eigenvalue estimates for each velocity component

  • CFL_v::Real: CFL number for velocity

source
JustRelax.JustRelax2D.update_phase_ratios_2D! Method
julia
update_phase_ratios!(
    phase_ratios::JustPIC.PhaseRatios, phase_arrays::NTuple{N, AbstractMatrix}, xci, xvi
) where {B, T <: AbstractMatrix, N}

JustRelax routine based on JustPIC._2D.update_phase_ratios! or JustPIC._3D.update_phase_ratios!. Update the phase ratios in phase_ratios using the provided phase_arrays, xci, and xvi. The phase arrays need to be AbstractArrays and have values between 0 and 1.

#Example:

julia
nx, ny = 100, 100
phase_1 = zeros(nx, ny)
phase_1[User_criterion .== true] .= 1.0
phase_2 = zeros(nx, ny)
phase_2[User_criterion .== false] .= 1.0
phase_arrays = (phase_1, phase_2)

# Advect both phase arrays and update phase ratios
update_phase_ratios!(phase_ratios, phase_arrays, xci, xvi)
source
JustRelax.JustRelax2D.update_phase_ratios_3D! Method
julia
update_phase_ratios!(
    phase_ratios::JustPIC.PhaseRatios, phase_arrays::NTuple{N, AbstractArray}, xci, xvi
) where {B, T <: AbstractArray, N}

JustRelax routine based on JustPIC._2D.update_phase_ratios! or JustPIC._3D.update_phase_ratios!. Update the phase ratios in phase_ratios using the provided phase_arrays, xci, and xvi. The phase arrays need to be AbstractArrays and have values between 0 and 1.

#Example:

julia
nx, ny, nz = 100, 100, 100
phase_1 = zeros(nx, ny, nz)
phase_1[User_criterion .== true] .= 1.0
phase_2 = zeros(nx, ny, nz)
phase_2[User_criterion .== false] .= 1.0
phase_arrays = (phase_1, phase_2)

# Advect both phase arrays and update phase ratios
update_phase_ratios!(phase_ratios, phase_arrays, xci, xvi)
source
JustRelax.JustRelax2D.update_rock_ratio! Method
julia
update_rock_ratio!::JustRelax.RockRatio, phase_ratios, air_phase)

Update the rock ratio ϕ based on the provided phase_ratios and air_phase.

Arguments

  • ϕ::JustRelax.RockRatio: The rock ratio object to be updated.

  • phase_ratios: The ratios of different phases present.

  • air_phase: The phase representing air.

source
JustRelax.JustRelax2D.update_rock_ratio! Method
julia
update_rock_ratio!::JustRelax.RockRatio, phase_ratios, air_phase)

Update the rock ratio ϕ for a 3D grid based on the provided phase_ratios and air_phase.

Arguments

  • ϕ::JustRelax.RockRatio: The rock ratio object to be updated.

  • phase_ratios: The ratios of different phases present.

  • air_phase: The phase representing air.

source
JustRelax.JustRelax2D.update_rock_ratio_cv! Method
julia
update_rock_ratio_cv!(ϕ, ratio_center, ratio_vertex, air_phase)

Update the rock ratio for both center and vertex values based on the provided ratio_center, ratio_vertex, and air_phase.

source
JustRelax.JustRelax2D.update_α_β! Method
julia
update_α_β!(βV, αV, dτV, cV)

Generic N-dimensional version (2D and 3D) of the acceleration parameters update.

Updates the damping parameters βV and αV for each velocity component based on the pseudo-time step dτV and the preconditioner diagonal cV.

Arguments

  • βV::NTuple{N, AbstractArray{T, N}}: Tuple of damping parameters β for each velocity component

  • αV::NTuple{N, AbstractArray{T, N}}: Tuple of acceleration parameters α for each velocity component

  • dτV::NTuple{N, AbstractArray{T, N}}: Tuple of pseudo-time steps for each velocity component

  • cV::NTuple{N, AbstractArray{T, N}}: Tuple of preconditioner diagonal entries for each velocity component

source
JustRelax.JustRelax2D.velocity2vertex! Method
julia
velocity2vertex!(Vx_v, Vy_v, Vz_v, Vx, Vy, Vz)

In-place interpolation of the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the pre-allocated Vx_d, Vy_d, Vz_d 3D arrays located at the grid vertices.

source
JustRelax.JustRelax2D.velocity2vertex Method
julia
velocity2vertex(Vx, Vy, Vz)

Interpolate the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the grid vertices.

source
JustRelax.JustRelax2D.@add Macro
julia
@add(I, args...)

Add I to the scalars in args

source
JustRelax.JustRelax2D.@allocate Macro
julia
@allocate(ni...)

Convenience macro to allocate a PTArray of size ni... with undef values.

source
JustRelax.JustRelax2D.@copy Macro
julia
copy(B, A)

convenience macro to copy data from the array A into array B

source
JustRelax.JustRelax2D.@displacement Macro
julia
@displacement(U)

Unpacks the displacement arrays U from the StokesArrays A.

source
JustRelax.JustRelax2D.@idx Macro
julia
@idx(args...)

Make a linear range from 1 to args[i], with i ∈ [1, ..., n]

source
JustRelax.JustRelax2D.@normal Macro
julia
@normal(A)

Unpacks the normal components of the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@plastic_strain Macro
julia
@plastic_strain(A)

Unpacks the plastic strain rate tensor ε_pl from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@qT Macro
julia
@qT(V)

Unpacks the flux arrays qT_i from the ThermalArrays A.

source
JustRelax.JustRelax2D.@qT2 Macro
julia
@qT2(V)

Unpacks the flux arrays qT2_i from the ThermalArrays A.

source
JustRelax.JustRelax2D.@residuals Macro
julia
@residuals(A)

Unpacks the momentum residuals from A.

source
JustRelax.JustRelax2D.@shear Macro
julia
@shear(A)

Unpacks the shear components of the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@shear_center Macro
julia
@shear_center(A)

Unpacks the shear components of the symmetric tensor A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@strain Macro
julia
@strain(A)

Unpacks the strain rate tensor ε from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@strain_center Macro
julia
@strain_center(A)

Unpacks the strain rate tensor ε from the StokesArrays A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@strain_increment Macro
julia
@strain_increment(A)

Unpacks the strain rate tensor ε from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@stress Macro
julia
@stress(A)

Unpacks the deviatoric stress tensor τ from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@stress_center Macro
julia
@stress_center(A)

Unpacks the deviatoric stress tensor τ from the StokesArrays A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@tensor Macro
julia
@tensor(A)

Unpacks the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@tensor_center Macro
julia
@tensor_center(A)

Unpacks the symmetric tensor A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@tensor_vertex Macro
julia
tensor_vertex(A)

Unpacks the symmetric tensor A, where its components are defined in the vertices of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax2D.@tuple Macro
julia
@tuple(A)

Convenience maktro to unpack the fields of the struct A into a tuple. Works with Velocity and SymmetricTensor structs.

source
JustRelax.JustRelax2D.@unpack Macro
julia
@unpack(x)

Convenience macro to unpack the fields of the struct x into a tuple.

source
JustRelax.JustRelax2D.@velocity Macro
julia
@velocity(V)

Unpacks the velocity arrays V from the StokesArrays A.

source
JustRelax.JustRelax3D.DYREL! Method
julia
DYREL!(dyrel::JustRelax.DYREL, stokes::JustRelax.StokesArrays, rheology, phase_ratios, di, dt; CFL=0.99, γfact=20.0)

Updates the fields of the DYREL struct in-place for the current time step.

This function recomputes:

  • Bulk viscosity and penalty parameter γ_eff.

  • Gershgorin estimates for eigenvalues and preconditioners.

  • Damping coefficients.

Arguments

  • dyrel: JustRelax.DYREL struct to modify.

  • stokes: JustRelax.StokesArrays containing current simulation state.

  • rheology, phase_ratios: Material properties.

  • di: Grid spacing.

  • dt: Current time step.

  • CFL: Courant number (default: 0.99).

  • γfact: Penalty factor (default: 20.0).

Returns nothing.

source
JustRelax.JustRelax3D.DYREL Method
julia
DYREL(stokes, rheology, phase_ratios, di, dt; ϵ=1e-6, ϵ_vel=1e-6, CFL=0.99, c_fat=0.5, γfact=20.0)

Constructs and initializes a DYREL object based on existing Stokes fields.

This function:

  1. Allocates zero-initialized arrays using grid dimensions from stokes.

  2. Computes initial bulk viscosity and penalty parameters.

  3. Computes Gershgorin estimates for eigenvalues and preconditioners.

  4. Updates damping coefficients.

Arguments

  • stokes: JustRelax.StokesArrays struct.

  • rheology: Material properties.

  • phase_ratios: Phase fraction information.

  • di: Grid spacing tuple.

  • dt: Time step.

  • γfact: Factor for penalty parameter calculation (default: 20.0).

source
JustRelax.JustRelax3D.DYREL Method
julia
DYREL(ni::NTuple{N, Integer}; ϵ=1e-6, ϵ_vel=1e-6, CFL=0.99, c_fat=0.5) where N

Creates a new DYREL struct with fields initialized to zero.

Arguments

  • ni: Tuple containing the grid dimensions (nx, ny) for 2D or (nx, ny, nz) for 3D.

  • ϵ: General convergence tolerance.

  • ϵ_vel: Velocity convergence tolerance.

  • CFL: Courant-Friedrichs-Lewy number.

  • c_fat: Damping scaling factor.

source
JustRelax.JustRelax3D.Displacement Method
julia
Displacement(nx::Integer, ny::Integer, nz::Integer)

Create the displacement arrays for the Stokes solver in 3D.

Fields

  • Ux: Displacement in x direction at their staggered location

  • Uy: Displacement in y direction at their staggered location

  • Uz: Displacement in z direction at their staggered location

source
JustRelax.JustRelax3D.Displacement Method
julia
Displacement(nx::Integer, ny::Integer)

Create the displacement arrays for the Stokes solver in 2D.

Fields

  • Ux: Displacement in x direction at their staggered location

  • Uy: Displacement in y direction at their staggered location

source
JustRelax.JustRelax3D.PrincipalStress Method
julia
PrincipalStress(ni::NTuple{N, Integer}) where {N}

Create the principal stress arrays for the Stokes solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).

Fields

  • σ1: First principal stress

  • σ2: Second principal stress

  • σ3: Third principal stress (only in 3D). In 2D it is a placeholder array of size (2, 1, 1).

source
JustRelax.JustRelax3D.Residual Method
julia
Residual(nx::Integer, ny::Integer, nz::Integer)

Create the residual arrays for the Stokes solver in 3D.

Fields

  • Rx: Residual for the x-momentum equation

  • Ry: Residual for the y-momentum equation

  • Rz: Residual for the z-momentum equation

  • RP: Residual for the continuity equation

source
JustRelax.JustRelax3D.Residual Method
julia
Residual(nx::Integer, ny::Integer)

Create the residual arrays for the Stokes solver in 2D.

Fields

  • Rx: Residual for the x-momentum equation

  • Ry: Residual for the y-momentum equation

  • RP: Residual for the continuity equation

source
JustRelax.JustRelax3D.RockRatio Method
julia
RockRatio(nx, ny, nz)

Create a RockRatio object for a 3D grid with dimensions nx x ny x nz on a staggered grid.

source
JustRelax.JustRelax3D.RockRatio Method
julia
RockRatio(nx, ny)

Create a RockRatio object for a 2D grid with dimensions nx x ny on a staggered grid.

source
JustRelax.JustRelax3D.StokesArrays Method
julia
StokesArrays(ni::NTuple{N,Integer}) where {N}

Create the Stokes arrays object in 2D or 3D.

Fields

  • P: Pressure field

  • P0: Previous pressure field

  • ∇V: Velocity gradient

  • V: Velocity fields

  • Q: Volumetric source/sink term e.g. ΔV/V_tot [m³/m³]

  • U: Displacement fields

  • ω: Vorticity field

  • τ: Stress tensors

  • τ_o: Old stress tensors

  • ε: Strain rate tensors

  • ε_pl: Plastic strain rate tensors

  • EII_pl: Second invariant of the accumulated plastic strain

  • viscosity: Viscosity fields

  • R: Residual fields

  • Δε: Strain increment tensor

  • ∇U: Displacement gradient

  • λ : plastic multiplier @ centers

  • λv : plastic multiplier @ vertices

  • ΔPψ : pressure correction in dilatant case

source
JustRelax.JustRelax3D.SymmetricTensor Method
julia
SymmetricTensor(nx::Integer, ny::Integer, nz::Integer)

Create the symmetric tensor arrays for the Stokes solver in 3D.

Fields

  • xx: xx component of the tensor at cell centers

  • yy: yy component of the tensor at cell centers

  • zz: zz component of the tensor at cell centers

  • xx_v: xx component of the tensor at vertices

  • yy_v: yy component of the tensor at vertices

  • zz_v: zz component of the tensor at vertices

  • xy: xy component of the tensor at vertices

  • yz: yz component of the tensor at vertices

  • xz: xz component of the tensor at vertices

  • yz_c: yz component of the tensor at cell centers

  • xz_c: xz component of the tensor at cell centers

  • xy_c: xy component of the tensor at cell centers

  • II: second invariant of the tensor at cell centers

source
JustRelax.JustRelax3D.SymmetricTensor Method
julia
SymmetricTensor(nx::Integer, ny::Integer)

Create the symmetric tensor arrays for the Stokes solver in 2D.

Fields

  • xx: xx component of the tensor at cell centers

  • yy: yy component of the tensor at cell centers

  • xx_v: xx component of the tensor at vertices

  • yy_v: yy component of the tensor at vertices

  • xy: xy component of the tensor at vertices

  • xy_c: xy component of the tensor at cell centers

  • II: second invariant of the tensor at cell centers

source
JustRelax.JustRelax3D.ThermalArrays Method
julia
ThermalArrays(nx::Integer, ny::Integer, nz::Integer)

3D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx, ny and nz.

Fields

  • T: Temperature at stag. location WITHOUT ghost nodes (nx + 1, ny + 1, nz + 1)

  • Tc: Temperature at cell centers (nx, ny, nz)

  • Told: Temperature at previous time step at stag. location WITHOUT ghost nodes (nx + 1, ny + 1, nz + 1)

  • ΔT: Temperature change at stag. location WITHOUT ghost nodes (nx + 1, ny + 1, nz + 1)

  • ΔTc: Temperature change at cell centers (nx, ny, nz)

  • adiabatic: Adiabatic term α (u ⋅ ∇P) at their staggered location (nx - 1, ny - 1, nz - 1)

  • dT_dt: Time derivative of temperature at their staggered location (nx - 1, ny - 1, nz - 1)

  • qTx: Conductive heat flux in x direction at their staggered location (nx, ny - 1, nz - 1)

  • qTy: Conductive heat flux in y direction at their staggered location (nx - 1, ny, nz - 1)

  • qTz: Conductive heat flux in z direction at their staggered location (nx - 1, ny - 1, nz)

  • qTx2: Conductive heat flux in x direction at their staggered location for second order scheme (nx, ny - 1, nz - 1)

  • qTy2: Conductive heat flux in y direction at their staggered location for second order scheme (nx - 1, ny, nz - 1)

  • qTz2: Conductive heat flux in z direction at their staggered location for second order scheme (nx - 1, ny - 1, nz)

  • H: Source terms at cell centers (nx, ny, nz)

  • shear_heating: Shear heating terms at cell centers (nx, ny, nz)

  • ResT: Residual of the temperature equation at their staggered location (nx - 1, ny - 1, nz - 1)

source
JustRelax.JustRelax3D.ThermalArrays Method
julia
ThermalArrays(nx::Integer, ny::Integer)

2D constructor for the thermal arrays for the heat diffusion solver with the extents given by nx and ny.

Fields

  • T: Temperature at stag. location with ghost nodes (nx + 3, ny + 1)

  • Tc: Temperature at cell centers (nx, ny)

  • Told: Temperature at previous time step at stag. location with ghost nodes (nx + 3, ny + 1)

  • ΔT: Temperature change at stag. location with ghost nodes (nx + 3, ny + 1)

  • ΔTc: Temperature change at cell centers (nx, ny)

  • adiabatic: Adiabatic term α (u ⋅ ∇P) at their staggered location (nx + 1, ny - 1)

  • dT_dt: Time derivative of temperature at their staggered location (nx + 1, ny - 1)

  • qTx: Conductive heat flux in x direction at their staggered location (nx + 2, ny - 1)

  • qTy: Conductive heat flux in y direction at their staggered location (nx + 1, ny)

  • qTx2: Conductive heat flux in x direction at their staggered location for second order scheme (nx + 2, ny - 1)

  • qTy2: Conductive heat flux in y direction at their staggered location for second order scheme (nx + 1, ny)

  • H: Source terms at cell centers (nx, ny)

  • shear_heating: Shear heating terms at cell centers (nx, ny)

  • ResT: Residual of the temperature equation at their staggered location (nx + 1, ny - 1)

source
JustRelax.JustRelax3D.ThermalArrays Method
julia
ThermalArrays(ni::NTuple{N, Integer}) where {N}

Create the thermal arrays for the heat diffusion solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).

source
JustRelax.JustRelax3D.ThermalArrays Method
julia
ThermalArrays(::Backend, ni::NTuple{N, Integer}) where {N}

Internal entry point function for the ThermalArrays constructor. This allows for dispatching on the backend type and then calling the main constructor with the dimensions.

source
JustRelax.JustRelax3D.Velocity Method
julia
Velocity(nx::Integer, ny::Integer, nz::Integer)

Create the velocity arrays for the Stokes solver in 3D.

Fields

  • Vx: Velocity in x direction (nx + 1, ny + 2, nz + 2)

  • Vy: Velocity in y direction (nx + 2, ny + 1, nz + 2)

  • Vz: Velocity in z direction (nx + 2, ny + 2, nz + 1)

source
JustRelax.JustRelax3D.Velocity Method
julia
Velocity(nx::Integer, ny::Integer)

Create the velocity arrays for the Stokes solver in 2D.

Fields

  • Vx: Velocity in x direction (nx + 1, ny + 2)

  • Vy: Velocity in y direction (nx + 2, ny + 1)

source
JustRelax.JustRelax3D.Viscosity Method
julia
Viscosity(ni::NTuple{N, Integer}) where {N}

Create the viscosity arrays for the Stokes solver in 2D or 3D with the extents given by ni (nx x ny or `nx x ny x nz``).

Fields

  • η: Viscosity at cell centers

  • ηv: Viscosity at vertices

  • η_vep: Viscosity for visco-elastic-plastic rheology

  • ητ: Pseudo-transient viscosity for stress update

source
JustRelax.JustRelax3D.Vorticity Method
julia
Vorticity(nx::Integer, ny::Integer, nz::Integer)

Create the vorticity arrays for the Stokes solver in 3D.

Fields

  • yz: Vorticity component yz at their staggered location

  • xz: Vorticity component xz at their staggered location

  • xy: Vorticity component xy at their staggered location

source
JustRelax.JustRelax3D.Vorticity Method
julia
Vorticity(nx::Integer, ny::Integer)

Create the vorticity arrays for the Stokes solver in 2D.

Fields

  • xy: Vorticity component xy at vertices
source
JustRelax.JustRelax3D.WENO_advection! Method
julia
WENO_advection!(u, Vxi, weno, di, ni, dt)

Perform the advection step of the Weighted Essentially Non-Oscillatory (WENO) scheme for the solution of hyperbolic partial differential equations.

Arguments

  • u: field to be advected.

  • Vxi: velocity field.

  • weno: structure containing the WENO scheme parameters and temporary variables.

  • di: grid spacing.

  • ni: number of grid points.

  • dt: time step.

Description

The function approximates the advected fluxes using the WENO scheme and use a strong-stability preserving (SSP) Runge-Kutta method of order 3 for the time integration.

source
JustRelax.JustRelax3D._heatdiffusion_PT! Method
julia
heatdiffusion_PT!(thermal, pt_thermal, K, ρCp, dt, di; iterMax, nout, verbose)

Heat diffusion solver using Pseudo-Transient iterations. Both K and ρCp are n-dimensional arrays.

source
JustRelax.JustRelax3D._heatdiffusion_PT! Method
julia
heatdiffusion_PT!(thermal, pt_thermal, rheology, dt, di; iterMax, nout, verbose)

Heat diffusion solver using Pseudo-Transient iterations.

source
JustRelax.JustRelax3D._update_rock_ratio! Method
julia
_update_rock_ratio!(ϕ, ratio, air_phase)

Inner kernel of update_rock_ratio that clamps the computed rock ratio to the range [0, 1] for the given ratio and air_phase.

source
JustRelax.JustRelax3D.allzero Method
julia
allzero(x::Vararg{T,N}) where {T,N}

Check if all elements in x are zero.

Arguments

  • x::Vararg{T,N}: The input array.

Returns

  • Bool: true if all elements in x are zero, false otherwise.
source
JustRelax.JustRelax3D.assign! Method
julia
assign!(B::AbstractArray{T,N}, A::AbstractArray{T,N}) where {T,N}

Assigns the values of array A to array B in parallel.

Arguments

  • B::AbstractArray{T,N}: The destination array.

  • A::AbstractArray{T,N}: The source array.

source
JustRelax.JustRelax3D.compute_P! Method

compute_P!(P, P0, RP, ∇V, Q, ΔTc, η, rheology::NTuple{N,MaterialParams}, phase_ratio::C, dt, r, θ_dτ)

Compute the pressure field P and the residual RP for the compressible case. This function introduces thermal stresses after the implementation of Kiss et al. (2023).

Arguments

  • P: pressure field

  • RP: residual field

  • ∇V: divergence of the velocity field

  • Q: volumetric source/sink term which should have the properties of dV/V_tot [m³/m³] normalized per cell, default is zero.

  • ΔTc: temperature difference on the cell center, to account for thermal stresses. The thermal expansivity α is computed from the material parameters.

  • η: viscosity field

  • rheology: material parameters

  • phase_ratio: phase field

  • melt_fraction: melt fraction field, used for the thermal expansion coefficient if provided

  • dt: time step

  • r: relaxation parameter for the pressure update

  • θ_dτ: numerical parameter for the pressure update

source
JustRelax.JustRelax3D.compute_V! Method
julia
compute_V!(Vx, Vy, Vz, Rx, Ry, Rz, P, fx, fy, fz, τxx, τyy, τzz, τyz, τxz, τxy, ητ, ηdτ, ϕ, _dx, _dy, _dz)

Compute the 3D velocity field V from the pressure P, stress components τ, body forces f, and other parameters, with the rock ratio ϕ and grid spacing _dx, _dy, _dz.

source
JustRelax.JustRelax3D.compute_V! Method
julia
compute_V!(Vx, Vy, Rx, Ry, P, τxx, τyy, τxy, ηdτ, ρgx, ρgy, ητ, ϕ, _dx, _dy, dt)

Compute the velocity field V with the timestep dt from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ, grid spacing _dx, _dy, and time step dt.

source
JustRelax.JustRelax3D.compute_V! Method
julia
compute_V!(Vx, Vy, Rx, Ry, P, τxx, τyy, τxy, ηdτ, ρgx, ρgy, ητ, ϕ, _dx, _dy)

Compute the velocity field V from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ and grid spacing _dx, _dy.

source
JustRelax.JustRelax3D.compute_Vx! Method
julia
compute_Vx!(Vx, Rx, P, τxx, τxy, ηdτ, ρgx, ητ, ϕ, _dx, _dy)

Compute the x-component of the velocity field Vx from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ and grid spacing _dx, _dy.

source
JustRelax.JustRelax3D.compute_Vy! Method
julia
compute_Vy!(Vy, Vx_on_Vy, Ry, P, τyy, τxy, ηdτ, ρgy, ητ, ϕ, _dx, _dy, dt)

Compute the y-component of the velocity field Vy from the pressure P, stress components τ, and other parameters, taking into account the rock ratio ϕ, grid spacing _dx, _dy, and time step dt.

source
JustRelax.JustRelax3D.compute_air_ratio Method
julia
compute_air_ratio(phase_ratio, air_phase, inds...)

Compute the air ratio at the given indices based on the phase_ratio and air_phase.

source
JustRelax.JustRelax3D.compute_bulk_viscosity_and_penalty! Method
julia
compute_bulk_viscosity_and_penalty!(dyrel, stokes, rheology, phase_ratios, γfact, dt)

Computes the bulk viscosity ηb and the effective penalty parameter γ_eff.

  1. Bulk Viscosity (ηb): Computed based on the bulk modulus of the material phases.
  • If Kb is infinite (incompressible), ηb defaults to γfact * η_mean.

  • Otherwise ηb = Kb * dt.

  1. Penalty Parameter (γ_eff): A combination of numerical (γ_num) and physical (γ_phy) penalty terms.
  • γ_num = γfact * η_mean

  • γ_phy = Kb (or related term)

  • γ_eff = (γ_phy * γ_num) / (γ_phy + γ_num)

Arguments

  • dyrel: JustRelax.DYREL struct to update.

  • stokes: JustRelax.StokesArrays.

  • rheology: Material properties.

  • phase_ratios: Phase fraction information.

  • γfact: Numerical factor for penalty parameter (default: 20.0).

  • dt: Time step.

This function parallelizes the computation across grid cells.

source
JustRelax.JustRelax3D.compute_buoyancy Method
julia
compute_buoyancy(rheology, args, phase_ratios)

Compute the buoyancy forces based on the given rheology, arguments, and phase ratios.

Arguments

  • rheology: The rheology used to compute the buoyancy forces.

  • args: Additional arguments required by the rheology.

  • phase_ratios: The ratios of the different phases.

source
JustRelax.JustRelax3D.compute_buoyancy Method
julia
compute_buoyancy(rheology, args)

Compute the buoyancy forces based on the given rheology and arguments.

Arguments

  • rheology: The rheology used to compute the buoyancy forces.

  • args: Additional arguments required for the computation.

source
JustRelax.JustRelax3D.compute_buoyancy Method
julia
compute_buoyancy(rheology::MaterialParams, args, phase_ratios)

Compute the buoyancy forces for a given set of material parameters, arguments, and phase ratios.

Arguments

  • rheology: The material parameters.

  • args: The arguments.

  • phase_ratios: The phase ratios.

source
JustRelax.JustRelax3D.compute_buoyancy Method
julia
compute_buoyancy(rheology::MaterialParams, args)

Compute the buoyancy forces based on the given rheology parameters and arguments.

Arguments

  • rheology::MaterialParams: The material parameters for the rheology.

  • args: The arguments for the computation.

source
JustRelax.JustRelax3D.compute_dt Method
julia
compute_dt(S::JustRelax.StokesArrays, args...)

Compute the time step dt for the simulation.

source
JustRelax.JustRelax3D.compute_maxloc! Method
julia
compute_maxloc!(B, A; window)

Compute the maximum value of A in the window = (width_x, width_y, width_z) and store the result in B.

source
JustRelax.JustRelax3D.compute_rock_ratio Method
julia
compute_rock_ratio(phase_ratio, air_phase, inds...)

Compute the rock ratio at the given indices based on the phase_ratio and air_phase.

source
JustRelax.JustRelax3D.compute_shear_heating! Method
julia
compute_shear_heating!(thermal, stokes, rheology, dt)

Compute the shear heating term at cell centers for the thermal arrays thermal using the stress and strain rate from the Stokes arrays stokes and the rheology model rheology with a time step dt.

source
JustRelax.JustRelax3D.compute_strain_rate! Method
julia
compute_strain_rate!(εxx, εyy, εzz, εyz, εxz, εxy, ∇V, Vx, Vy, Vz, ϕ, _dx, _dy, _dz)

Compute the 3D components of the strain rate tensor ε from the velocity field V and its divergence ∇V, taking into account the rock ratio ϕ and grid spacing _dx, _dy, _dz.

source
JustRelax.JustRelax3D.compute_strain_rate! Method
julia
compute_strain_rate!(εxx, εyy, εxy, ∇V, Vx, Vy, ϕ, _dx, _dy)

Compute the components of the strain rate tensor ε from the velocity field V and its divergence ∇V, taking into account the rock ratio ϕ and grid spacing _dx, _dy.

source
JustRelax.JustRelax3D.compute_strain_rate_from_increment! Method
julia
compute_strain_rate_from_increment!(εxx, εyy, εxy, Δεxx, Δεyy, Δεxy, ϕ, _dt)

Compute the components of the strain rate tensor ε from the strain increments Δε, taking into account the rock ratio ϕ and time step _dt.

source
JustRelax.JustRelax3D.compute_ρg! Method
julia
compute_ρg!(ρg, rheology, args)

Calculate the buoyance forces ρg for the given GeoParams.jl rheology object and correspondent arguments args.

source
JustRelax.JustRelax3D.compute_ρg! Method
julia
compute_ρg!(ρg, phase_ratios, rheology, args)

Calculate the buoyance forces ρg for the given GeoParams.jl rheology object and correspondent arguments args. The phase_ratios are used to compute the density of the composite rheology.

source
JustRelax.JustRelax3D.compute_∇V! Method
julia
compute_∇V!(∇V, V, ϕ, _di)

Compute the divergence of the velocity field V and store it in ∇V, taking into account the rock ratio ϕ and grid spacing _di.

source
JustRelax.JustRelax3D.continuation_linear Method
julia
continuation_linear(x_new, x_old, ν)

Do a continuation step (1-ν)*x_old + ν*x_new with damping parameter ν

source
JustRelax.JustRelax3D.continuation_log Method
julia
continuation_log(x_new, x_old, ν)

Do a continuation step exp((1-ν)*log(x_old) + ν*log(x_new)) with damping parameter ν

source
JustRelax.JustRelax3D.flow_bcs! Method
julia
flow_bcs!(stokes, bcs::VelocityBoundaryConditions)

Apply the prescribed flow boundary conditions bc on the stokes

source
JustRelax.JustRelax3D.flow_bcs! Method
julia
flow_bcs!(stokes, bcs::DisplacementBoundaryConditions)

Apply the prescribed flow boundary conditions bc on the stokes

source
JustRelax.JustRelax3D.fn_ratio Method
julia
fn_ratio(fn::F, rheology::NTuple{N, AbstractMaterialParamsStruct}, ratio) where {N, F}

Average the function fn over the material phases in rheology using the phase ratios ratio.

source
JustRelax.JustRelax3D.interp_Vx_on_Vy! Method
julia
interp_Vx_on_Vy!(Vx_on_Vy, Vx)

Interpolates the values of Vx onto the grid points of Vy.

Arguments

  • Vx_on_Vy::AbstractArray: Vx at Vy grid points.

  • Vx::AbstractArray: Vx at its staggered grid points.

source
JustRelax.JustRelax3D.isvalid_c Method
julia
isvalid_v::JustRelax.RockRatio, inds...)

Check if ϕ.vertex[inds...] is a not a nullspace in 3D.

source
JustRelax.JustRelax3D.isvalid_c Method
julia
isvalid_c::JustRelax.RockRatio, inds...)

Check if ϕ.center[inds...] is a not a nullspace in 2D.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax3D.isvalid_v Method
julia
isvalid_v::JustRelax.RockRatio, inds...)

Check if ϕ.vertex[inds...] is a not a nullspace in 3D.

source
JustRelax.JustRelax3D.isvalid_v Method
julia
isvalid_v::JustRelax.RockRatio, inds...)

Check if ϕ.vertex[inds...] is a not a nullspace 2D.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax3D.isvalid_velocity Method
julia
isvalid_velocity::JustRelax.RockRatio, inds...)

Check if the velocity components at the given indices are not nullspaces in 3D.

source
JustRelax.JustRelax3D.isvalid_velocity Method
julia
isvalid_velocity::JustRelax.RockRatio, inds...)

Check if the velocity components at the given indices are not nullspaces in 2D.

source
JustRelax.JustRelax3D.isvalid_vx Method
julia
isvalid_vx::JustRelax.RockRatio, inds...)

Check if ϕ.Vx[inds...] is a not a nullspace.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax3D.isvalid_vz Method
julia
isvalid_vz::JustRelax.RockRatio, inds...)

Check if ϕ.Vz[inds...] is a not a nullspace.

Arguments

  • ϕ::JustRelax.RockRatio: The RockRatio object to check against.

  • inds: Cartesian indices to check.

source
JustRelax.JustRelax3D.isvalid_xy Method
julia
isvalid_xy(ϕ, inds...)

Check if the xy shear component at the given indices is not a nullspace.

source
JustRelax.JustRelax3D.isvalid_xz Method
julia
isvalid_xz(ϕ, inds...)

Check if the xz shear component at the given indices is not a nullspace.

source
JustRelax.JustRelax3D.isvalid_yz Method
julia
isvalid_yz(ϕ, inds...)

Check if the yz shear component at the given indices is not a nullspace.

source
JustRelax.JustRelax3D.maximum_mpi Method
julia
maximum_mpi(A)

Compute the maximum value of array A across all MPI processes.

source
JustRelax.JustRelax3D.mean_mpi Method
julia
mean_mpi(A)

Compute the mean of array A across all MPI processes.

source
JustRelax.JustRelax3D.minimum_mpi Method
julia
minimum_mpi(A)

Compute the minimum value of array A across all MPI processes.

source
JustRelax.JustRelax3D.multi_copy! Method
julia
multi_copy!(dst::NTuple{N, T}, src::NTuple{N, T}) where {N, T}

Copy data from the tuple of arrays src into the tuple of arrays dst in parallel.

source
JustRelax.JustRelax3D.norm_mpi Method
julia
norm_mpi(A)

Compute the L2 norm of array A across all MPI processes.

source
JustRelax.JustRelax3D.sum_mpi Method
julia
sum_mpi(A)

Compute the sum of array A across all MPI processes.

source
JustRelax.JustRelax3D.take Method
julia
take(fldr::String)

Create folder fldr if it does not exist.

source
JustRelax.JustRelax3D.tensor_invariant! Method
julia
tensor_invariant!(A::JustRelax.SymmetricTensor)

Compute the tensor invariant of the given symmetric tensor A.

Arguments

  • A::JustRelax.SymmetricTensor: The input symmetric tensor.
source
JustRelax.JustRelax3D.thermal_bcs! Method
julia
thermal_bcs!(T, bcs::TemperatureBoundaryConditions)

Apply the prescribed heat boundary conditions bc on the T

source
JustRelax.JustRelax3D.unpack Method
julia
unpack(x::T)

Generated function to unpack the fields of the struct x into a tuple.

source
JustRelax.JustRelax3D.update_dτV_α_β! Method
julia
update_dτV_α_β!(dτV, βV, αV, cV, λmaxV, CFL_v)

Generic N-dimensional version (2D and 3D) for updating pseudo-time step and acceleration parameters.

Computes the pseudo-time step dτV from the maximum eigenvalue estimate λmaxV and CFL number, then updates the damping parameters βV and acceleration parameters αV accordingly.

Arguments

  • dτV::NTuple{N, AbstractArray{T, N}}: Tuple of pseudo-time steps for each velocity component

  • βV::NTuple{N, AbstractArray{T, N}}: Tuple of damping parameters β for each velocity component

  • αV::NTuple{N, AbstractArray{T, N}}: Tuple of acceleration parameters α for each velocity component

  • cV::NTuple{N, AbstractArray{T, N}}: Tuple of preconditioner diagonal entries for each velocity component

  • λmaxV::NTuple{N, AbstractArray{T, N}}: Tuple of maximum eigenvalue estimates for each velocity component

  • CFL_v::Real: CFL number for velocity

source
JustRelax.JustRelax3D.update_phase_ratios_2D! Method
julia
update_phase_ratios!(
    phase_ratios::JustPIC.PhaseRatios, phase_arrays::NTuple{N, AbstractMatrix}, xci, xvi
) where {B, T <: AbstractMatrix, N}

JustRelax routine based on JustPIC._2D.update_phase_ratios! or JustPIC._3D.update_phase_ratios!. Update the phase ratios in phase_ratios using the provided phase_arrays, xci, and xvi. The phase arrays need to be AbstractArrays and have values between 0 and 1.

#Example:

julia
nx, ny = 100, 100
phase_1 = zeros(nx, ny)
phase_1[User_criterion .== true] .= 1.0
phase_2 = zeros(nx, ny)
phase_2[User_criterion .== false] .= 1.0
phase_arrays = (phase_1, phase_2)

# Advect both phase arrays and update phase ratios
update_phase_ratios!(phase_ratios, phase_arrays, xci, xvi)
source
JustRelax.JustRelax3D.update_phase_ratios_3D! Method
julia
update_phase_ratios!(
    phase_ratios::JustPIC.PhaseRatios, phase_arrays::NTuple{N, AbstractArray}, xci, xvi
) where {B, T <: AbstractArray, N}

JustRelax routine based on JustPIC._2D.update_phase_ratios! or JustPIC._3D.update_phase_ratios!. Update the phase ratios in phase_ratios using the provided phase_arrays, xci, and xvi. The phase arrays need to be AbstractArrays and have values between 0 and 1.

#Example:

julia
nx, ny, nz = 100, 100, 100
phase_1 = zeros(nx, ny, nz)
phase_1[User_criterion .== true] .= 1.0
phase_2 = zeros(nx, ny, nz)
phase_2[User_criterion .== false] .= 1.0
phase_arrays = (phase_1, phase_2)

# Advect both phase arrays and update phase ratios
update_phase_ratios!(phase_ratios, phase_arrays, xci, xvi)
source
JustRelax.JustRelax3D.update_rock_ratio! Method
julia
update_rock_ratio!::JustRelax.RockRatio, phase_ratios, air_phase)

Update the rock ratio ϕ based on the provided phase_ratios and air_phase.

Arguments

  • ϕ::JustRelax.RockRatio: The rock ratio object to be updated.

  • phase_ratios: The ratios of different phases present.

  • air_phase: The phase representing air.

source
JustRelax.JustRelax3D.update_rock_ratio! Method
julia
update_rock_ratio!::JustRelax.RockRatio, phase_ratios, air_phase)

Update the rock ratio ϕ for a 3D grid based on the provided phase_ratios and air_phase.

Arguments

  • ϕ::JustRelax.RockRatio: The rock ratio object to be updated.

  • phase_ratios: The ratios of different phases present.

  • air_phase: The phase representing air.

source
JustRelax.JustRelax3D.update_rock_ratio_cv! Method
julia
update_rock_ratio_cv!(ϕ, ratio_center, ratio_vertex, air_phase)

Update the rock ratio for both center and vertex values based on the provided ratio_center, ratio_vertex, and air_phase.

source
JustRelax.JustRelax3D.update_α_β! Method
julia
update_α_β!(βV, αV, dτV, cV)

Generic N-dimensional version (2D and 3D) of the acceleration parameters update.

Updates the damping parameters βV and αV for each velocity component based on the pseudo-time step dτV and the preconditioner diagonal cV.

Arguments

  • βV::NTuple{N, AbstractArray{T, N}}: Tuple of damping parameters β for each velocity component

  • αV::NTuple{N, AbstractArray{T, N}}: Tuple of acceleration parameters α for each velocity component

  • dτV::NTuple{N, AbstractArray{T, N}}: Tuple of pseudo-time steps for each velocity component

  • cV::NTuple{N, AbstractArray{T, N}}: Tuple of preconditioner diagonal entries for each velocity component

source
JustRelax.JustRelax3D.velocity2vertex! Method
julia
velocity2vertex!(Vx_v, Vy_v, Vz_v, Vx, Vy, Vz)

In-place interpolation of the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the pre-allocated Vx_d, Vy_d, Vz_d 3D arrays located at the grid vertices.

source
JustRelax.JustRelax3D.velocity2vertex Method
julia
velocity2vertex(Vx, Vy, Vz)

Interpolate the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the grid vertices.

source
JustRelax.JustRelax3D.@add Macro
julia
@add(I, args...)

Add I to the scalars in args

source
JustRelax.JustRelax3D.@allocate Macro
julia
@allocate(ni...)

Convenience macro to allocate a PTArray of size ni... with undef values.

source
JustRelax.JustRelax3D.@copy Macro
julia
copy(B, A)

convenience macro to copy data from the array A into array B

source
JustRelax.JustRelax3D.@displacement Macro
julia
@displacement(U)

Unpacks the displacement arrays U from the StokesArrays A.

source
JustRelax.JustRelax3D.@idx Macro
julia
@idx(args...)

Make a linear range from 1 to args[i], with i ∈ [1, ..., n]

source
JustRelax.JustRelax3D.@normal Macro
julia
@normal(A)

Unpacks the normal components of the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@plastic_strain Macro
julia
@plastic_strain(A)

Unpacks the plastic strain rate tensor ε_pl from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@qT Macro
julia
@qT(V)

Unpacks the flux arrays qT_i from the ThermalArrays A.

source
JustRelax.JustRelax3D.@qT2 Macro
julia
@qT2(V)

Unpacks the flux arrays qT2_i from the ThermalArrays A.

source
JustRelax.JustRelax3D.@residuals Macro
julia
@residuals(A)

Unpacks the momentum residuals from A.

source
JustRelax.JustRelax3D.@shear Macro
julia
@shear(A)

Unpacks the shear components of the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@shear_center Macro
julia
@shear_center(A)

Unpacks the shear components of the symmetric tensor A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@strain Macro
julia
@strain(A)

Unpacks the strain rate tensor ε from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@strain_center Macro
julia
@strain_center(A)

Unpacks the strain rate tensor ε from the StokesArrays A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@strain_increment Macro
julia
@strain_increment(A)

Unpacks the strain rate tensor ε from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@stress Macro
julia
@stress(A)

Unpacks the deviatoric stress tensor τ from the StokesArrays A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@stress_center Macro
julia
@stress_center(A)

Unpacks the deviatoric stress tensor τ from the StokesArrays A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@tensor Macro
julia
@tensor(A)

Unpacks the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@tensor_center Macro
julia
@tensor_center(A)

Unpacks the symmetric tensor A, where its components are defined in the center of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@tensor_vertex Macro
julia
tensor_vertex(A)

Unpacks the symmetric tensor A, where its components are defined in the vertices of the grid cells. Shear components are unpack following Voigt's notation.

source
JustRelax.JustRelax3D.@tuple Macro
julia
@tuple(A)

Convenience maktro to unpack the fields of the struct A into a tuple. Works with Velocity and SymmetricTensor structs.

source
JustRelax.JustRelax3D.@unpack Macro
julia
@unpack(x)

Convenience macro to unpack the fields of the struct x into a tuple.

source
JustRelax.JustRelax3D.@velocity Macro
julia
@velocity(V)

Unpacks the velocity arrays V from the StokesArrays A.

source
JustRelax.DataIO.checkpoint_name Method
julia
checkpointing_jld2(dst, stokes, thermal, time, timestep, igg; kwargs...)

Save necessary data in dst as a jld2 file to restart the model from the state at time. If run in parallel, the file will be named after the corresponidng rank e.g. checkpoint0000.jld2 and thus can be loaded by the processor while restarting the simulation. If you want to restart your simulation from the checkpoint you can use load() and specify the MPI rank by providing a dollar sign and the rank number.

Arguments

  • dst: The destination directory where the checkpoint file will be saved.

  • stokes: The stokes flow variables to be saved.

  • thermal: (Optional) The thermal variables to be saved.

  • time: The current simulation time.

  • timestep: The current timestep.

  • igg: (Optional) The IGG struct for parallel runs.

Keyword Arguments

  • kwargs...: Additional variables to be saved in the checkpoint file. These will be added to the base checkpoint data. Example
    julia
source
JustRelax.DataIO.checkpointing_hdf5 Method
julia
checkpointing_hdf5(dst, stokes, T, η, time, timestep)

Save necessary data in dst as and HDF5 file to restart the model from the state at time

source
JustRelax.DataIO.load_checkpoint_hdf5 Method
julia
load_checkpoint_hdf5(file_path)

Load the state of the simulation from an .h5 file.

Arguments

  • file_path: The path to the .h5 file.

Returns

  • P: The loaded state of the pressure variable.

  • T: The loaded state of the temperature variable.

  • Vx: The loaded state of the x-component of the velocity variable.

  • Vy: The loaded state of the y-component of the velocity variable.

  • Vz: The loaded state of the z-component of the velocity variable.

  • η: The loaded state of the viscosity variable.

  • t: The loaded simulation time.

  • dt: The loaded simulation time.

Example

julia
# Define the path to the .h5 file
file_path = "path/to/your/file.h5"

# Use the load_checkpoint function to load the variables from the file
P, T, Vx, Vy, Vz, η, t, dt = `load_checkpoint(file_path)``
source
JustRelax.DataIO.load_checkpoint_jld2 Method
julia
load_checkpoint_jld2(file_path)

Load the state of the simulation from a .jld2 file.

Arguments

  • file_path: The path to the .jld2 file.

Returns

  • stokes: The loaded state of the stokes variable.

  • thermal: The loaded state of the thermal variable. Can be nothing if not present in the file.

  • time: The loaded simulation time.

  • timestep: The loaded time step.

  • igg: The IGG struct if needed for parallel runs.

Example

julia
stokes, thermal, time, timestep = load_checkpoint_jld2("path/to/checkpoint.jld2", igg)

or without thermal

julia
stokes, _, time, timestep = load_checkpoint_jld2("path/to/checkpoint.jld2")
source
JustRelax.DataIO.metadata Method
julia
metadata(src, dst, files...)

Copy files..., Manifest.toml, and Project.toml from src to dst

source
JustRelax.DataIO.save_hdf5 Method
julia
function save_hdf5(dst, fname, data)

Save data as the fname.h5 HDF5 file in the folder dst

source
JustRelax.DataIO.save_hdf5 Method
julia
function save_hdf5(fname, data)

Save data as the fname.h5 HDF5 file

source
JustRelax.DataIO.save_marker_chain Method
julia
save_marker_chain(fname::String, chain::MarkerChain; conversion=1.0e3, pvd=nothing, t=0.0)

Save a vector of points as a line in a VTK file.

Arguments

  • fname::String: The name of the VTK file to save. The extension .vtk will be appended to the name.

  • chain::MarkerChain: Marker chain object from JustPIC.jl.

  • conversion: Conversion factor for coordinates (default: 1.0e3)

  • pvd::Union{Nothing, String}: Optional ParaView collection filename for time series

  • t::Number: Time value (default: 0.0)

source
JustRelax.DataIO.save_particles Method
julia
save_particles(particles::Particles{B, 2}, pPhases; conversion = 1e3, fname::String = "./particles", pvd=nothing, t=0.0) where B

Save particle data and their material phase to a VTK file.

Arguments

  • particles::Particles{B, 2}: The particle data, where B is the type of the particle coordinates.

  • pPhases: The phases of the particles.

  • conversion: A conversion factor for the particle coordinates (default is 1e3).

  • fname::String: The name of the VTK file to save (default is "./particles").

  • pvd::Union{Nothing, String}: Optional ParaView collection filename for time series

  • t::Number: Time value (default: 0.0)

source
JustRelax.DataIO.save_particles Method
julia
save_particles(particles::Particles{B, 2}; conversion = 1e3, fname::String = "./particles", pvd=nothing, t=0.0) where B

Save particle data to a VTK file.

Arguments

  • particles::Particles{B, 2}: The particle data, where B is the type of the particle coordinates.

  • conversion: A conversion factor for the particle coordinates (default is 1e3).

  • fname::String: The name of the VTK file to save (default is "./particles").

  • pvd::Union{Nothing, String}: Optional ParaView collection filename for time series

  • t::Number: Time value (default: 0.0)

source
JustRelax.DataIO.save_vtk Method
julia
save_vtk(fname::String, xvi, xci, data_v::NamedTuple, data_c::NamedTuple, velocity; t=0, pvd=nothing)

Save VTK data with multiblock format containing both vertex and cell data.

Arguments

  • fname::String: The filename for the VTK file (without extension)

  • xvi: Vertex coordinates (tuple of coordinate arrays)

  • xci: Cell center coordinates (tuple of coordinate arrays)

  • data_v::NamedTuple: Data defined at vertices

  • data_c::NamedTuple: Data defined at cell centers

  • velocity::NTuple{N, T}: Velocity field as a tuple of N-dimensional arrays

  • t::Number: Time value (default: 0)

  • pvd::Union{Nothing, String}: Optional ParaView collection filename. If provided, the VTK file will be added to a time series collection. WriteVTK.jl automatically handles creating new collections or appending to existing ones.

Examples

julia
# Basic usage (backward compatible)
save_vtk("output", xvi, xci, data_v, data_c, velocity; t=1.0)

# With ParaView collection for time series
save_vtk("timestep_001", xvi, xci, data_v, data_c, velocity; t=1.0, pvd="simulation")
save_vtk("timestep_002", xvi, xci, data_v, data_c, velocity; t=2.0, pvd="simulation")
# This creates simulation.pvd containing the time series

# Time series example
times = 0:0.1:10
for (i, t) in enumerate(times)
    fname = "timestep_$(lpad(i, 3, '0'))"
    save_vtk(fname, xvi, xci, data_v, data_c, velocity; t=t, pvd="full_simulation")
end
source
JustRelax.DataIO.save_vtk Method
julia
save_vtk(fname::String, xci, data_c::NamedTuple, velocity; t=nothing, pvd=nothing)

Save VTK data with cell-centered data and velocity field.

Arguments

  • fname::String: The filename for the VTK file (without extension)

  • xci: Cell center coordinates (tuple of coordinate arrays)

  • data_c::NamedTuple: Data defined at cell centers

  • velocity::NTuple{N, T}: Velocity field as a tuple of N-dimensional arrays

  • t::Number: Time value (default: nothing)

  • pvd::Union{Nothing, String}: Optional ParaView collection filename. If provided, the VTK file will be added to a time series collection. WriteVTK.jl automatically handles creating new collections or appending to existing ones.

Examples

julia
# Basic usage
save_vtk("output", xci, data_c, velocity; t=1.0)

# With ParaView collection
save_vtk("timestep_001", xci, data_c, velocity; t=1.0, pvd="simulation")
source