12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061(* File: mesh_easymesh.ml
Copyright (C) 2006-
Christophe Troestler <Christophe.Troestler@umons.ac.be>
WWW: http://math.umons.ac.be/an/software/
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2.1 or
later as published by the Free Software Foundation, with the special
exception on linking described in the file LICENSE.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
LICENSE for more details. *)(** Put the full path if not in your search path. *)leteasymesh="EasyMesh.exe"openPrintfopenBigarrayclass['l]pslg=['l]Mesh.pslgletpslg=Mesh.pslgletcreate=Mesh.create(* Interface to easymesh -- gathering the FORTRAN and C layouts together
***********************************************************************)letread(typel)(layout:llayout)fname:lMesh.t=matchlayoutwith|C_layout->Mesh_easymeshC.readMesh_easymeshC.empty_pslgfname|Fortran_layout->Mesh_easymeshF.readMesh_easymeshF.empty_pslgfnamelettriangulate(typel)~max_area(pslg:lpslg)=(* Save domain file *)let(fname_plsg,fh)=Filename.open_temp_file"EasyMesh"".d"inletfname=Filename.chop_extensionfname_plsgin(matchMesh.layoutpslgwith|C_layout->Mesh_easymeshC.output_pslgfhpslgmax_area|Fortran_layout->Mesh_easymeshF.output_pslgfhpslgmax_area);close_outfh;(* Execute easymesh *)let_=Sys.command(sprintf"%s %s -m"easymeshfname)in(* The return code of EasyMesh is unrelialble, do not check it. *)(* Read the result *)letmesh:lMesh.t=matchMesh.layoutpslgwith|C_layout->Mesh_easymeshC.readpslgfname|Fortran_layout->Mesh_easymeshF.readpslgfnameinSys.remove(fname_plsg);Sys.remove(fname^".n");Sys.remove(fname^".e");Sys.remove(fname^".s");meshletwrite(typel)(mesh:lMesh.t)file=matchMesh.layoutmeshwith|C_layout->Mesh_easymeshC.writemeshfile|Fortran_layout->Mesh_easymeshF.writemeshfile