1

I'm trying to plot a finite element mesh with its node id's. But i'm facing a problem with the ListLinePlot, which connects all poits, instead connect only the neighbour node. I need to eliminate the diagonal lines from the following ListLinePlot:

topol={{4, 1, 5, 8, 3, 2, 6, 7}, {5, 13, 17, 8, 10, 15, 11, 6},
       {30, 37, 35, 26, 33, 36, 31, 28}, {35, 32, 24, 26, 34, 29, 25, 31},
       {17, 23, 18, 8, 20, 21, 12, 11}, {4, 8, 18, 14, 7, 12, 16, 9},
       {24, 14, 18, 26, 19, 16, 22, 25}, {26, 18, 23, 30, 22, 21, 27, 28}};

nnodes = {{0, 6}, {0, 4.5}, {2.5, 6}, {0, 3}, {2.5, 3}, {0, 1.5}, {5, 6},
          {5, 4.5}, {5, 3}, {0, 0}, {2.5, 0}, {5, 1.5}, {7.5, 6}, {5, 0},
          {7.5, 3}, {7.5, 0}, {10, 6}, {10, 4.5}, {10, 3}, {10, 1.5}, {10, 0}};

 allcoords = {{{5, 0}, {5, 3}, {0, 3}, {0, 0}, {5, 1.5}, {2.5, 3}, {0, 1.5}, {2.5, 0}}, 
              {{10, 0}, {10, 3}, {5, 3}, {5, 0}, {10, 1.5}, {7.5, 3}, {5, 1.5}, {7.5, 0}},
              {{5, 3}, {5, 6}, {0, 6}, {0, 3}, {5, 4.5}, {2.5, 6}, {0, 4.5}, {2.5, 3}},
              {{10, 3}, {10, 6}, {5, 6}, {5, 3}, {10, 4.5}, {7.5, 6}, {5, 4.5}, {7.5, 3}}};

nodeids = 
  ListPlot[Table[Labeled[nnodes[[i]], i], {i, Length@nnodes}], 
   AspectRatio -> Automatic];
undefplot = 
  ListLinePlot[Tooltip[allcoords], AspectRatio -> Automatic, 
   PlotMarkers -> Automatic, PlotStyle -> {Thick}];
Show[nodeids, undefplot]

enter image description here

I need something like this:

Needs["NDSolve`FEM`"]
q = QuadElement[topol]
mesh = ToElementMesh["Coordinates" -> nnodes, "MeshElements" -> {q}]
Show[mesh["Wireframe"],
 mesh["Wireframe"["MeshElement" -> "PointElements", 
   "MeshElementStyle" -> Directive[Red, PointSize[0.02]], 
   "MeshElementIDStyle" -> Blue]]]

enter image description here

But in the figure above is missing the interior nodes.

How can i do that? Thank you!

corey979
  • 23,947
  • 7
  • 58
  • 101
Stratus
  • 2,942
  • 12
  • 24

1 Answers1

3
ord = FindCurvePath /@ allcoords // Flatten[#, 1] &;

allcoordsNEW = MapThread[Part[#1, #2] &, {allcoords, ord}];
 (* or *)
allcoordsNEW = Table[allcoords[[i, ord[[i]]]], {i, 1, Length@ord}];

undefplot = 
  ListLinePlot[Tooltip[allcoordsNEW], AspectRatio -> Automatic, 
   PlotMarkers -> Automatic, PlotStyle -> {Thick}];

Show[nodeids, undefplot]

enter image description here

corey979
  • 23,947
  • 7
  • 58
  • 101