I have created a 3D graphic using GraphicsComplex and then use ToElementMesh to generate a 3D Mesh that I want to solve a PDE on, but I cannot figure out how to apply ElementMarkers to the Boundaries. I am aware of the boundaryMarkerFunction but cannot seem to apply it correctly. Nice would be to apply the ElementMarkers to the faces of the 3D Graphic which is then Discretized using DiscretizeGraphics. Most examples of the boundaryMarkerFunction floating around seem to be for 2D meshes. In particular I would like to assign different boundary conditions to the base and fins of the object, therefore need appropriate ElementMarkers.
My Code is
Needs["NDSolve`FEM`"]
ft = 0.002;
fb = 0.005;
fh = 0.04;
bt = 0.005;
fins = 8;
w = 0.1;
l = 0.1;
g = (w - (fins*fb))/(fins - 1);
dfx = (fb - ft)/2;
dx = 2*dfx + ft + g;
nodes = 4*fins + 2;
base = {{0, y, 0}, {w, y, 0}, {w, y, bt}};
lastfin = {{dfx + ft, y, bt + fh}, {dfx, y, bt + fh}, {0, y, bt}};
restfins =
Flatten[Table[{{w - dfx - i*dx, y, bt + fh}, {w - dfx - ft - i*dx,
y, bt + fh}, {w - 2*dfx - ft - i*dx, y,
bt}, {w - 2*dfx - ft - g - i*dx, y, bt}}, {i, 0, fins - 2}], 1];
face1 = Join[base, restfins, lastfin] /. y -> 0;
face2 = Join[base, restfins, lastfin] /. y -> l;
fintops =
Table[{4 + 4 i, 4 + nodes + 4 i, 5 + nodes + 4 i, 5 + 4 i}, {i, 0,
fins - 1}];
basetops =
Table[{6 + 4 i, 6 + nodes + 4 i, 7 + nodes + 4 i, 7 + 4 i}, {i, 0,
fins - 2}];
finsidesright =
Table[{5 + 4 i, 5 + nodes + 4 i, 6 + nodes + 4 i, 6 + 4 i}, {i, 0,
fins - 2}];
finsidesleft =
Table[{7 + 4 i, 7 + nodes + 4 i, 8 + nodes + 4 i, 8 + 4 i}, {i, 0,
fins - 2}];
heatsink =
Graphics3D[
GraphicsComplex[Join[face1, face2],
Polygon[Join[{Table[i, {i, 1, nodes}],
Table[i, {i, nodes + 1, 2*nodes}], {1, 2, 2 + nodes,
1 + nodes}, {2, 2 + nodes, 3 + nodes, 3}, {3, 3 + nodes,
4 + nodes, 4}, {1, 1 + nodes, nodes + nodes, nodes}, {nodes,
2*nodes, 2*nodes - 1, nodes - 1}}, fintops, basetops,
finsidesright, finsidesleft]]]]
DiscretizeGraphics[heatsink]
looks a bit strange:
Fortunately, however, ToElementMesh
looks okay
mesh = ToElementMesh[DiscretizeGraphics[heatsink]]["Wireframe"]
Any tips on how I can assign the faces / boundaries "ElementMarkers" would be most appreciated.
Note at first I used Regions to create the object but it seemed to get distorted during meshing unless a very fine mesh was used.
bmesh = ToBoundaryMesh[DiscretizeGraphics[heatsink], "BoundaryMarkerFunction" -> (2 & /@ # &)]; emesh = ToElementMesh[bmesh]
-- there might be other ways, but it's a little unclear whether you want different markers on the bound. $\endgroup$BoundaryDiscretizeGraphics
issue as a bug. $\endgroup$