Currently, the mesh generation routine utilizes Matlab-style scripts, which are simply inserted in the middle of other code when it is being compiled, making it difficult to follow where different variables come from. As an example, we might take a look at the lines 5–31 in zef_create_fem_mesh:
Here the problem is that pml_ind_aux is not defined anywhere in this file, and is instead generated in the script zef_segmentation_counter_step, the code of which is inserted place of its invocation on line 9, when the function is being compiled. This is all completely hidden from the user, unless they realize that they should look into the mentioned script.
Expected behavior
It would be much more readable, if scripts were turned into functions, with clear input and output values. This might also make the code more optimizable for the Matlab compiler. Any other scripts than the one mentioned here should also get the same treatment.
As an additional note, this also facilitates the extraction of one of the core Zeffiro Interface components, the mesh generation routine, into its own module.
Description
Currently, the mesh generation routine utilizes Matlab-style scripts, which are simply inserted in the middle of other code when it is being compiled, making it difficult to follow where different variables come from. As an example, we might take a look at the lines 5–31 in
zef_create_fem_mesh
:https://github.com/sampsapursiainen/zeffiro_interface/blob/3b1b2ffedc08cff1102a3bd88315e78221bfcccb/m/zef_create_fem_mesh.m#L5-L31
Here the problem is that
pml_ind_aux
is not defined anywhere in this file, and is instead generated in the scriptzef_segmentation_counter_step
, the code of which is inserted place of its invocation on line 9, when the function is being compiled. This is all completely hidden from the user, unless they realize that they should look into the mentioned script.Expected behavior
It would be much more readable, if scripts were turned into functions, with clear input and output values. This might also make the code more optimizable for the Matlab compiler. Any other scripts than the one mentioned here should also get the same treatment.
Context