Generation and export of system matrices

More
4 years 1 month ago #3252 by michiba
Hello,

I want to integrate the FE model of a given geometry in a simulation model that is solved in another tool, e.g. Matlab. For that I want to mesh the geometry with Netgen and generate/export the system matrices (as linearization at a given point).


The problem would be a transient heat transfer problem. The interface/BC should be the heat flux densities at the surface elements of the generated mesh.

Would this be possible to do with Netgen/NGSolve?

Thanks!
Michael
More
4 years 1 month ago #3253 by christopher
In principle? Yes. You can create numpy/scipy matrics from NGSolve and afaik you can store these matrices in Matlab format. Probably won't be very efficient though...
More
4 years 1 month ago #3254 by michiba
Thanks for the rapid reply.
Efficiency is not our major concern atm.
Can you give me an entry point in the documentation for this?
More
4 years 1 month ago #3255 by christopher
I think the easiest way is to first go to numpy. Then there is a lot of stuff online for numpy <-> matlab. For exporting to numpy see for example here:

ngsolve.org/docu/latest/how_to/howto_numpy.html?highlight=scipy
More
4 years 1 month ago #3256 by michiba
Ok, thanks. I guess Numpy/Matlab is already covered on my side.
Basically I wanted to know if there is (easy) access to a vector/matrix representation of the system equations in NGSolve.
More
4 years 1 month ago #3257 by christopher
Yes. After assembling the matrix (stored in sparse csr format) is accessible by a.mat, the vector of the right hand side as f.vec. The sparse matrix has .CSR and .COO methods to get numpy arrays for the different sparse matrix formats.

For the input it depends how your heat flux is given. If it is described by a function you can formulate it using NGSolve CoefficientFunctions.
Time to create page: 0.111 seconds