Dot vs inner and complex suport

I’m sorry for creating a topic for such a short question but I don’t seem to find its answer in any place in the documentation (am I not searching in the right way?)

The question is: Is there any difference between dot and inner ? because I’ve seen codes with one or the other.

And talking about that, If dolfin-x has complex support. Does it means that every funcional space that I create is already complex valued? do real values are considered just a subset of complex values? Is there any keyword to specify a space to be complex/real?

Thank you very much, I’m sorry if this is already clear in the documentation.

See the comment in: Implementation — FEniCSx tutorial
and Form language — Unified Form Language (UFL) 2021.1.0 documentation

In DOLFINx you can create a function if any type by specifying the dtype, see: dolfinx.fem — DOLFINx 0.8.0.0 documentation

However, to be able to solve problems, you would need to use PETSc with appropriate floating type.
In the docker images dolfinx/dolfinx, pre-installed versions of the real-32 (default) and (complex-32)
version of PETSc (linked with DOLFINx) is installed, and can be accessed by calling source dolfinx-complex-mode or source dolfinx-real-mode (as explained in: GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment)

Thank you very much for pointing me to the documentation.

By the way, in the documentation says:

For variational formulations with complex numbers, one cannot use ufl.dot to compute inner products. One has to use ufl.inner, with the test-function as the second input argument for ufl.inner

I understood that the problem was that dot was not an inner product, as it was not conjugating the second argument. However, the docstring of doc (in version 0.3.0) is:

Docstring: UFL operator: Take the dot product of a and b. The complex conjugate of the second argument is taken.

Is still necessary to use the inner function?

The docstring in the documentation is wrong, as illustrated by this minimal example:

import ufl
import dolfinx
from mpi4py import MPI
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
V = dolfinx.fem.FunctionSpace(mesh, ufl.VectorElement("Lagrange", mesh.ufl_cell(), 1))
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)
a = ufl.inner(u, v) * ufl.dx
print(str(a))
A = dolfinx.fem.form(a)
a2 = ufl.dot(u, v) * ufl.dx
print(str(a2))
A2 = dolfinx.fem.form(a2)

but also the actual source code

Can you paste the output of your minimal example? I have version 0.3.0 and it does not have dolfinx.mesh.create_unit_square

You can do this with pure ufl as well:

import ufl
cell = ufl.triangle
c_el = ufl.VectorElement("Lagrange", cell, 1)
mesh = ufl.Mesh(c_el)
V = ufl.FunctionSpace(mesh, c_el)
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)
a = ufl.inner(u, v) * ufl.dx
print(str(a))
a2 = ufl.dot(u, v) * ufl.dx
print(str(a2))

returning

{ conj(((v_0) : (v_1))) } * dx(<Mesh #0>[everywhere], {})
{ (v_1) . (v_0) } * dx(<Mesh #0>[everywhere], {})

I’ve created an issue at Error in online documentation · Issue #106 · FEniCS/ufl · GitHub

Thank you very much, I’m very new to all of this and I have problems creating the MWE that help me see the differences. I hope I improve with time