I am solving a complex PDE and have split the real and imaginary parts into two separate PDEs and solved. I now have two scalar functions, that I would like to combine back into a vector function so that I can plot the results.
I found the question
https://fenicsproject.org/qa/8838/combine-scalar-valued-functions-into-vector-valued-function
but I don't want to use the function in a form so it doesn't appear to apply, plus I am using the c++ api and I can't find an equivalent to the as_vector function.
I want to do something like this:
auto V = std::make_shared<real::FunctionSpace>(mesh);
auto W = std::make_shared<imaginary::FunctionSpace>(mesh);
auto u0 = std::make_shared<RealBoundaryCondition>(*mesh);
auto w0 = std::make_shared<ImaginaryBoundaryCondition>(*mesh);
auto f = std::make_shared<dolfin::Constant>(0);
auto boundary = std::make_shared<DirichletBoundary>();
dolfin::DirichletBC realbc(V, u0, boundary);
dolfin::DirichletBC imaginarybc(W, w0, boundary);
real::BilinearForm a(V, V);
real::LinearForm L(V);
L.f = f;
imaginary::BilinearForm b(W, W);
imaginary::LinearForm M(W);
M.f = f;
dolfin::Function u(V);
dolfin::solve(a == L, u, realbc);
dolfin::Function w(W);
dolfin::solve(b == M, w, imaginarybc);
[combine u and w into a single vector function "vec"]
dolfin::plot(vec);
dolfin::interactive();