Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print the final solution #20

Open
soumyadipghosh opened this issue Feb 19, 2020 · 5 comments
Open

Print the final solution #20

soumyadipghosh opened this issue Feb 19, 2020 · 5 comments
Assignees
Labels
enhancement Improvement/s on existing code.

Comments

@soumyadipghosh
Copy link
Collaborator

soumyadipghosh commented Feb 19, 2020

A way to visualize the final solution in the domain would be helpful. My suggestion would be to write the final solution to a file aand then use matplotlib in a python script to do the plotting as a heatmap.

@pratikvn
Copy link
Owner

bench_ras.cpp has the overall final solution in explicit_laplacian_solution. It is a gko::Dense<> object.

It should be easy to print this out to a file.

For each subdomain, the local_solution object in the SolverBase<>::run should contain what you want. Again, you can write a function to basically take a gko::Dense<> object or a ValueType * (you can get this from gko::Dense by using ->get_values ) and print them out to ofstream.

@pratikvn pratikvn added the enhancement Improvement/s on existing code. label Feb 21, 2020
@soumyadipghosh
Copy link
Collaborator Author

I tried doing fp << explicit_laplacian_solution->get_values() but I guess that just outputs the pointer variable. How can I get the size of a gko::Dense<> object to iterate over it ?

@pratikvn
Copy link
Owner

To get the size of an object of type gko::Dense<>, you just use ->get_size() member function. This returns an object if type gko::dim, which contains the size of the matrix. For example, to get the number of rows, you would just do explicit_laplacian_solution->get_size()[0] and number of columns would be explicit_laplacian_solution->get_size()[1]

@soumyadipghosh
Copy link
Collaborator Author

soumyadipghosh commented Mar 2, 2020

From the definition of explicit_laplacian_solution, it appears to be a 1-D vector. How do I reorder that back to a matrix representing the 2-D domain?

Edit: I can do it the sloppy way of printing the vector like a matrix but is there a library function to convert it to a matrix ?

@pratikvn
Copy link
Owner

pratikvn commented Mar 3, 2020

You can technically, use strides to view it as a matrix. But in any case with matplotlib/matlab, it should be just as easy to plot the 1D vector in a 2D space as it would be for a 2D vector. So, I think printing it as a 1D vector is the best way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement/s on existing code.
Projects
None yet
Development

No branches or pull requests

2 participants