<div dir="ltr"><div dir="ltr">Hello all,<div><br></div><div>I am trying to refine a mesh to be very fine around a curve and very coarse away from it. This works very well using one or two curves (photo 1) using Distance and Threshold. When I try and do more curves (completing a circuit)  the mesh becomes fine everywhere on the plane (Photo 2) ignoring the mesh size at DistMax. I understand there are other functions such as  Box or cylinder but I need this to work for any geometry. My code is below, It is a simple example of a box. The loop is to find the lines that make up the surface on which I am trying to refine the boundary. Any help would be greatly appreciated!</div><div><br></div><div>Thanks,</div><div>Terrence </div><div><div><img src="cid:ii_jqs7uo550" alt="photo1.PNG" width="498" height="425"><div><img src="cid:ii_jqs7uo5n1" alt="photo2.PNG" width="498" height="432"><br></div></div></div><div><div>//+</div><div>SetFactory("OpenCASCADE");</div><div>ShapeFromFile("box.iges")</div><div>//+</div><div>lns[];</div><div>h = 0;</div><div>For i In {1:newl-1}</div><div>  pnts[] = Boundary{Line{i};}; </div><div>  Printf("line %g",i);</div><div>  Printf("point one = %g",pnts[0]);</div><div>  Printf("point two = %g",pnts[1]);</div><div>  coords1[] = Point{pnts[0]};</div><div>  coords2[] = Point{pnts[1]};</div><div>  If(coords1[2]==254 && coords2[2]==254)// 254=top surface z coord</div><div>    Printf("line %g is on boundary",i);</div><div>    lns[h] = i;</div><div>    h = h+1; </div><div>  EndIf    </div><div>EndFor</div><div>Field[1] = Distance;</div><div>Field[1].EdgesList = {lns[]};</div><div>Field[1].NNodesByEdge = 100;</div><div>Field[2] = Threshold;<br></div><div>Field[2].IField = 1;</div><div>Field[2].LcMin = 0.5;</div><div>Field[2].LcMax = 100;</div><div>Field[2].DistMin = 1;</div><div>Field[2].DistMax = 50;</div><div>Background Field = 2;<br></div></div><div><br></div><div><br></div></div></div>