How to know the maximum and minumum values of DG solution without plotting?

Hi,

My question does not particularly belong to specific problems. When solving a PDE using CG FEM, since the basis functions are defined as 1 at each vertex, the DOFs are actually solution values. However, since DG basis functions are defined differently, we cannot do the same way as CG solution. Is there any way to get the maximum and minimum values of the DG solution without plotting? This question is related to postprocessing DG solution. Below is an example code.

domain = mesh.create_unit_square(MPI.COMM_WORLD, 10, 10, cell_type=mesh.CellType.triangle)
P = fem.functionspace(domain, ("DG", 2))
ph = fem.Function(P)
problem = LinearProblem(ufl.lhs(F1), ufl.rhs(F1), bcs=[],
                        petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
ph = problem.solve()

ph contains the DOFs of the DG solution.

Thanks.

I’ve made a convenience function for scifem to solve this problem, as you are required to solve a local minimization problem on each cell:

The function gives you two options, run the optimization yourself on each cell (find_cell_extrema) or first use the average L^p norm of your function per cell to reduce the number of cells where you evaluate the optimization algorithm (compute_extrema).

1 Like