Internal deal.II error when instantiating TrilinosWrappers::block_operator

31 views
Skip to first unread message

Lucas Myers

unread,
Apr 27, 2023, 5:10:19 PM4/27/23
to deal.II User Group
Hi folks,

I'm trying to use the block_operator technique on Trilinos vectors and matrices, but I can't quite get it to compile. For simplicity, the relevant lines of code are:
```
#include <deal.II/lac/linear_operator_tools.h>
#include <deal.II/lac/trilinos_linear_operator.h>

using vec = dealii::LinearAlgebraTrilinos::MPI::Vector;
using block_vec = dealii::LinearAlgebraTrilinos::MPI::BlockVector;
const auto B = dealii::TrilinosWrappers::linear_operator<vec, vec>(system_matrix.block(0, 0));
const auto P_inv = dealii::TrilinosWrappers::block_operator<1, 1, block_vec>({B});
```
where system_matrix is of type `dealii::LinearAlgebraTrilinos::MPI::BlockSparseMatrix`.

The first error that comes up looks like:

`deal.II/lac/block_linear_operator.h:679:37: error: ‘populate_linear_operator_functions’ was not declared in this scope; did you mean ‘dealii::internal::BlockLinearOperatorImplementation::populate_linear_operator_functions’?`

Is this a bug in deal.II? That would be my first inclination, given that I cannot see how it would be template-related.

There are a few other errors that come up, so I'm attaching the error message in a text file. 

Any tips on debugging this? I'm finding the compiler output basically inscrutable. Any help is appreciated, so sorry for all the spam!

- Lucas
linear_operator_bug.txt

Wolfgang Bangerth

unread,
Apr 27, 2023, 11:19:29 PM4/27/23
to dea...@googlegroups.com

Lucas:

> I'm trying to use the block_operator technique on Trilinos vectors and
> matrices, but I can't quite get it to compile. For simplicity, the relevant
> lines of code are:
> ```
> #include <deal.II/lac/linear_operator_tools.h>
> #include <deal.II/lac/trilinos_linear_operator.h>
>
> using vec = dealii::LinearAlgebraTrilinos::MPI::Vector;
> using block_vec = dealii::LinearAlgebraTrilinos::MPI::BlockVector;
> const auto B = dealii::TrilinosWrappers::linear_operator<vec,
> vec>(system_matrix.block(0, 0));
> const auto P_inv = dealii::TrilinosWrappers::block_operator<1, 1, block_vec>({B});
> ```
> where system_matrix is of type
> `dealii::LinearAlgebraTrilinos::MPI::BlockSparseMatrix`.
>
> The first error that comes up looks like:
>
> `deal.II/lac/block_linear_operator.h:679:37: error:
> ‘populate_linear_operator_functions’ was not declared in this scope; did you
> mean
> ‘dealii::internal::BlockLinearOperatorImplementation::populate_linear_operator_functions’?`
>
> Is this a bug in deal.II?

Perhaps. I don't know the LinearOperator framework well, and so don't quite
know what to suggest -- I hope that someone else might chime in.

Is the code above all you actually need?

Best
W.

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


Luca Heltai

unread,
Apr 28, 2023, 3:53:15 AM4/28/23
to Deal.II Users
Dear Lucas,

take a look at the tests directory of deal.II:

https://github.com/dealii/dealii/blob/master/tests/lac/block_linear_operator_05.cc

there are many small examples and snippets that show how to use this.

In particular, I think the problem is in the fact that you are calling directly dealii::TrilinosWrappers::linear_operator and dealii::TrilinosWrappers::block_operator.

These are used internally by the functions in linear_operator_tools, and, btw, you are not required to include

#include <deal.II/lac/trilinos_linear_operator.h>

as these are included by linear_operator_tools.h, and the typical usage is through the functions dealii::linear_operator, dealii::block_operator, dealii::block_diagonal_operator, etc. (notice these are in dealii namespace, not in dealii::TrilinosWrappers namespace).

e.g., this should compile:

using vec = dealii::LinearAlgebraTrilinos::MPI::Vector;
using block_vec = dealii::LinearAlgebraTrilinos::MPI::BlockVector;

const auto B = linear_operator<vec>(system_matrix.block(0, 0)); // Notice this is not dealii::TrilinosWrappers::linear_operator
const auto P_inv = block_diagonal_operator<1, block_vec >(std::array<decltype(B), 1>({{B}}));

Creating (as for your example) a block operator with a single block.

L.

Ps: I don’t see an obvious reason why your example should not compile too. Could you try to modify

https://github.com/dealii/dealii/blob/master/tests/lac/block_linear_operator_05.cc

to reflect your example, and open an issue with a MWE that fails to compile? Reading your code, I would have expected it to compile, and I think you have spotted a problem in deal.II due to an unusual way in which you are using the code.
> --
> 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 on the web visit https://groups.google.com/d/msgid/dealii/8a6be404-f323-4edc-9720-fe603c92dfe6n%40googlegroups.com.
> <linear_operator_bug.txt>

Reply all
Reply to author
Forward
0 new messages