Hi Danial,
where do your values relate to ? If every value corresponds to one element, you can define an L2-gridfunction, and set its coefficients to your values:
Code:
fespace = L2(mesh, order=0)
gf = GridFunction(fespace)
for i in range(fes.ndof):
gf.vec[i| = value[i]
You can plot the GridFunction, and you can use it where you want to use your coefficient. A GridFunction is a CoefficientFunction, too.
The basis-functions of the L2(order=0) space are exactly the characteristic functions of every element.
If your values correspond to vertices, you use an H1-space (with order=1) instead.
Best, Joachim