deal.II with PETSc: compiling with support for complex numbers

283 views
Skip to first unread message

Artur Safin

unread,
Nov 14, 2015, 8:35:43 PM11/14/15
to deal.II User Group
Hello all,

I have an installation of PETSc with support for complex numbers ('--with-scalar-type=complex' as the installation argument), and now I am trying to compile deal with this installation of PETSc. I am getting errors that look like

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/artur/dealii-8.3.0/source/numerics/data_out_dof_data.cc:In instantiation of ‘void dealii::internal::DataOut::DataEntry<DH, VectorType>::get_function_values(const dealii::FEValuesBase<DH:: dimension, DH:: space_dimension>&, std::vector<double>&) const [with DH = dealii::hp::DoFHandler<1, 3>; VectorType = dealii::PETScWrappers::MPI::BlockVector]’:
/home/artur/dealii-8.3.0/source/numerics/data_out_dof_data.cc:1251:1:   required from here
/home/artur/dealii-8.3.0/source/numerics/data_out_dof_data.cc:589:25: error: cannot convert ‘__gnu_cxx::__alloc_traits<std::allocator<std::complex<double> > >::value_type {aka std::complex<double>}’ to ‘__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}’ in assignment
         patch_values[i] = tmp[i];
                         ^
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

For a standard PETSc installation (without support for complex numbers), deal compiles without any problems. I have two questions:

1) Does deal support complex PETSc vectors and matrices?
2) Is there a way to work around the error above?

Best,

Artur

Timo Heister

unread,
Nov 15, 2015, 9:21:23 AM11/15/15
to dea...@googlegroups.com
> 1) Does deal support complex PETSc vectors and matrices?

While we honor the PetscScalar type in the wrapper classes, this is
not used/tested very well and I wouldn't be surprised if you run into
problems.

> 2) Is there a way to work around the error above?

This is related to complex support inside deal.II, which is work in
progress. Please see
https://github.com/dealii/dealii/wiki/Frequently-Asked-Questions#can-i-solve-problems-over-complex-numbers
to avoid matrices/vectors with complex entries.

--
Timo Heister
http://www.math.clemson.edu/~heister/

Denis Davydov

unread,
Nov 15, 2015, 5:22:16 PM11/15/15
to deal.II User Group
Hi Arthur,
yes, but not on the master. There are still a couple of places which won't compile.
The most problematic is the DataOutput class.
 
2) Is there a way to work around the error above?
yes, you can do it in deal.II even without doing the split into real and imaginary part.

Alternatively, and actually preferably, would be if you could give the current master a look and
for starters try disabling instantiation of DataOut class for PETSc vectors in case
of complex-valued PETSc. It very-well could be the only not-coverd part of deal.II yet.
Then the work-around would be to copy PETSc vectors into, say, Trilinos for output only.
If you are lucky all the weak forms and solvers would stay with complex algebra.

Regards,
Denis.

Wolfgang Bangerth

unread,
Nov 15, 2015, 6:05:39 PM11/15/15
to dea...@googlegroups.com

> 2) Is there a way to work around the error above?
>
> yes, you can do it in deal.II even without doing the split into real and
> imaginary part.
> see this branch https://github.com/davydden/dealii/tree/branch_petscscalar_complex

I'm willing to accept incremental patches that get master in the direction you
want to go -- it doesn't have to be the one grand patch that does it all in
one fall swoop :-)

Cheers
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

Denis Davydov

unread,
Nov 16, 2015, 2:41:06 AM11/16/15
to deal.II User Group
On Monday, November 16, 2015 at 12:05:39 AM UTC+1, bangerth wrote:

>     2) Is there a way to work around the error above?
>
> yes, you can do it in deal.II even without doing the split into real and
> imaginary part.
> see this branch https://github.com/davydden/dealii/tree/branch_petscscalar_complex

I'm willing to accept incremental patches that get master in the direction you
want to go -- it doesn't have to be the one grand patch that does it all in
one fall swoop :-) 

We already have most of that branch in master (e.g. FEValues, constraint matrix, etc).
What is left:
1. vector and scalar list for complex/real valued
2. use of thereof to mask some parts of the library which are not yet extended to complex numbers (DataOut is a pandora box!..)

Now thinking about it, the alternative could be to provide explicit specialisation of un-supported classes for complex vectors where needed
when PETSc is complex. Theoretically that should not require changing/introducing new  definitions.

Regards,
Denis.

Artur Safin

unread,
Nov 17, 2015, 3:42:49 PM11/17/15
to deal.II User Group
Timo, Denis,

Thank you for your suggestions. 

I am aware that you can avoid these problems by doubling the basis, but the problem I am solving may perform better with a complex numbers formulation, so it makes sense to go this route.

Denis, I have tried to compile the master against complex PETSc. After getting past errors in data_out, I ran into similar issues in the derivative_approximation & error_estimator classes - I stopped after that, since at this point I was commenting out essential parts of the package. I'll try to see if I can get your branch to work.

Best,

Artur

Wolfgang Bangerth

unread,
Nov 21, 2015, 8:30:00 AM11/21/15
to dea...@googlegroups.com
This should be uncontroversial. Feel free to get that off your branch and onto
mainline with a simple patch.


> 2. use of thereof to mask some parts of the library which are not yet extended
> to complex numbers (DataOut is a pandora box!..)

I don't think it's actually going to be that difficult. See
https://github.com/dealii/dealii/issues/1894
Or do you already have a different implementation?

Best

Denis Davydov

unread,
Feb 22, 2016, 11:53:13 AM2/22/16
to deal.II User Group
FYI, i made the master branch compile with complex-valued PETSc (with some minor masking of parts of the library described here: https://github.com/dealii/dealii/issues/2033#issuecomment-187159252), 
there are  a number of pull-reqests pending (aggregated in this issue https://github.com/dealii/dealii/issues/2033 ).
So it will be possible to use the up-to-date deal.II in that scenario very soon...

Regards,
Denis.
Reply all
Reply to author
Forward
0 new messages