NonlinearProblem.J_pc(P, x) is not called

#1

Hello All,

I was trying to provide a preconditioning form for my Newton solver. I wrote my own NewtonSolver and NonlinearProblem. Here’s what I observed:

  1. MyNewtonSolver.solver_setup (is exactly the same as NewtonSolver.solver_setup, just for test purpose) does be called and Preconditioning matrix does be created
  2. MyNonlinearProblem.J_pc(P, x) is never called.

MyNonlinearProblem.J_pc(P, x) is:

def J_pc(self, P, x):
    print('jpc is called')
    if self.j_pc is not None:
        dolfin.assemble(self.j_pc, tensor=P)
        for bc in self.bcs:
            bc.apply(P)

Can anyone tell me what to do pls?

Thanks in advance,
Victor

#2

It might be useful for future users, so I put my investigation here.

Yes, in C++, NonlinearProblem allows users to override NonlinearProblem::J_pc. Yet, looking at the pybind11 interfaces files, one can see that NonlinearProblem.J(...) is open to use and override for Python users but J_pc is not (version: 2018.1.0). Is there any reason setting it in this way?