Custom Newton Solver in C++

I would like to implement the hyperelasticity demo and a nonlinear poisson equation code that I made using a custom newton solver in C++, FEniCSx version 0.5.2. Are there any templates/demos that I can use? I have looked at the source code in NewtonSolver.cpp file and the python example however I am still unsure of how to implement it in C++.

Consider: Custom Newton solvers — FEniCSx tutorial

You should be able to more or less copy-paste these steps to C++.

As you can see from dolfinx/main.cpp at main · FEniCS/dolfinx · GitHub
and the source code for the NewtonSolver.cpp, we hook things to dolfinx/NewtonSolver.cpp at 9f55e8be10a3e3f6c3f2a2146395ddb2a332e5c1 · FEniCS/dolfinx · GitHub
and execute those functions in the order specified here.

1 Like