darsia.BeckmannGproxPGHDSolver#

class BeckmannGproxPGHDSolver(grid, weight=None, options={})[source]#

Bases: BeckmannProblem

This contains the implementation of the GproxPDHG algorithm described in “SOLVING LARGE-SCALE OPTIMIZATION PROBLEMS WITH A CONVERGENCE RATE INDEPENDENT OF GRID SIZE”

Methods

broken_darcy_with_custom_flux_block(...)

Construct the broken Darcy operator with given flux-flux block.

cell_weighted_flux(cell_flux)

Compute the cell-weighted flux.

compute_dual(p, gradient_poisson)

Compute the value of the dual functional.

compute_kantorovich_potential(...[, tol])

Compute the kantorovich potential from the normal flux

compute_primal(flux)

Compute the value of the primal functional $int_{Domain} | flux | $

distance_matrix(images)

Compute the distance between each iteam of a list.

eliminate_flux(jacobian, residual)

Eliminate the flux block from the jacobian and residual.

eliminate_lagrange_multiplier(...)

Eliminate the lagrange multiplier from the reduced system.

exact_linearization(solution)

Compute the exact linearization of the constrained minimization problem.

flat_view(img)

Flatten the image to a vector.

flux_view(vector)

Extract the flux from the vector.

l1_dissipation(flat_flux)

Compute the l1 dissipation of the solution.

leray_projection(p)

Leray projection of a vector fiels

linear_solve(matrix, rhs[, ...])

Solve the linear system.

ndofs()

Return the total number of degrees of freedom.

optimality_conditions(solution, ...)

Evaluate optimality conditions of the constrained minimization problem.

pressure_view(vector)

Extract the pressure from the vector.

rescaled_flux_optimality_conditions(solution)

Evaluate scaled optimality conditions of the constrained minimization problem.

setup_amg_options()

Setup the infrastructure for multilevel solvers.

setup_poisson_solver(solver_prefix[, rtol, ...])

Return the Poisson solver.

solve_beckmann_problem(flat_mass_diff)

Solve the Beckmann problem using GproxPDHG.

transport_density(flat_flux[, weighted, flatten])

Compute the transport density from the solution.

transport_density_faces(flat_flux)

Compute the transport density from the solution.

Attributes

grid

darsia.Grid: grid

voxel_size

np.ndarray: voxel size

weight

Optional[darsia.Image]: weight

options

dict: options for the solver

verbose

bool: verbosity

callbacks

list: list of callbacks to be called at each iteration

norm_mode

str: mode for computing the norm: l2 or manhattan

regularization

float: regularization parameter

mobility_mode

str: mode for computing the mobility

compute_dual(p, gradient_poisson)[source]#

Compute the value of the dual functional.

\[\int_\Omega \mathrm{pot}\,(f^+ - f^-) = \int_\Omega \mathrm{pot}\,(-\operatorname{div} \mathrm{poisson}) = \int_\Omega \nabla \mathrm{pot} \cdot \nabla \mathrm{poisson} = \int_\Omega p \cdot \nabla \mathrm{poisson}\]
compute_kantorovich_potential(flat_mass_diff, flux, tol=1e-06)[source]#

Compute the kantorovich potential from the normal flux

Parameters:
flat_mass_diffnp.ndarray

Difference of mass distributions.

fluxnp.ndarray

Flux on the faces.

Returns:
np.ndarray

Kantorovich potential.

compute_primal(flux)[source]#

Compute the value of the primal functional $int_{Domain} | flux | $

leray_projection(p)[source]#

Leray projection of a vector fiels

Parameters:
pnp.ndarray

Pressure.

Returns:
np.ndarray

Divergence free flux.

setup_amg_options()[source]#

Setup the infrastructure for multilevel solvers.

Basic default setup based on jacobi and block Gauss-Seidel smoothers. User-defined options can be passed via the options dictionary, using the key “amg_options”. The options follow the pyamg interface.

setup_poisson_solver(solver_prefix, rtol=1e-06, permeability_faces=None)[source]#

Return the Poisson solver.

Parameters:
permeability_facesnp.ndarray, optional

Permeability faces. Defaults to None.

Returns:
darsia.linalg.KSP

Poisson solver.

solve_beckmann_problem(flat_mass_diff)[source]#

Solve the Beckmann problem using GproxPDHG.

Parameters:
flat_mass_diffnp.ndarray

Difference of mass distributions.

Returns:
tuple

Distance, solution, info.

callbacks#

list: list of callbacks to be called at each iteration

grid#

darsia.Grid: grid

norm_mode#

str: mode for computing the norm: l2 or manhattan

options#

dict: options for the solver

verbose#

bool: verbosity

voxel_size#

np.ndarray: voxel size

weight#

Optional[darsia.Image]: weight