point_value, Real&Imaginary parts, step-29

86 views
Skip to first unread message

Hermes Sampedro

unread,
Aug 10, 2021, 9:41:07 AM8/10/21
to deal.II User Group
Dear all, 

It is explained in Step-3 how to evaluate the solution in a point. I am trying to do the same for Step-29, to evaluate the real and imaginary parts separately in a single point:

std::cout << "Solution at (0.2,0.2): "<< VectorTools::point_value(dof_handler, solution,Point<2>(0.2, 0.2))<< std::endl;

I do not have any problems compiling however, an error occurs when running:

The violated condition was:  dof.get_fe(0).n_components() == 1

What is the proper way to call the real and imaginary parts of the solution at a particular point here?


Thank you very much!

H.

Daniel Arndt

unread,
Aug 10, 2021, 9:49:14 AM8/10/21
to dea...@googlegroups.com
Hermes,

Use another overload. The one returning the solution as a parameter should work: https://www.dealii.org/current/doxygen/deal.II/namespaceVectorTools.html#acd358e9b110ccbf4a7f76796d206b9c7

Best,
Daniel

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/54a2d44e-194a-43c0-aa7f-9fddd5bd0dean%40googlegroups.com.

Hermes Sampedro

unread,
Aug 10, 2021, 10:09:48 AM8/10/21
to dea...@googlegroups.com
Thank you for your answer. I am not sure if I fully understand your suggestion. Do you mean something like that:

 Vector<double> vecSol;

 std::cout << "Solution at (0.2,0.2): "<< VectorTools::point_value(dof_handler, solution,Point<2>(0.2, 0.2),vecSol)<< std::endl;

           


I still get some errors. Is there not any way to get for example the real part of solution easily and use it directly on the point_value as in step-3?


Thank you 

H


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/Ru1_uMbix30/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/CAOYDWb%2BR0bRTVxB-F22Hwk_ZexN4%3DVwCbZ7ZKqs3JjEaHFhncA%40mail.gmail.com.

Jean-Paul Pelteret

unread,
Aug 10, 2021, 1:40:45 PM8/10/21
to dea...@googlegroups.com
Hi Hermes,

You don’t say what errors you’re seeing, but my guess is that it now doesn’t compile. This variant of the function (the one that Daniel linked to) returns void, so you should call it before outputting the result:

Vector<double> vecSol;
VectorTools::point_value(dof_handler, solution,Point<2>(0.2, 0.2),vecSol)
std::cout << "Solution at (0.2,0.2): "<< vecSol << std::endl;

This will hopefully get you what you want.

Best,
Jean-Paul


Jean-Paul Pelteret

unread,
Aug 10, 2021, 1:46:32 PM8/10/21
to dea...@googlegroups.com
Another thing: You probably also need to initialise with the right number of components. So something like
Vector<double> vecSol (fe.n_components());

Hermes Sampedro

unread,
Aug 11, 2021, 4:12:36 AM8/11/21
to dea...@googlegroups.com
Thank you very much, I could make it work.

Regards, 
Hermes

Hermes Sampedro

unread,
Aug 24, 2021, 8:05:54 AM8/24/21
to dea...@googlegroups.com
Dear all, 

I am trying to extend my implementation with parallel computing. I would like to get the solution in a single point when having a distributed system. For example, in step-40 I have the locally_relevant_solution at the output_result(...) function.
In a non distributed implementation I used:

      Vector<double> vecSol (fe.n_components());

      VectorTools::point_value(dof_handler, solution,Point<2>(0.2, 0.2),vecSol);


What is the easiest way to do that? Is it possible to check if the point is inside the locally_relevant_solution? Or would be more appropriate to create a copy of the solution in a global vector and get the point from there?


Thank you

H

Martin Kronbichler

unread,
Aug 24, 2021, 8:12:22 AM8/24/21
to dea...@googlegroups.com

Dear Hermes,

