cellml / libcellml

Repository for libCellML development.
https://libcellml.org
Apache License 2.0
16 stars 21 forks source link

Improve human readability in C generation #1171

Open FinbarArgus opened 1 year ago

FinbarArgus commented 1 year ago

Include Aliases to improve the readability of generated C code.

Currently generated code looks like:

rate[1] = f(variable[1], variable[2])
rate[2] = g(variable[1], variable[2])

It would be nice to have a flag for human readability that changes the generated code to something like this:

name_of_variable_1 = variable[1]
name_of_variable_2 = variable[2]

d_name_of_variable_1 = f(name_of_variable_1, name_of_variable_2)
d_name_of_variable_2 = g(name_of_variable_1, name_of_variable_2)

rate[1] = d_name_of_variable_1
rate[2] = d_name_of_variable_2

Or something similar?

This would make it much easier to collaborate with other groups, i.e. if I want to generate an ANS model to collaborate with a group working on CVS modelling I need to send them the C++ code of the ANS model. If it's not readable it makes things tough. It would also make debugging errors within steps of the solver much easier.

agarny commented 1 year ago

Definitely possible and relatively easy to do. We could make it an option to Generator::implementationCode().