List of all functions
Here an overview of all functions:
JustRelax.DYREL Type
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.
JustRelax.Geometry Type
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.
JustRelax.RockRatio Type
RockRatio{T, N} <: AbstractMaskA 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.
sourceJustRelax.velocity_grids Method
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.
JustRelax.versioninfo Function
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().
JustRelax.JustRelax2D.DYREL! Method
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.DYRELstruct to modify.stokes:JustRelax.StokesArrayscontaining 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.
JustRelax.JustRelax2D.DYREL Method
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:
Allocates zero-initialized arrays using grid dimensions from
stokes.Computes initial bulk viscosity and penalty parameters.
Computes Gershgorin estimates for eigenvalues and preconditioners.
Updates damping coefficients.
Arguments
stokes:JustRelax.StokesArraysstruct.rheology: Material properties.phase_ratios: Phase fraction information.di: Grid spacing tuple.dt: Time step.γfact: Factor for penalty parameter calculation (default: 20.0).
JustRelax.JustRelax2D.DYREL Method
DYREL(ni::NTuple{N, Integer}; ϵ=1e-6, ϵ_vel=1e-6, CFL=0.99, c_fat=0.5) where NCreates 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.
JustRelax.JustRelax2D.Displacement Method
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 locationUy: Displacement in y direction at their staggered locationUz: Displacement in z direction at their staggered location
JustRelax.JustRelax2D.Displacement Method
Displacement(nx::Integer, ny::Integer)Create the displacement arrays for the Stokes solver in 2D.
Fields
Ux: Displacement in x direction at their staggered locationUy: Displacement in y direction at their staggered location
JustRelax.JustRelax2D.PrincipalStress Method
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).
JustRelax.JustRelax2D.Residual Method
Residual(nx::Integer, ny::Integer, nz::Integer)Create the residual arrays for the Stokes solver in 3D.
Fields
Rx: Residual for the x-momentum equationRy: Residual for the y-momentum equationRz: Residual for the z-momentum equationRP: Residual for the continuity equation
JustRelax.JustRelax2D.Residual Method
Residual(nx::Integer, ny::Integer)Create the residual arrays for the Stokes solver in 2D.
Fields
Rx: Residual for the x-momentum equationRy: Residual for the y-momentum equationRP: Residual for the continuity equation
JustRelax.JustRelax2D.RockRatio Method
RockRatio(nx, ny, nz)Create a RockRatio object for a 3D grid with dimensions nx x ny x nz on a staggered grid.
JustRelax.JustRelax2D.RockRatio Method
RockRatio(nx, ny)Create a RockRatio object for a 2D grid with dimensions nx x ny on a staggered grid.
JustRelax.JustRelax2D.StokesArrays Method
StokesArrays(ni::NTuple{N,Integer}) where {N}Create the Stokes arrays object in 2D or 3D.
Fields
P: Pressure fieldP0: Previous pressure field∇V: Velocity gradientV: Velocity fieldsQ: 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 tensorsEII_pl: Second invariant of the accumulated plastic strainviscosity: Viscosity fieldsR: Residual fieldsΔε: Strain increment tensor∇U: Displacement gradientλ: plastic multiplier @ centersλv: plastic multiplier @ verticesΔPψ: pressure correction in dilatant case
JustRelax.JustRelax2D.SymmetricTensor Method
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 centersyy: yy component of the tensor at cell centerszz: zz component of the tensor at cell centersxx_v: xx component of the tensor at verticesyy_v: yy component of the tensor at verticeszz_v: zz component of the tensor at verticesxy: xy component of the tensor at verticesyz: yz component of the tensor at verticesxz: xz component of the tensor at verticesyz_c: yz component of the tensor at cell centersxz_c: xz component of the tensor at cell centersxy_c: xy component of the tensor at cell centersII: second invariant of the tensor at cell centers
JustRelax.JustRelax2D.SymmetricTensor Method
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 centersyy: yy component of the tensor at cell centersxx_v: xx component of the tensor at verticesyy_v: yy component of the tensor at verticesxy: xy component of the tensor at verticesxy_c: xy component of the tensor at cell centersII: second invariant of the tensor at cell centers
JustRelax.JustRelax2D.ThermalArrays Method
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)
JustRelax.JustRelax2D.ThermalArrays Method
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)
JustRelax.JustRelax2D.ThermalArrays Method
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``).
JustRelax.JustRelax2D.ThermalArrays Method
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.
sourceJustRelax.JustRelax2D.Velocity Method
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)
JustRelax.JustRelax2D.Velocity Method
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)
JustRelax.JustRelax2D.Viscosity Method
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
JustRelax.JustRelax2D.Vorticity Method
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 locationxz: Vorticity component xz at their staggered locationxy: Vorticity component xy at their staggered location
JustRelax.JustRelax2D.Vorticity Method
Vorticity(nx::Integer, ny::Integer)Create the vorticity arrays for the Stokes solver in 2D.
Fields
xy: Vorticity component xy at vertices
JustRelax.JustRelax2D.WENO_advection! Method
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.
sourceJustRelax.JustRelax2D._heatdiffusion_PT! Method
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.
JustRelax.JustRelax2D._heatdiffusion_PT! Method
heatdiffusion_PT!(thermal, pt_thermal, rheology, dt, di; iterMax, nout, verbose)Heat diffusion solver using Pseudo-Transient iterations.
sourceJustRelax.JustRelax2D._update_rock_ratio! Method
_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.
JustRelax.JustRelax2D.allzero Method
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:trueif all elements inxare zero,falseotherwise.
JustRelax.JustRelax2D.assign! Method
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.
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 fieldRP: residual field∇V: divergence of the velocity fieldQ: volumetric source/sink term which should have the properties ofdV/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 fieldrheology: material parametersphase_ratio: phase fieldmelt_fraction: melt fraction field, used for the thermal expansion coefficient if provideddt: time stepr: relaxation parameter for the pressure updateθ_dτ: numerical parameter for the pressure update
JustRelax.JustRelax2D.compute_V! Method
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.
JustRelax.JustRelax2D.compute_V! Method
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.
JustRelax.JustRelax2D.compute_V! Method
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.
JustRelax.JustRelax2D.compute_Vx! Method
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.
JustRelax.JustRelax2D.compute_Vy! Method
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.
JustRelax.JustRelax2D.compute_air_ratio Method
compute_air_ratio(phase_ratio, air_phase, inds...)Compute the air ratio at the given indices based on the phase_ratio and air_phase.
JustRelax.JustRelax2D.compute_bulk_viscosity_and_penalty! Method
compute_bulk_viscosity_and_penalty!(dyrel, stokes, rheology, phase_ratios, γfact, dt)Computes the bulk viscosity ηb and the effective penalty parameter γ_eff.
- Bulk Viscosity (
ηb): Computed based on the bulk modulus of the material phases.
If
Kbis infinite (incompressible),ηbdefaults toγfact * η_mean.Otherwise
ηb = Kb * dt.
- 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.DYRELstruct 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.
sourceJustRelax.JustRelax2D.compute_buoyancy Method
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.
JustRelax.JustRelax2D.compute_buoyancy Method
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.
JustRelax.JustRelax2D.compute_buoyancy Method
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.
JustRelax.JustRelax2D.compute_buoyancy Method
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.
JustRelax.JustRelax2D.compute_dt Method
compute_dt(S::JustRelax.StokesArrays, args...)Compute the time step dt for the simulation.
JustRelax.JustRelax2D.compute_maxloc! Method
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.
JustRelax.JustRelax2D.compute_rock_ratio Method
compute_rock_ratio(phase_ratio, air_phase, inds...)Compute the rock ratio at the given indices based on the phase_ratio and air_phase.
JustRelax.JustRelax2D.compute_shear_heating! Method
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.
JustRelax.JustRelax2D.compute_strain_rate! Method
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.
JustRelax.JustRelax2D.compute_strain_rate! Method
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.
JustRelax.JustRelax2D.compute_strain_rate_from_increment! Method
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.
JustRelax.JustRelax2D.compute_ρg! Method
compute_ρg!(ρg, rheology, args)Calculate the buoyance forces ρg for the given GeoParams.jl rheology object and correspondent arguments args.
JustRelax.JustRelax2D.compute_ρg! Method
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.
JustRelax.JustRelax2D.compute_∇V! Method
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.
JustRelax.JustRelax2D.continuation_linear Method
continuation_linear(x_new, x_old, ν)Do a continuation step (1-ν)*x_old + ν*x_new with damping parameter ν
JustRelax.JustRelax2D.continuation_log Method
continuation_log(x_new, x_old, ν)Do a continuation step exp((1-ν)*log(x_old) + ν*log(x_new)) with damping parameter ν
JustRelax.JustRelax2D.flow_bcs! Method
flow_bcs!(stokes, bcs::VelocityBoundaryConditions)Apply the prescribed flow boundary conditions bc on the stokes
JustRelax.JustRelax2D.flow_bcs! Method
flow_bcs!(stokes, bcs::DisplacementBoundaryConditions)Apply the prescribed flow boundary conditions bc on the stokes
JustRelax.JustRelax2D.fn_ratio Method
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.
JustRelax.JustRelax2D.interp_Vx_on_Vy! Method
interp_Vx_on_Vy!(Vx_on_Vy, Vx)Interpolates the values of Vx onto the grid points of Vy.
Arguments
Vx_on_Vy::AbstractArray:VxatVygrid points.Vx::AbstractArray:Vxat its staggered grid points.
JustRelax.JustRelax2D.isvalid_c Method
isvalid_v(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.vertex[inds...] is a not a nullspace in 3D.
JustRelax.JustRelax2D.isvalid_c Method
isvalid_c(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.center[inds...] is a not a nullspace in 2D.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax2D.isvalid_v Method
isvalid_v(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.vertex[inds...] is a not a nullspace in 3D.
JustRelax.JustRelax2D.isvalid_v Method
isvalid_v(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.vertex[inds...] is a not a nullspace 2D.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax2D.isvalid_velocity Method
isvalid_velocity(ϕ::JustRelax.RockRatio, inds...)Check if the velocity components at the given indices are not nullspaces in 3D.
sourceJustRelax.JustRelax2D.isvalid_velocity Method
isvalid_velocity(ϕ::JustRelax.RockRatio, inds...)Check if the velocity components at the given indices are not nullspaces in 2D.
sourceJustRelax.JustRelax2D.isvalid_vx Method
isvalid_vx(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.Vx[inds...] is a not a nullspace.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax2D.isvalid_vz Method
isvalid_vz(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.Vz[inds...] is a not a nullspace.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax2D.isvalid_xy Method
isvalid_xy(ϕ, inds...)Check if the xy shear component at the given indices is not a nullspace.
sourceJustRelax.JustRelax2D.isvalid_xz Method
isvalid_xz(ϕ, inds...)Check if the xz shear component at the given indices is not a nullspace.
sourceJustRelax.JustRelax2D.isvalid_yz Method
isvalid_yz(ϕ, inds...)Check if the yz shear component at the given indices is not a nullspace.
sourceJustRelax.JustRelax2D.maximum_mpi Method
maximum_mpi(A)Compute the maximum value of array A across all MPI processes.
JustRelax.JustRelax2D.mean_mpi Method
mean_mpi(A)Compute the mean of array A across all MPI processes.
JustRelax.JustRelax2D.minimum_mpi Method
minimum_mpi(A)Compute the minimum value of array A across all MPI processes.
JustRelax.JustRelax2D.multi_copy! Method
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.
JustRelax.JustRelax2D.norm_mpi Method
norm_mpi(A)Compute the L2 norm of array A across all MPI processes.
JustRelax.JustRelax2D.solve_DYREL! Method
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.StokesArrayscontaining the simulation fields.ρg: buoyancy forces arrays.dyrel: DYREL-specific parameters and fields.flow_bcs:AbstractFlowBoundaryConditionsdefining velocity boundary conditions.phase_ratios:JustPIC.PhaseRatiosfor 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:IGGobject 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.
JustRelax.JustRelax2D.solve_VariationalStokes! Method
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.
sourceJustRelax.JustRelax2D.solve_VariationalStokes! Method
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.
sourceJustRelax.JustRelax2D.sum_mpi Method
sum_mpi(A)Compute the sum of array A across all MPI processes.
JustRelax.JustRelax2D.take Method
take(fldr::String)Create folder fldr if it does not exist.
JustRelax.JustRelax2D.tensor_invariant! Method
tensor_invariant!(A::JustRelax.SymmetricTensor)Compute the tensor invariant of the given symmetric tensor A.
Arguments
A::JustRelax.SymmetricTensor: The input symmetric tensor.
JustRelax.JustRelax2D.thermal_bcs! Method
thermal_bcs!(T, bcs::TemperatureBoundaryConditions)Apply the prescribed heat boundary conditions bc on the T
JustRelax.JustRelax2D.unpack Method
unpack(x::T)Generated function to unpack the fields of the struct x into a tuple.
JustRelax.JustRelax2D.update_dτV_α_β! Method
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 componentcV::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 componentCFL_v::Real: CFL number for velocity
JustRelax.JustRelax2D.update_phase_ratios_2D! Method
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:
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)JustRelax.JustRelax2D.update_phase_ratios_3D! Method
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:
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)JustRelax.JustRelax2D.update_rock_ratio! Method
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.
JustRelax.JustRelax2D.update_rock_ratio! Method
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.
JustRelax.JustRelax2D.update_rock_ratio_cv! Method
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.
JustRelax.JustRelax2D.update_α_β! Method
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 componentdτV::NTuple{N, AbstractArray{T, N}}: Tuple of pseudo-time steps for each velocity componentcV::NTuple{N, AbstractArray{T, N}}: Tuple of preconditioner diagonal entries for each velocity component
JustRelax.JustRelax2D.velocity2vertex! Method
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.
JustRelax.JustRelax2D.velocity2vertex Method
velocity2vertex(Vx, Vy, Vz)Interpolate the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the grid vertices.
JustRelax.JustRelax2D.@allocate Macro
@allocate(ni...)Convenience macro to allocate a PTArray of size ni... with undef values.
JustRelax.JustRelax2D.@copy Macro
copy(B, A)convenience macro to copy data from the array A into array B
JustRelax.JustRelax2D.@displacement Macro
@displacement(U)Unpacks the displacement arrays U from the StokesArrays A.
JustRelax.JustRelax2D.@idx Macro
@idx(args...)Make a linear range from 1 to args[i], with i ∈ [1, ..., n]
JustRelax.JustRelax2D.@normal Macro
@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.
JustRelax.JustRelax2D.@plastic_strain Macro
@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.
JustRelax.JustRelax2D.@qT Macro
@qT(V)Unpacks the flux arrays qT_i from the ThermalArrays A.
JustRelax.JustRelax2D.@qT2 Macro
@qT2(V)Unpacks the flux arrays qT2_i from the ThermalArrays A.
JustRelax.JustRelax2D.@residuals Macro
@residuals(A)Unpacks the momentum residuals from A.
JustRelax.JustRelax2D.@shear Macro
@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.
JustRelax.JustRelax2D.@shear_center Macro
@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.
JustRelax.JustRelax2D.@strain Macro
@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.
JustRelax.JustRelax2D.@strain_center Macro
@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.
JustRelax.JustRelax2D.@strain_increment Macro
@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.
JustRelax.JustRelax2D.@stress Macro
@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.
JustRelax.JustRelax2D.@stress_center Macro
@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.
JustRelax.JustRelax2D.@tensor Macro
@tensor(A)Unpacks the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.
JustRelax.JustRelax2D.@tensor_center Macro
@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.
JustRelax.JustRelax2D.@tensor_vertex Macro
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.
JustRelax.JustRelax2D.@tuple Macro
@tuple(A)Convenience maktro to unpack the fields of the struct A into a tuple. Works with Velocity and SymmetricTensor structs.
JustRelax.JustRelax2D.@unpack Macro
@unpack(x)Convenience macro to unpack the fields of the struct x into a tuple.
JustRelax.JustRelax2D.@velocity Macro
@velocity(V)Unpacks the velocity arrays V from the StokesArrays A.
JustRelax.JustRelax3D.DYREL! Method
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.DYRELstruct to modify.stokes:JustRelax.StokesArrayscontaining 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.
JustRelax.JustRelax3D.DYREL Method
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:
Allocates zero-initialized arrays using grid dimensions from
stokes.Computes initial bulk viscosity and penalty parameters.
Computes Gershgorin estimates for eigenvalues and preconditioners.
Updates damping coefficients.
Arguments
stokes:JustRelax.StokesArraysstruct.rheology: Material properties.phase_ratios: Phase fraction information.di: Grid spacing tuple.dt: Time step.γfact: Factor for penalty parameter calculation (default: 20.0).
JustRelax.JustRelax3D.DYREL Method
DYREL(ni::NTuple{N, Integer}; ϵ=1e-6, ϵ_vel=1e-6, CFL=0.99, c_fat=0.5) where NCreates 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.
JustRelax.JustRelax3D.Displacement Method
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 locationUy: Displacement in y direction at their staggered locationUz: Displacement in z direction at their staggered location
JustRelax.JustRelax3D.Displacement Method
Displacement(nx::Integer, ny::Integer)Create the displacement arrays for the Stokes solver in 2D.
Fields
Ux: Displacement in x direction at their staggered locationUy: Displacement in y direction at their staggered location
JustRelax.JustRelax3D.PrincipalStress Method
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).
JustRelax.JustRelax3D.Residual Method
Residual(nx::Integer, ny::Integer, nz::Integer)Create the residual arrays for the Stokes solver in 3D.
Fields
Rx: Residual for the x-momentum equationRy: Residual for the y-momentum equationRz: Residual for the z-momentum equationRP: Residual for the continuity equation
JustRelax.JustRelax3D.Residual Method
Residual(nx::Integer, ny::Integer)Create the residual arrays for the Stokes solver in 2D.
Fields
Rx: Residual for the x-momentum equationRy: Residual for the y-momentum equationRP: Residual for the continuity equation
JustRelax.JustRelax3D.RockRatio Method
RockRatio(nx, ny, nz)Create a RockRatio object for a 3D grid with dimensions nx x ny x nz on a staggered grid.
JustRelax.JustRelax3D.RockRatio Method
RockRatio(nx, ny)Create a RockRatio object for a 2D grid with dimensions nx x ny on a staggered grid.
JustRelax.JustRelax3D.StokesArrays Method
StokesArrays(ni::NTuple{N,Integer}) where {N}Create the Stokes arrays object in 2D or 3D.
Fields
P: Pressure fieldP0: Previous pressure field∇V: Velocity gradientV: Velocity fieldsQ: 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 tensorsEII_pl: Second invariant of the accumulated plastic strainviscosity: Viscosity fieldsR: Residual fieldsΔε: Strain increment tensor∇U: Displacement gradientλ: plastic multiplier @ centersλv: plastic multiplier @ verticesΔPψ: pressure correction in dilatant case
JustRelax.JustRelax3D.SymmetricTensor Method
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 centersyy: yy component of the tensor at cell centerszz: zz component of the tensor at cell centersxx_v: xx component of the tensor at verticesyy_v: yy component of the tensor at verticeszz_v: zz component of the tensor at verticesxy: xy component of the tensor at verticesyz: yz component of the tensor at verticesxz: xz component of the tensor at verticesyz_c: yz component of the tensor at cell centersxz_c: xz component of the tensor at cell centersxy_c: xy component of the tensor at cell centersII: second invariant of the tensor at cell centers
JustRelax.JustRelax3D.SymmetricTensor Method
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 centersyy: yy component of the tensor at cell centersxx_v: xx component of the tensor at verticesyy_v: yy component of the tensor at verticesxy: xy component of the tensor at verticesxy_c: xy component of the tensor at cell centersII: second invariant of the tensor at cell centers
JustRelax.JustRelax3D.ThermalArrays Method
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)
JustRelax.JustRelax3D.ThermalArrays Method
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)
JustRelax.JustRelax3D.ThermalArrays Method
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``).
JustRelax.JustRelax3D.ThermalArrays Method
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.
sourceJustRelax.JustRelax3D.Velocity Method
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)
JustRelax.JustRelax3D.Velocity Method
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)
JustRelax.JustRelax3D.Viscosity Method
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
JustRelax.JustRelax3D.Vorticity Method
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 locationxz: Vorticity component xz at their staggered locationxy: Vorticity component xy at their staggered location
JustRelax.JustRelax3D.Vorticity Method
Vorticity(nx::Integer, ny::Integer)Create the vorticity arrays for the Stokes solver in 2D.
Fields
xy: Vorticity component xy at vertices
JustRelax.JustRelax3D.WENO_advection! Method
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.
sourceJustRelax.JustRelax3D._heatdiffusion_PT! Method
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.
JustRelax.JustRelax3D._heatdiffusion_PT! Method
heatdiffusion_PT!(thermal, pt_thermal, rheology, dt, di; iterMax, nout, verbose)Heat diffusion solver using Pseudo-Transient iterations.
sourceJustRelax.JustRelax3D._update_rock_ratio! Method
_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.
JustRelax.JustRelax3D.allzero Method
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:trueif all elements inxare zero,falseotherwise.
JustRelax.JustRelax3D.assign! Method
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.
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 fieldRP: residual field∇V: divergence of the velocity fieldQ: volumetric source/sink term which should have the properties ofdV/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 fieldrheology: material parametersphase_ratio: phase fieldmelt_fraction: melt fraction field, used for the thermal expansion coefficient if provideddt: time stepr: relaxation parameter for the pressure updateθ_dτ: numerical parameter for the pressure update
JustRelax.JustRelax3D.compute_V! Method
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.
JustRelax.JustRelax3D.compute_V! Method
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.
JustRelax.JustRelax3D.compute_V! Method
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.
JustRelax.JustRelax3D.compute_Vx! Method
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.
JustRelax.JustRelax3D.compute_Vy! Method
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.
JustRelax.JustRelax3D.compute_air_ratio Method
compute_air_ratio(phase_ratio, air_phase, inds...)Compute the air ratio at the given indices based on the phase_ratio and air_phase.
JustRelax.JustRelax3D.compute_bulk_viscosity_and_penalty! Method
compute_bulk_viscosity_and_penalty!(dyrel, stokes, rheology, phase_ratios, γfact, dt)Computes the bulk viscosity ηb and the effective penalty parameter γ_eff.
- Bulk Viscosity (
ηb): Computed based on the bulk modulus of the material phases.
If
Kbis infinite (incompressible),ηbdefaults toγfact * η_mean.Otherwise
ηb = Kb * dt.
- 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.DYRELstruct 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.
sourceJustRelax.JustRelax3D.compute_buoyancy Method
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.
JustRelax.JustRelax3D.compute_buoyancy Method
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.
JustRelax.JustRelax3D.compute_buoyancy Method
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.
JustRelax.JustRelax3D.compute_buoyancy Method
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.
JustRelax.JustRelax3D.compute_dt Method
compute_dt(S::JustRelax.StokesArrays, args...)Compute the time step dt for the simulation.
JustRelax.JustRelax3D.compute_maxloc! Method
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.
JustRelax.JustRelax3D.compute_rock_ratio Method
compute_rock_ratio(phase_ratio, air_phase, inds...)Compute the rock ratio at the given indices based on the phase_ratio and air_phase.
JustRelax.JustRelax3D.compute_shear_heating! Method
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.
JustRelax.JustRelax3D.compute_strain_rate! Method
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.
JustRelax.JustRelax3D.compute_strain_rate! Method
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.
JustRelax.JustRelax3D.compute_strain_rate_from_increment! Method
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.
JustRelax.JustRelax3D.compute_ρg! Method
compute_ρg!(ρg, rheology, args)Calculate the buoyance forces ρg for the given GeoParams.jl rheology object and correspondent arguments args.
JustRelax.JustRelax3D.compute_ρg! Method
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.
JustRelax.JustRelax3D.compute_∇V! Method
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.
JustRelax.JustRelax3D.continuation_linear Method
continuation_linear(x_new, x_old, ν)Do a continuation step (1-ν)*x_old + ν*x_new with damping parameter ν
JustRelax.JustRelax3D.continuation_log Method
continuation_log(x_new, x_old, ν)Do a continuation step exp((1-ν)*log(x_old) + ν*log(x_new)) with damping parameter ν
JustRelax.JustRelax3D.flow_bcs! Method
flow_bcs!(stokes, bcs::VelocityBoundaryConditions)Apply the prescribed flow boundary conditions bc on the stokes
JustRelax.JustRelax3D.flow_bcs! Method
flow_bcs!(stokes, bcs::DisplacementBoundaryConditions)Apply the prescribed flow boundary conditions bc on the stokes
JustRelax.JustRelax3D.fn_ratio Method
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.
JustRelax.JustRelax3D.interp_Vx_on_Vy! Method
interp_Vx_on_Vy!(Vx_on_Vy, Vx)Interpolates the values of Vx onto the grid points of Vy.
Arguments
Vx_on_Vy::AbstractArray:VxatVygrid points.Vx::AbstractArray:Vxat its staggered grid points.
JustRelax.JustRelax3D.isvalid_c Method
isvalid_v(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.vertex[inds...] is a not a nullspace in 3D.
JustRelax.JustRelax3D.isvalid_c Method
isvalid_c(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.center[inds...] is a not a nullspace in 2D.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax3D.isvalid_v Method
isvalid_v(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.vertex[inds...] is a not a nullspace in 3D.
JustRelax.JustRelax3D.isvalid_v Method
isvalid_v(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.vertex[inds...] is a not a nullspace 2D.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax3D.isvalid_velocity Method
isvalid_velocity(ϕ::JustRelax.RockRatio, inds...)Check if the velocity components at the given indices are not nullspaces in 3D.
sourceJustRelax.JustRelax3D.isvalid_velocity Method
isvalid_velocity(ϕ::JustRelax.RockRatio, inds...)Check if the velocity components at the given indices are not nullspaces in 2D.
sourceJustRelax.JustRelax3D.isvalid_vx Method
isvalid_vx(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.Vx[inds...] is a not a nullspace.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax3D.isvalid_vz Method
isvalid_vz(ϕ::JustRelax.RockRatio, inds...)Check if ϕ.Vz[inds...] is a not a nullspace.
Arguments
ϕ::JustRelax.RockRatio: TheRockRatioobject to check against.inds: Cartesian indices to check.
JustRelax.JustRelax3D.isvalid_xy Method
isvalid_xy(ϕ, inds...)Check if the xy shear component at the given indices is not a nullspace.
sourceJustRelax.JustRelax3D.isvalid_xz Method
isvalid_xz(ϕ, inds...)Check if the xz shear component at the given indices is not a nullspace.
sourceJustRelax.JustRelax3D.isvalid_yz Method
isvalid_yz(ϕ, inds...)Check if the yz shear component at the given indices is not a nullspace.
sourceJustRelax.JustRelax3D.maximum_mpi Method
maximum_mpi(A)Compute the maximum value of array A across all MPI processes.
JustRelax.JustRelax3D.mean_mpi Method
mean_mpi(A)Compute the mean of array A across all MPI processes.
JustRelax.JustRelax3D.minimum_mpi Method
minimum_mpi(A)Compute the minimum value of array A across all MPI processes.
JustRelax.JustRelax3D.multi_copy! Method
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.
JustRelax.JustRelax3D.norm_mpi Method
norm_mpi(A)Compute the L2 norm of array A across all MPI processes.
JustRelax.JustRelax3D.sum_mpi Method
sum_mpi(A)Compute the sum of array A across all MPI processes.
JustRelax.JustRelax3D.take Method
take(fldr::String)Create folder fldr if it does not exist.
JustRelax.JustRelax3D.tensor_invariant! Method
tensor_invariant!(A::JustRelax.SymmetricTensor)Compute the tensor invariant of the given symmetric tensor A.
Arguments
A::JustRelax.SymmetricTensor: The input symmetric tensor.
JustRelax.JustRelax3D.thermal_bcs! Method
thermal_bcs!(T, bcs::TemperatureBoundaryConditions)Apply the prescribed heat boundary conditions bc on the T
JustRelax.JustRelax3D.unpack Method
unpack(x::T)Generated function to unpack the fields of the struct x into a tuple.
JustRelax.JustRelax3D.update_dτV_α_β! Method
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 componentcV::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 componentCFL_v::Real: CFL number for velocity
JustRelax.JustRelax3D.update_phase_ratios_2D! Method
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:
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)JustRelax.JustRelax3D.update_phase_ratios_3D! Method
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:
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)JustRelax.JustRelax3D.update_rock_ratio! Method
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.
JustRelax.JustRelax3D.update_rock_ratio! Method
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.
JustRelax.JustRelax3D.update_rock_ratio_cv! Method
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.
JustRelax.JustRelax3D.update_α_β! Method
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 componentdτV::NTuple{N, AbstractArray{T, N}}: Tuple of pseudo-time steps for each velocity componentcV::NTuple{N, AbstractArray{T, N}}: Tuple of preconditioner diagonal entries for each velocity component
JustRelax.JustRelax3D.velocity2vertex! Method
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.
JustRelax.JustRelax3D.velocity2vertex Method
velocity2vertex(Vx, Vy, Vz)Interpolate the velocity field Vx, Vy, Vz from a staggered grid with ghost nodes onto the grid vertices.
JustRelax.JustRelax3D.@allocate Macro
@allocate(ni...)Convenience macro to allocate a PTArray of size ni... with undef values.
JustRelax.JustRelax3D.@copy Macro
copy(B, A)convenience macro to copy data from the array A into array B
JustRelax.JustRelax3D.@displacement Macro
@displacement(U)Unpacks the displacement arrays U from the StokesArrays A.
JustRelax.JustRelax3D.@idx Macro
@idx(args...)Make a linear range from 1 to args[i], with i ∈ [1, ..., n]
JustRelax.JustRelax3D.@normal Macro
@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.
JustRelax.JustRelax3D.@plastic_strain Macro
@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.
JustRelax.JustRelax3D.@qT Macro
@qT(V)Unpacks the flux arrays qT_i from the ThermalArrays A.
JustRelax.JustRelax3D.@qT2 Macro
@qT2(V)Unpacks the flux arrays qT2_i from the ThermalArrays A.
JustRelax.JustRelax3D.@residuals Macro
@residuals(A)Unpacks the momentum residuals from A.
JustRelax.JustRelax3D.@shear Macro
@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.
JustRelax.JustRelax3D.@shear_center Macro
@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.
JustRelax.JustRelax3D.@strain Macro
@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.
JustRelax.JustRelax3D.@strain_center Macro
@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.
JustRelax.JustRelax3D.@strain_increment Macro
@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.
JustRelax.JustRelax3D.@stress Macro
@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.
JustRelax.JustRelax3D.@stress_center Macro
@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.
JustRelax.JustRelax3D.@tensor Macro
@tensor(A)Unpacks the symmetric tensor A, where its components are defined in the staggered grid. Shear components are unpack following Voigt's notation.
JustRelax.JustRelax3D.@tensor_center Macro
@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.
JustRelax.JustRelax3D.@tensor_vertex Macro
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.
JustRelax.JustRelax3D.@tuple Macro
@tuple(A)Convenience maktro to unpack the fields of the struct A into a tuple. Works with Velocity and SymmetricTensor structs.
JustRelax.JustRelax3D.@unpack Macro
@unpack(x)Convenience macro to unpack the fields of the struct x into a tuple.
JustRelax.JustRelax3D.@velocity Macro
@velocity(V)Unpacks the velocity arrays V from the StokesArrays A.
JustRelax.DataIO.checkpoint_name Method
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. Examplejulia
JustRelax.DataIO.checkpointing_hdf5 Method
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
JustRelax.DataIO.load_checkpoint_hdf5 Method
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
# 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)``JustRelax.DataIO.load_checkpoint_jld2 Method
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 benothingif 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
stokes, thermal, time, timestep = load_checkpoint_jld2("path/to/checkpoint.jld2", igg)or without thermal
stokes, _, time, timestep = load_checkpoint_jld2("path/to/checkpoint.jld2")JustRelax.DataIO.metadata Method
metadata(src, dst, files...)Copy files..., Manifest.toml, and Project.toml from src to dst
JustRelax.DataIO.save_hdf5 Method
function save_hdf5(dst, fname, data)Save data as the fname.h5 HDF5 file in the folder dst
JustRelax.DataIO.save_hdf5 Method
function save_hdf5(fname, data)Save data as the fname.h5 HDF5 file
JustRelax.DataIO.save_marker_chain Method
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.vtkwill 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 seriest::Number: Time value (default: 0.0)
JustRelax.DataIO.save_particles Method
save_particles(particles::Particles{B, 2}, pPhases; conversion = 1e3, fname::String = "./particles", pvd=nothing, t=0.0) where BSave particle data and their material phase to a VTK file.
Arguments
particles::Particles{B, 2}: The particle data, whereBis 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 seriest::Number: Time value (default: 0.0)
JustRelax.DataIO.save_particles Method
save_particles(particles::Particles{B, 2}; conversion = 1e3, fname::String = "./particles", pvd=nothing, t=0.0) where BSave particle data to a VTK file.
Arguments
particles::Particles{B, 2}: The particle data, whereBis 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 seriest::Number: Time value (default: 0.0)
JustRelax.DataIO.save_vtk Method
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 verticesdata_c::NamedTuple: Data defined at cell centersvelocity::NTuple{N, T}: Velocity field as a tuple of N-dimensional arrayst::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
# 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")
endJustRelax.DataIO.save_vtk Method
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 centersvelocity::NTuple{N, T}: Velocity field as a tuple of N-dimensional arrayst::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
# 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")