#
# Laser and mirrors convection-diffusion experiment with known diffusivity and convectivity
#
import laser_and_mirrors_aux
from measures import DiscreteMeasure_2_f64
from pointsource_pde import Problem, RegTerm
from pointsource_pde.compose import (
    ComposeFnWithOperator,
    InjectSecond,
)

# Give name to the problem
name = "laser_and_mirrors"

# Override algorithm settings
algorithm_overrides = laser_and_mirrors_aux.algorithm_overrides


# Setup routine
def setup(prefix):
    dat, auxtrue, _μ_bound, μ_true, plot_factory = laser_and_mirrors_aux.generic_setup(
        prefix
    )

    μ0 = DiscreteMeasure_2_f64([])

    reg = RegTerm.NonnegRadon(1.5e-6)

    dat_simple = ComposeFnWithOperator(dat, InjectSecond(auxtrue))
    dat_simple.curvature_bound_components = lambda: (None, None)
    print("Initial data term value:", dat_simple.apply(μ0))
    print("Data term value at true μ:", dat_simple.apply(μ_true))

    return Problem(
        dataterm=dat_simple, regterm=reg, μinit=μ0, plot_factory=plot_factory
    )
