HI, Wofgang,

thanks very much for your reply. It indeed helps. Now I can
 get the gradient of the velocity of the previous solution, basically
\nabla u, which is a nonsymmetric second-order tensor, with 4 entries
in a 2D case.

 std::vector<Tensor<2,dim> > grads_velocity (n_q_points);

for (; cell!=endc; ++cell, ++stokes_cell)
{
    stokes_fe_values[velocities].get_function_gradients (stokes_solution,
    
                                                                             
grads_velocity);
}

where grads_velocity[0] is a second-order tensor for the 0-th (first) 
quadrature point.
For a 2D problem, it should have 2*2=4 entries, corresponding to a matrix 
like 
{dudx, dvdx,
 dudy, dvdy} .

In fact, I can also get access to the four entries of grads_velocity[0] as
grads_velocity[0][0][0], grads_velocity[0][0][1], grads_velocity[0][1][0],
grads_velocity[0][1][1]. Now the only thing I need to know what is the 
one-to-one
correspondence between the above 2-by-2 matrix and the four entries
of the tensor? 

Thanks in advance,

best,
lailai 




On Sunday, December 11, 2016 at 9:58:49 PM UTC-5, Wolfgang Bangerth wrote:
>
> On 12/10/2016 05:18 PM, Lailai Zhu wrote: 
> > 
> > I started everything from the step-31, Stokes equations solving vector 
> > field 'u' and scalar field 'p', and a temperature equation for 'T'. 
> > 
> > My problem is similar to this, namely I have a scalar field, say 'C', 
> 'C' 
> > is an explicit function of 'u' and 'p' (for example C=(\nabla u : \nabla 
> u) 
> > - p ), so i don't need to use fem to solve for 'C' like the example 31 
> > solving for 'T'.  'C' can be directly expression by 'u' and 'p'. 
> > 
> > I would like to use 'C' a lot as intermediate variable (for example to 
> > help define the volume force of the momentum equations), so I need to 
> know 
> > 'C' at every quadrature points. I also want to export 'C' in the .vtk 
> > output. 
> > 
> > My question is what be the most reasonable or efficient way to define 
> and 
> > calculate such 'C'. Do I need to define 'C' as a solution variable, 
> exactly 
> > like 'T' even I don't really need to solve for it? Thanks in advance, 
>
> The answer is different for the two contexts. For creating output in a 
> .vtk 
> file, you will want to compute the quantity in a postprocessor derived 
> from 
> DataPostprocessor. There are a number of tutorial programs that show how 
> to do 
> this. 
>
> On the other hand, if you need this quantity in the assembly of another 
> equation, then you will want to compute it at the quadrature points you 
> care 
> about, whenever that is necessary. That is no different than using the 
> previous solution to define the coefficient in the current iteration in a 
> nonlinear scheme. You probably want to look at step-15 to see how to do 
> this. 
>
> Best 
>   W. 
>
> -- 
> ------------------------------------------------------------------------ 
> Wolfgang Bangerth          email:                 [email protected] 
> <javascript:> 
>                             www: http://www.math.colostate.edu/~bangerth/ 
>
>

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