Matrix tools in MatrixCreator namespace

22 views
Skip to first unread message

Sumedh Yadav

unread,
Feb 16, 2017, 3:53:21 AM2/16/17
to deal.II User Group
Hello,
I want to use the create_mass_matrix and create_laplace_matrix functionality of MatrixCreator namespace. The function prototype here requires to pass a pointer (which is by default 0 meaning that there is no variable coefficient associated with variable or laplace of variable) to a function object. I want to build the mass/laplace matrices taking in account the constraints so I pass the ConstraintMatrix argument as the last argument of the function. Code snippet:

    MatrixCreator::create_mass_matrix(dof_handler, QGauss<dim>(fe.degree+1), mass_matrix, ________, constraints);

Here dof_hadler, mass_matrix and constraints are appropriate objects as the name suggests. I don't have the variable coefficient/s so I need to know what to pass in the blank space which requires a pointer argument as mentioned above?

Thank you
 

Daniel Arndt

unread,
Feb 16, 2017, 5:17:44 AM2/16/17
to deal.II User Group
Sumedh,


I want to use the create_mass_matrix and create_laplace_matrix functionality of MatrixCreator namespace. The function prototype here requires to pass a pointer (which is by default 0 meaning that there is no variable coefficient associated with variable or laplace of variable) to a function object. I want to build the mass/laplace matrices taking in account the constraints so I pass the ConstraintMatrix argument as the last argument of the function. Code snippet:

    MatrixCreator::create_mass_matrix(dof_handler, QGauss<dim>(fe.degree+1), mass_matrix, ________, constraints);

Here dof_hadler, mass_matrix and constraints are appropriate objects as the name suggests. I don't have the variable coefficient/s so I need to know what to pass in the blank space which requires a pointer argument as mentioned above?
You already gave the answer yourself:
The documentation tells you that MatrixCreator::create_mass_matrix is declared as

template<int dim, typename number , int spacedim>
void MatrixCreator::create_mass_matrix
(const Mapping< dim, spacedim > & mapping,
const DoFHandler< dim, spacedim > & dof,
const Quadrature< dim > & q,
SparseMatrix< number > & matrix,
const Function< spacedim > *const a = 0,
const ConstraintMatrix & constraints = ConstraintMatrix())

In particular, using a null pointer (0, NULL or nullptr) for the 'Function' pointer 'a' gives you a constant coefficient equal to one.

Best,
Daniel

Sumedh Yadav

unread,
Feb 16, 2017, 6:58:48 AM2/16/17
to deal.II User Group
Hey Daniel,
Thanks for the reply!
I tried doing what you suggested. The code snippet:
    void * ptr = nullptr; //I tried with NULL and 0 synonyms as well
    MatrixCreator::create_mass_matrix(dof_handler, QGauss<dim>(fe.degree+1), mass_matrix, ptr , constraints);

The error:
step-26.cc:209:69: error: no matching function for call to ‘create_mass_matrix(dealii::DoFHandler<2>&, dealii::QGauss<2>, dealii::SparseMatrix<double>&, void*&, dealii::ConstraintMatrix&)’
                                       mass_matrix, ptr , constraints);
                                                                                   ^

Bruno Turcksin

unread,
Feb 16, 2017, 8:09:38 AM2/16/17
to deal.II User Group
Sumedh,


On Thursday, February 16, 2017 at 6:58:48 AM UTC-5, Sumedh Yadav wrote:
Hey Daniel,
Thanks for the reply!
I tried doing what you suggested. The code snippet:
    void * ptr = nullptr; //I tried with NULL and 0 synonyms as well
Why are you using void* You should use const Function< spacedim > *const a = 0 like Daniel advised you to do.

Best,

Bruno

Reply all
Reply to author
Forward
0 new messages