refactor(meshGeneration): working on gmsh to generate curvilinear isogeomatric spherical mesh

This commit is contained in:
2025-04-30 07:26:58 -04:00
parent ec37fda35b
commit 424f6eee9b
11 changed files with 43664 additions and 28 deletions

View File

@@ -0,0 +1,38 @@
SetFactory("OpenCASCADE");
// Define parameters - these can be overridden from the command line
// using the -setnumber flag, e.g., gmsh sphere.geo -setnumber Parameters/Order 2
DefineConstant[
radius = {1.0, Name "Parameters/Radius"},
coreRes = {0.01, Name "Parameters/CoreRes"},
outerRes = {0.1, Name "Parameters/OuterRes"},
kVal = {2.0, Name "Parameters/K"},
order = {2, Name "Parameters/Order"} // Mesh element order
];
// Define Geometry
Sphere(1) = {0, 0, 0, radius};
Physical Volume("sphere_volume", 1) = {1}; // Tag the volume
// Define variable mesh size using a MathEval Field
// Field Formula: a + (b-a) * (1 - Exp(-k*r))
// Need to handle r=0 case for Sqrt and Exp
Field[1] = MathEval;
Field[1].F = Sprintf("%.15g + (%.15g - %.15g) * (1 - Exp(-%.15g * Max(Sqrt(x*x+y*y+z*z), 1e-9)))", coreRes, outerRes, coreRes, kVal);
// Use this field as the background mesh size field
Background Field = 1;
// Set Mesh Options
Mesh.ElementOrder = order; // Set the mesh order (1=linear, 2=quadratic, etc.)
// Optional: Optimize high-order elements for better quality
// Mesh.HighOrderOptimize = 1;
// Optional: Choose 3D meshing algorithm if default isn't good (e.g., 1=MeshAdapt, 4=Frontal, 5=Delaunay, 6=Frontal-Delaunay, 7=MMG3D)
// Mesh.Algorithm3D = 7;
// Define Physical Groups (optional but good practice)
// Physical Volume("sphere_volume", 1) = {1}; // Tag the volume
// Physical Surface("sphere_surface", 2) = {1}; // Tag the boundary surface