2
$\begingroup$

I have been trying to refine a cylindrical mesh that i have generated but somehow the refinement that i visualize is not exactly that i prescribed. Here is the piece of code for it.

<< NDSolve`FEM`;
lsub0 = 0.1;
R = 0.5;
L = 8;
COD = 0.1;
aDim = 0.2;
reg1 = Cylinder[{{0, 0, 0}, {0, 0, L}}, R];
p1 = {-R, -aDim, L/2}; p2 = {-R, -R, L/2 + COD}; p3 = {-R, -R, 
L/2 - COD};
p4 = {R, -aDim, L/2}; p5 = {R, -R, L/2 + COD}; p6 = {R, -R, L/2 - COD};
reg2 = Prism[{p1, p2, p3, p4, p5, p6}];
reg3 = RegionDifference[reg1, reg2];
elVol = (lsub0/2)^3/(6 \[Sqrt]2);
Omegasuph = 
ToElementMesh[reg3, {{-R, R}, {-R, R}, {0, L}}, 
MaxCellMeasure -> {"Volume" -> 0.5}, "MeshOrder" -> 1, 
MeshRefinementFunction -> 
Function[{vertices, Vol}, 
Block[{x, y, z, tol}, {x, y, z} = Mean[vertices]; tol = 0.05; 
 If[(z <= L/2 + tol && z >= L/2 - tol) , Vol > elVol, Vol > 5]]]]

I am trying to refine the region at z = L/2, where L is the length of the cylinder. The mesh after refinement is shown below.The mesh doesn't get refined all the way to the top. In the mesh refinement function, i have not prescribed any bounds on x and y as i would like to refine it for all x and y between z = L/2-tol and z = L/2+tol. I would really appreciate any pointers on what am i doing wrong here. My apologies for the long description of the problem. Thanks.

Omegasuph[
 "Wireframe"["MeshElement" -> "MeshElements", 
  PlotRange -> {All, All, {L/2 - 0.2, L/2 + 0.2}}]]

mesh after refinement

$\endgroup$
3
$\begingroup$

I think the boundary mesh needs to be a bit finer for this:

Omegasuph = 
  ToElementMesh[reg3, {{-R, R}, {-R, R}, {0, L}}, 
   MaxCellMeasure -> {"Volume" -> 0.5}, "MeshOrder" -> 1, 
   "MaxBoundaryCellMeasure" -> 0.05, 
   MeshRefinementFunction -> 
    Function[{vertices, Vol}, 
     Block[{x, y, z, tol}, {x, y, z} = Mean[vertices]; tol = 0.1;
      If[((z <= L/2 + tol) && (z >= L/2 - tol)), Vol > elVol, 
       Vol > 1]]]];
Omegasuph[
 "Wireframe"["MeshElement" -> "MeshElements", 
  PlotRange -> {All, All, {L/2 - 0.2, L/2 + 0.2}}]]

enter image description here

$\endgroup$
  • $\begingroup$ @User21Thank you. I somehow missed it completely as i thought the meshrefinement function takes care of it. $\endgroup$ – KVK318 Apr 11 '18 at 14:25
  • $\begingroup$ @KVK318, and it usually does work like you suggest; perhaps a little short coming in TetGen. Not serious I think though. $\endgroup$ – user21 Apr 12 '18 at 5:11

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.