How to set the NeumannValue conditions when the conditions are Discrete points?

For example i can use Piecewise when the condition is a Continuous function NeumannValue[Piecewise[{{x^2 + y^2, Abs[x + y] < 2.5}}], z == 1] But when the condition is not continuous p=Table[Piecewise[{{x^2 + y^2, Abs[x + y] < 2.5}}], {x, -2, 2, 1}, {y, -2, 2, 1}] how can i apply the p to NeumannValue condition? Thanks

• Pointwise Neumann conitions quite certainly don't make sense for a two-dimensional problem... – Henrik Schumacher Jan 3 at 15:38
• @Henrik Schumacher how can i apply Pointwise Neumann or DirichletCondition? – xin pei Jan 4 at 1:42

You could, for example, generate an interpolating function like so:

p = Table[
Piecewise[{{x^2 + y^2, Abs[x + y] < 2.5}}], {x, -2, 2, 1}, {y, -2,
2, 1}]
{{0, 0, 4, 5, 8}, {0, 2, 1, 2, 5}, {4, 1, 0, 1, 4}, {5, 2, 1, 2,
0}, {8, 5, 4, 0, 0}}
ifun = ListInterpolation[p, {{-2, 2}, {-2, 2}}]


You can then use that in the NeumannValue.

NDSolveValue[{Laplacian[u[x, y, z], {x, y, z}] ==
1 + NeumannValue[ifun[x, y], z == 2],
DirichletCondition[u[x, y, z] == 0, z == -2]}, u, {x, y,
z} \[Element] Cuboid[{-2, -2, -2}, {2, 2, 2}]]


You'd need to think a bit how you want the interpolation to work. For example what interpolation order you want to use.