4
$\begingroup$

I have just a misunderstanding of a sort. What I want is (1) to build a boundary mesh, (2) then to disassemble it into a list of the boundary points, and (3) to further assemble it back starting from this list.

What stays behind this task is to be able to later add elements to the this boundary mesh, to refine its parts etc. But this will come later. I am stuck on the very first step.

Let us take a simple disk for the trial. The following makes the boundary mesh of the disk.

    Needs["NDSolve`FEM`"]
bm = ToBoundaryMesh[Disk[]]
(*   ElementMesh[{{-1., 1.}, {-1., 1.}}, Automatic] *)

one can look at the resulting boundary mesh:

 Show[{
  bm["Wireframe"],
  bm["Wireframe"["MeshElement" -> "PointElements"]]
  }, ImageSize -> 150]

enter image description here

Now, let us retrieve the list of coordinates, coord and make the corresponding list of incidents, incLst. The list of incidents should be the same as it presumably was in the initial boundary mesh, that is, the first point connects to the second one, the second - to the third and so on, and the last point - to the first one:

    coord = bm["Coordinates"];
lth = Length[coord];
incLst = Join[Table[{i, i + 1}, {i, 1, lth - 1}], {{lth, 1}}]

(* {{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {9, 
  10}, {10, 11}, {11, 12}, {12, 13}, {13, 14}, {14, 15}, {15, 
  16}, {16, 17}, {17, 18}, {18, 19}, {19, 20}, {20, 21}, {21, 
  22}, {22, 23}, {23, 24}, {24, 25}, {25, 26}, {26, 27}, {27, 
  28}, {28, 29}, {29, 30}, {30, 31}, {31, 32}, {32, 33}, {33, 
  34}, {34, 35}, {35, 36}, {36, 37}, {37, 38}, {38, 39}, {39, 
  40}, {40, 41}, {41, 42}, {42, 43}, {43, 44}, {44, 45}, {45, 
  46}, {46, 47}, {47, 48}, {48, 1}}   *)

Now it seems that the following should again build the same boundary mesh:

    ToBoundaryMesh["Coordinates" -> coord, 
 "MeshElements" -> {LineElement[incLst]}]

It does not though. This operation returns the input unevaluated. So, clearly Mma cannot fulfill the operation.

What am I doing wrong?

$\endgroup$
5
$\begingroup$

You've done everything right, except it is not "MeshElements" but "BoundaryElements" you're supposed to specify. This works:

ToBoundaryMesh["Coordinates" -> coord, 
 "BoundaryElements" -> {LineElement[incLst]}]
$\endgroup$
  • $\begingroup$ Thank you, indeed. By the way, do you know, if it is possible to get the list of incidents just from the boundary mesh instead to creating it manually? $\endgroup$ – Alexei Boulbitch May 18 '15 at 11:42
  • $\begingroup$ @AlexeiBoulbitch yes, look in the (Details section of..) documentation for ElementMesh and you should be able to do bm["BoundaryElements"] which gets you {LineElement[{{1, 2}, {2, 3},...}]} so you can do bm["BoundaryElements"][[1,1]] to get the list $\endgroup$ – Histograms May 18 '15 at 11:58
  • 1
    $\begingroup$ @AlexeiBoulbitch, you could also use ElementIncidents to extract the incidents. $\endgroup$ – user21 May 18 '15 at 15:25
  • $\begingroup$ @ user21 It is interesting. How it is to be applied? My trial bm["ElementIncidents"] returns the error message: "ElementMesh::nomthd: "There is no method \!(\"ElementIncidents\") for ElementMesh objects". $\endgroup$ – Alexei Boulbitch May 19 '15 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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