Did you try VectorTools::point_values, https://www.dealii.org/current/doxygen/deal.II/namespaceVectorTools.html#a1ad6eceb6cbeaa505baf7f938289bbde ?

As an alternative, you can also check if the point is in the locally owned cell of the respective cell, and run the evaluation only on that MPI rank. You can then use an MPI collective, like MPI_Bcast or deal.II's version Utilities::MPI::broadcast, to get the solution to all MPI ranks (typically with another collective to make all ranks agree on who sends the information).

Best,
Martin

This is a variant that allows the evaluation even on remote processes.

Hermes Sampedro

unread,
Aug 24, 2021, 8:46:46 AM8/24/21
to dea...@googlegroups.com
Thank you for pointing that function.

I am having some problems when creating the mapping and I am not sure if the function call is right. Could you please help me with that? 

      std::vector<double> pointSol;

      Mapping<dim> mapping;

      

      dealii::Utilities::MPI::RemotePointEvaluation<dim> remotePoint;

      remotePoint.reinit();

      pointSol = VectorTools::point_values(mapping, dof_handler,locally_relevant_solution,Point<2>(0.2, 0.2),remotePoint);



Thank you

H

      


peterrum

unread,
Aug 24, 2021, 8:59:29 AM8/24/21
to deal.II User Group
Hi Hermes,

You don't need to do anything regarding the setup (it is done within the function). Just take at a look at: https://github.com/dealii/dealii/blob/44b6aadb35aca2333e4bfb6c9ce29c613f4dc9e9/tests/remote_point_evaluation/vector_tools_evaluate_at_points_01.cc#L214-L216

I'll extend the documentation with an example today or tomorrow!

Hope that helps,
PM

Hermes Sampedro

unread,
Aug 24, 2021, 9:26:05 AM8/24/21
to dea...@googlegroups.com
Thank you.

Doing something similar:

      const MappingQ1<dim> mapping;

      Utilities::MPI::RemotePointEvaluation<dim> evaluation_cache;

      VectorTools::point_values<dim>(mapping, dof_handler, locally_relevant_solution, Point<2>(0.2, 0.2), evaluation_cache);


I get the following error:

 error: no matching function for call to 'point_values'

      VectorTools::point_values<dim>(mapping, dof_handler, locally_relevant_solution, Point<2>(0.2, 0.2), evaluation_cache);

   

I checked the parameters and seems to be ok. What can be producing the error?

Thank you again

H  


peterrum

unread,
Aug 24, 2021, 9:39:49 AM8/24/21
to deal.II User Group
You need to pass a vector of points.

PM

peterrum

unread,
Aug 27, 2021, 3:33:11 AM8/27/21
to deal.II User Group
Hi Hermes,

I have extended the documentation a bit. See https://github.com/dealii/dealii/pull/12714.

Maybe you could give us a short feedback if `VectorTools::point_values()` is working for complex numbers. If this is not the case, we can extend the function for this use case.

PM

Hermes Sampedro

unread,
Sep 6, 2021, 5:28:00 AM9/6/21
to dea...@googlegroups.com
Thank you very much. I have been trying and I only get the real part of the solution and it seems not to be right so far. Would be possible to make it work for complex numbers?

Thank you
H.

Wolfgang Bangerth

unread,
Sep 6, 2021, 10:28:16 PM9/6/21
to dea...@googlegroups.com
On 9/6/21 3:27 AM, Hermes Sampedro wrote:
> Thank you very much. I have been trying and I only get the real part of the
> solution and it seems not to be right so far. Would be possible to make it
> work for complex numbers?

Hermes,
do you think you could come up with a small, self-contained program that
illustrates what isn't working? It's often not very difficult to debug once
one has a small testcase, but it's often very difficult to come up with a
testcase without access to the original program that someone says isn't working.

Best
W.

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

Hermes Sampedro

unread,
Sep 9, 2021, 5:21:36 AM9/9/21
to dea...@googlegroups.com
Thank you for your answer, I could make it work. 

Regards, 
Hermes

--
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/Ru1_uMbix30/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages