Re: [deal.II] Loading solution in step 6

2019-02-26 Thread Jean-Paul Pelteret
Ah, right, Thanks for the correction Wolfgang!

> On 27 Feb 2019, at 06:58, Wolfgang Bangerth  wrote:
> 
> On 2/26/19 7:54 AM, Jean-Paul Pelteret wrote:
>> 
>> Do you mean a 6-sided hexagon? Well, this is the sort of geometry that one 
>> might want to use a mesh generation tool (e.g. GMSH, Cubit) for since you 
>> can’t trivially create a structured mesh for it. You could also look at 
>> Texhex 
>> (https://github.com/martemyev/tethex/wiki) as a possible way to convert a 
>> structured triangular mesh to one that uses quads.
> 
> No no, a hexagon is really just three quadrilaterals:
> 
> 
>   *-*
>  / / \
> *-*   *
>  \ \ /
>   *-*
> 
> Step-49 explains how to do that.
> 
> Cheers
>  W.
> 
> -- 
> 
> Wolfgang Bangerth  email: bange...@colostate.edu
>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 the Google Groups 
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to dealii+unsubscr...@googlegroups.com.
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-26 Thread Wolfgang Bangerth
On 2/26/19 7:54 AM, Jean-Paul Pelteret wrote:
> 
> Do you mean a 6-sided hexagon? Well, this is the sort of geometry that one 
> might want to use a mesh generation tool (e.g. GMSH, Cubit) for since you 
> can’t trivially create a structured mesh for it. You could also look at 
> Texhex 
> (https://github.com/martemyev/tethex/wiki) as a possible way to convert a 
> structured triangular mesh to one that uses quads.

No no, a hexagon is really just three quadrilaterals:


   *-*
  / / \
*-*   *
  \ \ /
   *-*

Step-49 explains how to do that.

Cheers
  W.

-- 

Wolfgang Bangerth  email: bange...@colostate.edu
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-26 Thread Jean-Paul Pelteret
Dear John,

> Another simple question  is that how to obtain the triangulation of a 
> standard hexagonal in 2d?

Do you mean a 6-sided hexagon? Well, this is the sort of geometry that one 
might want to use a mesh generation tool (e.g. GMSH, Cubit) for since you can’t 
trivially create a structured mesh for it. You could also look at Texhex 
(https://github.com/martemyev/tethex/wiki 
) as a possible way to convert a 
structured triangular mesh to one that uses quads.

I hope that this helps you.

Best,
Jean-Paul

P.S. In future, please post follow-up questions that differ from the original 
topic as new questions. It makes it easier for anyone looking for answers to 
the second question to find them!

> On 26 Feb 2019, at 15:44, yswang  wrote:
> 
> Dear all, 
> 
> Another simple question  is that how to obtain the triangulation of a 
> standard hexagonal in 2d?
> 
> Best
> John
> 
>> 在 2019年2月25日,下午10:24,yswang  写道:
>> 
>> Thank you very much!
>> 
>> Best
>> John
>> 
>>> 在 2019年2月25日,下午3:01,Wolfgang Bangerth  写道:
>>> 
>>> On 2/23/19 7:16 PM, Yangshuai Wang wrote:
 Thanks so much! I delete const, and the error says:
 
 An error occurred in line <1105> of file 
 
  in function
   Number ::Vector::operator()(const 
 dealii::Vector::size_type) [number = double]
 The violated condition was:
   i>>> Additional information:
   Index 289 is not in the half-open range [0,289).
>>> 
>>> So you sized the vector to have 289 elements (0...288) but then you try to 
>>> write into element 289 as you continue to read from a file. Apparently, 
>>> your 
>>> file has more than 289 double precision numbers. (You also have to pay 
>>> attention that you could have been reading the first 289 elements already 
>>> and 
>>> the 289th read fails -- but you only find out about it after the fact 
>>> because 
>>> the statement 'while(!File.eof())' might only stop the iteration once the 
>>> last 
>>> read failed. This could happen if, for example, you have a space or a 
>>> newline 
>>> after the 289th element: in that case, after reading the 289th element, you 
>>> are not yet at the end of the file, and so you attempt to read and write 
>>> into 
>>> the 290th element, even though the read will have failed.)
>>> 
>>> 
 By the way, I can read my "solution-txt" file to an array, but how to 
 transfer the array to Vector type since the solution in 
 KellyErrorEstimator::estimate must be a Vector.
>>> 
>>> You could create a Vector of the correct size and simply copy the elements 
>>> one 
>>> by one from your array into the vector.
>>> 
>>> Best
>>> W.
>>> 
>>> -- 
>>> 
>>> Wolfgang Bangerth  email: bange...@colostate.edu
>>>  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 the Google Groups 
>>> "deal.II User Group" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to dealii+unsubscr...@googlegroups.com.
>>> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
>> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-26 Thread yswang
Dear all, 

Another simple question  is that how to obtain the triangulation of a standard 
hexagonal in 2d?

Best
John

> 在 2019年2月25日,下午10:24,yswang  写道:
> 
> Thank you very much!
> 
> Best
> John
> 
>> 在 2019年2月25日,下午3:01,Wolfgang Bangerth  写道:
>> 
>> On 2/23/19 7:16 PM, Yangshuai Wang wrote:
>>> Thanks so much! I delete const, and the error says:
>>> 
>>> An error occurred in line <1105> of file 
>>> 
>>>  in function
>>>Number ::Vector::operator()(const 
>>> dealii::Vector::size_type) [number = double]
>>> The violated condition was:
>>>i>> Additional information:
>>>Index 289 is not in the half-open range [0,289).
>> 
>> So you sized the vector to have 289 elements (0...288) but then you try to 
>> write into element 289 as you continue to read from a file. Apparently, your 
>> file has more than 289 double precision numbers. (You also have to pay 
>> attention that you could have been reading the first 289 elements already 
>> and 
>> the 289th read fails -- but you only find out about it after the fact 
>> because 
>> the statement 'while(!File.eof())' might only stop the iteration once the 
>> last 
>> read failed. This could happen if, for example, you have a space or a 
>> newline 
>> after the 289th element: in that case, after reading the 289th element, you 
>> are not yet at the end of the file, and so you attempt to read and write 
>> into 
>> the 290th element, even though the read will have failed.)
>> 
>> 
>>> By the way, I can read my "solution-txt" file to an array, but how to 
>>> transfer the array to Vector type since the solution in 
>>> KellyErrorEstimator::estimate must be a Vector.
>> 
>> You could create a Vector of the correct size and simply copy the elements 
>> one 
>> by one from your array into the vector.
>> 
>> Best
>> W.
>> 
>> -- 
>> 
>> Wolfgang Bangerth  email: bange...@colostate.edu
>>   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 the Google Groups 
>> "deal.II User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to dealii+unsubscr...@googlegroups.com.
>> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-25 Thread yswang
Thank you very much!

Best
John

> 在 2019年2月25日,下午3:01,Wolfgang Bangerth  写道:
> 
> On 2/23/19 7:16 PM, Yangshuai Wang wrote:
>> Thanks so much! I delete const, and the error says:
>> 
>> An error occurred in line <1105> of file 
>> 
>>  in function
>> Number ::Vector::operator()(const 
>> dealii::Vector::size_type) [number = double]
>> The violated condition was:
>> i> Additional information:
>> Index 289 is not in the half-open range [0,289).
> 
> So you sized the vector to have 289 elements (0...288) but then you try to 
> write into element 289 as you continue to read from a file. Apparently, your 
> file has more than 289 double precision numbers. (You also have to pay 
> attention that you could have been reading the first 289 elements already and 
> the 289th read fails -- but you only find out about it after the fact because 
> the statement 'while(!File.eof())' might only stop the iteration once the 
> last 
> read failed. This could happen if, for example, you have a space or a newline 
> after the 289th element: in that case, after reading the 289th element, you 
> are not yet at the end of the file, and so you attempt to read and write into 
> the 290th element, even though the read will have failed.)
> 
> 
>> By the way, I can read my "solution-txt" file to an array, but how to 
>> transfer the array to Vector type since the solution in 
>> KellyErrorEstimator::estimate must be a Vector.
> 
> You could create a Vector of the correct size and simply copy the elements 
> one 
> by one from your array into the vector.
> 
> Best
>  W.
> 
> -- 
> 
> Wolfgang Bangerth  email: bange...@colostate.edu
>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 the Google Groups 
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to dealii+unsubscr...@googlegroups.com.
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-24 Thread Wolfgang Bangerth
On 2/23/19 7:16 PM, Yangshuai Wang wrote:
> Thanks so much! I delete const, and the error says:
> 
> An error occurred in line <1105> of file 
> 
>  in function
>  Number ::Vector::operator()(const 
> dealii::Vector::size_type) [number = double]
> The violated condition was:
>  i Additional information:
>  Index 289 is not in the half-open range [0,289).

So you sized the vector to have 289 elements (0...288) but then you try to 
write into element 289 as you continue to read from a file. Apparently, your 
file has more than 289 double precision numbers. (You also have to pay 
attention that you could have been reading the first 289 elements already and 
the 289th read fails -- but you only find out about it after the fact because 
the statement 'while(!File.eof())' might only stop the iteration once the last 
read failed. This could happen if, for example, you have a space or a newline 
after the 289th element: in that case, after reading the 289th element, you 
are not yet at the end of the file, and so you attempt to read and write into 
the 290th element, even though the read will have failed.)


> By the way, I can read my "solution-txt" file to an array, but how to 
> transfer the array to Vector type since the solution in 
> KellyErrorEstimator::estimate must be a Vector.

You could create a Vector of the correct size and simply copy the elements one 
by one from your array into the vector.

Best
  W.

-- 

Wolfgang Bangerth  email: bange...@colostate.edu
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-23 Thread Yangshuai Wang
Thanks so much! I delete const, and the error says:

An error occurred in line <1105> of file 

 in function
Number ::Vector::operator()(const dealii::Vector::size_type) 
[number = double]
The violated condition was: 
i type since the solution in 
KellyErrorEstimator::estimate must be a Vector.

Thanks for your time.

Best
John 
- 原始邮件 -
发件人: "Wolfgang Bangerth" 
收件人: dealii@googlegroups.com
发送时间: 星期六, 2019年 2 月 23日 下午 11:25:42
主题: Re: [deal.II] Loading solution in step 6

> void Step6::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];

In this line, you are trying to write into 'solution[n]', but the function you 
are in is marked as 'const' and consequently the 'solution' vector is 'const'. 
You can't write into const objects.

Best
  W.

-- 

Wolfgang Bangerth  email: bange...@colostate.edu
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- 
Best Regards
王阳帅 John
上海交通大学 自然科学研究院 计算数学
Computational mathematics , Institude of natural science,
Shanghai Jiao tong University, Shanghai , China
Tel:+86 18817288575
E-mail:yswang2...@sjtu.edu.cn / wys_m...@foxmail.com

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-23 Thread Wolfgang Bangerth


> void Step6::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];

