@@ -24,42 +24,35 @@ export class meshGeneration {
2424 * @param {number } [config.numElementsY=1] - Number of elements along the y-axis (for 1D meshes)
2525 * @param {number } [config.maxY=0] - Maximum y-coordinate of the mesh (for 1D meshes)
2626 * @param {string } [config.meshDimension='2D'] - The dimension of the mesh, either 1D or 2D
27- * @param {string|File } [config.meshFile=null] - Optional mesh file for predefined meshes (.msh)
2827 * @param {string } [config.elementOrder='linear'] - The order of elements, either 'linear' or 'quadratic'
28+ * @param {object } [config.parsedMesh=null] - Optional pre-parsed mesh data
2929 */
3030 constructor ( {
3131 numElementsX = null ,
3232 maxX = null ,
3333 numElementsY = null ,
3434 maxY = null ,
3535 meshDimension = null ,
36- meshFile = null ,
3736 elementOrder = "linear" ,
37+ parsedMesh = null ,
3838 } ) {
3939 this . numElementsX = numElementsX ;
4040 this . numElementsY = numElementsY ;
4141 this . maxX = maxX ;
4242 this . maxY = maxY ;
4343 this . meshDimension = meshDimension ;
44- this . meshFile = meshFile ;
4544 this . elementOrder = elementOrder ;
45+ this . parsedMesh = parsedMesh ;
4646 }
4747
4848 /**
49- * Function to generate the mesh based on the dimension or parse a custom mesh file
49+ * Function to generate the mesh based on the dimension or use a pre-parsed mesh
5050 * @returns {object } The generated mesh containing node coordinates and total nodes
5151 */
5252 generateMesh ( ) {
53- if ( this . meshFile ) {
54- // If a mesh file is provided, check if it's a Gmsh (.msh) file and parse it
55- if ( ( typeof this . meshFile === 'string' && this . meshFile . toLowerCase ( ) . endsWith ( '.msh' ) ) ||
56- ( this . meshFile instanceof File && this . meshFile . name . toLowerCase ( ) . endsWith ( '.msh' ) ) ) {
57- return this . generateMeshFromMshFile ( this . meshFile ) ;
58- } else {
59- const errorMessage = "Only .msh files are supported for mesh import" ;
60- errorLog ( errorMessage ) ;
61- throw new Error ( errorMessage ) ;
62- }
53+ // If pre-parsed mesh data is provided, use it directly
54+ if ( this . parsedMesh ) {
55+ return this . parsedMesh ;
6356 } else {
6457 // Validate required geometry parameters based on mesh dimension
6558 if ( this . meshDimension === "1D" ) {
@@ -88,19 +81,6 @@ export class meshGeneration {
8881 }
8982 }
9083
91- /**
92- * Function to import a mesh from a Gmsh (.msh) file
93- * @param {string|File } file - Path or File object to the mesh file (.msh format)
94- * @returns {object } An object containing the coordinates of nodes,
95- * total number of nodes, nodal numbering (NOP) array, and boundary elements
96- */
97- async generateMeshFromMshFile ( file ) {
98- // Import mesh data from the Gmsh file
99- const outputMesh = await importGmshQuadTri ( file ) ;
100-
101- return outputMesh ;
102- }
103-
10484 /**
10585 * Function to generate a structured mesh based on the geometry configuration
10686 * @returns {object } An object containing the coordinates of nodes,
0 commit comments