Avoid holding matrices in vector for MeshWorker

19 views
Skip to first unread message

Franco Milicchio

unread,
Mar 24, 2017, 12:21:56 PM3/24/17
to deal.II User Group
Dear all,

I have seen that MeshWorker with the MatrixSimple assembler has an initialize member that needs a vector of matrices. However that isn't really good for my case, as I'd like to assign ownership of matrices as I wish, not necessarily to a vector.

Is there any possibility to assemble in parallel several matrices without having a vector of matrices? For instance, the ResidualSimple assembles vectors, but can use pointers, as in this code:

    // Data containing pointers to vectors

    AnyData data;

    

    // Add them all

    data.add(&system_rhs,  "rhs");

    data.add(&system_rhs2, "rhs2");


No class, as far as I've seen, can do this with matrices using AnyData or any other workaround.

Did I miss something?

Thanks!
    Franco

Daniel Arndt

unread,
Mar 26, 2017, 6:20:16 AM3/26/17
to deal.II User Group
Franco,

You are right that there is no matrix assembler class that accepts an AnyData object.

I have seen that MeshWorker with the MatrixSimple assembler has an initialize member that needs a vector of matrices. However that isn't really good for my case, as I'd like to assign ownership of matrices as I wish, not necessarily to a vector. 
Is there any possibility to assemble in parallel several matrices without having a vector of matrices?
Actually, MatrixSimple just stores pointers to matrices and not the matrices itself. Therefore, you don't loose ownership of these objects by handing them to MatrixSimple. Does this answer your question?
In the end, the assembler classes are not overly complicated to implement and don't need that much code. The implementation of MatrixSimple is approximately 150 lines long 
[1]. Saying that, if MatrixSimple doesn't match your needs, you should be able to modify that class as you like. The interaction with the other MeshWorker classes is basically via the assemble functions (line 657 and line 681). They take the local matrices you assemble in your LocalIntegrator and distribute the entries to the global matrices.

Best,
Daniel

Franco Milicchio

unread,
Mar 27, 2017, 9:18:35 AM3/27/17
to deal.II User Group
Thanks, Daniel, I modified the Assembler class to suit my needs.
    Franco
Reply all
Reply to author
Forward
0 new messages