Thanks for the clarification, Jean-Paul. I'm glad to hear that my syntax is 
correct.

I am indeed using an extractor, e.g. here's a line from my code:
const Tensor<2, dim> gradv = fe_values[velocity].gradient(j, quad);

I'm having some trouble finding an example of the S[i][j] syntax in either 
tutorial. Part of step 44 has the following for the geometric stress 
contribution:
data.cell_matrix(i, j) += grad_Nx[i][component_i] * tau
 * grad_Nx[j][component_j] * JxW;

which is at least using the same operators to read the components; but it's 
not clear to me that this maps to the $S_{i,j}$ notation we discussed. It 
seems they have to do some work to map to the correct indices, i.e. with
const unsigned int component_i = fe.system_to_component_index 
<https://dealii.org/developer/doxygen/deal.II/classFiniteElement.html#a27220a135402b96c7e6eecbb04acda56>
(i).first;

For now I'm satisfied with having an experience user confirm that my syntax 
is correct; but I might want to formulate a test, unless a clear example 
already exists somewhere. I should be able to write something down for a 
simple PDE with a simple basis. I get the feeling that I'd just be testing 
a well established deal.II code behavior. Maybe I'm missing something 
obvious in the information you already provided.

I'm going to describe my specific problem a bit more in case there's an all 
around better way to do this: This is coming from the incompressible 
Navier-Stokes momentum equation with the term $(\mathbf{u} \cdot \nabla) 
\mathbf{u}$. The nonlinear variational form uses the operator 
$c(\mathbf{w};mathbf{z},mathbf{v} = \int{[(\mathbf{w} \cdot \nabla) 
\mathbf{z}] \cdot \mathbf{v} d\Omega}_\Omega = 
\sum{\sum{\int{w_j(\partial_j z_i)v_i d\Omega}_\Omega}_{j=1}^n}_{i=1}^n$

When I implement this with higher level library, FEniCS, I don't have to 
write the summation; but I think I have to write the summation in deal.II; 
hence I need to access $\partial_j z_i$, which I'm doing with the S[i][j] 
syntax that we discussed. I actually implement something similar to the 
integrand of this operator, for a given quadrature point and degree of 
freedom, with the lambda function:
    auto c = [](
        const Tensor<1, dim> _w,
        const Tensor<2, dim> _gradz,
        const Tensor<1, dim> _v)
    {
        double sum = 0.;
        
        for (unsigned int i = 0; i < dim ; ++i)
        {
            for (unsigned int j = 0; j < dim; ++j)
            {


                sum += _w[j]*_gradz[i][j]*_v[i];
        
            }
        }            
                
        return sum;
    };


Thanks for the help!

P.S. What's the best way to communicate math equations on the mailing list? 
I'm just typing what I think is roughly the correct LaTeX syntax, but this 
seems a bit clunky.

On Wednesday, April 5, 2017 at 3:04:04 PM UTC+2, Jean-Paul Pelteret wrote:
>
> Dear Alex,
>
> What you've stated is correct. The tensor component $S_{ij}$ is exactly 
> component S[i][j] of a Tensor<2,dim> S if "S" represents $S_{ij} = 
> \partial v_{i} \partial x_{j}$.
>
> As for an example, both steps 18 
> <https://dealii.org/developer/doxygen/deal.II/step_18.html#TopLevelupdate_quadrature_point_history>
>  
> and 44 
> <https://dealii.org/developer/doxygen/deal.II/step_44.html#Solidupdate_qph_incremental>
>  
> both extract gradient of the vector-valued solution field. In step-18, the 
> gradient tensor is constructed manually after a the call to 
> fe_values.get_function_gradients 
> <https://dealii.org/developer/doxygen/deal.II/classFEValuesBase.html#a69c63f8be0311c8970253276ac7df138>
>  
> (incremental_displacement,
>                                  displacement_increment_grads);
> while in step-44 an extractor is used as well in order to produce $\Grad 
> \mathbf{u}$ (u representing the displacement) at each quadrature point 
> directly:
>   scratch.fe_values_ref[u_fe].get_function_gradients(scratch.
> solution_total,
>                                                     scratch.
> solution_grads_u_total);
>
> Depending on whether or not you use an extractor to perform this task, the 
> data structure in which the result is placed (here, 
> displacement_increment_grads 
> and scratch.solution_grads_u_total) is slightly different. When using an 
> extractor you will end up with the vector (each entry representing data at 
> a quadrature point) of rank-2 tensors because it is known that this is the 
> gradient of a vector field - this would be exactly "S" if the extractor 
> pertains to the velocity field. In contrast, the FEValues object knows 
> nothing about the solved fields if no extractor is used, so you'd have to 
> reconstruct "S" manually, in a similar way to that which is done in step-18.
>
> I hope that this helps clarify things a little bit.
>
> Best regards,
> Jean-Paul
>
>
> On Wednesday, April 5, 2017 at 1:10:00 PM UTC+2, Alex Zimmerman wrote:
>>
>> I am debugging a code where part of my weak form requires indexing into 
>> the Tensor<2,dim> that results from getting the gradient of a Tensor<1,dim> 
>> (in this case, a velocity vector).
>>
>> I found the convention for the index notation here: 
>> http://dealii.org/8.4.1/doxygen/deal.II/classFEValuesViews_1_1Vector.html
>>
>> The important part of that documentation for me is that "The gradient of 
>> a vector $d_k, 0 <= k < dim$ is defined as $S_{ij} = \frac{\partial 
>> d_i}{\partial x_j}, 0 <= i,j < dim$.
>>
>> What is the exact syntax for getting component $S_{ij}$ in my code? For a 
>> Tensor<2,dim> S
>>
>> I am currently assuming that I want 
>> S[i][j]
>>
>> But I am not 100% sure that don't have this backwards. I have reviewed 
>> the documentation about how these tensors are rolled/unrolled; but I'm 
>> having trouble devising a test to ensure that I am understanding this 
>> correctly, and I'm guessing that this is something quite obvious to most 
>> users.
>>
>> Also it would help if someone could point me toward an existing 
>> tutorial/example that accesses components of the gradient of a physical 
>> vector. I had no luck finding one.
>>
>> Thanks,
>>
>> Alex
>>
>

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