Open simonsticko opened 5 months ago
Hey @simonsticko, I've managed to reproduce the error.
For some reason, the code is not allocating the elemental contributions correctly (creating float-based arrays instead of complex-based arrays).
A complete fix might be a little involved, but for now you can do this:
using Gridap
# Using float works fine. Complex gives an error.
# T = Float64
T = ComplexF64
domain = (0, 1, 0, 1)
partition = (4, 4)
model = CartesianDiscreteModel(domain, partition)
order = 1
reffe = ReferenceFE(lagrangian, Float64, order)
V1 = TestFESpace(model, reffe; conformity=:H1, vector_type=Vector{T})
V2 = TestFESpace(model, reffe; conformity=:H1, vector_type=Vector{T})
U1 = TrialFESpace(V1)
U2 = TrialFESpace(V2)
Y = MultiFieldFESpace([V1, V2])
X = MultiFieldFESpace([U1, U2])
degree = 2 * order
Ω = Triangulation(model)
dΩ = Measure(Ω, degree)
ONE = 1.0+0.0im
# Project constant 1 into both spaces.
a((u1, u2), (v1, v2)) = ∫(ONE*(v1 * u1 + v2 * u2))dΩ
l((v1, v2)) = ∫(ONE*(v1 + v2))dΩ
op = AffineFEOperator(a, l, X, Y)
uh1, uh2 = solve(op)
It's basically your code, but I force the type of the integrand to be of complex type by multiplying everywhere by a complex-valued one.
Actually: your weakform has nothing complex about it, it only involves real-valued functions. When you try an actual complex-valued problem, complex numbers will appear naturally and you will no longer have to do this trick (at least that would be my guess).
Let me know if it works for you as well.
Let me know if it works for you as well.
Yes. That works. Thank you for the work-around, and for the quick reply. :+1:
When you try an actual complex-valued problem, complex numbers will appear naturally and you will no longer have to do this trick (at least that would be my guess).
I don't think this is necessarily true. In for example, Helmholz equation the coefficients in the weak form are real, unless there is damping added.
Hi.
I tried to use
MultiFieldFESpace
based on two complex spaces, but I am getting a type conversion error. Is this a bug? Or have I misunderstood how this should be done? (Gridap v0.17.22)Minimal working example:
Error message: