# Projection of Gradient of Tensor object

**URL:** https://discourse.julialang.org/t/projection-of-gradient-of-tensor-object/135467
**Category:** Modelling & Simulations
**Tags:** question, gridap
**Created:** [February 5, 2026, 9:03am UTC](https://discourse.julialang.org/t/projection-of-gradient-of-tensor-object/135467 "2026-02-05T09:03:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ankan\_Man](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ankan_man/32/215850_2.png) [@Ankan\_Man](https://discourse.julialang.org/u/Ankan_Man)
#### Post date: [February 5, 2026, 9:03am UTC](https://discourse.julialang.org/t/projection-of-gradient-of-tensor-object/135467/1 "2026-02-05T09:03:42Z")

</div>

Hi all. I am having an issue with projecting the derivative of a tensor on a sphere. This is the term in the weak form. Let P be the projector ( P = I - nxn). How to properly do the projection. Please help

term = ∇(q) ⊙ ∇(tq)

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [February 5, 2026, 2:41pm UTC](https://discourse.julialang.org/t/projection-of-gradient-of-tensor-object/135467/2 "2026-02-05T14:41:16Z")

</div>

Welcome @Ankan_Man, is this about Julia code? Or is this just about the pure maths? Either way, what have you tried?

You’ll need to give a bit more context, but you should be aware that this isn’t a homework help site.

---

<div class="post-metadata">

### Author: ![Ankan\_Man](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ankan_man/32/215850_2.png) [@Ankan\_Man](https://discourse.julialang.org/u/Ankan_Man)
#### Post date: [February 5, 2026, 2:55pm UTC](https://discourse.julialang.org/t/projection-of-gradient-of-tensor-object/135467/3 "2026-02-05T14:55:41Z")

</div>

We are trying to solve Landao ginsberg on the surface of a sphere.  
The tensor object used is as follows

```julia-auto
const QST = SymTracelessTensorValue{3,Float64,6} # Symmetric traceless tensor with 6 components

model = GmshDiscreteModel("sphere.msh")

Ω = Triangulation(model)

degree = 2

# 2. Create the measure dΩ from the triangulation Ω

dΩ = Measure(Ω, degree)

order = 1

reffe_T = ReferenceFE(lagrangian, QST, order)

VT = FESpace(model, reffe_T, conformity=:H1)

```

The weak form is given as below

```julia-auto
function weak_form(q, q0, tq, dt, D)
  print(2)
  n = get_normal_vector(Ω)
  I3 = one(TensorValue{3,3,Float64})
  P = I3 - outer(n,n) # same as I - n ⊗ n

  # Time derivative: (q - q0)/dt
  time_derivative = (q - q0) / dt

  # Non-linear term: q ⋅ q ⋅ q (Ensure the inner products match the tensor rank)
  # For SymTracelessTensorValue, q⋅q is a dot product.
  q3 = q ⋅ q ⋅ q 
  
  # The Weak Form Terms
  # Term 1: Time derivative dotted with test function
  term1 = time_derivative ⊙ tq
  
  # Term 2: Diffusion term (Laplacian in weak form)
  # Use ⊙ (inner product) for tensors
  #term2 = D * (∇(q) ⊙ ∇(tq)) # without projection
  term2 = D * ((P ⋅ ∇(q)) ⊙ ( P ⋅ ∇(tq)))
  
  # Term 3: Nonlinear potential term
  term3 = q3 ⊙ tq

  # Term 4 : Linear term
  term4 = q ⊙ tq
  print(3)
  return term1 - term2 + term3 - term4 
end

# Initialize the fields for the solver

V = FESpace(model, reffe_T, conformity=:H1)

U = TrialFESpace(V)

resi(V, U) = ∫( weak_form(V, Q0, U, dt, D) )*dΩ

```

This is how I was trying to project it, but this is not the right way. This is because the projection must also act on the basis. We are suppose to use 3 projection operators.

P \partial\_j A P (P e\_k) - This is the right way to do it in a eienstein convension. I was wondering how to do proper projection in Julia. And this is not a homework!! :-/

---

<div class="post-metadata">

### Author: ![marteaua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marteaua/32/214927_2.png) [@marteaua](https://discourse.julialang.org/u/marteaua)
#### Post date: [June 17, 2026, 12:31pm UTC](https://discourse.julialang.org/t/projection-of-gradient-of-tensor-object/135467/4 "2026-06-17T12:31:26Z")

</div>

@Ankan_Man can you provide a full MWE (Minimum Working example) as well as the strong form of the PDE you are trying to solve ?
