Hi,

Using the postprocessor approach according to step-33 I have computed the 
strain tensor successfully by means of the 
Postprocessor<dim>::compute_derived_quantities_vector function and its 
displacement gradient duh.

Unfortunately, within an arbitrary function called right after I solve the 
system, exactly before postprocessing, I try the same, but obtain different 
results:

const QGauss<dim> quadrature_formula(2);

const unsigned int n_q_points = quadrature_formula.size();

 FEValues<dim> fe_values(fe, quadrature_formula, update_values | 
update_gradients | update_quadrature_points | update_JxW_values);

 LA::MPI::Vector rel_solution;
rel_solution = locally_relevant_solution;

 std::vector<Vector<double> > solution_values(n_q_points, Vector<double>(dim 
+ 1));

 std::vector<std::vector<Tensor<1, dim> > > solution_grads(n_q_points, std::
vector<Tensor<1, dim> >(dim + 1));

 typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.
begin_active(), endc = dof_handler.end();
for (; cell != endc; ++cell)
{
      if ( cell->is_locally_owned() )
      {
           fe_values.reinit(cell);

            fe_values.get_function_values(rel_solution, solution_values);
           fe_values.get_function_gradients(rel_solution, solution_grads);

            int cell_index = cell->active_cell_index();

//          std::cout << cell_index << std::endl;

            Tensor<2, dim> grad_u, eps;

            for (unsigned int q = 0; q < n_q_points; ++q)
           {
                 std::cout << "\n - in energy GAUSS point " << q + 1 << " - 
\n" << std::endl;

                  for (unsigned int i = 0; i < dim; ++i)
                 {
                        std::cout << "GRADIENT 1: " << solution_grads[q][0] 
<< std::endl;
                        std::cout << "GRADIENT 2: " << solution_grads[q][1] 
<< std::endl;

                         // Compute displacement gradients
                        grad_u[i] = solution_grads[q][i];

                         // Compute strains
                         eps = 0.5 * (grad_u + transpose(grad_u));

                  }

                  print_tensor(grad_u, "DISPLACEMENT GRADIENT");
          }

      }
}

The above code gives me the following output:

- in GAUSS point 1 - 

GRADIENT 1: -0.000312
GRADIENT 2: -0.001801
GRADIENT 1: -0.000312
GRADIENT 2: -0.001801

DISPLACEMENT GRADIENT
 0.001081   -0.001477  
 -0.000000   -0.008525  


STRAIN TENSOR
 0.001081   -0.000738  
 -0.000738   -0.008525  


 - in GAUSS point 2 - 

GRADIENT 1: 0.000312
GRADIENT 2: -0.001801
GRADIENT 1: 0.000312
GRADIENT 2: -0.001801

DISPLACEMENT GRADIENT
 0.001081   0.001477  
 -0.000000   -0.008525  


STRAIN TENSOR
 0.001081   0.000738  
 0.000738   -0.008525  


 - in GAUSS point 3 - 

GRADIENT 1: -0.001164
GRADIENT 2: -0.006723
GRADIENT 1: -0.001164
GRADIENT 2: -0.006723

DISPLACEMENT GRADIENT
 0.004034   -0.001477  
 -0.000000   -0.008525  


STRAIN TENSOR
 0.004034   -0.000738  
 -0.000738   -0.008525  


 - in GAUSS point 4 - 

GRADIENT 1: 0.001164
GRADIENT 2: -0.006723
GRADIENT 1: 0.001164
GRADIENT 2: -0.006723

DISPLACEMENT GRADIENT
 0.004034   0.001477  
 -0.000000   -0.008525  


STRAIN TENSOR
 0.004034   0.000738  
 0.000738   -0.008525  


And the below are results from the postprocessor computation for a single 
element (already checked them, they should be correct):

- in GAUSS point 1 - 


DISPLACEMENT GRADIENT
 0.000000   -0.002557  
 0.000000   -0.008525  


STRAIN TENSOR
 0.000000   -0.001279  
 -0.001279   -0.008525  


 - in GAUSS point 2 - 


DISPLACEMENT GRADIENT
 0.000000   0.002557  
 0.000000   -0.008525  


STRAIN TENSOR
 0.000000   0.001279  
 0.001279   -0.008525  


 - in GAUSS point 3 - 


DISPLACEMENT GRADIENT
 0.005115   -0.002557  
 -0.000000   -0.008525  


STRAIN TENSOR
 0.005115   -0.001279  
 -0.001279   -0.008525  


 - in GAUSS point 4 - 


DISPLACEMENT GRADIENT
 0.005115   0.002557  
 -0.000000   -0.008525  


STRAIN TENSOR
 0.005115   0.001279  
 0.001279   -0.008525  

Why is the fe_values.get_function_gradients() function giving me wrong 
gradients?

Kind regards,
S. A. Mohseni 


-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to