cs481-ekh / s24-meshers

MIT License
0 stars 0 forks source link

Develop a suitable file format that users can input to pyMGM #59

Open paulvxx opened 9 months ago

paulvxx commented 9 months ago

References #11 and #13

[ ] - As a developer/user, I need a convenient file format that can handle raw data such as matrix entries (or possibly elliptical partial differential equations, or both, or any other component relevant to MGM problem input) [ ] - In addition, I need to develop a method in python which can successfully parse such a file, and load the data directly into the gallery class [ ] - I also need a way to test that the data was successfully transferred over to entities in the gallery class

gradywright commented 9 months ago

The typical way sparse matrices are stored is in CSR or CSC - see the scipy.sparse.csc_matrix and scipy.sparse.csr_matrix functions.

You can also load in MATLAB .mat files using scipy.io.loadmat. This will be a convenient way to load in the current data files from the mgm/+util/matrices directory, which is what the gallery function loads in. To get the matrices, nodes, right hand side, and exact solution from this data file you would do something like

from scipy.io import loadmat
m_dict = loadmat(`PoissonNeumann2DDiskFenicsP3.mat`)
Lh = m_dict['Lh']
x = m_dict['x']
fh = np.transpose(m_dict['fh'])
uexact = np.transpose(m_dict['uexact'])