Re: [deal.II] How to use create_mass_matrix tools with FESystem

32 views
Skip to first unread message

Simon Sticko

unread,
Apr 10, 2022, 3:01:23 AM4/10/22
to dea...@googlegroups.com
Hi,

In the stacktrace it looks like the error does not come from create_mass_matrix but from VectorTools::project. It complains that the passed Function has 1 component when it should have dim components.

If you are projecting your own function, you need to make sure you set the number of components in the constructor, e.g. as for the body-force in step-18:

https://github.com/dealii/dealii/blob/39e29ba7e1cb8c7f711df6b89d19a76394b16f6a/examples/step-18/step-18.cc#L552

Best,
Simon



On 10/04/2022 01:51, Matthew Rich wrote:
> Hi all,
>
> I am trying to use the helper tools to assemble a system for a vector valued problem.
>
> I am looking to have 2 or 3 displacement DoFs.
>
> So I use
>
> FESystem<dim> fe;
>
> and initialize with
>
> fe(FE_Q <https://www.dealii.org/current/doxygen/deal.II/classFE__Q.html><dim>(1), dim)
>
> So my code compiles, but when I try and run I get the following....
>
> --------------------------------------------------------
> An error occurred in line <182> of file </build/deal.ii-KebjEf/deal.ii-9.2.0/include/deal.II/numerics/vector_tools_project.templates.h> in function
>     void dealii::VectorTools::internal::project_matrix_free(const dealii::Mapping<dim, spacedim>&, const dealii::DoFHandler<dim, spacedim>&, const dealii::AffineConstraints<number>&, const dealii::Quadrature<dim>&, const dealii::Function<spacedim, typename dealii::LinearAlgebra::distributed::Vector<Number>::value_type>&, dealii::LinearAlgebra::distributed::Vector<Number>&, bool, const dealii::Quadrature<(dim - 1)>&, bool) [with int components = 2; int fe_degree = 1; int dim = 2; Number = double; int spacedim = 2; typename dealii::LinearAlgebra::distributed::Vector<Number>::value_type = double]
> The violated condition was:
>     dof.get_fe(0).n_components() == function.n_components
> Additional information:
>     Dimension 2 not equal to 1.
>
> Stacktrace:
> -----------
> #0  /usr/lib/x86_64-linux-gnu/libdeal.ii.g.so.9.2.0: void dealii::VectorTools::internal::project_matrix_free<2, 1, 2, double, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<double> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::LinearAlgebra::distributed::Vector<double, dealii::MemorySpace::Host>::value_type> const&, dealii::LinearAlgebra::distributed::Vector<double, dealii::MemorySpace::Host>&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
> #1  /usr/lib/x86_64-linux-gnu/libdeal.ii.g.so.9.2.0: void dealii::VectorTools::internal::project_matrix_free_degree<2, 2, double, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<double> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::LinearAlgebra::distributed::Vector<double, dealii::MemorySpace::Host>::value_type> const&, dealii::LinearAlgebra::distributed::Vector<double, dealii::MemorySpace::Host>&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
> #2  /usr/lib/x86_64-linux-gnu/libdeal.ii.g.so.9.2.0: void dealii::VectorTools::internal::project_matrix_free_component<2, double, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<double> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::LinearAlgebra::distributed::Vector<double, dealii::MemorySpace::Host>::value_type> const&, dealii::LinearAlgebra::distributed::Vector<double, dealii::MemorySpace::Host>&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
> #3  /usr/lib/x86_64-linux-gnu/libdeal.ii.g.so.9.2.0: void dealii::VectorTools::internal::project_matrix_free_copy_vector<2, dealii::Vector<double>, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::Vector<double>::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::Vector<double>::value_type> const&, dealii::Vector<double>&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
> #4  /usr/lib/x86_64-linux-gnu/libdeal.ii.g.so.9.2.0: void dealii::VectorTools::internal::project<dealii::Vector<double>, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::Vector<double>::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::Vector<double>::value_type> const&, dealii::Vector<double>&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
> #5  /usr/lib/x86_64-linux-gnu/libdeal.ii.g.so.9.2.0: void dealii::VectorTools::project<2, dealii::Vector<double>, 2>(dealii::Mapping<2, 2> const&, dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::Vector<double>::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::Vector<double>::value_type> const&, dealii::Vector<double>&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
> #6  /usr/lib/x86_64-linux-gnu/libdeal.ii.g.so.9.2.0: void dealii::VectorTools::project<2, dealii::Vector<double>, 2>(dealii::DoFHandler<2, 2> const&, dealii::AffineConstraints<dealii::Vector<double>::value_type> const&, dealii::Quadrature<2> const&, dealii::Function<2, dealii::Vector<double>::value_type> const&, dealii::Vector<double>&, bool, dealii::Quadrature<(2)-(1)> const&, bool)
> #7  ./final_proj: final_proj::WaveEquation<2>::run()
> #8  ./final_proj: main
> --------------------------------------------------------
>
> Using some crude debugging it is complaining about the create_mass_matrix call. Now I know there are two variants. I was trying to create the matrix without passing a mapping but that is generating this error. My issue is I am not sure how to create a mapping that works.
>
> How does one make a mapping for a system? I looked at some of the tutorials but I could not find what I am looking for....
>
>
> Thanks in advance.
>
>
>
>
> --
> The deal.II project is located at http://www.dealii.org/ <http://www.dealii.org/>
> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en <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 <mailto:dealii+un...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/14903aed-45a1-4c13-94df-3c2e1c877388n%40googlegroups.com <https://groups.google.com/d/msgid/dealii/14903aed-45a1-4c13-94df-3c2e1c877388n%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages