Thanks Daniel.
What is the order these vertices are placed in the vector(does it
correspond to the node/vertex number/index as defined by the dof_handler?)?
I am trying to play with the solution and generate the visualization. I am
trying to assign the x-coordinate of a vertex as the scalar solution at the
vertex. The expected output is a smooth gradient along the x-axis. But what
I'm getting is a random solution. Please check the code below. (Though
there are multiple access to a vertex when iterating over cells)
template <int dim>
void Step5<dim>::prepare_solution()
{
Point<dim> point1;
std::vector<Point<dim>> vertices(dof_handler.n_dofs());
vertices = triangulation.get_vertices();
const unsigned int dofs_per_cell = fe.dofs_per_cell;
std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
typename DoFHandler<dim>::active_cell_iterator cell =
dof_handler.begin_active(), endc = dof_handler.end();
TriaAccessor<dim, dim, dim> triaaccessor(&triangulation);
for (; cell!=endc; ++cell)
{
cell->get_dof_indices(local_dof_indices);
for (unsigned int i=0; i<dofs_per_cell; ++i)
{
point1 = vertices[local_dof_indices[i]];
std::cout << int(local_dof_indices[i]) << std::endl;
// solution(local_dof_indices[i]) = cell->material_id();
solution(local_dof_indices[i]) = point1(0);
std::cout << "point1(0)" << point1(0)<< std::endl;
}
}
// int i=0;
// int ndofs = dof_handler.n_dofs();
// for (; i!=ndofs; ++i)
// {
// point1 = vertices[i];
// solution(i) = point1(0);
// std::cout << "point1(0)" << point1(0)<< std::endl;
// }
output_results(3);
}
<https://lh3.googleusercontent.com/-2_6LM7O2tX0/WRSzLk1zaqI/AAAAAAAABtQ/ltU9DpJHS3A7YRV_x9tuOFeT007e32qrACLcB/s1600/Screenshot_20170512_002836.png>
Please suggest.
Thanks,
Bhanu.
On Thursday, May 11, 2017 at 4:00:42 PM UTC+5:30, Daniel Arndt wrote:
>
> Bhanu,
>
> Am Donnerstag, 11. Mai 2017 12:08:52 UTC+2 schrieb Bhanu Teja:
>>
>> Dear dealii developers/users
>>
>> is there a method/function from Triangulation class that returns the
>> vertex given its global_index?
>>
> There is "Triangulation<dim, spacedim>::get_vertices"[1] which returns a
> std::vector to all vertices.
>
> Best,
> Daniel
>
> [1]
> https://www.dealii.org/8.5.0/doxygen/deal.II/classTriangulation.html#a6fcee3caf27bb54c53ddb279cf6b8f5a
>
--
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.