sampsapursiainen / zeffiro_interface

Interface for using finite elements in inverse problems with complex domains
GNU General Public License v3.0
23 stars 15 forks source link

Split mesh generation into proper functions #246

Open SeSodesa opened 11 months ago

SeSodesa commented 11 months ago

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 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.

Context

Name Value
Version bf185da9 Add files via upload
OS Any and all
Shell Any and all
SeSodesa commented 11 months ago

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.