- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hi;

I have C++ FEM code wrote long time ago with its own functions. Now, i am trying to upgrade this code to be faster. i am trying to convert the existing linear system function to the mkl linear system functions. the bottelneck here is the assembly of the global stiffness matrix in csr format. i want to use PARDISO solver, so i have to assemble the global matrix in csr format taking in consideration that we do not know the No. of nonzero elements (NNZ) so we have to maximize NNZ to the max possible number.

Is there any exsiting function/s that can do this?

Any Ideas will be appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

There is nothing tricky about assembling FEM global matrices. For each element, you have to determine the mapping between local node numbers (e.g., 1-2-3-4 for a four-node element) and global node numbers. If you write A(i,j) = expr. when assembling a dense A matrix, instead you write:

nnz = nnz+1

row(nnz) = i

col(nnz) = j

val(nnz) = expr

When you have done this for all elements in the mesh, you have the COO representation of the global matrix. There will be some multiple entries, that is, more than one entry in VAL may be present for the same values of ROW and COL. to consolidate them, you have to sort by row and column, and sum up entries that share row and column, thus obtaining the CSR data. MKL_?CSRCOO does this conversion, if you wish to use it.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

You may have to make two passes over the mesh. In the first pass, only the connectivity is of interest, and the calculations to find the element contributions to the global matrix can be skipped. During this process, there can be multiple contributions to A_{ij} coming from adjacent elements, and book-keeping work is needed to keep track of and consolidate these contributions. At the end of this pass, the row index array IA will have been formed. The final value in this array will be nnz, and that value is used to allocate the column index and value arrays JA and A.

During the second pass, the element contributions are calculated and inserted into their proper places in A.

Alternatively, you can assemble the matrix in coordinate oriented format (COO), and call mkl_csrcoo() to obtain the CSR data.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Thank you for your response

Is that very tricky to be implemented directly?, i mean , i spent some time searching but i did not find a way to implement it. even, i did not find a way to assemble in coo format.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

There is nothing tricky about assembling FEM global matrices. For each element, you have to determine the mapping between local node numbers (e.g., 1-2-3-4 for a four-node element) and global node numbers. If you write A(i,j) = expr. when assembling a dense A matrix, instead you write:

nnz = nnz+1

row(nnz) = i

col(nnz) = j

val(nnz) = expr

When you have done this for all elements in the mesh, you have the COO representation of the global matrix. There will be some multiple entries, that is, more than one entry in VAL may be present for the same values of ROW and COL. to consolidate them, you have to sort by row and column, and sum up entries that share row and column, thus obtaining the CSR data. MKL_?CSRCOO does this conversion, if you wish to use it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

*);*

);

*);*

);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

You have shown some bits of code. Depending on what is in the other lines of code in the program, and on what was left out but should have been present, the program may or may not work. We would not write a program to handle a problem with exactly two elements. With a small number of elements, a dense matrix solver, such as one of the Lapack routines, would be easier to use.

Your job[] values are definitely wrong. Consult the documentation, look at the examples provided with MKL, and correct your mistakes.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

This is a separate trial code i have made for myself to try how things work. I know that i should make a general code for any element/number of element. I am sorry for no attaching the error message. But i received this messages while trying to compile the code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

The error messages are perfectly clear. For instance, take the third argument to mkl_dcsrcoo(). What should its type be, according to the documentation? What is the type that you are passing? What should its value be? What is the value that you are passing?

These are matters that you must learn to handle by yourself.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page