Reply to topic

How to efficiently assemble a FEM sparse matrix

flyhigh
Registered Member
Posts
1
Karma
0
Deal all,
Thank you for your time to read my question.
Eigen is really awesome, I'm using Eigen to write some FEM code.

I read the Eigen3.3.4 document, and in this website(http://eigen.tuxfamily.org/dox-devel/To ... Types.html), it says
we should use Ref<MatrixBase> to avoid the additioinal copy and obtain high performance.

So in my FEM code, for the sparse matrix assemble part, let's say the function is:

FormFE(const Ref<VectorXd> &U,const Ref<VectorXd> &V,Ref<SparseMatrix<double> > AMATRIX,Ref<VectorXd> RHS)

where U represent the displacement, V represent the velocity term. AMATRIX is my sparse matrix, RHS is the residual term.

Then I try to first initializing my AMATRIX before assemble(I have a tripletList which contains all the non-zero element and its value(I set the value to zero for initializing))
So I tried: AMATRIX.setFromTriplets(ZeroTripList.begin(),ZeroTripList.end());
But I have an error: class Eigen::Ref<Eigen::SparseMatrix<double, 0, int> >’ has no member named ‘setFromTriplets
So how could I solve this problem?

One of my solution is using
FormFE(const Ref<VectorXd> &U,const Ref<VectorXd> &V,SparseMatrix<double> &AMATRIX,Ref<VectorXd> RHS)

this is working very fine, but I'm not sure it is efficient or not.
I'm not very good at cpp :P

Actually, I have three questions:
1. How to efficiently use Eigen(especially for FEM calculation), I use Eigen's VectorXd and MatrixXd almost everywhere in each of my FEM-related function.
2. How to efficiently assemble a SparseMatrix?
3. Is it possible to do some OpenMP parallelization for the FEM assemble?

Thank you.
Best regards.
User avatar ggael
Moderator
Posts
3431
Karma
19
OS

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], boudewijn, Capitain_Jack, chrisogilvie, Exabot [Bot], flyfan, Google [Bot], JesusM, johnguicar, johssw, jsola, lynnux, maymax, rblackwell, Sogou [Bot], waynes, Yahoo [Bot]