Hi everyone,
I’ve been exploring different ways to encapsulate mesh creation in FreeFem++ (version 4.15), experimenting with the available data types. My goal is to build a catalog of functions, each of which takes a structure containing mesh parameters and returns a different mesh. While the parameters may vary between meshes, the structure should remain consistent.
I’ve tested passing the mesh parameters as an array:
func mesh meshFunction(real[int] meshParameters)
and as a dictionary (dynamic map):
func mesh meshFunction(real[string] meshParameters)
Passing an array works as expected and the script exits without error. However, passing a real[string] map causes a segmentation fault. After some testing, I noticed that both function definitions pass their arguments by value. I then tried passing the real[string] map by reference:
func mesh meshFunction(real[string]& meshParameters)
and it worked.
I suspect there might be an issue with how map<string, real>
is copied when passed by value, potentially causing a segmentation fault at the level of the virtual machine. I’m not sure whether this is a known issue, but I thought I’d share it in case it’s helpful to others encountering similar problems.
I’ve attached a minimal working example below.
mesh_dict.edp (1.9 KB)