Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mat + mat_e of bilinear form #55

Closed
martemyev opened this issue May 5, 2016 · 4 comments
Closed

mat + mat_e of bilinear form #55

martemyev opened this issue May 5, 2016 · 4 comments
Assignees

Comments

@martemyev
Copy link
Contributor

martemyev commented May 5, 2016

Dear All,

After eliminating bc there is a mat_e sparse matrix such as mat+mat_e=full_matrix of the bilinear form. There are functions like FullMult and FullAddMult that use both mat and mat_e in the matrix-vector multiplication. I am wondering if I can get a full sparse matrix. I didn't find anything existing in the library, so I'm thinking about the following options:

const SparseMatrix &S = billiear_form.FullSpMat();

where

SparseMatrix BilinearForm::FullSpMat() const { return mat + mat_e; } // create a full matrix

Or maybe, something like this:

bilinear_form.RestoreFullMatrix(); // that would involve mat += mat_e
const SparseMatrix &S = bilinear_form.SpMat(); // existing way

Thanks,
Mikhail

@tzanio
Copy link
Member

tzanio commented May 5, 2016

Hi Mikhail,

Can you provide more details about your use case?

Of the two options you are proposing, I think the second one is better, because it will also enable the use of FormLinearSystem(), at least in some case.

Cheers,
Tzanio

@tzanio tzanio added the question label May 5, 2016
@tzanio tzanio self-assigned this May 5, 2016
@martemyev
Copy link
Contributor Author

martemyev commented May 5, 2016

Hi Tzanio,

My goal is to compute a dense matrix D = W^T * S * W, where S is a full matrix of a bilinear form, and W is a dense matrix each column X_i of which is a solution of the equation S*X_i = 0, where i corresponds to a boundary degree of freedom, i.e. W = DenseMatrix(fespace.GetVSize(), n_bdr_dofs). To solve many equations S*X_i = 0 I use the FormLinearSystem function, which creates mat_e, eliminates rows and columns corresponding to boundary dofs, and finalizes the matrix, so when I compute D using D = RAP(S, W);, the S matrix is not full, and I need it to be without boundary conditions applied.

What I do right now is - I compute S two times: first time - to compute W, and the second time - to compute D. That works fine, but I'm wondering if I can do it more efficiently.

Thanks,
Mikhail

@tzanio
Copy link
Member

tzanio commented May 7, 2016

Hi Mikhail,

If I understand correctly, D is the Schur complement with respect to the boundary? The action of D can probably be computed more efficiently than solving the many systems, but if you need the actual dense matrix itself, than I what you are doing is certainly a valid approach.

If you want to restore the full matrix, you probably want to call

SparseMatrix * Add(const SparseMatrix & A, const SparseMatrix & B);

though depending on the sizes, this may not be more efficient than reassembly.

Hope this helps,
Tzanio

@martemyev
Copy link
Contributor Author

Hi Tzanio,

Thank you for the reply. I do need the dense matrix W itself, so I need to construct it explicitly. I'm going to follow your advice on the computation of the full matrix using Add() function, therefore I created a pull request to get an access to the mat_e matrix.

Thank you,
Mikhail

@tzanio tzanio added the fem label Feb 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants