Data communication between dealii and other tools written in different languages

57 views
Skip to first unread message

Yiliang Wang

unread,
Nov 28, 2024, 6:08:10 PM11/28/24
to deal.II User Group
Hi

I need to exchange data between dealii and another software written in different languages. To achieve the best efficiency, it is better to print and load data in a binary mode. 

I found an example of code (see here) which exchange data between dealii and Matlab in a binary mode. But this is only for Vector. I am wondering if there is any codes for the exchange of sparse matrix in the same way.

Best regards,
Yiliang

Wolfgang Bangerth

unread,
Nov 30, 2024, 11:06:24 AM11/30/24
to dea...@googlegroups.com
On 11/28/24 16:08, Yiliang Wang wrote:
>
> I need to exchange data between dealii and another software written in
> different languages. To achieve the best efficiency, it is better to print and
> load data in a binary mode.
>
> I found an example of code (see here <https://
> nam10.safelinks.protection.outlook.com/?
> url=https%3A%2F%2Fgithub.com%2Fdealii%2Fdealii%2Fwiki%2FInterfacing-With-
> Matlab&data=05%7C02%7CWolfgang.Bangerth%40colostate.edu%7C1928ed4acf844c0fe18c08dd103ce754%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638684575965135717%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=GDadNa2RHaL1pZ4Tmx4K6O%2BlDG8K4h%2BsHNQw9u1etA0%3D&reserved=0>) which exchange data between dealii and Matlab in a binary mode. But this is only for Vector. I am wondering if there is any codes for the exchange of sparse matrix in the same way.

Yiliang,
I don't know if there are corresponding examples, but you can probably utilize
the SparseMatrix::block_write() function in the same way as for the vector class:
https://www.dealii.org/current/doxygen/deal.II/classSparseMatrix.html#a8b32b99a054482f06fc026248c27bb74
You will have to understand the format in which the block_write() function
writes the data so that you can read it in the other program. That's
relatively straightforward for vectors since they are just one long array, but
it should not be very difficult to do the same for matrices as well.

Best
W.

Yiliang Wang

unread,
Dec 3, 2024, 8:19:49 AM12/3/24
to dea...@googlegroups.com
Thank you for your reply, Dr. Bangerth. I will take a look at block_write() and figure out how to read the binary data.

Best regards,
Yiliang Wang

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dealii/23874582-50a2-48ef-a7ce-907cc288a18c%40colostate.edu.
Reply all
Reply to author
Forward
0 new messages