Inverse Solver
The inverse solver computes gradients of the objective function with respect to material parameters using the adjoint method. See the Mathematical Reference for the full derivation.
Objective Function
The data-misfit objective is
Sentinel.compute_objective Function
compute_objective(calc::Displacement, meas::Displacement) -> Float64Compute the displacement-only objective function value (L2 misfit): Φ = ½‖u_calc − u_meas‖²
This calls displacement_error! internally to compute the misfit and returns calc.abserror.
compute_objective(calc::Displacement, meas::Displacement,
material::Material, regularizations;
iteration::Int=1) -> Float64Compute the total objective function value including regularization penalties.
Stores displacement error in material.disperror, per-regularization errors in material.regerror, and the total in material.totalerror.
Gradient Initialization
The gradient structure maps material parameters to a flat index vector for optimization. Each entry corresponds to a specific (property, real/imaginary, value index) triple.
Sentinel.init_gradient! Function
init_gradient!(grad::MaterialGradient, material::Material;
realparamind::Union{AbstractMatrix{Bool}, Nothing}=nothing)Initialize the MaterialGradient struct from a Material, building the index mapping from (property, real/imag, value_index) to a flat gradient vector offset.
Ports initmtrlgrad + propparamindices from FEmaterial.f90.
Arguments
grad:MaterialGradientto initialize in-placematerial:Materialstruct with property definitionsrealparamind: optional(2*numprop, max_nvpp)Bool matrix selecting which parameter groups are active.nothing→ all active.
Index layout
For each property iprop (1-based) and value index jprop (1-based):
Row
2*(iprop-1)+1→ real partRow
2*(iprop-1)+2→ imaginary part
realprop2param[row, jprop] gives the starting 1-based index in grad.rvalue for the flattened gradient entries of that parameter group. realparam2prop[k, :] = [iprop, jprop, iii] is the reverse mapping (iii=1 for real, 2 for imaginary).
Gradient Computation
The adjoint gradient is:
Dispatched per material model type for model-specific
Sentinel.compute_gradient! Function
compute_gradient!(grad::MaterialGradient,
dh::DofHandler, cv_disp::CellValues,
calc::Displacement, adjnt::Displacement,
model::IsotropicIncompressible,
material::Material,
gp2mtrs::Vector{GP2Mtr},
meshes::Vector{MaterialMesh},
ω::Float64; numdispsets::Int=1)Compute the adjoint gradient for the IsotropicIncompressible model (Model 1).
Ports isoadjointgrad_multimesh from FEgradient.f90 (lines 126–416).
The gradient formula for parameter θ_m at material mesh node m is:
∂Φ/∂θ_m = -Σ_dispsets Re[ Σ_elem Σ_gp wght · (∂K/∂θ)_ij · λᵢ · uⱼ ]where wght = basis_m (hex8 shape function at material mesh node m).
Three property derivatives for Model 1:
∂K/∂μ: deviatoric stiffness (9 terms per node pair)
∂K/∂ρ: mass matrix diagonal (-ω²·Nᵢ·Nⱼ)
∂K/∂κ: pressure-pressure block ((1/κ²)·ψ_p·ψ_q)
Arguments
grad: initializedMaterialGradient(frominit_gradient!)dh:DofHandlerwith vector fieldLagrange{RefHexahedron, 2}()^3cv_disp:CellValuesfor scalarLagrange{RefHexahedron, 2}()calc: calculated displacement (forward solution)adjnt: adjoint displacementmodel:IsotropicIncompressible()singletonmaterial:Materialwith properties μ, ρ, κgp2mtrs: vector ofGP2Mtr(one per material mesh)meshes: vector ofMaterialMeshω: angular frequency [rad/s]numdispsets: number of displacement sets (default 1)
Gradient Type
Sentinel.MaterialGradient Type
MaterialGradientStores the adjoint gradient of the objective function with respect to all real material parameter values. Corresponds to the Fortran mtrlgrad derived type.
Fields
numprop: number of material propertiesnpr: per-property count of real parameter pointsnpi: per-property count of imaginary parameter pointsnvpp: per-property values per pointnumrealparam: total number of distinct real parameter groups (including real+imag parts)totnumrealparam: total flattened gradient vector lengthrealprop2param: maps(2*iprop-1/2, ival)→ starting index inrvaluerealparam2prop: maps gradient index →(iprop, ival, 1=real/2=imag)nreg: number of regularization termstoterrinit: initial total errortotalerror: complete error including regularizationdisperror: displacement misfit onlyregerror: per-regularization-term error, lengthnregrvalue: gradient values, lengthtotnumrealparam
Full Inverse Problem
The full inverse solver orchestrates multi-zone inversion using Zone Decomposition to partition the domain and solve subproblems independently. See the Optimization API for ForwardProblemContext, evaluate_objective!, compute_full_gradient!, and material operation utilities.