libMesh/libmesh: coverage diff

Base 8fa69b Head #4537 bb2485
Total Total +/- New
Rate 65.94% 65.92% -0.02% 100.00%
Hits 79391 79399 +8 54
Misses 41015 41050 +35 0
Filename Stmts Miss Cover
include/numerics/petsc_mffd_matrix.h +4 +1 +5.00%
include/solvers/nonlinear_solver.h +2 +2 -3.04%
src/mesh/mesh_triangle_holes.C 0 -1 +0.28%
src/numerics/petsc_matrix_shell_matrix.C +30 +30 -48.30%
src/solvers/petsc_nonlinear_solver.C +1 0 +0.08%
src/systems/nonlinear_implicit_system.C +6 +3 -0.07%
TOTAL +43 +35 -0.02%
code
coverage unchanged
code
coverage increased
code
coverage decreased
+
line added or modified

include/numerics/petsc_mffd_matrix.h

110  
111  
112  
113 +
114  
115  
116 +
117 +
118 +
119 +
120  
121  
122  
123  

template <typename T>
void
PetscMFFDMatrix<T>::assign(Mat m, bool set_context)
{
  this->_mat = m;
  this->_is_initialized = true;
  this->_destroy_mat_on_exit = false;
  if (set_context)
    this->set_context();
}

template <typename T>
void

include/solvers/nonlinear_solver.h

109  
110  
111  
112 +
113  
114  
115  
116  
117  
118  
119 +
120  
121  
122  
   * default implementation ignores \p jac_in and simply forwards to the single-matrix solve(),
   * for solver backends that do not distinguish between the two.
   */
  virtual std::pair<unsigned int, Real> solve (SparseMatrix<T> & /* jac_in */,
                                               SparseMatrix<T> & pre_in,
                                               NumericVector<T> & x_in,
                                               NumericVector<T> & r_in,
                                               const double tol,
                                               const unsigned int m_its)
  {
    return this->solve(pre_in, x_in, r_in, tol, m_its);
  }

  /**

src/mesh/mesh_triangle_holes.C

276  
277  
278  
279  
280  
281  
282  
    {
      ray_target = inside - Point(1);
      intersection_distances =
        this->find_ray_intersections(inside, ray_target);
    }

  // I'd make this an assert, but I'm not 100% confident we can't

src/numerics/petsc_matrix_shell_matrix.C

56  
57  
58  
59 +
60  
61 +
62  
63  
64  
65  
66 +
67  
68 +
69  
70  
71  
72  
73 +
74  
75 +
76  
77  
78  
79  
80 +
81  
82 +
83  
84  
85  
86  
87 +
88  
89 +
90  
91  
92  
93  
94 +
95  
96  
97  
98 +
99  
100  
101  
102  
103 +
104  
105  
106 +
107  
108  
109  
110  
111 +
112  
113 +
114  
115  
116  
117  
118 +
119  
120 +
121  
122  
123  
124  
125 +
126  
127 +
128  
129  
130  
131  
132 +
133  
134 +
135  
136  
137  
138  
139 +
140  
141 +
142  
143  
144  
145  
146 +
147  
148 +
149  
150  
151  
152  
153 +
154  
155 +
156  
157  
158  
159  
160 +
161  
162  
163  
164 +
165  
166  
167  

template <typename T>
void
PetscMatrixShellMatrix<T>::zero()
{
  libmesh_error();
}

template <typename T>
std::unique_ptr<SparseMatrix<T>>
PetscMatrixShellMatrix<T>::zero_clone() const
{
  libmesh_error();
}

template <typename T>
std::unique_ptr<SparseMatrix<T>>
PetscMatrixShellMatrix<T>::clone() const
{
  libmesh_not_implemented();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::set(const numeric_index_type, const numeric_index_type, const T)
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::add(const numeric_index_type, const numeric_index_type, const T)
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::add_matrix(const DenseMatrix<T> &,
                                      const std::vector<numeric_index_type> &,
                                      const std::vector<numeric_index_type> &)
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::add_matrix(const DenseMatrix<T> &,
                                      const std::vector<numeric_index_type> &)
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::add(const T, const SparseMatrix<T> &)
{
  libmesh_error();
}

template <typename T>
T
PetscMatrixShellMatrix<T>::operator()(const numeric_index_type, const numeric_index_type) const
{
  libmesh_error();
}

template <typename T>
Real
PetscMatrixShellMatrix<T>::l1_norm() const
{
  libmesh_error();
}

template <typename T>
Real
PetscMatrixShellMatrix<T>::linfty_norm() const
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::print_personal(std::ostream &) const
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::get_diagonal(NumericVector<T> &) const
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::get_transpose(SparseMatrix<T> &) const
{
  libmesh_error();
}

template <typename T>
void
PetscMatrixShellMatrix<T>::get_row(numeric_index_type,
                                   std::vector<numeric_index_type> &,
                                   std::vector<T> &) const
{
  libmesh_error();
}

template class LIBMESH_EXPORT PetscMatrixShellMatrix<Number>;

src/solvers/petsc_nonlinear_solver.C

452  
453  
454  
455 +
456  
457  
458  
        Jac = &mffd_jac;
        // mffd_jac is function-local, so don't attach a context to jac here -- it would
        // dangle once mffd_jac is destroyed at the end of this call.
        mffd_jac.assign(jac, /*set_context=*/false);
      }

    // We already computed the Jacobian during the residual evaluation
