How to import image with .svg image file format in Gmsh and mesh it ?
Hi,
I am interested in knowing how can I mesh an SVG
image file format. Till now, I have used PNG
in geo file and applying mesh on it and it was serving what I wanted to do but now I am facing issue in which PNG
might be the cause of the error. Kindly see this post How to understand and solve the unforeseen issue of iterative solver and Gmsh generated msh file? on FEniCS discourse which explains why I want to try SVG
instead of PNG
. I was using the below code for meshing PNG file -
If(PostProcessing.NbViews == 0)
// Merge the image (this will create a new post-processing view, View[0]), and
// modify the normalized pixel values (v0) to make them reasonnable
// characteristic lengths for the mesh
Merge "input.png";
//Plugin(ModifyComponents).Expression0 = "v0 * 10";
Plugin(ModifyComponents).Expression0 = "1 + v0^2 * 10";
Plugin(ModifyComponents).Run;
EndIf
// Apply the view as the current background mesh
Background Mesh View[0];
// Build a simple geometry on top of the background mesh
w = View[0].MaxX;
h = View[0].MaxY;
Point(1)={0,0,0,w};
Point(2)={w,0,0,w};
Point(3)={w,h,0,w};
Point(4)={0,h,0,w};
Line(1) = {1,2};
Line(2) = {2,3};
Line(3) = {3,4};
Line(4) = {4,1};
Line Loop(5) = {3,4,1,2};
Plane Surface(6) = {5};
outfile = StrCat(CurrentDirectory, "out.png");
DefineConstant[
algo = {Mesh.Algorithm, AutoCheck 0, GmshOption "Mesh.Algorithm",
Choices{1="MeshAdapt", 5="Delaunay", 6="Frontal", 8="DelQuad"},
Name "Meshing parameters/Algorithm"},
sizeFact = {Mesh.CharacteristicLengthFactor, AutoCheck 0,
GmshOption "Mesh.CharacteristicLengthFactor", Min 0.1, Max 10, Step 0.1,
Name "Meshing parameters/Element size factor"},
sizeMin = {Mesh.CharacteristicLengthMin, AutoCheck 0,
GmshOption "Mesh.CharacteristicLengthMin", Min w/100, Max w, Step 0.1,
Name "Meshing parameters/Minimum element size"},
save = {StrCat("View.ShowScale=0;Print '", CurrentDirectory, "out.png';"),
AutoCheck 0, Macro "GmshParseString",
Name "Save PNG"}
];
Mesh.ColorCarousel = 0;
Mesh.Color.Triangles = Black;
Mesh.Color.Quadrangles = Black;
Mesh.RecombineAll = (algo == 8);
Solver.AutoMesh = 2; // always remesh//+
I want to do similar thing with SVG file, kindly suggest how can I go about it. Thanks.