In this line, you are trying to write into 'solution[n]', but the function you 
are in is marked as 'const' and consequently the 'solution' vector is 'const'. 
You can't write into const objects.

Best
  W.

-- 

Wolfgang Bangerth  email: bange...@colostate.edu
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-23 Thread yswang
Dear Bruno,

I am so sorry. My problem is:
I add a function to read the solution from outside:
template 
void Step6::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') 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  写道:
> 
> 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 > > 写道:
>> 
>> 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() 
>> 
>>  and block_read() 
>> 
>>  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, yswang2...@sjtu.edu.cn 
>>>  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 
>>> 
>>> void Step6::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/ 
>>> 
>>> 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+unsubscr...@googlegroups.com 
>>> .
>>> For more options, visit 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 dealii+unsubscr...@googlegroups.com 
>> .
>> For more options, visit 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 dealii+unsubscr...@googlegroups.com 
> 

Re: [deal.II] Loading solution in step 6

2019-02-22 Thread Bruno Turcksin
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  写道:
>
> 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() 
> 
>  and block_read() 
> 
>  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, yswang2...@sjtu.edu.cn 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::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/
> 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+unsubscr...@googlegroups.com.
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-22 Thread yswang
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  写道:
> 
> 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() 
> 
>  and block_read() 
> 
>  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, yswang2...@sjtu.edu.cn 
>>  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 
>> 
>> void Step6::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/ 
>> 
>> 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+unsubscr...@googlegroups.com 
>> .
>> For more options, visit 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 dealii+unsubscr...@googlegroups.com 
> .
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [deal.II] Loading solution in step 6

2019-02-22 Thread Jean-Paul Pelteret
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() 

 and block_read() 

 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, yswang2...@sjtu.edu.cn 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 
> 
> void Step6::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/ 
> 
> 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+unsubscr...@googlegroups.com 
> .
> For more options, visit 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 dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Loading solution in step 6

2019-02-22 Thread yswang2016


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::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/
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.