698  
699  
700  
701 +
702  
703  
704  
  _default_monitor(true),
  _snesmf_reuse_base(true),
  _computing_base_vector(true),
  _setup_reuse(false)
{
}

905  
906  
907  
908 +
909  
910  
911  
912  
913 +
914  
915  
916  
                                const double        tol,     // Stopping tolerance
                                const unsigned int  m_its)
{
  return this->solve(pre_in, pre_in, x_in, r_in, tol, m_its);
}

template <typename T>
std::pair<unsigned int, Real>
PetscNonlinearSolver<T>::solve (SparseMatrix<T> &  jac_in,  // Jacobian operator matrix (Amat)
                                SparseMatrix<T> &  pre_in,  // Preconditioning matrix (Pmat)
                                NumericVector<T> & x_in,    // Solution vector
                                NumericVector<T> & r_in,    // Residual vector
923  
924  
925  
926 +
927  
928  
929  
  this->init ();

  // Make sure the data passed in are really of Petsc types
  PetscMatrixBase<T> * jac = cast_ptr<PetscMatrixBase<T> *>(&jac_in);
  PetscMatrixBase<T> * pre = cast_ptr<PetscMatrixBase<T> *>(&pre_in);
  PetscVector<T> * x   = cast_ptr<PetscVector<T> *>(&x_in);
  PetscVector<T> * r   = cast_ptr<PetscVector<T> *>(&r_in);
965  
966  
967  
968 +
969  
970  
971  
  // Only set the jacobian function if we've been provided with something to call.
  // This allows a user to set their own jacobian function if they want to
  if (this->jacobian || this->jacobian_object || this->residual_and_jacobian_object)
    LibmeshPetscCall(SNESSetJacobian (_snes, jac->mat(), pre->mat(), libmesh_petsc_snes_jacobian, this));

  // Have the Krylov subspace method use our good initial guess rather than 0
  KSP ksp;

src/systems/nonlinear_implicit_system.C

38  
39  
40  
41 +
42 +
43  
44  
45  
  nonlinear_solver          (NonlinearSolver<Number>::build(*this)),
  diff_solver               (),
  _n_nonlinear_iterations   (0),
  _final_nonlinear_residual (1.e20),
  _operator_matrix          (nullptr)
{
  // Set default parameters
  // These were chosen to match the Petsc defaults
132  
133  
134  
135  
136  
137  
138  
    es.parameters.get<unsigned int>("nonlinear solver maximum function evaluations");

  const double abs_resid_tol = parameters.have_parameter<Real>("nonlinear solver absolute residual tolerance") ?
    double(parameters.get<Real>("nonlinear solver absolute residual tolerance")) :
    double(es.parameters.get<Real>("nonlinear solver absolute residual tolerance"));

  const double rel_resid_tol = parameters.have_parameter<Real>("nonlinear solver relative residual tolerance") ?
228  
229  
230  
231 +
232 +
233 +
234 +
235 +
236  
237 +
238 +
239 +
240 +
241  
242  
243  
      // If a distinct Jacobian operator matrix has been registered (see
      // set_operator_matrix()), use it as Amat while *matrix remains the preconditioning matrix
      // (Pmat); otherwise use the ordinary single-matrix solve.
      if (_operator_matrix)
        std::tie(_n_nonlinear_iterations, _final_nonlinear_residual) =
          nonlinear_solver->solve (*_operator_matrix, *matrix, *solution, *rhs,
                                   nonlinear_solver->relative_residual_tolerance,
                                   nonlinear_solver->max_linear_iterations);
      else
        std::tie(_n_nonlinear_iterations, _final_nonlinear_residual) =
          nonlinear_solver->solve (*matrix, *solution, *rhs,
                                   nonlinear_solver->relative_residual_tolerance,
                                   nonlinear_solver->max_linear_iterations);
    }

  // Update the system after the solve