Does MatrixFree support multiple different types of Quadrature formula?

34 views
Skip to first unread message

Chengjiang Yin

unread,
Feb 19, 2025, 1:40:01 AM2/19/25
to deal.II User Group
Hi all,

I notice that the overloaded member function of MatrixFree::reinit says MatrixFree support multi-component finite elements together with multiple quadrature formulas.

However the quadratures are input by std::vector<QuadratureType>. Since std::vector does not have polymorphism, does this mean only the same type of quadrature with different quadrature degrees are supported? ( for example std::vector{QGauss<1>(2), QGauss<1>(3)}, but not std::vector{QGauss<1>(2),  QGaussLobatto<1>(3)} )

I have checked the tutorials and test cases and didn't find any example of using this reinit function.

Regards
Chengjiang Yin

Martin Kronbichler

unread,
Feb 19, 2025, 2:35:08 AM2/19/25
to dea...@googlegroups.com

Dear Chengjiang,

This is a good question. This case is supported, but one needs to work slightly harder (and I admit we do not show this case). You should do as follows:

    std::vector<Quadrature<1>> quad;
    quad.push_back(QGauss<1>(fe_degree + 1));
    quad.push_back(QGaussLobatto<1>(fe_degree + 2));
    mf_data.reinit(MappingQ1<dim>{},
                   dof,
                   constraints,
                   quad,
                   typename MatrixFree<dim, number>::AdditionalData(
                     MatrixFree<dim, number>::AdditionalData::none));

I added a test with this code now to make sure this feature keeps working: https://github.com/dealii/dealii/pull/18148 . If you want to construct the quadrature objects in place, you should be able to do so by casting both objects in the initializer list to Quadrature<1>.

Best regards,
Martin

Am 19.02.25 um 07:40 schrieb Chengjiang Yin:
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dealii/7e995192-78a4-44a4-8cdd-d12450858ae7n%40googlegroups.com.
Message has been deleted

Chengjiang Yin

unread,
Feb 19, 2025, 1:36:05 PM2/19/25
to deal.II User Group
Hi Martin,

Thanks for the very quick reply and test case! So quadrature formulas only differ by their ctors and all the quad points and weights are stored within their base class Quadrature. Hence by using std::vector<Quadrature<1>> is enough to pass all the info.

BTW we can specify the template parameter and it would automatically convert to its base class like

mf_data.reinit<Quadrature<1>, double, Mapping<dim>>(
    mapping,
    {&dof1, &dof2},
    {&constraint1, &constraint2},
    {QGauss<1>{2}, QGaussLobatto<1>{3}},
    additional_data
)

Regards,
Chengjiang Yin

Reply all
Reply to author
Forward
0 new messages