2
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Pointwise Neumann conitions quite certainly don't make sense for a two-dimensional problem... $\endgroup$ Commented Jan 3, 2019 at 15:38
  • $\begingroup$ @Henrik Schumacher how can i apply Pointwise Neumann or DirichletCondition? $\endgroup$
    – XinBae
    Commented Jan 4, 2019 at 1:42

1 Answer 1

3
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.