1
$\begingroup$

I would like to specify a Dirichlet condition from a polyhedron defined by a set of points.

    DirichletCondition[u[x, y, z] == 5, Region`RegionProperty[RegionBoundary[object], {x, y, z}, "FastDescription"][[1]][[2]]]

However, this part

    Region`RegionProperty[RegionBoundary[object], {x, y, z}, 
    "FastDescription"][[1]][[2]]]

doesn't work given the oddly shaped polygon given by RegionBoundary[object]. I haven't been able to find out much about RegionProperty or find out where I can find alternatives to "FastDescription".

Here is how I define object:

center = {39, 19, 0};
objcoords = {{0.35744634112855245, 
19.49760834744405}, {10.42305798361631, 
19.4864491327628}, {12.243503729806417, 
18.29241316186902}, {16.364505056976796, 
18.11755617591872}, {18.196197885680288, 
22.372731682760513}, {15.189009198663676, 
24.589812823211748}, {0.2100041188046311, 24.861851631504276}, {0,
 24.86}, {-61.5, 24.86}, {-61.5, 15.86}, {-5, 15.86}};
objcoords[[;; , 1]] = objcoords[[;; , 1]] - center[[1]];
objcoords[[;; , 2]] = objcoords[[;; , 2]] - center[[2]];
(*create 3D polygon from the coordinates*)
objTop = 
  Table[{objcoords[[i, 1]], objcoords[[i, 2]], 1}, {i, 1, 
    Length[objcoords]}];
objBottom = 
  Table[{objcoords[[i, 1]], objcoords[[i, 2]], -1}, {i, 1, 
    Length[objcoords]}];
object = ConvexHullRegion[Join[objTop, objBottom]]

Please could someone help me get a Dirichlet condition from a user-defined polyhedron/polygon?

Thank you in advance for any help you might be able to give me with this.

object polygon

$\endgroup$
8
  • 1
    $\begingroup$ It is not clear what do you try to solve. Is object to be a region for your numerical solution? $\endgroup$ Commented Mar 6, 2022 at 7:28
  • $\begingroup$ Thanks for your question. object is an electrode in a wider space in which I need to find the potential due to the electrode being near by. That is why I need to set a boundary condition on object. $\endgroup$
    – E Crane
    Commented Mar 6, 2022 at 8:45
  • $\begingroup$ What is the region (wider space?) to solve this problem? Could you upload equation and boundary condition in mathematical notation? $\endgroup$ Commented Mar 6, 2022 at 9:13
  • $\begingroup$ bc = { DirichletCondition[u[x, y, z] == Vobj, Region`RegionProperty[RegionBoundary[object], {x, y, z}, "FastDescription"][[1]][[2]]] }; $\endgroup$
    – E Crane
    Commented Mar 6, 2022 at 10:29
  • $\begingroup$ eq = Laplacian[u[x, y, z], {x, y, z}] == 0; U = NDSolveValue[{eq, bc}, u, {x, y, z} [Element] mesh]; $\endgroup$
    – E Crane
    Commented Mar 6, 2022 at 10:29

1 Answer 1

2
$\begingroup$

This is solution with zero boundary condition on the air boundary

center = {39, 19, 0};
objcoords = {{0.35744634112855245, 
    19.49760834744405}, {10.42305798361631, 
    19.4864491327628}, {12.243503729806417, 
    18.29241316186902}, {16.364505056976796, 
    18.11755617591872}, {18.196197885680288, 
    22.372731682760513}, {15.189009198663676, 
    24.589812823211748}, {0.2100041188046311, 24.861851631504276}, {0,
     24.86}, {-61.5, 24.86}, {-61.5, 15.86}, {-5, 15.86}};
objcoords[[;; , 1]] = objcoords[[;; , 1]] - center[[1]];
objcoords[[;; , 2]] = objcoords[[;; , 2]] - center[[2]];
(*create 3D polygon from the coordinates*)
objTop = Table[{objcoords[[i, 1]], objcoords[[i, 2]], 1}, {i, 1, 
    Length[objcoords]}];
objBottom = 
  Table[{objcoords[[i, 1]], objcoords[[i, 2]], -1}, {i, 1, 
    Length[objcoords]}];
object = ConvexHullRegion[Join[objTop, objBottom]]

Needs["NDSolve`FEM`"]

xair = yair = zair = 70; air = 
 Cuboid[{-xair, -yair, -zair}, {xair, yair, zair}]; reg = 
 RegionDifference[air, object]; mesh = 
 ToElementMesh[reg, 
  MeshRefinementFunction -> 
   Function[{vertices, area}, 
    area > 0.1 (0.1 + 10 Norm[Mean[vertices]])]];
xmax = Max[objcoords[[All, 1]]]; ymm = MinMax[objcoords[[All, 2]]]

bc = {DirichletCondition[
   u[x, y, z] == 5, -xair <= x <= xmax && -1 <= z <= 1 && 
    ymm[[1]] <= y <= ymm[[2]]], 
  DirichletCondition[u[x, y, z] == 0, True]}; eq = 
 Laplacian[u[x, y, z], {x, y, z}] == 0; U = 
 NDSolveValue[{eq, bc}, u, Element[{x, y, z}, mesh]]

Visualization

{ContourPlot[U[x, y, 0], {x, -xair, xair}, {y, -yair, yair}, 
  ColorFunction -> Hue, PlotRange -> All, PlotPoints -> 50, 
  PlotLegends -> Automatic, Contours -> 20, FrameLabel -> Automatic], 
 ContourPlot[U[x, 0, z], {x, -xair, xair}, {z, -zair, zair}, 
  ColorFunction -> Hue, PlotRange -> All, PlotPoints -> 50, 
  PlotLegends -> Automatic, Contours -> 20, FrameLabel -> Automatic]}

Figure 1

$\endgroup$
5
  • $\begingroup$ This is it! Thank you so very much!! $\endgroup$
    – E Crane
    Commented Mar 6, 2022 at 15:23
  • $\begingroup$ So it looks like the exact locations of the edges of the object don't matter so much in the Dirichlet condition then? For example, x < xmax suffices $\endgroup$
    – E Crane
    Commented Mar 6, 2022 at 15:25
  • 1
    $\begingroup$ Yes, with DirichletCondition[ u[x, y, z] == 5, -xair <= x <= xmax && -1 <= z <= 1 && ymm[[1]] <= y <= ymm[[2]]] Mathematica FEM automatically computed all cells on the surface of object included in the mesh. $\endgroup$ Commented Mar 6, 2022 at 16:14
  • $\begingroup$ I see, thank you. $\endgroup$
    – E Crane
    Commented Mar 6, 2022 at 16:19
  • $\begingroup$ @ECrane You are welcome! $\endgroup$ Commented Mar 6, 2022 at 16:46

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.