<div dir="ltr"><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><font size="2"><font face="trebuchet ms, sans-serif">Dear Developers,</font></font></div><div><font size="2"><font face="trebuchet ms, sans-serif"><br></font></font></div><div><font size="2"><font face="trebuchet ms, sans-serif">I tried to use the multi-color finite-difference (MC-FD) method for constructing the Jacobians. However, I find it is very slow compared to the exact Jacobian. </font></font></div><div><font size="2"><font face="trebuchet ms, sans-serif">My implementation of MC-FD Jacobian is posted below, would you please check whether I am correct? Anything missed? Thank you!</font></font></div><div><font size="2"><font face="trebuchet ms, sans-serif"><br></font></font></div><div><font size="2"><font face="trebuchet ms, sans-serif">////////// Setup phase:</font></font></div><div>          MatStructure flag;<br>          ISColoring   iscoloring;<br>          ierr = MatGetColoring(Jac,MATCOLORINGSL,&iscoloring);<br>          ierr = MatFDColoringCreate(Jac,iscoloring,&this->matfdcoloring);<br>          ierr = MatFDColoringSetFunction(this->matfdcoloring,(PetscErrorCode (*)(void))__libmesh_petsc_snes_residual,(void *)this);<br>          ierr = MatFDColoringSetFromOptions(this->matfdcoloring);<br>          ierr = ISColoringDestroy(&iscoloring);<font size="2"><font face="trebuchet ms, sans-serif"><br></font></font></div><div><br></div><div><font size="2"><font face="trebuchet ms, sans-serif">//////////// Apply:</font></font></div><div>          ierr = MatZeroEntries(*jac);CHKERRQ(ierr);<br>          ierr = MatFDColoringApply(*jac,solver->matfdcoloring,x,msflag,snes);</div><div><br></div><div>Best regards,</div><div>Li Luo</div></div></div></div>

<br>
<div><hr></div><font face="Arial" size="1">This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.</font>