简体   繁体   中英

Matrix from a input file to LAPACK and inverse to a output file again

I am working on a FEM project where I need a linear solution of Ku=f. I am doing this by LAPACK solver. As you may be familiar that sometimes the K matrix will be so huge (30GB). Its needs good ram to malloc such a matrix in conventional way. I just need your help if I can write the matrix to a file Can you please suggest me to input such a matrix from file itself to lapack solver and get output to a file.

Thanks in advance. Maharshi.

30G is not a large size for computing servers. You may want to upgrade your server.

With limited hardware, yes, you can put the matrix in file, and use the same LAPACK routines to solve the equation. The technique is called memory mapped file. It maps the content of a file to a memory address range with the same size, without allocating the physical memory. When you read/write the data from/to this address range, you are actually read/write the file.

https://en.wikipedia.org/wiki/Memory-mapped_file

On linux you can use mmap() to achieve this.

http://man7.org/linux/man-pages/man2/mmap.2.html

However the speed to access the memory address range is as slow as accessing the disk file.

Depending on the support of shape functions used in your FEM code, the matrix K is often sparse : most of the elements of the matrix are null. Hence, using a format dedicated to sparse matrices such as CSR is much more efficient to store the matrix. Unfortunately, LAPACK offers little support for such matrices, although it can handle banded matrices.

Take a look at the Eigen library or the PETSc library . These libraries provide interfaces to efficient solvers dedicated to sparse matrices. See there for PETSc. For instance, see Mumps or SuiteSparse .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM