@@ -377,8 +377,8 @@ int SNESSolver::init() {
377377 auto n_cross = (*options)[" stencil:cross" ]
378378 .doc (" Extent of stencil (cross)" )
379379 .withDefault <int >(0 );
380- // Set n_taxi 2 if nothing else is set
381- // Probably a better way to do this
380+ // Set n_taxi 2 if nothing else is set
381+ // Probably a better way to do this
382382 if (n_square == 0 && n_taxi == 0 && n_cross == 0 ) {
383383 output_info.write (" Setting solver:stencil:taxi = 2\n " );
384384 n_taxi = 2 ;
@@ -485,7 +485,7 @@ int SNESSolver::init() {
485485 d_nnz.reserve (nlocal);
486486
487487 for (int i = 0 ; i < nlocal; ++i) {
488- // Assume all elements in the z direction are potentially coupled
488+ // Assume all elements in the z direction are potentially coupled
489489 d_nnz.emplace_back (d_nnz_map3d[i].size () * mesh->LocalNz
490490 + d_nnz_map2d[i].size ());
491491 o_nnz.emplace_back (o_nnz_map3d[i].size () * mesh->LocalNz
@@ -598,9 +598,22 @@ int SNESSolver::init() {
598598 MatAssemblyBegin (Jfd, MAT_FINAL_ASSEMBLY);
599599 MatAssemblyEnd (Jfd, MAT_FINAL_ASSEMBLY);
600600
601- // The above will probably miss some non-zero entries at process boundaries
602- // Making sure the colouring matrix is symmetric will in some/all(?)
603- // of the missing non-zeros
601+ {
602+ // Test if the matrix is symmetric
603+ // Values are 0 or 1 so tolerance (1e-5) shouldn't matter
604+ PetscBool symmetric;
605+ ierr = MatIsSymmetric (Jfd, 1e-5 , &symmetric);
606+ CHKERRQ (ierr);
607+ if (!symmetric) {
608+ output_warn.write (" Jacobian pattern is not symmetric\n " );
609+ }
610+ }
611+
612+ // The above can miss entries around the X-point branch cut:
613+ // The diagonal terms are complicated because moving in X then Y
614+ // is different from moving in Y then X at the X-point.
615+ // Making sure the colouring matrix is symmetric does not
616+ // necessarily give the correct stencil but may help.
604617 if ((*options)[" force_symmetric_coloring" ]
605618 .doc (" Modifies coloring matrix to force it to be symmetric" )
606619 .withDefault <bool >(false )) {
0 commit comments