This is a question about understanding a piece of random code that does not necessarily require knowledge of it's theory. This is very specific and may not be of use to the community in general but some may find it interesting. I have shown a snippet of python code below. In my attempt to take this code from python to C++, I have marked the lines which can go directly to UFL and those which require C++ conversion and then go to main.cpp.
Du_elastic_energy = derivative(elastic_energy, u, w) # Goes as it is to UFL
Dv_kinetic_energy = derivative(kinetic_energy, v, w) # Goes as it is to UFL
M, F_tot = lhs(replace(Dv_kinetic_energy, {v: du})), - Du_elastic_energy # Goes as it is to UFL
M_lumped = action(M, Constant(1.0)) # Mass lumping # Goes as it is to UFL
ML = PETScVector() # Goes to main.cpp
FT = PETScVector() # Goes to main.cpp
assemble(M_lumped, tensor=ML) # Goes to main.cpp
def solve_a(): # Goes to main.cpp
assemble(F_tot, tensor=FT)
a.vector().set_local(FT.array() / ML.array())
Is the following a correct C++ conversion of the above FEniCS python code?
auto ML = std::make_shared<dolfin::PETScVector>(); # M_lumped.(new dolfin::PETScMatrix());
auto FT = std::make_shared<dolfin::PETScVector>();
dolfin::Assembler assembler;
assembler.assemble(ML, *M_lumped); # assembler_->assemble(*A);
void solve_a()
{
assembler.assemble(FT, *F_tot);
a.vector() = FT.vector() / ML.vector()
}