Compiling error in a poroelastic problem similar to step-21

24 views
Skip to first unread message

Teresa Sanchez Rúa

unread,
Mar 12, 2020, 1:07:26 PM3/12/20
to deal.II User Group

Dear all,

I am trying to solve a poroelastic problem by using a FE_System consisting of FE_Q for displacements, FE_RaviartThomas for velocities and FE_DGQ for pressure and I want to use an academic example to check that the code is correct. This example needs to implement a non-null right-hand-side vector. And here it is my problem, when compiling my code, I obtain an error when defining the local right-hand-side vector. 

Here you can see the make error I have obtained:

 

/home/teresa/dealii/Poroelast_simple/Poroelasticity.cc: In instantiation of ‘void Poroelastic::PoroelasticProblem<dim>::assemble_system() [with int dim = 2]’:

/home/teresa/dealii/Poroelast_simple/Poroelasticity.cc:593:21:   required from ‘void Poroelastic::PoroelasticProblem<dim>::run() [with int dim = 2]

/home/teresa/dealii/Poroelast_simple/Poroelasticity.cc:612:31:   required from here

/home/teresa/dealii/Poroelast_simple/Poroelasticity.cc:545:37: error: no match for ‘operator*’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<dealii::Vector<double> > >::value_type {aka dealii::Vector<double>}’ and ‘const dealii::Tensor<1, 2>’)

                 (disp_rhs_values[q] * phi_i_u - pres_rhs_values[q] * phi_i_p) * fe_values.JxW(q);

                                     ^

/home/teresa/dealii/Poroelast_simple/Poroelasticity.cc:545:37: note: candidates are:

In file included from /home/teresa/.local/bin/deal.II/include/deal.II/lac/block_vector_base.h:29:0,

                 from /home/teresa/.local/bin/deal.II/include/deal.II/lac/block_vector.h:25,

                 from /home/teresa/dealii/Poroelast_simple/Poroelasticity.cc:30:

/home/teresa/.local/bin/deal.II/include/deal.II/lac/vector.h:478:10: note: template<class Number2> Number dealii::Vector<Number>::operator*(const dealii::Vector<OtherNumber>&) const [with Number2 = Number2; Number = double]

   Number operator*(const Vector<Number2> &V) const;

          ^

/home/teresa/.local/bin/deal.II/include/deal.II/lac/vector.h:478:10: note:   template argument deduction/substitution failed:

/home/teresa/dealii/Poroelast_simple/Poroelasticity.cc:545:37: note:   ‘const dealii::Tensor<1, 2>’ is not derived from ‘const dealii::Vector<OtherNumber>

                 (disp_rhs_values[q] * phi_i_u - pres_rhs_values[q] * phi_i_p) * fe_values.JxW(q);

                                     ^

In file included from /home/teresa/.local/bin/deal.II/include/deal.II/base/template_constraints.h:22:0,

                 from /home/teresa/.local/bin/deal.II/include/deal.II/base/tensor.h:24,

                 from /home/teresa/.local/bin/deal.II/include/deal.II/base/point.h:23,

                 from /home/teresa/.local/bin/deal.II/include/deal.II/base/quadrature.h:22,

                 from /home/teresa/.local/bin/deal.II/include/deal.II/base/quadrature_lib.h:22,

                 from /home/teresa/dealii/Poroelast_simple/Poroelasticity.cc:25:

/home/teresa/.local/bin/deal.II/include/deal.II/base/complex_overloads.h:41:1: note: template<class T, class U> typename dealii::ProductType<std::complex<_Tp>, std::complex<_Up> >::type dealii::operator*(const std::complex<_Tp>&, const std::complex<_Up>&)

 operator*(const std::complex<T> &left, const std::complex<U> &right)

 ^


Maybe the make error is a key to find the error, but I am unable to understand the problem. 


I send attached a simplified version of the code that I am using. 


Does anyone know what is the problem?


Thank you in advance.


Best regards,


       Teresa.

Poroelasticity.cc

Wolfgang Bangerth

unread,
Mar 12, 2020, 1:17:41 PM3/12/20
to dea...@googlegroups.com
On 3/12/20 11:07 AM, Teresa Sanchez Rúa wrote:
> line 545:37: error: no match for ‘operator*’ (operand types are
> ‘*__gnu_cxx::__alloc_traits<std::allocator<dealii::Vector<double> >
> >::value_type {aka dealii::Vector<double>}*’ and ‘*const
> dealii::Tensor<1, 2>*’)
>
>                  (disp_rhs_values[q] * phi_i_u - pres_rhs_values[q] *
> phi_i_p) * fe_values.JxW(q);

Teresa,
the error actually lists quite clearly what is happening:
* You are invoking operator*, i.e., you are multiplying two objects
* The left argument is a Vector<double>
* The right argument is a Tensor<1,2>
* There is no operator that multiplies these two.

Further down, it lists the line where that is happening:

> (disp_rhs_values[q] * phi_i_u - pres_rhs_values[q] *
> phi_i_p) * fe_values.JxW(q);
>
> * ^*

So apparently, disp_rhs_values[q] is the Vector and phi_i_u is the
Tensor<1,2>. Indeed, that's what I see in your code.

So how to fix this:
* You could spell the product of these two objects out element-by-element.
* You could convert disp_rhs_values into a std::vector<Tensor<1,dim>>
instead of std::vector<Vector<double>> because there is an operator* for
Tensor<1,dim> objects on the lhs and rhs of the operation.

The latter would be what I would do. Of course, there is the place where
you fill that vector<Tensor> object:


disp_right_hand_side.vector_value_list(fe_values.get_quadrature_points(),
disp_rhs_values);

This would no longer compile if you change the type of disp_rhs_values,
but the easiest approach to this would be if you derived
DispRightHandSide from TensorFunction instead of Function. This seems
reasonable anyway because it is not a function with some arbitrary
number of components, but it is in fact a function whose dim components
represent a physical vector with exactly dim components.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Teresa Sanchez Rúa

unread,
Mar 13, 2020, 7:48:44 AM3/13/20
to deal.II User Group
Thank you very much for your help, Wolfgang.
Following your advice, I have changed the definition of DispRightHandSide from Function to TensorFunction and the subsequent lines and the code have compiled successfully. 
Again, thanks for your help.
Best,

      Teresa. 
Reply all
Reply to author
Forward
0 new messages