Ah, I see. I agree that there's a lack of efficiency here. To complete the 
previous thought, there's the GridTools:: find_cells_adjacent_to_vertex 
<https://www.dealii.org/developer/doxygen/deal.II/namespaceGridTools.html#addb822f0e3068e48640ecc981ee6c1e6>
 
function, which does the second half of the job for you. Or you can do them 
both in one shot using GridTools::vertex_to_cell_map 
<https://www.dealii.org/developer/doxygen/deal.II/namespaceGridTools.html#a9b7e2ca8ecd26a472e5225ba91a58acb>
 and 
simply fetch the given cell for a vertex and then extract the solution 
using cell->vertex_dof_index.

What may be most efficient here (assuming that you're doing this for just a 
single point) is to simply use GridTools::find_active_cell_around_point 
<https://www.dealii.org/developer/doxygen/deal.II/namespaceGridTools.html#aa57c66000d93c12c70f05995c0c3308f>
 
and then find the closest vertex to the given point yourself. That would 
involve only one loop over all cells of a triangulation and a single loop 
over one cell's vertices. If you're wanting this for many points 
then GridTools::vertex_to_cell_map is probably most efficient.

J-P

On Tuesday, October 25, 2016 at 4:31:28 PM UTC+2, krei wrote:
>
> Hi Jean-Paul, thanks for the reply.
>
> With cell->vertex_dof_index(v, d) I need to somehow find the cell, which 
> the vertex is a part of. I guess I could loop over every cell to find this, 
> but this doesn't seem very efficient.
>
> In principle, the solution vector contains the solutions at every vertex 
> in the mesh and it would be good if I somehow got the solution direction 
> from the index of the vertex (found by find_closest_vertex). Basically, I 
> need the mapping between the "global vertex index" given by 
> find_closest_vertex  and the solution vector index.
>
> On Tuesday, October 25, 2016 at 5:13:38 PM UTC+3, Jean-Paul Pelteret wrote:
>>
>> Hi Krei,
>>
>> This has been a popular topic as of late. Here's a list of posts 
>> <https://groups.google.com/forum/#!searchin/dealii/vertex_dof_index%7Csort:date>
>>  
>> that will help you achieve what you're looking to do.
>>
>> Regards,
>> J-P
>>
>> On Tuesday, October 25, 2016 at 4:08:43 PM UTC+2, krei wrote:
>>>
>>> Hi, I have a vector valued solution (2 components), corresponding 
>>> triangulation and the dofhandler:
>>>
>>> Triangulation<dim> triangulation;
>>> DoFHandler<dim> dof_handler;
>>> Vector<double> solution;
>>>
>>>
>>> I want to find the nearest vertex to an arbitrary point 
>>> Point<dim> &p
>>> and then find the values of both of the components of the solution in 
>>> that vertex.
>>>
>>> I can find the global index by 
>>> unsigned index = GridTools::find_closest_vertex(triangulation, p);
>>>
>>> But how do I find the solution in the vertex with the index? And how to 
>>> access both components of the solution?
>>>
>>>
>>> (I need this to interpolate the solution to slightly different mesh, 
>>> where I will continue the calculation with slightly different Neumann 
>>> boundary conditions.)
>>>
>>

-- 
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.

Reply via email to