Dear Maxi,

Did you try to call 'operator=' in the same line as you declare the variable? In that case, you still go through the (missing) constructor. It should work if you first declare the float vector in one statement and then assign in the next. We have this function:

https://dealii.org/current/doxygen/deal.II/classLinearAlgebra_1_1distributed_1_1Vector.html#ad364c47c5b3b7b991490cd626c729f0b

Furthermore, there is also a function LinearAlgebra::distributed::Vector::copy_locally_owned_subrange_from() which also works with different number types, say double to float:

https://dealii.org/current/doxygen/deal.II/classLinearAlgebra_1_1distributed_1_1Vector.html#ab792ddb04b95a220e489f2d7f9eee990

(In that case, no data is exchanged, and the vectors need to have compatible locally owned dofs before calling.)

Best,
Martin

On 23.09.19 17:07, 'Maxi Miller' via deal.II User Group wrote:
When doing that in my code, I get the error
|
error:conversion from‘Vector<double,[...]>’to non-scalar type ‘Vector<float,[...]>’requested
|

thus I assume I have to implement it myself...

Am Freitag, 13. September 2019 17:53:37 UTC+2 schrieb Wolfgang Bangerth:

    On 9/13/19 8:39 AM, 'Maxi Miller' via deal.II User Group wrote:
    > In my program I have to reuse old solutions (due to time
    dependency),
    > but would like to use them both as double values and float values
    > (preconditioning does not require double values). Unfortunately
    my old
    > solution is only given as a
    > LinearAlgebra::distributed::Vector<double>(), but I have to use a
    > LinearAlgebra::distributed::Vector<float>. Direct conversion via
    > LinearAlgebra::distributed::Vector<float>
    float_solution(old_solution)
    > does not work. Are there other ways for conversion?

    I think that the other classes all have conversion constructors or
    conversion operator=. If this class doesn't have one, you probably
    want
    to add it to support what you need. It should be a relatively easy
    patch
    to write, and we'd of course be happy to take it, as always!

    Best
      W.

-- ------------------------------------------------------------------------

    Wolfgang Bangerth          email: [email protected] <javascript:>
                                www:
    http://www.math.colostate.edu/~bangerth/
    <http://www.math.colostate.edu/~bangerth/>

--
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 [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/1e88472a-6dce-4a26-ada0-197a82adea63%40googlegroups.com <https://groups.google.com/d/msgid/dealii/1e88472a-6dce-4a26-ada0-197a82adea63%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/32b70356-bde3-a7be-fd08-9880cc7539ae%40gmail.com.

Reply via email to