This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Error: Unable to write data to VTK file?

0 votes

Hello all. I am relatively new to FEniCS. I am trying to solve the Helmholtz wave equation in a mixed space for electromagnetic problems with complex values. I am receiving a strange error I don't know how to handle when I attempt to export the data for visualization.

Here is what I believe to be the only relevant parts of the code:

# Formulation
mesh = UnitSquareMesh(100, 100)
Vreal = FunctionSpace(mesh,"Nedelec 1st kind H(curl)", 2)    
Vimag = FunctionSpace(mesh,"Nedelec 1st kind H(curl)", 2)    
V = Vreal*Vimag

E0 = Constant((1,1))
E = TrialFunction(V)
Ereal, Eimag = split(E)
v = TestFunction(V)
vreal,vimag = split(v)

# Solve system
E = Function(V)
E_vector = E.vector()
solve(A, E_vector, b)

# Plot and export solution
plot(E,mode = "color", interactive = False)

file = File("Plasmonics.pvd")
file << E

Error:

*** Error:   Unable to write data to VTK file.
*** Reason:  Don't know how to handle vector function with dimension other than 2 or 3.
*** Where:   This error was encountered inside VTKFile.cpp.

I am not certain what the issue is and why I am receiving this error. Especially because similar examples do not have this issue. I hope I have provided enough code. Any help would be greatly appreciated.

asked Nov 16, 2016 by nwinner FEniCS Novice (120 points)

1 Answer

0 votes

It looks like your function E which belongs to your $[V]^{2d}$ vector space ($d$ real, $d$ imaginary, E = Function(V)) cannot be output as-is. You should try splitting or projecting the vector E into separate real and imaginary components of dimension $d, d = 2, 3$ and outputting those.

answered Nov 22, 2016 by nate FEniCS Expert (17,050 points)
...