4
$\begingroup$

I'm trying to generate mesh for axial symetric heat transfer model. The model contains four regions build from four different kinds of materials.

Inside the steel component is empty air hole present.

I tried to join coordinates from every region, and then use ToBoundaryMesh with LineElement like technique below:

el = LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 
     8}, {8, 1}, {2, 7}, {3, 6}}];
bmesh = ToBoundaryMesh["Coordinates" -> coord, 
   "BoundaryElements" -> {el}];

Show[bmesh["Wireframe"],
 bmesh["Wireframe"["MeshElement" -> "PointElements", 
   "MeshElementStyle" -> Directive[Red, PointSize[0.02]], 
   "MeshElementIDStyle" -> Blue]]]

Unfortunately, It seems to be a little bit complicated way, besides I have a problem with an element containing an air hole.

Could you give me any advice how to do that? What is the best technic to solve this type of task?

I will be appreciated for any help.

Below defined polygons and graphics (pic) in order to you may see what I have tried to meshing.

ClearAll["Global`*"]
Needs["NDSolve`FEM`"];
mcr = Polygon[{{0.275, 0.095}, {0.398, 0.095}, {0.447, 0.308}, {0.447,
      0.323}, {0.415, 0.323}, {0.415, 0.350}, {0.447, 0.350}, {0.447, 
     0.868}, {0.275, 0.868}, {0.275, 0.095}}];
betw = Polygon[{{0.398, 0.095}, {0.447, 0.308}, {0.447, 
     0.323}, {0.415, 0.323}, {0.415, 0.350}, {0.447, 0.350}, {0.447, 
     0.868}, {0.483, 0.868}, {0.483, 0.350}, {0.440, 0.350}, {0.440, 
     0.333}, {0.485, 0.333}, {0.485, 0.308}, {0.423, 0.095}}];
betz = Polygon[{{0.275, 0}, {0.620, 0}, {0.620, 0.772}, {0.528, 
     0.772}, {0.528, 0.588}, {0.513, 0.588}, {0.513, 0.308}, {0.449, 
     0.095}, {0.275, 0.095}}];

st = Polygon[{{0.528, 0.772}, {0.620, 0.772}, {0.620, 0.786}, {0.528, 
     0.786}, {0.528, 0.818}, {0.520, 0.818}, {0.513, 0.818}, {0.513, 
     0.868}, {0.483, 0.868}, {0.483, 0.350}, {0.440, 0.350}, {0.440, 
     0.333}, {0.485, 0.333}, {0.485, 0.308}, {0.423, 0.095}, {0.449, 
     0.095}, {0.513, 0.308}, {0.513, 0.588}, {0.528, 0.588}}];
air = Polygon[{{0.495, 0.608}, {0.513, 0.608}, {0.513, 0.798}, {0.495,
      0.798}}];

steel = RegionDifference[st, air];

pic= Graphics[
  {
   {EdgeForm[Thin], LightBlue, mcr},
   {EdgeForm[Thin], LightGray, betw},
   {EdgeForm[Thin], LightGreen, betz},
   {EdgeForm[Thin], LightYellow, steel}
   },
  PlotRange -> {{0, 0.7}, {-0.1, 1}}, Frame -> True
  ]

My join cooordinates problem...

coord = Join[MeshCoordinates@MeshRegion@mcr, 
  MeshCoordinates@MeshRegion@betw, MeshCoordinates@MeshRegion@betz, 
  MeshCoordinates@MeshRegion@steel]

likzew

$\endgroup$
1
  • $\begingroup$ In essence you need to clean up your data a bit. $\endgroup$ – user21 Feb 17 at 14:48
6
$\begingroup$

I think you betw data is a bit messed up. I show you how to work around that.

We ignore betw and in stead ad a line connecting the str and mcr

boundaries = {mcr, betz, st, air};

Needs["NDSolve`FEM`"]
bms = Join[
   ToBoundaryMesh /@ 
    boundaries, {ToBoundaryMesh[
     "Coordinates" -> {{0.447`, 0.868`}, {0.483`, 0.868`}}, 
     "BoundaryElements" -> {LineElement[{{1, 2}}]}]}];

Next we use the FEMAddOns to merge the boundaries.

ResourceFunction["FEMAddOnsInstall"][]
Needs["FEMAddOns`"]
bm = BoundaryElementMeshJoin[Sequence @@ bms];
bm["Wireframe"]

enter image description here

Now, we generate the full mesh, with air as the region hole and the other parts set as markers. Because we can we use different refinements in different sub-regions:

com = RegionCentroid /@ {mcr, betz, betw, st};
markers = 
  Transpose[{com, {1, 2, 3, 4}, {0.01, 0.01, 0.0001, 0.000025}}];
(mesh = ToElementMesh[bm,
    "RegionMarker" -> markers,
    "RegionHoles" -> RegionCentroid[air]])["Wireframe"]

enter image description here

Because we have a 0 marker there is still some sub-region not properly connected.

groups = mesh["MeshElementMarkerUnion"]
{0, 1, 2, 3, 4}

We visualize the mesh with colored sub-regions:

temp = Most[Range[0, 1, 1/(Length[groups])]];
colors = ColorData["BrightBands"][#] & /@ temp;
mesh["Wireframe"[
  "MeshElementStyle" -> (Directive[FaceForm[#]] & /@ colors)]]

enter image description here

We see that the red and green area should be connected but are not, you'd need to take a look at that.

$\endgroup$
3
  • $\begingroup$ Excellent, It seems you help me very much. I have to review carefully FEMAddOns and Indeed region green and red it is the same material. I will try to correct it. Thank you for your remarks. $\endgroup$ – likzew Feb 17 at 18:13
  • 1
    $\begingroup$ @likzew, the geometry looks like it's an interesting application, would you be willing to contribute that to the FEMAddOns PDE Model Application collection? $\endgroup$ – user21 Feb 18 at 5:10
  • $\begingroup$ of course, if you think so, I will be happy to share the model. $\endgroup$ – likzew Feb 18 at 10:07

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.