How to define transpose of a gridfunction

After solving the Stokes equation, I got the approximated solution u_h. Now I want to create a matrix
[tex]K=\frac{u_hu_h^T}{|u_h|^2}[/tex]
where u_h^T is the transpose of u_h for another problem.
I did as follows. Please see the attached file.

[code]uh=SolveStokes()
print(“uh”,uh)

I = Id(2)
K = uhuh.trans()/(uhuh)
Z = I + K[/code]
Then I got an error.

[code]uh gridfunction ‘gfu.1’ on space ‘CompoundFESpaces’
nested = 0


NgException Traceback (most recent call last)
in
95
96 I = Id(2)
—> 97 K = uhuh.trans()/(uhuh)
98 Z = I + K

NgException: Transpose of non-matrix called
[/code]
Could you please tell me how to define the transpose of the grid function u_h in this case?
Thank you so much.

Attachment: Stokes_eq.ipynb

You have to reshape your CoefficientFunction to a matrix::

uhmat = CoefficientFunction( uh, dims=(3,1) )

Joachim

I modified the code like this as you suggested.

[code]uh=SolveStokes()
print(“uh”,uh)
uhmat = CoefficientFunction( uh, dims=(3,1) )

I = Id(2)
K = uhmatuhmat.trans()/(uhuh)
Z = I + K[/code]
But I got another error.

[code]---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
96
97 I = Id(2)
—> 98 K = uhmatuhmat.trans()/(uhuh)
99 Z = I + K

TypeError: call(): incompatible function arguments. The following argument types are supported:
1. (self: ngsolve.fem.CoefficientFunction, mip: ngsolve.fem.BaseMappedIntegrationPoint) → object
2. (self: ngsolve.fem.CoefficientFunction, arg0: numpy.ndarray[ngsolve.fem.MeshPoint]) → array

Invoked with: <ngsolve.fem.CoefficientFunction object at 0x00000000080CA990>[/code]

Could you please tell me how to fix this?
Thank you so much.

it is just trans without brackets ()

It worked well. Thank you so much for your clarification.