On 07/25/2017 01:07 PM, Baoyun Ge wrote:
> |
>
> voidPostprocessor::evaluate_vector_field
> (constDataPostprocessorInputs::Vector<2>&inputs,
> std::vector<Vector<double>>&computed_quantities)const
> {
> constunsignedintn_quadrature_points =inputs.solution_gradients.size ();
>
> // for (unsigned int q = 0; q < n_quadrature_points; ++q)
> for(unsignedintq =0;q <1;++q)
> {
> for(unsignedintd =0;d <2;++d)
> {
> constTensor<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?
The function in question needs to compute two output quantities (d=1 and 2),
and you have the components of gradient_comp. So the correct look would simply be
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[d];
}
By the way, to make your code simpler, you may want to derive your class from
DataPostprocessorVector instead of simply DataPostprocessor.
Best
W.
--
------------------------------------------------------------------------
Wolfgang Bangerth email:
bang...@colostate.edu
www:
http://www.math.colostate.edu/~bangerth/