You want to do something like this:
DataOut<2> data_out;
data_out.attach_dof_handler(dof_handler);
data_out.add_data_vector(solution, "solution");
data_out.build_patches();
std::ofstream output("solution.vtk");
output.set_precisition(12);
data_out.write_vtk(output);
Best,
Bruno
Le mar. 11 oct. 2022 à 00:48, Wasim Niyaz Munshi ce21d400 <
[email protected]> a écrit :
> I used this to set precision of 12 for my solution vector
> *std::cout << "Solution" << std::setprecision(12) <<solution;*
>
> I had to add the following line of code also:
> *#include <iomanip>*
>
> I tried the following to write data to vtk file with a higher
> precision(12):
> DataOut<2> data_out;
> data_out.attach_dof_handler(dof_handler);
> data_out.add_data_vector(*std::setprecision(12)* <<solution,
> "solution");
> data_out.build_patches();
>
> std::ofstream output("solution.vtk");
> data_out.write_vtk(output);
>
> But it gives the following error:
> error: no match for ‘operator<<’ (operand types are ‘std::_Setprecision’
> and ‘const dealii::Vector<double>’)
>
> Thanks
>
> On Tuesday, October 11, 2022 at 1:27:54 AM UTC+5:30 Wolfgang Bangerth
> wrote:
>
>> On 10/10/22 11:45, Wasim Niyaz Munshi ce21d400 wrote:
>> > So I used set precision function when using the cout to print the
>> > solution vector.
>> > With setprecision, the values are printed accurately to machine
>> precision.
>> > However, I was still unable to write the values accurately upto machine
>> > precision, to a vtk file.
>>
>> Did you use .setprecision(...) also on the stream that you give to
>> data_out.write_vtk()? You need to set the precision separately for each
>> stream on which you want to output.
>>
>> Best
>> W.
>>
>> --
>> ------------------------------------------------------------------------
>> Wolfgang Bangerth email: [email protected]
>> www: 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 a topic in the
> Google Groups "deal.II User Group" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/dealii/8Ud1gkzUbNQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/7bad0073-391e-4b5a-8613-0749a664f21fn%40googlegroups.com
> <https://groups.google.com/d/msgid/dealii/7bad0073-391e-4b5a-8613-0749a664f21fn%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/CAGVt9eN%2BAu8NVxzV_jQfJMGxYEBWgzAW%3DbKo6126kSm3N_jf5g%40mail.gmail.com.