getting components of Blockvector

20 views
Skip to first unread message

Gabriel Peters

unread,
Aug 22, 2019, 6:58:02 AM8/22/19
to deal.II User Group
Hey everyone,

I have the following problem
I have a classical velocity - pressure Blockvector "soluion" and a FEsystem (initialized via
             fe(FE_Q<dim>(degree + 1), dim, FE_Q<dim>(degree), 1)

For some testing I want to get the velocity compontents of solution in seperate vectors,
i.e. a vector u_x which contains the velocity values of solution in x-direction.

I am not really sure yet how to get these values.

My attempt is to use FEValues and quadrature points


u_x.reinit(n_dofs_in_one_direction);
FEValues<dim>                             fe_values(fe, quadrature_formula, update_values);
std::vector<Tensor<1, dim>>          velocity_values(n_q_points);
const FEValuesExtractors::Vector   velocities(0);

for (const auto &cell : dof_handler.active_cell_iterators())
{
      fe_values.reinit(cell);
      fe_values[velocities].get_function_values(solution, velocity_values);
 
    [...]
}

With this procedure I get the vector of Tensors velocity_values, which contains the velocity-values of "solution" in every direction at the quadratue points. So now I an easily get the values of velocity_values in the x-direction at the quadrature points. But how do I get the values of u_x at the dofs?

Does somebody have an idea how to fix this, or a better way to do handle this?


Best regards

Gabriel
Message has been deleted

Daniel Arndt

unread,
Aug 22, 2019, 8:56:42 AM8/22/19
to dea...@googlegroups.com
Gabriel,

[...]
u_x.reinit(n_dofs_in_one_direction);
FEValues<dim>                             fe_values(fe, quadrature_formula, update_values);
std::vector<Tensor<1, dim>>          velocity_values(n_q_points);
const FEValuesExtractors::Vector   velocities(0);

for (const auto &cell : dof_handler.active_cell_iterators())
{
      fe_values.reinit(cell);
      fe_values[velocities].get_function_values(solution, velocity_values);
 
    [...]
}

With this procedure I get the vector of Tensors velocity_values, which contains the velocity-values of "solution" in every direction at the quadratue points. So now I an easily get the values of velocity_values in the x-direction at the quadrature points. But how do I get the values of u_x at the dofs?

Does somebody have an idea how to fix this, or a better way to do handle this?

You can use
fe.system_to_component_index(i).first;
to obtain the component of the local degree with number i, see https://www.dealii.org/current/doxygen/deal.II/step_8.html#ElasticProblemassemble_system.

Best,
Daniel

Reply all
Reply to author
Forward
0 new messages