4
$\begingroup$

I am trying to define an area on a volume that I can use for a boundary condition. This is a minimum working example to show the problem my real problem involves stress analysis.

I define a region using a contour plot

cp = ContourPlot[
  x - 1 + ((x^2 + y^2) (x - 1))/((x + 2) (x - 2)), {x, -1.5, 
   1.5}, {y, -1.5, 1.5}, Contours -> {-1.0}, ContourShading -> False]
reg = BoundaryDiscretizeGraphics[cp]

Mathematica graphics

Mathematica graphics

If I now try and use this region inNDSolve this is what happens

sol = NDSolve[{-Laplacian[f[x, y, z], {x, y, z}] == 1, 
   DirichletCondition[f[x, y, z] == 0, 
    z == 0 && {x, y} ∈ reg]}, 
  f, {x, y, z} ∈ Cuboid[{-2, -2, 0}, {2, 2, 2}]]

Mathematica graphics

I have now noticed that this also happens with

  sol = NDSolve[{-Laplacian[f[x, y, z], {x, y, z}] == 1, 
   DirichletCondition[f[x, y, z] == 0, 
    z == 0 && {x, y} ∈ Circle[{0, 0}, 0.1]]}, 
  f, {x, y, z} ∈ Cuboid[{-2, -2, 0}, {2, 2, 2}]]

So there is something wrong with defining a region in this way. What is wrong and is there a work around? Thanks

$\endgroup$
2
  • $\begingroup$ If you have an implicit description of the region as in the examples above, does this work?: sol = NDSolve[{-Laplacian[f[x, y, z], {x, y, z}] == 1, DirichletCondition[f[x, y, z] == 0, z == 0 && x - 1 + ((x^2 + y^2) (x - 1))/((x + 2) (x - 2)) < -1]}, f, {x, y, z} \[Element] Cuboid[{-2, -2, 0}, {2, 2, 2}]] $\endgroup$
    – Michael E2
    May 8, 2019 at 15:39
  • $\begingroup$ @MichaelE2 Yes that works but I don't have an implicit description. The implicit description was only for the minimum working example. I have a region, defined by a contour, coming out of another simulation. Thanks for the try. $\endgroup$
    – Hugh
    May 8, 2019 at 16:09

1 Answer 1

4
$\begingroup$

This works:

rmf = RegionMember[reg];
sol = NDSolve[{-Laplacian[f[x, y, z], {x, y, z}] == 1, 
   DirichletCondition[f[x, y, z] == 0, z == 0 && rmf[{x, y}]]}, 
  f, {x, y, z} \[Element] Cuboid[{-2, -2, 0}, {2, 2, 2}]]
$\endgroup$
1
  • $\begingroup$ Works nicely for my problem; thank you. $\endgroup$
    – Hugh
    May 9, 2019 at 9:31

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.