Dear Bruno,
I am so sorry. My problem is:
I add a function to read the solution from outside:
template <int dim>
void Step6<dim>::read_solution (const unsigned int cycle) const
{
int n = 0;
ifstream File;
File.open("solution-" + std::to_string(cycle) + ".txt");
while(!File.eof())
{
File >> solution[n];
n++;
}
File.close();
}
But the error says:
error:
invalid operands to binary expression ('std::__1::ifstream' (aka
'basic_ifstream<char>') and 'double')
File >> solution[n];
~~~~ ^ ~~~~~~~~~~~
I want to know how to fix it, and my "solution-…txt” is something like this:
"1.373e-03 0.000e+00 7.559e-04 0.000e+00 7.559e-04 4.303e-04 0.000e+00
2.336e-03 1.252e-03 0.000e+00 1.892e-03 1.024e-03 0.000e+00”.
Thanks for your time.
Best
John
> 在 2019年2月23日,上午1:31,Bruno Turcksin <[email protected]> 写道:
>
> John,
>
> You say that you have a problem but you don't say what it is. There is no way
> we can help you if you don't tell us what's wrong.
>
> Best,
>
> Bruno
>
> On Friday, February 22, 2019 at 9:42:22 AM UTC-5, yswang wrote:
> Dear Paul,
>
> Thanks for your quick response. My “solution-…txt” file is created from other
> language (Julia), just an array. I want to use deal ii to get mesh, then
> solve the minimization problem in Julia language on the mesh, and then do
> mesh refinement according to the solution by using deal ii again.
> I read the block_write() just now, It says that “This is done in a binary
> mode, so the output is neither readable by humans nor (probably) by other
> computers using a different operating system or number format.”, so I think
> it is not what I want.
>
> Best,
> John
>
>> 在 2019年2月22日,下午9:05,Jean-Paul Pelteret <[email protected]
>> <mailto:[email protected]>> 写道:
>>
>> Dear John,
>>
>> You don’t say how you write this "solution-…txt” file, so its difficult to
>> say exactly what the best course of action is. Do you know about the
>> block_write()
>> <https://www.dealii.org/9.0.0/doxygen/deal.II/classVector.html#aef98e4994a6c0b20bb33b0290f8d607c>
>> and block_read()
>> <https://www.dealii.org/9.0.0/doxygen/deal.II/classVector.html#a57d77409b8591a13d5ee10c2e705593a>
>> functions? It looks to me like these already do what you’re trying to
>> implement here.
>>
>> I hope that this helps.
>>
>> Best,
>> Jean-Paul
>>
>>> On 22 Feb 2019, at 09:13, [email protected]
>>> <mailto:[email protected]> wrote:
>>>
>>> Dear all,
>>>
>>>
>>> I am a beginner of deal ii and C++. I want to modify some codes in step-6.
>>> I want to load the solution from outside but I meet some problem and have
>>> no idea how to fix it. The following is my modification, I just add a
>>> function:
>>>
>>> template <int dim>
>>>
>>> void Step6<dim>::read_solution (const unsigned int cycle) const
>>>
>>> {
>>>
>>> int n = 0;
>>>
>>>
>>> ifstream File;
>>>
>>> File.open("solution-" + std::to_string(cycle) + ".txt");
>>>
>>> while(!File.eof())
>>>
>>> {
>>>
>>> File >> solution[n];
>>>
>>> n++;
>>>
>>> }
>>>
>>>
>>> File.close();
>>>
>>> }
>>>
>>> Thanks for your time and I know it’s a simple question.
>>>
>>>
>>> Bests,
>>>
>>> John
>>>
>>>
>>> --
>>> The deal.II project is located at http://www.dealii.org/
>>> <http://www.dealii.org/>
>>> For mailing list/forum options, see
>>> https://groups.google.com/d/forum/dealii?hl=en
>>> <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]>.
>>> For more options, visit https://groups.google.com/d/optout
>>> <https://groups.google.com/d/optout>.
>>
>>
>> --
>> The deal.II project is located at http://www.dealii.org/
>> <http://www.dealii.org/>
>> For mailing list/forum options, see
>> https://groups.google.com/d/forum/dealii?hl=en
>> <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]>.
>> For more options, visit https://groups.google.com/d/optout
>> <https://groups.google.com/d/optout>.
>
>
> --
> The deal.II project is located at http://www.dealii.org/
> <http://www.dealii.org/>
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> <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]>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
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].
For more options, visit https://groups.google.com/d/optout.