Hi there,
How can I subtract one gridfunction from another?
The following code to calculate c=a-b does not produce errors when running, but it does not return a plot and gives an error in glvis.
Please help.
Sai
MFEM abort: input stream is not a FiniteElementSpace!
... in function: mfem::FiniteElementCollection* mfem::FiniteElementSpace::Load(mfem::Mesh*, std::istream&)
... in file: fem/fespace.cpp:2216
GridFunction a(&fes_h1);
GridFunction b(&fes_h1);
//values calculated for a and b
GridFunction c(&fes_h1);
c=a-b;
socketstream c_sock(vishost, visport);
c_sock.precision(8);
c_sock << "solution\n" << *mesh << c << "window_title 'GridFunction c'" <<flush;
Try:
c = a;
c -= b;
That was unexpected. Thank you!
I didn't find -= or += operator in http://mfem.github.io/doxygen/html/classmfem_1_1GridFunction.html. How did you know that it would work? Please share.
GridFunction is Vector (subclass)
https://github.com/mfem/mfem/blob/master/linalg/vector.hpp#L250
I'll close this now, feel free to reopen if you have further questions.
Most helpful comment
GridFunction is Vector (subclass)
https://github.com/mfem/mfem/blob/master/linalg/vector.hpp#L250