Output file

51 views
Skip to first unread message

Hermes Sampedro

unread,
Aug 4, 2021, 9:49:11 AM8/4/21
to deal.II User Group
Hello, 

I am working with step-29 and I was wondering what is the best way to import the solution vectors (real, imaginary and intensity solutions) into Matlab. Is it possible to export one point of the solution into a txt file? Or what would be the easiest way using Dealii for that?

Thank you
Regards, 
H

Wolfgang Bangerth

unread,
Aug 4, 2021, 10:12:32 AM8/4/21
to dea...@googlegroups.com
It depends on what you actually want to do with it. I believe that Matlab can
read VTK or VTU files, but these are tailored towards visualization. If you
want the solution at a small number of individual points, you can evaluate it
with VectorTools::point_value() and then output these values by hand.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Hermes Sampedro

unread,
Aug 5, 2021, 8:18:44 AM8/5/21
to dea...@googlegroups.com
Thank you very much for your answer. Is it then not possible to use somehow the DataOut approach presented in step-29 and use a 'txt' parameter in the .prm file?

In case of doing that manually as you suggested, how could I access the real and imaginary parts in the solution vector (step-29)?

Doing something like:

   ofstream myfile;

        myfile.open ("solution.txt");

        myfile << "Point:\t" << VectorTools::point_value(dof_handler,solution,Point<2>(1./3, 1./3));

        myfile.close();


I get an error when running:


dof.get_fe(0).n_components() == 1


Thank you again for the help.

Regards, 

H



--
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/CoL0PqpZ5v8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/2596a4f4-4a43-4276-43d1-bf3d36fb3d98%40colostate.edu.

Wolfgang Bangerth

unread,
Aug 6, 2021, 3:01:03 PM8/6/21
to dea...@googlegroups.com
On 8/5/21 6:18 AM, Hermes Sampedro wrote:
> Thank you very much for your answer. Is it then not possible to use somehow
> the DataOut approach presented in step-29 and use a 'txt' parameter in the
> .prm file?

That's the wrong question. VTK and VTU files are text files, you can open them
with an editor. The question is not whether it's a text file or a binary file,
but what's in it. As I mentioned, the right question is what you want to do
with the information in the file, and depending on that, you choose a file format.

> In case of doing that manually as you suggested, how could I access the real
> and imaginary parts in the solution vector (step-29)?
>
> Doing something like:
>
> ofstream myfile;
>
> myfile.open ("solution.txt");
>
> myfile << "Point:\t" <<
> VectorTools::point_value(dof_handler,solution,Point<2>(1./3, 1./3));
>
> myfile.close();
>
>
> I get an error when running:
>
>
> dof.get_fe(0).n_components() == 1
>
>
> Thank you again for the help.

You are solving a problem that has more than one component -- the real and
imaginary parts are separate components. You need to call that variation of
the VectorTools::point_value() function that returns its information in the
form of a Vector<double> object.
Reply all
Reply to author
Forward
0 new messages