mfem / mfem

Lightweight, general, scalable C++ library for finite element methods
http://mfem.org
BSD 3-Clause "New" or "Revised" License
1.69k stars 494 forks source link

Newton solver using SuperLU #3335

Closed ricgross closed 1 year ago

ricgross commented 1 year ago

Hi!

I am currently using MFEM to solve structural problems accounting for geometric nonlinearities. In order to achieve that, I have defined a custom NonlinearFormIntegrator, in which I have modified the AssembleElementVector (to calculate inner forces) and AssembleElementGrad (to calculate the tangential stiffness matrix). Furthermore, I defined a custom Operator, where I defined the functions Mult and GetGradient. Finally I use a NewtonSolver to solve the problem. In my current implementation, I am utilizing the UMFPackSolver, which I define with the following code:

UMFPackSolver direct_solver;
NewtonSolver newton;
newton.SetSolver(direct_solver);

So far so good. I am now looking to solve the problem in parallel (using a direct sparse solver), and within that regard, I have a couple of questions:

SuperLUSolver *superlu = new SuperLUSolver(fespace->GetComm());
NewtonSolver newton;
newton.SetSolver(superlu); 

i get the error message that the solver cannot be initialized with a value of type mfem::SuperLUSolver. Any ideas on how to solve the issue?

Sorry in advance if the question might result trivial.

Best regards, Riccardo

jandrej commented 1 year ago

You probably want to pass the object

newton.SetSolver(*superlu); 

in your case.

ricgross commented 1 year ago

Hi @jandrej

Thank you for your prompt reply. You are completely right, it was an oversight from my side.

However, I am facing another issue. In order to utilize SuperLU, one must define the SuperLURowLocMatrix operator, which creates the parallel matrix. My question is, how can I define/build the parallel matrix to be inputted to the direct sparse solver from my NonlinearForm with a custom integrator? As far as I can see, methods such as ParallelAssemble (which could be used for a BilinearForm) are not applicable here.

Best regards, Riccardo

stale[bot] commented 1 year ago

:warning: This issue or PR has been automatically marked as stale because it has not had any activity in the last month. If no activity occurs in the next week, it will be automatically closed. Thank you for your contributions.