darsia.BeckmannGproxPGHDSolver#
- class BeckmannGproxPGHDSolver(grid, weight=None, options={})[source]#
Bases:
BeckmannProblemThis 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 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 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
darsia.Grid: grid
np.ndarray: voxel size
Optional[darsia.Image]: weight
dict: options for the solver
bool: verbosity
list: list of callbacks to be called at each iteration
str: mode for computing the norm: l2 or manhattan
regularizationfloat: regularization parameter
mobility_modestr: 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_diff
np.ndarray Difference of mass distributions.
- flux
np.ndarray Flux on the faces.
- flat_mass_diff
- Returns:
np.ndarrayKantorovich potential.
- leray_projection(p)[source]#
Leray projection of a vector fiels
- Parameters:
- p
np.ndarray Pressure.
- p
- Returns:
np.ndarrayDivergence 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_faces
np.ndarray,optional Permeability faces. Defaults to None.
- permeability_faces
- Returns:
darsia.linalg.KSPPoisson solver.
- solve_beckmann_problem(flat_mass_diff)[source]#
Solve the Beckmann problem using GproxPDHG.
- Parameters:
- flat_mass_diff
np.ndarray Difference of mass distributions.
- flat_mass_diff
- Returns:
tupleDistance, 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