Hi,

I am converting a scalar field (solution from the Laplace's equation) to a 
gradient field for visualization in software like Paraview. After searching 
around the forum, I got a sense that I need to implement a derived class 
from DataPostprocessor and implement the function evaluate_vector_field(&, 
&).

Here's my first attempt:

class Postprocessor : public DataPostprocessor<2>
{
public:
  virtual void evaluate_vector_field (const DataPostprocessorInputs::Vector<
2> &inputs,
                      std::vector<Vector<double> >             &
computed_quantities) const;

  virtual std::vector<std::string> get_names () const;

  virtual std::vector<DataComponentInterpretation::
DataComponentInterpretation> get_data_component_interpretation () const;

  virtual UpdateFlags get_needed_update_flags () const;
};

std::vector<std::string> Postprocessor :: get_names () const
{
  std::vector<std::string> solution_names (2, "elecfield");
  return solution_names;
}

std::vector<DataComponentInterpretation::DataComponentInterpretation> 
Postprocessor :: get_data_component_interpretation () const
{
  std::vector<DataComponentInterpretation::DataComponentInterpretation> 
interpretation (2,
                                            DataComponentInterpretation::
component_is_part_of_vector);

  return interpretation;
}

UpdateFlags Postprocessor :: get_needed_update_flags ()  const
{
  return update_gradients;
}

void Postprocessor :: evaluate_vector_field (const DataPostprocessorInputs::
Vector<2> &inputs,
                         std::vector<Vector<double> >             &
computed_quantities) const
{
  const unsigned int n_quadrature_points = inputs.solution_gradients.size 
();

  // for (unsigned int q = 0; q < n_quadrature_points; ++q)  
  for (unsigned int q = 0; q < 1; ++q)
    {
      for (unsigned int d = 0; d < 2; ++d)
    {
      const Tensor<1, 2> gradient_comp = inputs.solution_gradients[q][d];
      computed_quantities[q](d) = gradient_comp;
    }
    }
}

At the end, I know it's wrong to assign a Tensor<1, 2> type to a double 
type, but I don't know what I should do next to "parse" the tensor into the 
x-, y-component of the gradients. Any suggestions?

Also, I don't understand the description about solution_gradients in this 
page 
<https://dealii.org/developer/doxygen/deal.II/structDataPostprocessorInputs_1_1Vector.html#ac96fb295c3c807f96021bae734e8c3c3>.
 
Specifically the following line. What are the outer vector and inner 
vector? and What's the difference between the places where they are 
evaluated? Isn't the evaluation points the same as the finite element field 
for which output will be generated? I guess this is tide to the index d in 
the above code.

*The outer vector runs over the evaluation points, whereas the inner vector 
runs over the components of the finite element field for which output will 
be generated.*

Thanks!
Baoyun Ge

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