API Reference
The table below lists the main entry points exported by Geodynamo
. The listing is automatically generated during the documentation build.
Main Module
Geodynamo.AbstractScalarField
— TypeAbstract type for scalar fields (temperature, composition, etc.)
Geodynamo.AdvancedThreadManager
— TypeAdvancedThreadManager
Advanced thread management with CPU affinity, NUMA awareness, and work-stealing.
Geodynamo.AsyncCommManager
— TypeAsyncCommManager{T}
Advanced asynchronous communication manager for overlapping computation and communication.
Geodynamo.CPUParallelizer
— TypeCPUParallelizer{T}
Advanced CPU parallelization system with SIMD, NUMA, and task-based parallelism.
Geodynamo.CombinerConfig
— TypeCombinerConfig
Configuration structure for field combination process.
Geodynamo.DynamicLoadBalancer
— TypeDynamicLoadBalancer
Dynamic load balancing system that adapts to computational heterogeneity.
Geodynamo.ERK2Cache
— TypeERK2Cache{T}
Cached data structure for Exponential 2nd Order Runge-Kutta method. Stores precomputed matrix exponentials and φ functions for each spherical harmonic mode.
Geodynamo.FieldCombiner
— TypeFieldCombiner{T}
Structure for combining distributed Geodynamo.jl output files using the consistent field structures and parameter system.
Geodynamo.HybridParallelizer
— TypeHybridParallelizer{T}
Coordinates MPI and threads for maximum CPU parallelization.
Geodynamo.MasterParallelizer
— TypeMasterParallelizer{T}
Comprehensive parallelization system combining all techniques.
Geodynamo.MemoryOptimizer
— TypeMemoryOptimizer{T}
Advanced memory management with cache optimization and NUMA awareness.
Geodynamo.ParallelIOOptimizer
— TypeParallelIOOptimizer{T}
Advanced parallel I/O optimization with asynchronous writes and data staging.
Geodynamo.PerformanceMonitor
— TypePerformanceMonitor
Comprehensive performance monitoring for parallel efficiency analysis.
Geodynamo.SIMDOptimizer
— TypeSIMDOptimizer{T}
Advanced SIMD vectorization for mathematical operations with AVX/NEON support.
Geodynamo.SimulationState
— TypeSimulationState{T}
Unified simulation state with comprehensive parallelization and diagnostics.
Geodynamo.SpectralToPhysicalConverter
— TypeSpectralToPhysicalConverter{T}
Structure for converting spectral field data to physical space using the Geodynamo.jl infrastructure (PencilArrays + SHTns).
Geodynamo.TaskGraph
— TypeTaskGraph
Represents computation as a directed acyclic graph for optimal scheduling.
Geodynamo.TaskNode
— TypeTaskNode
Represents a computation task in a dependency graph.
Geodynamo.ThreadingAccelerator
— TypeThreadingAccelerator{T} (Backward Compatibility)
Basic CPU threading acceleration for existing code.
Geodynamo._get_influence_cache
— Method_get_influence_cache(domain::RadialDomain, dr_matrix)
Get or create cached influence functions and matrix for given domain. Note: drmatrix should be a BandedMatrix (defined in linearalgebra.jl)
Geodynamo._get_tau_cache
— Method_get_tau_cache(domain::RadialDomain)
Get or create cached tau polynomials and derivatives for given domain.
Geodynamo.add_internal_sources_local!
— Methodadd_internal_sources_local!(field::AbstractScalarField{T}, domain::RadialDomain) where T
Add volumetric sources (completely local operation). This works for any scalar field with radial source profile.
Geodynamo.analyze_load_balance
— Methodanalyze_load_balance(pencil::Pencil)
Analyze and report load balance for a given pencil decomposition.
Geodynamo.apply_banded_full!
— Methodapply_banded_full!(out, B, v)
Apply banded matrix to full vector.
Geodynamo.apply_composition_boundary_conditions!
— Methodapply_composition_boundary_conditions!(field; time_index=nothing)
Refresh composition boundary values from the BoundaryConditions subsystem and enforce Dirichlet data in spectral space.
Geodynamo.apply_enhanced_implicit_step!
— Methodapply_enhanced_implicit_step!(state, dt)
Apply enhanced implicit time integration with advanced solvers.
Geodynamo.apply_flux_bc_direct!
— Methodapply_flux_bc_direct!(spec_real, spec_imag, local_lm, lm_idx,
field::AbstractScalarField, domain, r_range)
Direct modification of boundary values to approximately satisfy flux BC. This is the simplest but least accurate method.
Geodynamo.apply_flux_bc_influence_matrix!
— Methodapply_flux_bc_influence_matrix!(spec_real, spec_imag, local_lm, lm_idx,
apply_inner, apply_outer, field::AbstractScalarField,
domain, r_range)
Apply flux boundary conditions using the influence matrix method.
Geodynamo.apply_flux_bc_spectral!
— Methodapply_flux_bc_spectral_complete!(temp_field, domain)
Complete implementation of flux boundary conditions in spectral space. This modifies the spectral coefficients to satisfy ∂T/∂r = prescribed_flux.
Geodynamo.apply_flux_bc_tau!
— Methodapply_flux_bc_tau!(spec_real, spec_imag, local_lm, lm_idx,
apply_inner, apply_outer, field::AbstractScalarField,
domain, r_range)
Apply flux boundary conditions using the tau method. This is the generalized version that works with any scalar field.
Geodynamo.apply_geometric_factors_spectral!
— Methodapply_geometric_factors_spectral!(field::AbstractScalarField{T}, domain::RadialDomain) where T
Apply geometric factors (1/r, 1/(r sin θ)) in spectral space. For gradients in spherical coordinates. This is generic.
Geodynamo.apply_magnetic_boundary_conditions!
— Methodapply_magnetic_boundary_conditions!(fields; time_index=nothing)
Refresh magnetic boundary data from the BoundaryConditions subsystem and enforce the corresponding Dirichlet values in spectral space.
Geodynamo.apply_scalar_flux_bc_spectral!
— Methodapply_scalar_flux_bc_spectral!(field::AbstractScalarField{T}, domain::RadialDomain;
method::Symbol=:tau) where T
Apply flux boundary conditions to a scalar field in spectral space. Methods available: :tau (most robust), :influence_matrix, :direct (simplest).
Geodynamo.apply_tau_correction!
— Methodapply_tau_correction!(profile::Vector{T}, tau_coeffs, domain::RadialDomain) where T
Add tau correction to the radial profile.
Geodynamo.apply_velocity_boundary_conditions!
— Methodapply_velocity_boundary_conditions!(fields; time_index=nothing)
Refresh velocity boundary data from the BoundaryConditions subsystem and immediately enforce Dirichlet constraints in spectral space.
Geodynamo.batch_convert_directory
— Methodbatch_convert_directory(input_dir::String, output_dir::String = "";
pattern::String = "combined_global_time_",
precision::Type{T} = Float64,
compute_diagnostics::Bool = true) where T
Convert all spectral files matching a pattern in a directory.
Geodynamo.batch_magnetic_transforms!
— Methodbatch_magnetic_transforms!(mag_fields::SHTnsMagneticFields{T}) where T
Perform batched transforms for better cache efficiency using shtnskit_transforms.jl
Geodynamo.batch_shtnskit_transforms!
— Methodbatch_shtnskit_transforms!(specs::Vector{SHTnsSpectralField{T}},
physs::Vector{SHTnsPhysicalField{T}}) where T
Batch process multiple transforms using SHTnsKit with PencilArrays.
Geodynamo.batch_spectral_to_physical!
— Methodbatch_spectral_to_physical!(specs, physs)
Compatibility wrapper that calls batch_shtnskit_transforms!
for batched spectral→physical transforms using SHTnsKit with PencilArrays/MPI.
Geodynamo.batch_velocity_transforms!
— Methodbatch_velocity_transforms!(fields::SHTnsVelocityFields{T}) where T
Perform batched transforms for better cache efficiency using shtnskit_transforms.jl
Geodynamo.batch_write_spectral_fields!
— Methodbatch_write_spectral_fields!(nc_file, fields::Dict, config::OutputConfig, field_info::FieldInfo)
Write multiple spectral fields in batched operations for better I/O performance
Geodynamo.build_banded_A
— Methodbuild_banded_A(T, domain, diffusivity, l) -> BandedMatrix{T}
Construct banded A = ν*(d²/dr² + (2/r)d/dr − l(l+1)/r²) in banded storage.
Geodynamo.build_influence_matrix
— Methodbuild_influence_matrix(G_inner, G_outer, dr_matrix, domain)
Construct a 2×2 matrix mapping influence amplitudes to boundary flux errors. Rows correspond to (inner, outer) boundaries; columns to (inner, outer) influence functions.
Geodynamo.build_rhs_cnab2!
— Methodbuild_rhs_cnab2!(rhs, un, nl, nl_prev, dt, matrices)
Build RHS for CNAB2 IMEX: rhs = un/dt + (1-θ)·L·un + (3/2)·nl − (1/2)·nl_prev, where θ = matrices.theta and L is the diffusivity-scaled linear operator.
Geodynamo.build_theta_derivative_matrix
— Methodbuild_theta_derivative_matrix(::Type{T}, config::SHTnsKitConfig) where T
Build sparse matrix for θ-derivatives in spectral space. This matrix couples different l modes with the same m.
Geodynamo.calculate_linear_neighbors
— Methodcalculate_linear_neighbors(rank::Int, dim::Int, proc_dims::Tuple, boundaries::Symbol)
Calculate neighbor ranks for non-Cartesian topologies.
Geodynamo.combine_distributed_time
— Methodcombine_distributed_time(output_dir::String, time::Float64;
config::CombinerConfig = create_combiner_config(),
precision::Type{T} = Float64) where T
Main function to combine distributed files for a specific time.
Geodynamo.combine_magnetic_spectral!
— Methodcombine_magnetic_spectral!(combiner::FieldCombiner{T}, lm_mapping::Dict) where T
Combine magnetic spectral coefficients from all distributed files.
Geodynamo.combine_physical_fields!
— Methodcombine_physical_fields!(combiner::FieldCombiner{T}) where T
Combine physical space temperature field from distributed files.
Geodynamo.combine_spectral_fields!
— Methodcombine_spectral_fields!(combiner::FieldCombiner{T}) where T
Combine spectral field data from distributed files.
Geodynamo.combine_time_series
— Methodcombine_time_series(output_dir::String, time_range::Tuple{Float64,Float64};
config::CombinerConfig = create_combiner_config(),
precision::Type{T} = Float64) where T
Combine multiple time points into a time series.
Geodynamo.combine_to_global!
— Methodcombine_to_global!(combiner::FieldCombiner{T}) where T
Combine distributed field data into global field structures.
Geodynamo.combine_velocity_spectral!
— Methodcombine_velocity_spectral!(combiner::FieldCombiner{T}, lm_mapping::Dict) where T
Combine velocity spectral coefficients from all distributed files.
Geodynamo.compute_all_gradients_spectral!
— Methodcompute_all_gradients_spectral!(field::AbstractScalarField{T}, domain::RadialDomain) where T
Compute all gradient components (θ, φ, r) in spectral space. This is the main driver function that works for any scalar field.
Geodynamo.compute_boundary_fluxes
— Methodcompute_boundary_fluxes(profile::Vector{T}, dr_matrix, domain::RadialDomain) where T
Compute flux (dT/dr) at both boundaries using the derivative matrix. Note: drmatrix should be a BandedMatrix{T} (defined in linearalgebra.jl)
Geodynamo.compute_chebyshev_polynomial
— Methodcompute_chebyshev_polynomial(n::Int, domain::RadialDomain)
Compute Chebyshev polynomial T_n on the radial grid.
Geodynamo.compute_global_diagnostics
— Methodcompute_global_diagnostics(combiner::FieldCombiner{T}) where T
Compute global diagnostics for the combined fields.
Geodynamo.compute_global_diagnostics
— Methodcompute_global_diagnostics(converter::SpectralToPhysicalConverter{T}) where T
Compute global field diagnostics using MPI reductions.
Geodynamo.compute_influence_functions_flux
— Methodcompute_influence_functions_flux(oc_domain::RadialDomain)
Compute influence functions for flux BCs. These are solutions to the homogeneous equation with specific BCs.
Geodynamo.compute_inner_tau_function
— Methodcompute_inner_tau_function(domain::RadialDomain)
Compute tau function for inner boundary only (zero derivative at outer).
Geodynamo.compute_magnetic_helicity
— Methodcompute_magnetic_helicity(mag_fields::SHTnsMagneticFields{T}) where T
Compute magnetic helicity using enhanced spectral integration
Geodynamo.compute_nonlinear!
— Methodcompute_nonlinear!(parallelizer, temp_field, vel_fields, domain)
Advanced CPU computation with SIMD, NUMA, and task-based parallelism.
Geodynamo.compute_outer_tau_function
— Methodcompute_outer_tau_function(domain::RadialDomain)
Compute tau function for outer boundary only (zero derivative at inner).
Geodynamo.compute_phi1_function
— Methodcompute_phi1_function(A, expA)
Compute φ1(A) = (exp(A) - I) / A efficiently with comprehensive error handling. Uses series expansion for small ||A|| to avoid numerical issues.
Geodynamo.compute_phi2_function
— Methodcompute_phi2_function(A, expA)
Compute φ2(A) = (exp(A) - I - A) / A² efficiently with comprehensive error handling. Uses series expansion for small ||A|| to avoid numerical issues.
Geodynamo.compute_phi_gradient_spectral!
— Methodcompute_phi_gradient_spectral!(field::AbstractScalarField{T}) where T
Compute ∂field/∂φ using spherical harmonic properties (local operation). This is generic and works for any scalar field.
Geodynamo.compute_radial_gradient_spectral!
— Methodcompute_radial_gradient_spectral!(field::AbstractScalarField{T}, domain::RadialDomain) where T
Compute ∂field/∂r using banded matrix derivative operator in spectral space (local operation). This uses the pre-computed derivative matrices from the field for optimal accuracy and efficiency.
Geodynamo.compute_scalar_advection_local!
— Methodcompute_scalar_advection_local!(field::AbstractScalarField{T}, vel_fields) where T
Compute -u·∇field in physical space (completely local operation). This works for any scalar field.
Geodynamo.compute_scalar_energy
— Methodcompute_scalar_energy(field::AbstractScalarField{T}, oc_domain::RadialDomain) where T
Compute energy ∫ field² dV
Geodynamo.compute_scalar_rms
— Methodcompute_scalar_rms(field::AbstractScalarField{T}, oc_domain::RadialDomain) where T
Compute RMS value of scalar field.
Geodynamo.compute_spectral_energy_diagnostics!
— Methodcompute_spectral_energy_diagnostics!(diagnostics, component, real_part, imag_part, field_info)
Compute spectral energy distribution diagnostics using SHTns configuration
Geodynamo.compute_tau_coefficients_both
— Methodcompute_tau_coefficients_both(flux_error_inner::T, flux_error_outer::T, domain::RadialDomain) where T
Compute tau polynomial coefficients for both boundaries. Uses highest two Chebyshev modes as tau functions.
Geodynamo.compute_tau_coefficients_inner
— Methodcompute_tau_coefficients_inner(flux_error::T, domain::RadialDomain) where T
Compute tau coefficient for inner boundary only. Uses a single tau function that doesn't affect outer boundary.
Geodynamo.compute_tau_coefficients_outer
— Methodcompute_tau_coefficients_outer(flux_error::T, domain::RadialDomain) where T
Compute tau coefficient for outer boundary only. Uses a single tau function that doesn't affect inner boundary.
Geodynamo.compute_theta_gradient_spectral!
— Methodcompute_theta_gradient_spectral!(field::AbstractScalarField{T}) where T
Compute ∂field/∂θ using spherical harmonic recurrence relations (local operation). This is generic and works for any scalar field.
Geodynamo.compute_theta_recurrence_coefficients
— Methodcompute_theta_recurrence_coefficients(::Type{T}, config::SHTnsKitConfig) where T
Pre-compute recurrence coefficients for θ-derivatives. Store as [nlm, 2] matrix: [:, 1] for l-1 coupling, [:, 2] for l+1 coupling
Geodynamo.convert_spectral_file
— Methodconvert_spectral_file(input_filename::String, output_filename::String = "";
precision::Type{T} = Float64,
compute_diagnostics::Bool = true) where T
Main function to convert a single spectral data file to physical space.
Geodynamo.convert_to_physical!
— Methodconvert_to_physical!(converter::SpectralToPhysicalConverter{T}) where T
Convert all loaded spectral data to physical space using SHTns transforms.
Geodynamo.create_boundary_slice
— Methodcreate_boundary_slice(size_arr::Tuple, dim::Int, side::Symbol, width::Int)
Create array slice for boundary data extraction.
Geodynamo.create_combiner_config
— Methodcreate_combiner_config(; kwargs...)
Create combiner configuration with keyword arguments.
Geodynamo.create_computation_pencils
— Methodcreate_computation_pencils(topology, dims, config)
Create specialized pencils for different stages of computation.
Geodynamo.create_enhanced_field_variables!
— Methodcreate_enhanced_field_variables!(nc_file, field_info::FieldInfo, config::OutputConfig,
available_fields::Vector{String})
Enhanced field variable setup that leverages SHTns configuration
Geodynamo.create_enhanced_output_config
— Methodcreate_enhanced_output_config(state)
Create output configuration with enhanced I/O settings.
Geodynamo.create_erk2_cache
— Methodcreate_erk2_cache(config, domain, diffusivity, dt; use_krylov=false, m=20, tol=1e-8)
Create ERK2 cache with precomputed matrix functions for all spherical harmonic modes.
Geodynamo.create_erk2_config
— Methodcreate_erk2_config(; lmax, mmax, nlat, nlon, optimize_for_erk2=true)
Create an SHTnsKit configuration for ERK2 timestepping.
Geodynamo.create_etd_cache
— Methodcreate_etd_cache(config, domain, diffusivity, dt) -> ETDCache
Build per-l exponential cache for the linear operator Al = diffusivity*(d²/dr² + (2/r)d/dr − l(l+1)/r²). Computes exp(dt Al) and phi1(dt A_l) via dense methods. Single-rank recommended.
Geodynamo.create_field_combiner
— Methodcreate_field_combiner(output_dir::String, time::Float64;
precision::Type{T} = Float64) where T
Create a field combiner by reading configuration from distributed files.
Geodynamo.create_halo_slice
— Methodcreate_halo_slice(size_arr::Tuple, dim::Int, side::Symbol, width::Int)
Create array slice for halo region insertion.
Geodynamo.create_memory_efficient_output_buffer
— Methodcreate_memory_efficient_output_buffer(data_size::Int, precision::DataType)
Create appropriately sized buffer for output operations
Geodynamo.create_parameter_template
— Methodcreate_parameter_template(filename::String)
Create a template parameter file for users to customize.
Geodynamo.create_pencil_array
— Methodcreate_pencil_array(::Type{T}, pencil::Pencil; init=:zero) where T
Create a PencilArray with specified initialization.
Geodynamo.create_pencil_decomposition_shtnskit
— Functioncreate_pencil_decomposition_shtnskit(nlat, nlon, nr, sht_config, comm, optimize)
Create PencilArrays decomposition optimized for theta-phi parallelization.
Geodynamo.create_pencil_fft_plans
— Methodcreate_pencil_fft_plans(pencils, dims)
Create PencilFFTs plans for efficient phi-direction transforms.
Geodynamo.create_pencil_topology
— Methodcreate_pencil_topology(shtns_config; optimize=true)
Create enhanced pencil decomposition for SHTns grids. Supports both 1D and 2D decompositions with automatic optimization. Accepts an object with fields nlat
, nlon
, and nlm
(e.g., SHTnsKitConfig
).
Geodynamo.create_shtns_aware_output_config
— Methodcreate_shtns_aware_output_config(shtns_config::SHTnsKitConfig, pencils::NamedTuple;
base_config::OutputConfig = default_config())
Create output configuration that integrates with SHTns configuration and pencil decomposition
Geodynamo.create_shtnskit_config
— Methodcreate_shtnskit_config(; lmax::Int, mmax::Int=lmax, nlat::Int=lmax+2,
nlon::Int=max(2*lmax+1, 4), optimize_decomp::Bool=true) -> SHTnsKitConfig
Create SHTnsKit configuration with MPI parallelization using PencilArrays. This creates proper integration with ../SHTnsKit.jl, PencilArrays, and PencilFFTs.
Geodynamo.create_shtnskit_transpose_plans
— Methodcreate_shtnskit_transpose_plans(pencils)
Create transpose plans for efficient pencil reorientations.
Geodynamo.create_spectral_converter
— Methodcreate_spectral_converter(filename::String; precision::Type{T} = Float64) where T
Create a spectral to physical converter by reading configuration from a NetCDF file.
Geodynamo.create_transpose_plans
— Methodcreate_transpose_plans(pencils)
Create enhanced transpose plans between pencil orientations. Includes caching and communication optimization.
Geodynamo.eab2_update!
— Methodeab2_update!(u, nl, nl_prev, etd, config)
Apply EAB2 update per (l,m): u^{n+1} = E u^n + dtphi1(3/2 nl^n − 1/2 nl^{n−1}).
Geodynamo.eab2_update_krylov!
— Methodeab2_update_krylov!(u, nl, nl_prev, domain, diffusivity, config, dt; m=20, tol=1e-8)
EAB2 update using Krylov exp/φ1 actions and banded LU for φ1.
Geodynamo.eab2_update_krylov_cached!
— Methodeab2_update_krylov_cached!(u, nl, nl_prev, alu_map, domain, ν, config, dt; m=20, tol=1e-8)
Same as eab2updatekrylov!, but reuses cached banded A and LU per l.
Geodynamo.enforce_composition_boundary_values!
— Methodenforce_composition_boundary_values!(field)
Anchor spectral boundary modes to stored Dirichlet values when applicable.
Geodynamo.enforce_magnetic_boundary_values!
— Methodenforce_magnetic_boundary_values!(fields)
Anchor magnetic toroidal/poloidal spectral data to cached Dirichlet boundary values on the inner and outer radial surfaces.
Geodynamo.enforce_velocity_boundary_values!
— Methodenforce_velocity_boundary_values!(fields)
Anchor toroidal and poloidal spectral coefficients to the currently cached Dirichlet boundary values on the inner and outer radial surfaces.
Geodynamo.erk2_stage_residual_stats
— Methoderk2_stage_residual_stats(buffers) -> NamedTuple
Compute diagnostic statistics for the difference between stage nonlinear terms and the base-step nonlinear terms.
Geodynamo.estimate_memory_usage
— Methodestimate_memory_usage(pencils, field_count::Int, precision::Type)
Estimate memory usage for given pencil configuration.
Geodynamo.estimate_memory_usage_shtnskit
— Methodestimate_memory_usage_shtnskit(nlat, nlon, lmax, field_count, T)
Estimate memory usage for SHTnsKit-based transforms with PencilArrays.
Geodynamo.evaluate_chebyshev_derivative
— Methodevaluate_chebyshev_derivative(n::Int, r::T, domain::RadialDomain) where T
Evaluate derivative of Chebyshev polynomial at a point.
Geodynamo.evaluate_tau_derivative_inner
— Methodevaluate_tau_derivative_inner(tau::Vector, domain::RadialDomain)
Evaluate tau function derivative at inner boundary.
Geodynamo.evaluate_tau_derivative_outer
— Methodevaluate_tau_derivative_outer(tau::Vector, domain::RadialDomain)
Evaluate tau function derivative at outer boundary.
Geodynamo.exchange_dimension_halos!
— Methodexchange_dimension_halos!(data::Array, pencil::Pencil, dim::Int,
halo_width::Int, boundaries::Symbol, comm::MPI.Comm)
Perform halo exchange along a specific dimension using MPI point-to-point communication.
Geodynamo.exp_action_krylov
— Methodexp_action_krylov(Aop!, v, dt; m=20, tol=1e-8) -> y ≈ exp(dt A) v
Simple Arnoldi-based approximation of the exponential action.
Geodynamo.extract_coefficients_for_shtnskit!
— Methodextract_coefficients_for_shtnskit!(coeffs_buffer, spec_real, spec_imag, r_local, config)
Extract spectral coefficients in format expected by SHTnsKit using pre-allocated buffer.
Geodynamo.extract_local_radial_profile!
— Methodextract_local_radial_profile!(profile, data, local_lm, nr, r_range)
In-place version to avoid allocations; writes the local radial line into profile
for the given local_lm
using the provided r_range
.
Geodynamo.extract_physical_slice_generic!
— Methodextract_physical_slice_generic!(slice_buffer, phys_data, r_local, config)
Generic extraction for any pencil orientation using pre-allocated buffer.
Geodynamo.extract_physical_slice_phi_local!
— Methodextract_physical_slice_phi_local!(slice_buffer, phys_data, r_local, config)
Extract physical slice when in phi-local pencil using pre-allocated buffer.
Geodynamo.extract_spectral_subset
— Methodextract_spectral_subset(field::SHTnsSpectralField{T}; l_max::Int = 10) where T
Extract a subset of spectral modes for analysis.
Geodynamo.extract_vector_component_generic!
— Methodextract_vector_component_generic!(component_buffer, v_data, r_local, config)
Generic extraction for vector components using pre-allocated buffer.
Geodynamo.find_distributed_files
— Functionfind_distributed_files(output_dir::String, time::Float64, filename_prefix::String = "geodynamo")
Find all distributed files for a specific simulation time.
Geodynamo.find_package_root
— Methodfind_package_root()
Find the root directory of the Geodynamo.jl package.
Geodynamo.get_comm
— Methodget_comm()
Get MPI communicator, initializing MPI if needed. Provides thread-safe lazy initialization.
Geodynamo.get_dimension_neighbors
— Methodget_dimension_neighbors(pencil::Pencil, dim::Int, boundaries::Symbol) -> (Int, Int)
Get left and right neighbor process ranks for a given dimension. Returns (leftneighbor, rightneighbor) where MPI.MPIPROCNULL indicates no neighbor.
Geodynamo.get_eab2_alu_cache!
— Methodget_eab2_alu_cache!(caches, key, ν, T, domain) -> Dict{Int,Tuple{BandedMatrix{T},BandedLU{T}}}
Retrieve or initialize a cache mapping l -> (Abanded, LU(Abanded)) for EAB2. Reinitializes if ν or nr changed.
Geodynamo.get_erk2_cache!
— Methodget_erk2_cache!(caches, key, diffusivity, config, domain, dt; use_krylov=false)
Retrieve or create ERK2 cache with automatic invalidation when parameters change.
Geodynamo.get_flux_value
— Methodget_flux_value(lm_idx::Int, boundary::Int, field::AbstractScalarField)
Get prescribed flux value for given mode and boundary from scalar field. This is a generic version that works with any scalar field.
Geodynamo.get_nprocs
— Methodget_nprocs()
Get total number of MPI processes.
Geodynamo.get_parameters
— Methodget_parameters()
Get the current global parameters. If not set, loads default parameters.
Geodynamo.get_pencil_orientation
— Methodget_pencil_orientation(pencil::Pencil{3}) -> Symbol
Get the orientation of a pencil (which dimensions are local).
Geodynamo.get_process_dimensions
— Methodget_process_dimensions(topology) -> Tuple
Extract process grid dimensions from topology.
Geodynamo.get_rank
— Methodget_rank()
Get MPI rank of current process.
Geodynamo.get_shtnskit_performance_stats
— Methodget_shtnskit_performance_stats()
Get performance statistics for SHTnsKit transforms with PencilArrays.
Geodynamo.hybrid_compute_nonlinear!
— Methodhybrid_compute_nonlinear!(parallelizer, temp_field, vel_fields, domain)
Compute nonlinear terms using hybrid MPI+threading parallelism.
Geodynamo.index_to_lm_shtnskit
— Methodindex_to_lm_shtnskit(idx, lmax, mmax) -> (l, m)
Convert linear index to (l,m) for SHTnsKit compatibility.
Geodynamo.infer_pencils_from_transpose_name
— Methodinfer_pencils_from_transpose_name(name::Symbol, plan) -> (src_pencil, dest_pencil)
Infer source and destination pencils from transpose operation name and plan. For TransposeOperator, we need to extract pencil info from context since the operator itself doesn't expose src/dest pencils directly.
Geodynamo.initialize_enhanced_simulation
— Methodinitialize_enhanced_simulation(::Type{T}=Float64; kwargs...)
Initialize simulation with all parallelization features enabled.
Geodynamo.initialize_parameters
— Functioninitialize_parameters(config_file::String = "")
Initialize the global parameter system.
Geodynamo.initialize_simulation
— Methodinitialize_master_simulation(::Type{T}=Float64; kwargs...)
Initialize simulation with comprehensive CPU parallelization.
Geodynamo.install_erk2_cache_bundle!
— Methodinstall_erk2_cache_bundle!(target, bundle)
Copy ERK2 caches from bundle
into the target cache dictionary.
Geodynamo.list_available_times
— Functionlist_available_times(output_dir::String, filename_prefix::String = "geodynamo")
List all available simulation times in the output directory.
Geodynamo.load_distributed_fields!
— Methodload_distributed_fields!(combiner::FieldCombiner{T}) where T
Load field data from all distributed files into the combiner structure.
Geodynamo.load_erk2_cache_bundle!
— Methodload_erk2_cache_bundle!(target, path) -> metadata
Load caches from path
and install them into target
, returning metadata.
Geodynamo.load_erk2_cache_bundle
— Methodload_erk2_cache_bundle(path) -> (caches, metadata)
Load ERK2 caches and associated metadata from disk.
Geodynamo.load_parameters
— Functionload_parameters(config_file::String = "")
Load parameters from a configuration file. If no file is specified, loads from the default config/default_params.jl file.
Arguments
config_file::String
: Path to parameter file (optional)
Returns
GeodynamoParameters
: Loaded parameters
Geodynamo.load_parameters_from_file
— Methodload_parameters_from_file(config_file::String)
Load parameters from a Julia file containing parameter definitions.
Geodynamo.load_physical_temperature!
— Methodload_physical_temperature!(field::SHTnsPhysicalField{T}, nc_file, var_name::String) where T
Load physical space temperature data from NetCDF file.
Geodynamo.load_single_file!
— Methodload_single_file!(combiner::FieldCombiner{T}, filename::String) where T
Load data from a single file (no combination needed).
Geodynamo.load_single_spectral_field!
— Methodload_single_spectral_field!(field::SHTnsSpectralField{T}, nc_file,
real_var::String, imag_var::String) where T
Load a single spectral field from NetCDF file.
Geodynamo.load_spectral_coefficients!
— Methodload_spectral_coefficients!(field::SHTnsSpectralField{T}, nc_file,
real_var_name::String, imag_var_name::String,
l_values::Vector{Int}, m_values::Vector{Int},
r_spectral::Vector{Float64}) where T
Load spectral coefficients from NetCDF file into a spectral field structure.
Geodynamo.load_spectral_data!
— Methodload_spectral_data!(converter::SpectralToPhysicalConverter{T}, filename::String) where T
Load spectral field data from NetCDF file into Geodynamo field structures.
Geodynamo.main_batch_convert
— Methodmain_batch_convert(input_dir::String; kwargs...)
Main entry point for batch conversion of files.
Geodynamo.main_combine_time
— Methodmain_combine_time(output_dir::String, time::Float64; kwargs...)
Main entry point for combining distributed files for a single time.
Geodynamo.main_combine_time_series
— Methodmain_combine_time_series(output_dir::String, time_range::Tuple{Float64,Float64}; kwargs...)
Main entry point for combining time series.
Geodynamo.main_convert_file
— Methodmain_convert_file(filename::String; kwargs...)
Main entry point for converting a single file.
Geodynamo.map_spectral_coefficients!
— Methodmap_spectral_coefficients!(global_tor_real, global_tor_imag, global_pol_real, global_pol_imag,
local_tor_real, local_tor_imag, local_pol_real, local_pol_imag,
local_l, local_m, lm_mapping)
Map local spectral coefficients to global arrays using (l,m) index mapping.
Geodynamo.maybe_log_erk2_stage_residual!
— Methodmaybe_log_erk2_stage_residual!(label, buffers, step)
Emit a diagnostic log entry when ERK2 diagnostics are enabled.
Geodynamo.modify_for_flux_inner!
— Methodmodify_for_flux_inner!(spec_real, spec_imag, local_lm, prescribed_flux,
dr_matrix, domain, r_range)
Modify coefficients near inner boundary to approximate flux condition. Uses low-order extrapolation.
Geodynamo.modify_for_flux_outer!
— Methodmodify_for_flux_outer!(spec_real, spec_imag, local_lm, prescribed_flux,
dr_matrix, domain, r_range)
Modify coefficients near outer boundary to approximate flux condition. Uses low-order extrapolation.
Geodynamo.normalize_influence_function!
— Methodnormalize_influence_function!(G::Vector{T}, domain::RadialDomain, which_boundary::Int) where T
Normalize influence function to have unit flux at the specified boundary.
Geodynamo.optimize_communication_order
— Methodoptimize_communication_order(plans::Dict)
Determine optimal order for transpose operations to minimize communication.
Geodynamo.optimize_erk2_transforms!
— Methodoptimize_erk2_transforms!(config::SHTnsKitConfig)
Optimize SHTnsKit transforms for ERK2 timestepping with PencilFFTs. This function pre-warms transform plans and optimizes memory layout.
Geodynamo.optimize_fft_performance!
— Methodoptimize_fft_performance!(config::SHTnsKitConfig)
Optimize PencilFFTs performance by warming up plans and checking efficiency.
Geodynamo.optimize_field_data_layout!
— Methodoptimize_field_data_layout!(field_data::Dict, field_info::FieldInfo)
Optimize data layout for output based on pencil decomposition
Geodynamo.optimize_magnetic_memory_layout!
— Methodoptimize_magnetic_memory_layout!(mag_fields::SHTnsMagneticFields{T}) where T
Optimize memory layout for better cache performance using pencil topology
Geodynamo.optimize_process_topology
— Methodoptimize_process_topology(nprocs::Int, dims::Tuple{Int,Int,Int})
Find optimal 2D process grid for given number of processes and problem dimensions. Minimizes communication volume.
Geodynamo.optimize_process_topology_shtnskit
— Methodoptimize_process_topology_shtnskit(nprocs, nlat, nlon)
Optimize MPI process topology for theta-phi parallelization.
Geodynamo.optimize_velocity_memory_layout!
— Methodoptimize_velocity_memory_layout!(fields::SHTnsVelocityFields{T}) where T
Optimize memory layout for better cache performance using pencil topology
Geodynamo.perform_analysis_direct!
— Methodperform_analysis_direct!(phys, spec, config)
Direct analysis without transpose (fallback).
Geodynamo.perform_analysis_from_phi_pencil!
— Methodperform_analysis_from_phi_pencil!(phys_phi, spec, config)
Perform analysis from phi-pencil data.
Geodynamo.perform_analysis_phi_local!
— Methodperform_analysis_phi_local!(phys, spec, config)
Perform analysis when physical field is in phi-pencil (phi is local).
Geodynamo.perform_analysis_with_transpose!
— Methodperform_analysis_with_transpose!(phys, spec, config, to_phi_plan)
Perform analysis with transpose to phi-pencil.
Geodynamo.perform_synthesis_direct!
— Methodperform_synthesis_direct!(spec, phys, config)
Direct synthesis without transpose (fallback method).
Geodynamo.perform_synthesis_phi_local!
— Methodperform_synthesis_phi_local!(spec, phys, config)
Perform synthesis when physical field is already in phi-pencil (phi is local).
Geodynamo.perform_synthesis_to_phi_pencil!
— Methodperform_synthesis_to_phi_pencil!(spec, phys_phi, config)
Perform synthesis directly to phi-pencil array.
Geodynamo.perform_synthesis_with_transpose!
— Methodperform_synthesis_with_transpose!(spec, phys, config, back_plan)
Perform synthesis with transpose to phi-pencil for optimal FFT performance.
Geodynamo.phi1_action_krylov
— Methodphi1_action_krylov(BA, LU_A, v, dt; m=20, tol=1e-8) -> y ≈ φ1(dt A) v
Compute φ1(dt A) v = A^{-1}[(exp(dt A) − I) v]/dt using Krylov exp(action) and banded solve.
Geodynamo.print_pencil_axes
— Methodprint_pencil_axes(pencils)
Print the axes_local
tuple for each pencil, showing the local index ranges for all three axes. This helps verify which axes are distributed (those with nontrivial subranges across ranks) and which axis is contiguous locally.
Geodynamo.print_pencil_info
— Methodprint_pencil_info(pencils)
Print detailed information about pencil decomposition.
Geodynamo.print_shtnskit_config_summary
— Methodprint_shtnskit_config_summary(nlat, nlon, lmax, mmax, nlm, nprocs, memory_estimate)
Print configuration summary for SHTnsKit setup.
Geodynamo.print_transpose_statistics
— Methodprint_transpose_statistics()
Print accumulated transpose timing statistics.
Geodynamo.read_distributed_metadata
— Methodread_distributed_metadata(filename::String)
Read metadata from a distributed NetCDF file to determine global configuration.
Geodynamo.read_file_metadata
— Methodread_file_metadata(filename::String)
Read metadata from NetCDF file to determine grid configuration.
Geodynamo.run_enhanced_simulation!
— Methodrun_enhanced_simulation!(state::SimulationState{T})
Run geodynamo simulation with all parallelization optimizations.
Geodynamo.run_simulation!
— Methodrun_master_simulation!(state::SimulationState{T})
Run geodynamo simulation with maximum CPU parallelization optimizations.
Geodynamo.save_combined_fields
— Methodsave_combined_fields(combiner::FieldCombiner{T}, output_filename::String;
config::CombinerConfig = create_combiner_config()) where T
Save combined fields to NetCDF file using Geodynamo I/O system.
Geodynamo.save_combined_time_series
— Methodsave_combined_time_series(combiners::Vector{FieldCombiner{T}}, output_dir::String,
filename_prefix::String;
config::CombinerConfig = create_combiner_config()) where T
Save combined time series to a single NetCDF file.
Geodynamo.save_erk2_cache_bundle
— Methodsave_erk2_cache_bundle(path, caches; metadata=Dict())
Persist a dictionary of ERK2 caches to disk along with optional metadata.
Geodynamo.save_parameters
— Methodsave_parameters(params::GeodynamoParameters, filename::String)
Save parameters to a Julia file.
Geodynamo.save_physical_fields
— Methodsave_physical_fields(converter::SpectralToPhysicalConverter{T}, output_filename::String) where T
Save converted physical space fields to NetCDF file using parallel I/O.
Geodynamo.set_parameters!
— Methodset_parameters!(params::GeodynamoParameters)
Set the global parameters.
Geodynamo.set_velocity_workspace!
— Methodset_velocity_workspace!(ws)
Register a global VelocityWorkspace to be used by velocity kernels when available. Pass nothing
to disable and fall back to internal buffers.
Geodynamo.setup_shtns_metadata!
— Methodsetup_shtns_metadata!(nc_file, shtns_config::SHTnsKitConfig, pencils::NamedTuple)
Add SHTns-specific metadata to NetCDF file
Geodynamo.shtnskit_physical_to_spectral!
— Methodshtnskit_physical_to_spectral!(phys::SHTnsPhysicalField{T},
spec::SHTnsSpectralField{T}) where T
Transform from physical to spectral space using SHTnsKit with PencilArrays.
Geodynamo.shtnskit_spectral_to_physical!
— Methodshtnskit_spectral_to_physical!(spec::SHTnsSpectralField{T},
phys::SHTnsPhysicalField{T}) where T
Transform from spectral to physical space using SHTnsKit with PencilArrays/PencilFFTs.
Geodynamo.shtnskit_vector_analysis!
— Methodshtnskit_vector_analysis!(vec_phys::SHTnsVectorField{T},
tor_spec::SHTnsSpectralField{T},
pol_spec::SHTnsSpectralField{T}) where T
Vector analysis using SHTnsKit with PencilArrays.
Geodynamo.shtnskit_vector_synthesis!
— Methodshtnskit_vector_synthesis!(tor_spec::SHTnsSpectralField{T},
pol_spec::SHTnsSpectralField{T},
vec_phys::SHTnsVectorField{T}) where T
Vector synthesis using SHTnsKit spheroidal-toroidal decomposition with PencilArrays.
Geodynamo.store_coefficients_from_shtnskit!
— Methodstore_coefficients_from_shtnskit!(spec_real, spec_imag, coeffs_matrix, r_local, config)
Store coefficients from SHTnsKit format back to spectral field.
Geodynamo.store_physical_slice_generic!
— Methodstore_physical_slice_generic!(phys_data, phys_slice, r_local, config)
Generic storage for any pencil orientation.
Geodynamo.store_physical_slice_phi_local!
— Methodstore_physical_slice_phi_local!(phys_data, phys_slice, r_local, config)
Store physical slice when in phi-local pencil.
Geodynamo.store_vector_components_generic!
— Methodstore_vector_components_generic!(v_theta, v_phi, vt_field, vp_field, r_local, config)
Store vector components for any pencil orientation.
Geodynamo.synchronize_halos!
— Methodsynchronize_halos!(arr::PencilArray; halo_width::Int=1, boundaries::Symbol=:all)
Synchronize ghost/halo regions for parallel finite difference computations.
Parameters
arr
: PencilArray to synchronizehalo_width
: Width of halo region (number of ghost cells), default 1boundaries
: Boundary handling (:all, :periodic, :nonperiodic), default :all
Notes
This function implements MPI point-to-point communication to exchange boundary data between neighboring processes in each decomposed dimension. It's essential for maintaining accuracy in finite difference stencil operations near subdomain boundaries.
For spectral methods, explicit halo exchange may not be needed as the global nature of spectral transforms handles boundary coupling through transpose operations.
Geodynamo.synchronize_pencil_data!
— Methodsynchronize_pencil_data!(field)
Synchronize PencilArray data across MPI processes to ensure consistency.
Geodynamo.synchronize_pencil_transforms!
— Methodsynchronize_pencil_transforms!(field::SHTnsSpectralField{T}) where T
Ensure all pending PencilFFTs operations are completed and data is consistent across processes.
Geodynamo.test_halo_exchange
— Methodtest_halo_exchange(pencil::Pencil, ::Type{T}=Float64; halo_width::Int=1, verbose::Bool=true) where T
Test halo exchange functionality by creating a test array with rank-based values. Returns true if halo exchange is working correctly.
Example
pencils = create_pencil_topology(shtns_config)
test_halo_exchange(pencils.θ, Float64; halo_width=1, verbose=true)
Geodynamo.transform_field_and_gradients_to_physical!
— Methodtransform_field_and_gradients_to_physical!(field::AbstractScalarField{T}) where T
Transform scalar field and all gradient components to physical space in a single batched operation to minimize communication.
Geodynamo.transpose_with_timer!
— Functiontranspose_with_timer!(dest, src, plan, label="")
Perform transpose with optional timing and statistics.
Geodynamo.update_derived_parameters!
— Methodupdate_derived_parameters!(params::GeodynamoParameters)
Update derived parameters based on primary parameters.
Geodynamo.update_global_parameters!
— Methodupdate_global_parameters!()
Update all global parameter variables with values from the current parameter struct.
Geodynamo.validate_magnetic_configuration
— Methodvalidate_magnetic_configuration(mag_fields::SHTnsMagneticFields{T}, config::SHTnsKitConfig) where T
Validate magnetic field configuration consistency with SHTns setup
Geodynamo.validate_mpi_consistency!
— Methodvalidate_mpi_consistency!(field::SHTnsSpectralField{T}) where T
Check that spectral field data is consistent across MPI processes after time stepping.
Geodynamo.validate_output_compatibility
— Methodvalidate_output_compatibility(field_info::FieldInfo, shtns_config::SHTnsKitConfig)
Validate that output field information is compatible with SHTns configuration
Geodynamo.validate_pencil_decomposition
— Methodvalidate_pencil_decomposition(config::SHTnsKitConfig)
Validate that pencil decomposition is optimal for the problem size and MPI configuration.
Geodynamo.validate_velocity_configuration
— Methodvalidate_velocity_configuration(fields::SHTnsVelocityFields{T}, config::SHTnsKitConfig) where T
Validate velocity field configuration consistency with SHTns setup
Geodynamo.write_enhanced_coordinates!
— Methodwrite_enhanced_coordinates!(nc_file, field_info::FieldInfo, config::OutputConfig)
Write coordinates with enhanced precision and metadata from SHTns config
Geodynamo.write_grid_file!
— Methodwrite_grid_file!(config::OutputConfig, field_info::FieldInfo,
shtns_config::Union{SHTnsKitConfig,Nothing},
metadata::Dict{String,Any})
Write a separate grid file containing all coordinate and grid information. This is written only once by rank 0 at the start of the simulation.
Geodynamo.write_single_spectral_component!
— Methodwrite_single_spectral_component!(nc_file, component, field_data, config)
Write a single spectral component with enhanced memory handling
Geodynamo.write_spectral_data_parallel!
— Methodwrite_spectral_data_parallel!(nc_file, real_name, imag_name, real_data, imag_data, field_info)
Write spectral data using parallel I/O strategies based on pencil decomposition
Geodynamo.zero_scalar_work_arrays!
— Methodzero_scalar_work_arrays!(field::AbstractScalarField{T}) where T
Efficiently zero all work arrays for a scalar field.
Boundary Conditions
Geodynamo.BoundaryConditions.AbstractBoundaryCondition
— TypeAbstractBoundaryCondition{T}
Abstract base type for all boundary conditions.
Geodynamo.BoundaryConditions.BoundaryCache
— TypeBoundaryCache{T}
Cache structure for storing processed boundary data.
Geodynamo.BoundaryConditions.BoundaryConditionSet
— TypeBoundaryConditionSet{T}
Complete set of boundary conditions for inner and outer boundaries.
Geodynamo.BoundaryConditions.BoundaryData
— TypeBoundaryData{T}
Common data structure for boundary condition data from any source.
Geodynamo.BoundaryConditions.BoundaryLocation
— TypeBoundaryLocation
Enumeration for boundary locations.
Geodynamo.BoundaryConditions.BoundaryType
— TypeBoundaryType
Enumeration for boundary condition types.
Geodynamo.BoundaryConditions.FieldType
— TypeFieldType
Enumeration for different physical field types.
Geodynamo.BoundaryConditions.add_noise_to_boundary
— Functionadd_noise_to_boundary(boundary_data::BoundaryData, noise_amplitude::Real,
noise_type::Symbol=:gaussian)
Add noise to existing boundary data.
Geodynamo.BoundaryConditions.apply_boundary_conditions!
— Methodapply_boundary_conditions!(field, field_type::FieldType, solver_state)
Apply boundary conditions during solver operations.
This function integrates boundary conditions with the timestepping and solving process.
Geodynamo.BoundaryConditions.apply_boundary_conditions_to_rhs!
— Methodapply_boundary_conditions_to_rhs!(rhs, state, field_type::FieldType)
Apply boundary conditions to right-hand side during timestepping.
This function modifies the RHS vector to enforce boundary conditions during implicit and explicit timestepping methods.
Geodynamo.BoundaryConditions.apply_composition_bc_to_rhs!
— Methodapply_composition_bc_to_rhs!(rhs, comp_field)
Apply composition boundary conditions to RHS vector.
Geodynamo.BoundaryConditions.apply_composition_boundaries!
— Methodapply_composition_boundaries!(comp_field, boundary_set::BoundaryConditionSet; time::Float64=0.0)
Apply composition boundary conditions from a BoundaryConditionSet to a composition field. This is a convenience wrapper that loads the boundary set and applies it.
Geodynamo.BoundaryConditions.apply_composition_boundary_conditions!
— Functionapply_composition_boundary_conditions!(comp_field, time_index::Int=1)
Apply composition boundary conditions to the field.
Geodynamo.BoundaryConditions.apply_gaussian_smoothing!
— Methodapply_gaussian_smoothing!(data::AbstractMatrix, theta::Vector, phi::Vector, radius::Real)
Apply Gaussian smoothing kernel to 2D data array.
Geodynamo.BoundaryConditions.apply_magnetic_bc_to_rhs!
— Methodapply_magnetic_bc_to_rhs!(rhs, magnetic_field)
Apply magnetic field boundary conditions to RHS vector.
Geodynamo.BoundaryConditions.apply_magnetic_boundary_conditions!
— Functionapply_magnetic_boundary_conditions!(magnetic_field, time_index::Int=1)
Apply magnetic field boundary conditions to the field.
Geodynamo.BoundaryConditions.apply_temperature_bc_to_rhs!
— Methodapply_temperature_bc_to_rhs!(rhs, temp_field)
Apply temperature boundary conditions to RHS vector.
Geodynamo.BoundaryConditions.apply_temperature_boundaries!
— Methodapply_temperature_boundaries!(temp_field, boundary_set::BoundaryConditionSet; time::Float64=0.0)
Apply temperature boundary conditions from a BoundaryConditionSet to a temperature field. This is a convenience wrapper that loads the boundary set and applies it.
Geodynamo.BoundaryConditions.apply_temperature_boundary_conditions!
— Functionapply_temperature_boundary_conditions!(temp_field, time_index::Int=1)
Apply temperature boundary conditions to the field.
Geodynamo.BoundaryConditions.apply_velocity_bc_to_rhs!
— Methodapply_velocity_bc_to_rhs!(rhs, velocity_field)
Apply velocity boundary conditions to RHS vector.
Geodynamo.BoundaryConditions.apply_velocity_boundary_conditions!
— Functionapply_velocity_boundary_conditions!(velocity_field, time_index::Int=1)
Apply velocity boundary conditions to the field.
Geodynamo.BoundaryConditions.bilinear_interpolate
— Methodbilinear_interpolate(data::Matrix{T}, theta_idx::Tuple{Int, Int}, phi_idx::Tuple{Int, Int},
theta_weights::Tuple{T, T}, phi_weights::Tuple{T, T}) where T
Perform bilinear interpolation on a 2D data array. Handles periodic boundary conditions in phi direction.
Geodynamo.BoundaryConditions.cache_boundary_data!
— Methodcache_boundary_data!(cache::BoundaryCache{T}, key::String, data::Array{T}) where T
Cache processed boundary data.
Geodynamo.BoundaryConditions.calculate_potential_field_boundary
— Methodcalculate_potential_field_boundary(coeffs::Dict, theta::Vector, phi::Vector, lmax::Int)
Calculate magnetic field from spherical harmonic coefficients of the potential.
Geodynamo.BoundaryConditions.check_interpolation_bounds
— Methodcheck_interpolation_bounds(boundary_data::BoundaryData, target_theta::Vector{T},
target_phi::Vector{T}) where T
Check if target grid is within the bounds of the source grid and warn if extrapolation is needed.
Geodynamo.BoundaryConditions.clear_boundary_cache!
— Methodclear_boundary_cache!(cache::BoundaryCache)
Clear all cached boundary data.
Geodynamo.BoundaryConditions.combine_programmatic_patterns
— Methodcombine_programmatic_patterns(patterns::Vector{Tuple{Symbol, Real}}, config;
parameters::Vector{Dict}=Dict[], description::String="")
Combine multiple programmatic patterns with different amplitudes.
Geodynamo.BoundaryConditions.compute_boundary_condition_residual
— Methodcompute_boundary_condition_residual(field, field_type::FieldType)
Compute residual to check how well boundary conditions are satisfied.
Returns a measure of how much the current field violates the boundary conditions. Useful for monitoring solution quality and debugging.
Geodynamo.BoundaryConditions.copy_boundary_conditions!
— Methodcopy_boundary_conditions!(dest_field, src_field, field_type::FieldType)
Copy boundary conditions from one field to another.
Geodynamo.BoundaryConditions.create_boundary_data
— Methodcreate_boundary_data(values::Array{T}, field_type::String;
theta=nothing, phi=nothing, time=nothing,
units="", description="", file_path="programmatic") where T
Create a BoundaryData structure from raw data.
Geodynamo.BoundaryConditions.create_composition_interpolation_cache
— Methodcreate_composition_interpolation_cache(boundary_set::BoundaryConditionSet, config)
Create interpolation cache for composition boundaries.
Geodynamo.BoundaryConditions.create_hybrid_composition_boundaries
— Methodcreate_hybrid_composition_boundaries(file_spec::String, prog_spec::Tuple, config; swap_boundaries=false)
Create hybrid composition boundaries (one from file, one programmatic).
Geodynamo.BoundaryConditions.create_hybrid_magnetic_boundaries
— Methodcreate_hybrid_magnetic_boundaries(file_spec::String, prog_spec::Tuple, config; swap_boundaries=false)
Create hybrid magnetic boundaries (one from file, one programmatic).
Geodynamo.BoundaryConditions.create_hybrid_temperature_boundaries
— Methodcreate_hybrid_temperature_boundaries(file_spec::String, prog_spec::Tuple, config; swap_boundaries=false)
Create hybrid temperature boundaries (one from file, one programmatic).
Geodynamo.BoundaryConditions.create_hybrid_velocity_boundaries
— Methodcreate_hybrid_velocity_boundaries(file_spec::String, prog_spec::Tuple, config; swap_boundaries=false)
Create hybrid velocity boundaries (one from file, one programmatic).
Geodynamo.BoundaryConditions.create_interpolation_cache
— Methodcreate_interpolation_cache(boundary_data::BoundaryData, target_theta::Vector{T},
target_phi::Vector{T}) where T
Create interpolation cache for efficient repeated interpolations.
Geodynamo.BoundaryConditions.create_layered_composition_boundary
— Methodcreate_layered_composition_boundary(config, layer_specs::Vector{Tuple{Real, Real, Real}})
Create layered composition boundary conditions.
Arguments
layer_specs
: Vector of (colatitudestart, colatitudeend, composition) tuples
Example
# Create three-layer composition structure
layer_specs = [
(0.0, π/3, 0.8), # High composition in top layer
(π/3, 2π/3, 0.4), # Medium composition in middle layer
(2π/3, π, 0.1) # Low composition in bottom layer
]
Geodynamo.BoundaryConditions.create_layered_temperature_boundary
— Methodcreate_layered_temperature_boundary(config, layer_specs::Vector{Tuple{Real, Real, Real}})
Create layered temperature boundary conditions.
Arguments
layer_specs
: Vector of (colatitudestart, colatitudeend, temperature) tuples
Example
# Create three-layer temperature structure
layer_specs = [
(0.0, π/3, 1000.0), # High temperature in top layer
(π/3, 2π/3, 500.0), # Medium temperature in middle layer
(2π/3, π, 100.0) # Low temperature in bottom layer
]
Geodynamo.BoundaryConditions.create_magnetic_interpolation_cache
— Methodcreate_magnetic_interpolation_cache(boundary_set::BoundaryConditionSet, config)
Create interpolation cache for magnetic boundaries.
Geodynamo.BoundaryConditions.create_programmatic_boundary
— Functioncreate_programmatic_boundary(pattern::Symbol, config, amplitude::Real=1.0;
parameters::Dict=Dict(), description::String="")
Create programmatically generated boundary conditions.
Available patterns:
:uniform
- Uniform value:y11
- Y₁₁ spherical harmonic:plume
- Gaussian plume pattern:hemisphere
- Hemispherical pattern:dipole
- Dipolar pattern (Y₁₀):quadrupole
- Quadrupolar pattern:custom
- User-defined function
Geodynamo.BoundaryConditions.create_programmatic_composition_boundaries
— Methodcreate_programmatic_composition_boundaries(inner_spec::Tuple, outer_spec::Tuple, config)
Create fully programmatic composition boundaries.
Geodynamo.BoundaryConditions.create_programmatic_magnetic_boundaries
— Methodcreate_programmatic_magnetic_boundaries(inner_spec::Tuple, outer_spec::Tuple, config)
Create fully programmatic magnetic boundaries.
Geodynamo.BoundaryConditions.create_programmatic_magnetic_boundary
— Functioncreate_programmatic_magnetic_boundary(pattern::Symbol, config, amplitude::Real=1.0;
parameters::Dict=Dict())
Create programmatically generated magnetic boundary conditions.
Available patterns:
:insulating
- Insulating boundary (Br = 0, ∂Btan/∂r = 0):perfect_conductor
- Perfect conductor (B_tan = 0):dipole
- Dipolar magnetic field pattern:quadrupole
- Quadrupolar magnetic field pattern:potential_field
- Potential field from spherical harmonic coefficients:uniform_field
- Uniform magnetic field:custom
- User-defined magnetic field function
Geodynamo.BoundaryConditions.create_programmatic_temperature_boundaries
— Methodcreate_programmatic_temperature_boundaries(inner_spec::Tuple, outer_spec::Tuple, config)
Create fully programmatic temperature boundaries.
Geodynamo.BoundaryConditions.create_programmatic_velocity_boundaries
— Methodcreate_programmatic_velocity_boundaries(inner_spec::Tuple, outer_spec::Tuple, config)
Create fully programmatic velocity boundaries.
Geodynamo.BoundaryConditions.create_programmatic_velocity_boundary
— Functioncreate_programmatic_velocity_boundary(pattern::Symbol, config, amplitude::Real=1.0;
parameters::Dict=Dict())
Create programmatically generated velocity boundary conditions.
Available patterns:
:no_slip
- Zero velocity at boundary (amplitude ignored):stress_free
- Zero stress at boundary (amplitude ignored):uniform_rotation
- Uniform rotation with angular velocity amplitude:differential_rotation
- Differential rotation pattern:zonal_flow
- Zonal (east-west) flow pattern:meridional_flow
- Meridional (north-south) flow pattern:custom
- User-defined velocity function
Geodynamo.BoundaryConditions.create_temperature_interpolation_cache
— Methodcreate_temperature_interpolation_cache(boundary_set::BoundaryConditionSet, config)
Create interpolation cache for temperature boundaries.
Geodynamo.BoundaryConditions.create_time_dependent_programmatic_boundary
— Methodcreate_time_dependent_programmatic_boundary(pattern::Symbol, config, time_span::Tuple{Real, Real},
ntime::Int; amplitude::Real=1.0,
parameters::Dict=Dict(), description::String="",
field_type::String="temperature")
Create time-dependent programmatically generated boundary conditions.
Geodynamo.BoundaryConditions.create_velocity_interpolation_cache
— Methodcreate_velocity_interpolation_cache(boundary_set::BoundaryConditionSet, config)
Create interpolation cache for velocity boundaries.
Geodynamo.BoundaryConditions.determine_field_type_from_name
— Methoddetermine_field_type_from_name(field_name::String) -> FieldType
Determine field type from field name string.
Geodynamo.BoundaryConditions.enforce_boundary_conditions_in_solution!
— Methodenforce_boundary_conditions_in_solution!(solution, state, field_type::FieldType)
Enforce boundary conditions in the solution vector after timestepping.
This function ensures that the solution satisfies the boundary conditions after each timestep, which may be necessary for certain discretization schemes.
Geodynamo.BoundaryConditions.enforce_composition_bc_in_solution!
— Methodenforce_composition_bc_in_solution!(solution, comp_field)
Enforce composition boundary conditions in solution vector.
Geodynamo.BoundaryConditions.enforce_magnetic_bc_in_solution!
— Methodenforce_magnetic_bc_in_solution!(solution, magnetic_field)
Enforce magnetic field boundary conditions in solution vector.
Geodynamo.BoundaryConditions.enforce_magnetic_boundary_constraints!
— Methodenforce_magnetic_boundary_constraints!(magnetic_field, bc_type::Symbol)
Enforce magnetic boundary condition constraints based on physics.
Boundary condition types:
:insulating
- Insulating boundary: Jnormal = 0, ∇×Btangential = 0 (B_r ≠ 0):perfect_conductor
- Perfect conductor: Btangential = 0, Br free:potential_field
- Potential field matching at boundary
Geodynamo.BoundaryConditions.enforce_temperature_bc_in_solution!
— Methodenforce_temperature_bc_in_solution!(solution, temp_field)
Enforce temperature boundary conditions in solution vector.
Geodynamo.BoundaryConditions.enforce_velocity_bc_in_solution!
— Methodenforce_velocity_bc_in_solution!(solution, velocity_field)
Enforce velocity boundary conditions in solution vector.
Geodynamo.BoundaryConditions.enforce_velocity_boundary_constraints!
— Functionenforce_velocity_boundary_constraints!(velocity_field, bc_type::Symbol=:no_slip)
Enforce specific velocity boundary constraints based on boundary condition type. Uses proper QST (Q-spheroidal-toroidal) decomposition from SHTnsKit.
Arguments
velocity_field
: Velocity field structure with QST componentsbc_type
: Type of boundary condition (:noslip, :stressfree, :custom)
Boundary Condition Mapping:
- No-slip: vr = vθ = v_φ = 0 → Q = S = T = 0 at boundaries
- Stress-free: v_r = 0, tangential stress = 0 → Q = 0, ∂S/∂r = ∂T/∂r = 0
- Impermeable: v_r = 0 → Q = 0 at boundaries (S, T unconstrained)
Geodynamo.BoundaryConditions.estimate_interpolation_error
— Methodestimate_interpolation_error(boundary_data::BoundaryData, target_theta::Vector{T},
target_phi::Vector{T}) where T
Estimate interpolation error based on grid resolution differences.
Geodynamo.BoundaryConditions.find_composition_boundary_time_index
— Methodfind_composition_boundary_time_index(boundary_set::BoundaryConditionSet, current_time::Float64)
Find the appropriate time index for the current simulation time.
Geodynamo.BoundaryConditions.find_grid_indices
— Methodfind_grid_indices(coords::Vector{T}, target::T; is_periodic::Bool=false) where T
Find the two surrounding indices in a coordinate array for interpolation. Handles periodic coordinates (e.g., longitude) if is_periodic=true.
Geodynamo.BoundaryConditions.find_temperature_boundary_time_index
— Methodfind_temperature_boundary_time_index(boundary_set::BoundaryConditionSet, current_time::Float64)
Find the appropriate time index for the current simulation time.
Geodynamo.BoundaryConditions.get_boundary_condition_summary
— Methodget_boundary_condition_summary(field, field_type::FieldType)
Get a summary of the current boundary condition state.
Geodynamo.BoundaryConditions.get_boundary_data
— Methodget_boundary_data(field, field_type::FieldType)
Get boundary data from field using unified interface with fallback support.
Geodynamo.BoundaryConditions.get_boundary_statistics
— Methodget_boundary_statistics(boundary_data::BoundaryData)
Get statistical information about boundary data.
Geodynamo.BoundaryConditions.get_cached_data
— Methodget_cached_data(cache::BoundaryCache{T}, key::String) where T
Retrieve cached boundary data.
Geodynamo.BoundaryConditions.get_comm
— Methodget_comm()
Get MPI communicator (with fallback).
Geodynamo.BoundaryConditions.get_composition_boundary_data
— Methodget_composition_boundary_data(comp_field)
Get boundary data from field or fallback cache.
Geodynamo.BoundaryConditions.get_composition_time_index
— Methodget_composition_time_index(comp_field)
Get current time index from field or fallback cache.
Geodynamo.BoundaryConditions.get_current_boundaries
— Methodget_current_boundaries(field, field_type::FieldType)
Get current boundary values for any field type.
Geodynamo.BoundaryConditions.get_current_composition_boundaries
— Methodget_current_composition_boundaries(comp_field)
Get current composition boundary conditions.
Geodynamo.BoundaryConditions.get_current_magnetic_boundaries
— Methodget_current_magnetic_boundaries(magnetic_field)
Get current magnetic field boundary conditions.
Geodynamo.BoundaryConditions.get_current_simulation_time
— Methodget_current_simulation_time(solver_state)
Extract current simulation time from solver state.
Geodynamo.BoundaryConditions.get_current_temperature_boundaries
— Methodget_current_temperature_boundaries(temp_field)
Get current temperature boundary conditions.
Geodynamo.BoundaryConditions.get_current_velocity_boundaries
— Methodget_current_velocity_boundaries(velocity_field)
Get current velocity boundary conditions.
Geodynamo.BoundaryConditions.get_default_boundary_type
— Methodget_default_boundary_type(field_type::FieldType, location::BoundaryLocation) -> BoundaryType
Get default boundary condition type for a field at a specific location.
Geodynamo.BoundaryConditions.get_default_units
— Methodget_default_units(field_type::FieldType) -> String
Get default units for a field type.
Geodynamo.BoundaryConditions.get_field_from_state
— Methodget_field_from_state(state, field_type::FieldType)
Extract the appropriate field from simulation state.
Geodynamo.BoundaryConditions.get_interpolation_statistics
— Methodget_interpolation_statistics(boundary_data::BoundaryData, interpolated_data::Array{T}) where T
Compute statistics comparing original and interpolated data.
Geodynamo.BoundaryConditions.get_interpolation_weights
— Methodget_interpolation_weights(coords::Vector{T}, target::T, indices::Tuple{Int, Int}) where T
Calculate interpolation weights for linear interpolation.
Geodynamo.BoundaryConditions.get_netcdf_file_info
— Methodget_netcdf_file_info(filename::String)
Get information about a NetCDF boundary condition file.
Geodynamo.BoundaryConditions.get_nprocs
— Methodget_nprocs()
Get number of MPI processes (with fallback).
Geodynamo.BoundaryConditions.get_rank
— Methodget_rank()
Get MPI rank (with fallback).
Geodynamo.BoundaryConditions.get_temperature_boundary_data
— Methodget_temperature_boundary_data(temp_field)
Get boundary data from field or fallback cache.
Geodynamo.BoundaryConditions.get_temperature_time_index
— Methodget_temperature_time_index(temp_field)
Get current time index from field or fallback cache.
Geodynamo.BoundaryConditions.get_time_index
— Methodget_time_index(field, field_type::FieldType)
Get current time index from field using unified interface with fallback support.
Geodynamo.BoundaryConditions.infer_velocity_bc_type
— Methodinfer_velocity_bc_type(boundary::BoundaryData)
Infer boundary condition type (Dirichlet or Neumann) from boundary metadata.
Geodynamo.BoundaryConditions.initialize_boundary_conditions!
— Methodinitialize_boundary_conditions!(field, field_type::FieldType, config)
Initialize boundary condition support for a field structure.
Adds the necessary boundary condition fields to existing field structures without breaking compatibility with existing code.
Geodynamo.BoundaryConditions.interpolate_boundary_to_grid
— Methodinterpolate_boundary_to_grid(boundary_data::BoundaryData, target_theta::Vector{T},
target_phi::Vector{T}, time_index::Int=1) where T
Interpolate boundary data to a target grid using bilinear interpolation.
Geodynamo.BoundaryConditions.interpolate_with_cache
— Functioninterpolate_with_cache(boundary_data::BoundaryData, cache::Dict, time_index::Int=1)
Perform interpolation using pre-computed cache for efficiency.
Geodynamo.BoundaryConditions.load_composition_boundaries_from_files
— Methodload_composition_boundaries_from_files(inner_file::String, outer_file::String, config)
Load composition boundary conditions from NetCDF files.
Geodynamo.BoundaryConditions.load_composition_boundary_conditions!
— Methodload_composition_boundary_conditions!(comp_field, boundary_specs::Dict)
Load composition boundary conditions from various sources.
Arguments
comp_field
: SHTnsCompositionField structureboundary_specs
: Dictionary specifying boundary sources
Examples
# NetCDF files for both boundaries
boundary_specs = Dict(
:inner => "cmb_composition.nc",
:outer => "surface_composition.nc"
)
# Mixed NetCDF and programmatic
boundary_specs = Dict(
:inner => "cmb_composition.nc",
:outer => (:uniform, 0.1) # 10% concentration
)
Geodynamo.BoundaryConditions.load_magnetic_boundaries_from_files
— Methodload_magnetic_boundaries_from_files(inner_file::String, outer_file::String, config)
Load magnetic field boundary conditions from NetCDF files.
Geodynamo.BoundaryConditions.load_magnetic_boundary_conditions!
— Methodload_magnetic_boundary_conditions!(magnetic_field, boundary_specs::Dict)
Load magnetic field boundary conditions from various sources.
Arguments
magnetic_field
: SHTnsMagneticField structureboundary_specs
: Dictionary specifying boundary sources
Examples
# Insulating inner, potential field outer
boundary_specs = Dict(
:inner => (:insulating, 0.0),
:outer => (:potential_field, "geomagnetic_coefficients.nc")
)
# Perfect conductor boundaries
boundary_specs = Dict(
:inner => (:perfect_conductor, 0.0),
:outer => (:perfect_conductor, 0.0)
)
# NetCDF files for both boundaries
boundary_specs = Dict(
:inner => "cmb_magnetic.nc",
:outer => "surface_magnetic.nc"
)
Geodynamo.BoundaryConditions.load_temperature_boundaries_from_files
— Methodload_temperature_boundaries_from_files(inner_file::String, outer_file::String, config)
Load temperature boundary conditions from NetCDF files.
Geodynamo.BoundaryConditions.load_temperature_boundary_conditions!
— Methodload_temperature_boundary_conditions!(temp_field, boundary_specs::Dict)
Load temperature boundary conditions from various sources.
Arguments
temp_field
: SHTnsTemperatureField structureboundary_specs
: Dictionary specifying boundary sources
Examples
# NetCDF files for both boundaries
boundary_specs = Dict(
:inner => "cmb_temperature.nc",
:outer => "surface_temperature.nc"
)
# Mixed NetCDF and programmatic
boundary_specs = Dict(
:inner => "cmb_temperature.nc",
:outer => (:uniform, 300.0)
)
Geodynamo.BoundaryConditions.load_velocity_boundaries_from_files
— Methodload_velocity_boundaries_from_files(inner_file::String, outer_file::String, config)
Load velocity boundary conditions from NetCDF files.
Geodynamo.BoundaryConditions.load_velocity_boundary_conditions!
— Methodload_velocity_boundary_conditions!(velocity_field, boundary_specs::Dict)
Load velocity boundary conditions from various sources.
Arguments
velocity_field
: SHTnsVelocityField structureboundary_specs
: Dictionary specifying boundary sources
Examples
# No-slip boundaries at both surfaces
boundary_specs = Dict(
:inner => (:no_slip, 0.0),
:outer => (:no_slip, 0.0)
)
# Stress-free boundaries
boundary_specs = Dict(
:inner => (:stress_free, 0.0),
:outer => (:stress_free, 0.0)
)
# NetCDF file for inner, no-slip for outer
boundary_specs = Dict(
:inner => "cmb_velocity.nc",
:outer => (:no_slip, 0.0)
)
Geodynamo.BoundaryConditions.log_boundary_condition_status
— Functionlog_boundary_condition_status(state, rank::Int=0)
Log the status of all boundary conditions in the simulation state.
Geodynamo.BoundaryConditions.magnetic_to_qst_coefficients
— Methodmagnetic_to_qst_coefficients(B_r, B_theta, B_phi, config)
Convert physical magnetic field components to QST spectral coefficients.
For magnetic fields:
- Q: Radial component coefficients (B_r)
- S: Spheroidal tangential component coefficients
- T: Toroidal tangential component coefficients
Geodynamo.BoundaryConditions.print_boundary_data_info
— Functionprint_boundary_data_info(boundary_data::BoundaryData, prefix::String="")
Print detailed information about boundary data.
Geodynamo.BoundaryConditions.print_boundary_info
— Methodprint_boundary_info(boundary_set::BoundaryConditionSet)
Print comprehensive information about a boundary condition set.
Geodynamo.BoundaryConditions.print_boundary_summary
— Methodprint_boundary_summary(field, field_type::FieldType)
Print a summary of loaded boundary conditions for any field type.
Geodynamo.BoundaryConditions.read_netcdf_boundary_data
— Methodread_netcdf_boundary_data(filename::String; precision::Type{T}=Float64) where T
Read boundary condition data from a NetCDF file.
Returns a BoundaryData structure containing all boundary information.
Geodynamo.BoundaryConditions.reset_boundary_conditions!
— Methodreset_boundary_conditions!(field, field_type::FieldType)
Reset/clear boundary conditions for a field.
Geodynamo.BoundaryConditions.set_programmatic_composition_boundaries!
— Methodset_programmatic_composition_boundaries!(comp_field, inner_spec::Tuple, outer_spec::Tuple)
Set programmatic composition boundary conditions.
Geodynamo.BoundaryConditions.set_programmatic_magnetic_boundaries!
— Methodset_programmatic_magnetic_boundaries!(magnetic_field, inner_spec::Tuple, outer_spec::Tuple)
Set programmatic magnetic boundary conditions.
Geodynamo.BoundaryConditions.set_programmatic_temperature_boundaries!
— Methodset_programmatic_temperature_boundaries!(temp_field, inner_spec::Tuple, outer_spec::Tuple)
Set programmatic temperature boundary conditions.
Geodynamo.BoundaryConditions.set_programmatic_velocity_boundaries!
— Methodset_programmatic_velocity_boundaries!(velocity_field, inner_spec::Tuple, outer_spec::Tuple)
Set programmatic velocity boundary conditions.
Geodynamo.BoundaryConditions.shtns_physical_to_spectral
— Methodshtns_physical_to_spectral(physical_data::Matrix{T}, config) where T
Transform physical boundary data to spectral coefficients using SHTnsKit. This is a common utility function used by both thermal and composition modules.
Geodynamo.BoundaryConditions.smooth_boundary_data
— Methodsmooth_boundary_data(boundary_data::BoundaryData, smoothing_radius::Real)
Apply spatial smoothing to boundary data.
Geodynamo.BoundaryConditions.spherical_harmonic
— Methodspherical_harmonic(l::Int, m::Int, theta::Real, phi::Real)
Compute spherical harmonic Y_l^m(θ, φ).
Geodynamo.BoundaryConditions.spherical_harmonic_phi_derivative
— Methodspherical_harmonic_phi_derivative(l::Int, m::Int, theta::Real, phi::Real)
Compute ∂Y_l^m/∂φ.
Geodynamo.BoundaryConditions.spherical_harmonic_theta_derivative
— Methodspherical_harmonic_theta_derivative(l::Int, m::Int, theta::Real, phi::Real)
Compute ∂Y_l^m/∂θ.
Geodynamo.BoundaryConditions.update_boundary_conditions_for_timestep!
— Methodupdate_boundary_conditions_for_timestep!(state, current_time::Float64)
Update all boundary conditions for the current timestep.
This function should be called at the beginning of each timestep to ensure all fields have up-to-date boundary conditions.
Geodynamo.BoundaryConditions.update_composition_time_index!
— Methodupdate_composition_time_index!(comp_field, time_index::Int)
Update time index in field or fallback cache.
Geodynamo.BoundaryConditions.update_temperature_time_index!
— Methodupdate_temperature_time_index!(temp_field, time_index::Int)
Update time index in field or fallback cache.
Geodynamo.BoundaryConditions.update_time_dependent_boundaries!
— Methodupdate_time_dependent_boundaries!(field, field_type::FieldType, current_time::Float64)
Update time-dependent boundary conditions for any field type.
Geodynamo.BoundaryConditions.update_time_dependent_composition_boundaries!
— Methodupdate_time_dependent_composition_boundaries!(comp_field, current_time::Float64)
Update time-dependent composition boundary conditions.
Geodynamo.BoundaryConditions.update_time_dependent_magnetic_boundaries!
— Methodupdate_time_dependent_magnetic_boundaries!(magnetic_field, current_time::Float64)
Update time-dependent magnetic boundary conditions.
Geodynamo.BoundaryConditions.update_time_dependent_temperature_boundaries!
— Methodupdate_time_dependent_temperature_boundaries!(temp_field, current_time::Float64)
Update time-dependent temperature boundary conditions.
Geodynamo.BoundaryConditions.update_time_dependent_velocity_boundaries!
— Methodupdate_time_dependent_velocity_boundaries!(velocity_field, current_time::Float64)
Update time-dependent velocity boundary conditions.
Geodynamo.BoundaryConditions.validate_boundary_compatibility
— Methodvalidate_boundary_compatibility(inner::BoundaryData, outer::BoundaryData, field_name::String)
Validate that inner and outer boundary data are compatible.
Geodynamo.BoundaryConditions.validate_boundary_files
— Methodvalidate_boundary_files(field_type::FieldType, boundary_specs::Dict, config)
Validate boundary condition files for any field type.
Geodynamo.BoundaryConditions.validate_composition_boundary_files
— Methodvalidate_composition_boundary_files(boundary_specs::Dict, config)
Validate composition boundary condition files.
Geodynamo.BoundaryConditions.validate_composition_range
— Methodvalidate_composition_range(boundary_data::BoundaryData)
Validate that composition values are in the physical range [0, 1].
Geodynamo.BoundaryConditions.validate_field_boundary_compatibility
— Methodvalidate_field_boundary_compatibility(field, field_type::FieldType, boundary_set::BoundaryConditionSet)
Validate that a field structure is compatible with boundary conditions.
Geodynamo.BoundaryConditions.validate_interpolation_grids
— Methodvalidate_interpolation_grids(src_theta::Vector, src_phi::Vector,
tgt_theta::Vector, tgt_phi::Vector)
Validate that source and target grids are compatible for interpolation.
Geodynamo.BoundaryConditions.validate_magnetic_boundary_files
— Methodvalidate_magnetic_boundary_files(boundary_specs::Dict, config)
Validate magnetic field boundary condition files.
Geodynamo.BoundaryConditions.validate_netcdf_boundary_file
— Functionvalidate_netcdf_boundary_file(filename::String, required_vars::Vector{String}=[])
Validate that a NetCDF boundary condition file has the required structure.
Geodynamo.BoundaryConditions.validate_temperature_boundary_files
— Methodvalidate_temperature_boundary_files(boundary_specs::Dict, config)
Validate temperature boundary condition files.
Geodynamo.BoundaryConditions.validate_temperature_range
— Methodvalidate_temperature_range(boundary_data::BoundaryData)
Validate that temperature values are in a reasonable physical range.
Geodynamo.BoundaryConditions.validate_velocity_boundary_files
— Methodvalidate_velocity_boundary_files(boundary_specs::Dict, config)
Validate velocity boundary condition files.
Geodynamo.BoundaryConditions.velocity_to_qst_coefficients
— Methodvelocity_to_qst_coefficients(v_r, v_theta, v_phi, config)
Convert physical velocity components (vr, vθ, v_φ) to QST spectral coefficients by using proper SHTnsKit decomposition.
The QST decomposition used by SHTnsKit:
- Q: Radial component coefficients (transforms like scalar field)
- S: Spheroidal horizontal component coefficients (curl-free part)
- T: Toroidal horizontal component coefficients (divergence-free part)
Arguments
v_r
: Radial velocity component [nlat, nlon]v_theta
: Colatitude velocity component [nlat, nlon]v_phi
: Azimuthal velocity component [nlat, nlon]config
: SHTnsKit configuration
Returns
(Q_coeffs, S_coeffs, T_coeffs)
: QST spectral coefficients
Geodynamo.BoundaryConditions.write_netcdf_boundary_data
— Methodwrite_netcdf_boundary_data(filename::String, boundary_data::BoundaryData)
Write boundary condition data to a NetCDF file.
Initial Conditions
Geodynamo.InitialConditions
— ModuleInitialConditions
Module for loading and generating initial conditions for geodynamo simulations. Supports loading from NetCDF files, generating random fields, and setting prescribed analytical patterns.
Geodynamo.InitialConditions.generate_random_composition!
— Methodgenerate_random_composition!(comp_field, amplitude, modes_range)
Generate random composition initial conditions.
Geodynamo.InitialConditions.generate_random_initial_conditions!
— Methodgenerate_random_initial_conditions!(field, field_type::Symbol;
amplitude=1.0, modes_range=1:10,
seed=nothing)
Generate random initial conditions for any field type.
Arguments
field
: Field structure to initializefield_type
: Type of field (:temperature, :magnetic, :velocity, :composition)amplitude
: Overall amplitude of random perturbationsmodes_range
: Range of spherical harmonic modes to exciteseed
: Random seed for reproducibility (optional)
Examples
# Random temperature field
generate_random_initial_conditions!(temp_field, :temperature, amplitude=0.1)
# Random magnetic field with specific modes
generate_random_initial_conditions!(mag_field, :magnetic,
amplitude=0.01, modes_range=1:20, seed=42)
Geodynamo.InitialConditions.generate_random_magnetic!
— Methodgenerate_random_magnetic!(mag_field, amplitude, modes_range)
Generate random magnetic initial conditions.
Geodynamo.InitialConditions.generate_random_temperature!
— Methodgenerate_random_temperature!(temp_field, amplitude, modes_range)
Generate random temperature initial conditions.
Geodynamo.InitialConditions.generate_random_velocity!
— Methodgenerate_random_velocity!(vel_field, amplitude, modes_range)
Generate random velocity initial conditions.
Geodynamo.InitialConditions.load_composition_initial_conditions!
— Methodload_composition_initial_conditions!(comp_field, file_path::String)
Load composition initial conditions from NetCDF file.
Geodynamo.InitialConditions.load_initial_conditions!
— Methodload_initial_conditions!(field, field_type::Symbol, file_path::String)
Load initial conditions from NetCDF file for any field type.
Arguments
field
: Field structure (temperature, magnetic, velocity, or composition type)field_type
: Field type (:temperature, :magnetic, :velocity, :composition)file_path
: Path to NetCDF file containing initial conditions
File Format
NetCDF files should contain:
- For scalar fields: spectral coefficients array
- For vector fields: toroidal and poloidal spectral coefficients
- Coordinate arrays: lm indices, radial grid
Geodynamo.InitialConditions.load_magnetic_initial_conditions!
— Methodload_magnetic_initial_conditions!(mag_field, file_path::String)
Load magnetic initial conditions from NetCDF file.
Geodynamo.InitialConditions.load_temperature_initial_conditions!
— Methodload_temperature_initial_conditions!(temp_field, file_path::String)
Load temperature initial conditions from NetCDF file.
Geodynamo.InitialConditions.load_velocity_initial_conditions!
— Methodload_velocity_initial_conditions!(vel_field, file_path::String)
Load velocity initial conditions from NetCDF file.
Geodynamo.InitialConditions.randomize_magnetic_field!
— Methodrandomize_magnetic_field!(field; amplitude, lmax, domain=nothing)
Populate magnetic toroidal/poloidal fields with random perturbations.
Geodynamo.InitialConditions.randomize_scalar_field!
— Methodrandomize_scalar_field!(field; amplitude, lmax, domain=nothing)
Populate a scalar spectral field (temperature/composition) with random perturbations up to degree lmax
. If a radial domain
is provided and includes r=0, ball regularity is enforced.
Geodynamo.InitialConditions.randomize_vector_field!
— Methodrandomize_vector_field!(field; amplitude, lmax, domain=nothing)
Populate velocity-like toroidal/poloidal fields with random perturbations up to degree lmax
.
Geodynamo.InitialConditions.save_initial_conditions
— Methodsave_initial_conditions(field, field_type::Symbol, file_path::String)
Save current field state as initial conditions to NetCDF file.
This function is useful for saving generated or computed initial conditions for later use in simulations.
Geodynamo.InitialConditions.set_analytical_composition!
— Methodset_analytical_composition!(comp_field, pattern, amplitude; parameters...)
Set analytical composition patterns.
Geodynamo.InitialConditions.set_analytical_initial_conditions!
— Methodset_analytical_initial_conditions!(field, field_type::Symbol, pattern::Symbol;
amplitude=1.0, parameters...)
Set analytical initial conditions based on predefined patterns.
Patterns
:conductive
- Conductive temperature profile:dipole
- Dipolar magnetic field:convective
- Small convective velocity pattern:stratified
- Stratified composition profile
Examples
# Conductive temperature profile
set_analytical_initial_conditions!(temp_field, :temperature, :conductive)
# Earth-like dipolar magnetic field
set_analytical_initial_conditions!(mag_field, :magnetic, :dipole, amplitude=1.0)
Geodynamo.InitialConditions.set_analytical_magnetic!
— Methodset_analytical_magnetic!(mag_field, pattern, amplitude; parameters...)
Set analytical magnetic field patterns.
Geodynamo.InitialConditions.set_analytical_temperature!
— Methodset_analytical_temperature!(temp_field, pattern, amplitude; parameters...)
Set analytical temperature patterns.
Geodynamo.InitialConditions.set_analytical_velocity!
— Methodset_analytical_velocity!(vel_field, pattern, amplitude; parameters...)
Set analytical velocity patterns.
Spherical Shell Geometry
Geodynamo.GeodynamoShell.apply_shell_composition_boundaries!
— Methodapply_shell_composition_boundaries!(comp_field, boundary_set; time=0)
Geodynamo.GeodynamoShell.apply_shell_temperature_boundaries!
— Methodapply_shell_temperature_boundaries!(temp_field, boundary_set; time=0)
Wrapper around core boundary application for shell geometry.
Geodynamo.GeodynamoShell.create_shell_composition_field
— Methodcreate_shell_composition_field(T, cfg::ShellConfig; nr=Geodynamo.i_N)
Geodynamo.GeodynamoShell.create_shell_hybrid_composition_boundaries
— Methodcreate_shell_hybrid_composition_boundaries(inner_spec, outer_spec, cfg::ShellConfig; precision=Float64)
Create composition boundaries for shell geometry. Dispatches to appropriate function based on spec types:
- Both Tuple: fully programmatic boundaries
- String + Tuple: hybrid (one from file, one programmatic)
- Both String: both from files
Geodynamo.GeodynamoShell.create_shell_hybrid_temperature_boundaries
— Methodcreate_shell_hybrid_temperature_boundaries(inner_spec, outer_spec, cfg::ShellConfig; precision=Float64)
Create temperature boundaries for shell geometry. Dispatches to appropriate function based on spec types:
- Both Tuple: fully programmatic boundaries
- String + Tuple: hybrid (one from file, one programmatic)
- Both String: both from files
Geodynamo.GeodynamoShell.create_shell_magnetic_fields
— Methodcreate_shell_magnetic_fields(T, cfg::ShellConfig; nr_oc=Geodynamo.i_N, nr_ic=Geodynamo.i_Nic)
Geodynamo.GeodynamoShell.create_shell_pencils
— Methodcreate_shell_pencils(cfg::ShellConfig; optimize=true)
Create a shell-oriented pencil decomposition using the core topology helper.
Geodynamo.GeodynamoShell.create_shell_physical_field
— Methodcreate_shell_physical_field(T, cfg::ShellConfig, domain::Geodynamo.RadialDomain, pencil)
Geodynamo.GeodynamoShell.create_shell_radial_domain
— Functioncreate_shell_radial_domain(nr=i_N) -> RadialDomain
Create a radial domain suitable for a spherical shell using the global parameter d_rratio
for inner radius ratio. This is a thin wrapper over Geodynamo.create_radial_domain
.
Geodynamo.GeodynamoShell.create_shell_spectral_field
— Methodcreate_shell_spectral_field(T, cfg::ShellConfig, domain::Geodynamo.RadialDomain, pencil)
Geodynamo.GeodynamoShell.create_shell_temperature_field
— Methodcreate_shell_temperature_field(T, cfg::ShellConfig; nr=Geodynamo.i_N)
Geodynamo.GeodynamoShell.create_shell_vector_field
— Methodcreate_shell_vector_field(T, cfg::ShellConfig, domain::Geodynamo.RadialDomain, pencils)
Geodynamo.GeodynamoShell.create_shell_velocity_fields
— Methodcreate_shell_velocity_fields(T, cfg::ShellConfig; nr=Geodynamo.i_N)
Solid Ball Geometry
Geodynamo.GeodynamoBall.apply_ball_composition_regularity!
— Methodapply_ball_composition_regularity!(comp_field)
Geodynamo.GeodynamoBall.apply_ball_temperature_regularity!
— Methodapply_ball_temperature_regularity!(temp_field)
Convenience to enforce scalar regularity on the temperature spectral field. Call after assembling or updating temp_field.spectral.
Geodynamo.GeodynamoBall.ball_physical_to_spectral!
— Methodball_physical_to_spectral!(phys::Geodynamo.SHTnsPhysicalField,
spec::Geodynamo.SHTnsSpectralField)
Wrapper for transforms in a solid sphere that enforces scalar regularity at r=0 after analysis. Use this for scalar fields (temperature, composition, etc.).
Geodynamo.GeodynamoBall.ball_vector_analysis!
— Methodball_vector_analysis!(vec::Geodynamo.SHTnsVectorField,
tor::Geodynamo.SHTnsSpectralField,
pol::Geodynamo.SHTnsSpectralField)
Wrapper for vector analysis in a solid sphere; enforces vector regularity at r=0 after transforming to spectral toroidal/poloidal.
Geodynamo.GeodynamoBall.create_ball_composition_field
— Methodcreate_ball_composition_field(T, cfg::BallConfig; nr=Geodynamo.i_N)
Geodynamo.GeodynamoBall.create_ball_hybrid_composition_boundaries
— Methodcreate_ball_hybrid_composition_boundaries(inner_spec, outer_spec, cfg::BallConfig; precision=Float64)
Geodynamo.GeodynamoBall.create_ball_hybrid_temperature_boundaries
— Methodcreate_ball_hybrid_temperature_boundaries(inner_spec, outer_spec, cfg::BallConfig; precision=Float64)
Geodynamo.GeodynamoBall.create_ball_magnetic_fields
— Methodcreate_ball_magnetic_fields(T, cfg::BallConfig; nr=Geodynamo.i_N)
Create magnetic fields for a solid sphere. Since a "core" split is not used in a ball, we pass the same domain for both oc and ic to reuse the core implementation.
Geodynamo.GeodynamoBall.create_ball_pencils
— Methodcreate_ball_pencils(cfg::BallConfig; optimize=true)
Geodynamo.GeodynamoBall.create_ball_physical_field
— Methodcreate_ball_physical_field(T, cfg::BallConfig, domain::Geodynamo.RadialDomain, pencil)
Geodynamo.GeodynamoBall.create_ball_radial_domain
— Functioncreate_ball_radial_domain(nr=i_N) -> RadialDomain
Create a radial domain for a solid sphere (inner radius = 0). Uses a cosine-stretched grid similar to the shell for compatibility, but sets the inner radius to zero and adjusts the coordinate columns to match expectations of downstream operators.
Geodynamo.GeodynamoBall.create_ball_spectral_field
— Methodcreate_ball_spectral_field(T, cfg::BallConfig, domain::Geodynamo.RadialDomain, pencil)
Geodynamo.GeodynamoBall.create_ball_temperature_field
— Methodcreate_ball_temperature_field(T, cfg::BallConfig; nr=Geodynamo.i_N)
Geodynamo.GeodynamoBall.create_ball_vector_field
— Methodcreate_ball_vector_field(T, cfg::BallConfig, domain::Geodynamo.RadialDomain, pencils)
Geodynamo.GeodynamoBall.create_ball_velocity_fields
— Methodcreate_ball_velocity_fields(T, cfg::BallConfig; nr=Geodynamo.i_N)
Geodynamo.GeodynamoBall.enforce_ball_scalar_regularity!
— Methodenforce_ball_scalar_regularity!(spec::Geodynamo.SHTnsSpectralField)
Enforce scalar regularity at r=0 for solid sphere: for l>0, the scalar amplitude must vanish at r=0. Sets inner radial plane to zero for all nonzero l modes (both real and imaginary parts).
Geodynamo.GeodynamoBall.enforce_ball_vector_regularity!
— Methodenforce_ball_vector_regularity!(tor_spec::Geodynamo.SHTnsSpectralField,
pol_spec::Geodynamo.SHTnsSpectralField)
Enforce vector-field regularity at r=0 for solid sphere. For smooth fields, both toroidal and poloidal potentials behave like r^{l+1}, so they vanish at r=0 for all l ≥ 1. Zeros the inner radial plane for l≥1.
For lower-level packages used internally (SHTnsKit, PencilArrays, MPI), refer to their respective documentation.