gridap / gridap/Gridap.jl

dimension order in gradients

Open
#822 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
879
Forks
119
Avg merge
6d 3h
Merged PRs (30d)
4

Description

Hi,

I (finally) figured out something that has given me a lot of headaches in the past:
Gridap appears to have made a very unconventional choice of dimension ordering when it comes to gradients.

According to e.g. [wikipedia](https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant)
the gradient of a vector field is defined as

$$
∂_j v_i = (∇v)_{ij}
$$

where the index of the derivative is added at the end.
However, for both vectors and tensors, gridap adds the derivative dimension at the ~~end~~ **beginning** (it's confusing....)

```
julia> model = CartesianDiscreteModel(domain,partition);

julia> tensor = interpolate(
x->TensorValue(x[1]+10x[2], 2x[1]+100x[2], 3x[1]+1000x[2], 4x[1]+10000x[2]),
TestFESpace(model, ReferenceFE(lagrangian, TensorValue{2,2,Float64, 4}, 1)));

julia> gr = ∇(tensor);

julia> evaluate(gr, VectorValue(1,1))
Gridap.TensorValues.ThirdOrderTensorValue{2, 2, 2, Float64, 8}(1.0, 10.0, 2.0, 100.0, 3.0, 1000.0, 4.0, 10000.0)

julia> vector = interpolate(x->VectorValue(x[1]+10x[2], 2x[1]+100x[2]),
TestFESpace(model, ReferenceFE(lagrangian, VectorValue{2,Float64}, 1)));

julia> gr = ∇(vector);

julia> evaluate(gr, VectorValue(1,1))
TensorValue{2, 2, Float64, 4}(1.0, 10.0, 2.0, 100.0)
```

Of course, this is not a problem for terms such as `∇(u)⊙∇(v)` but in asymmetric contractions this is important.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.