<commit_before>// $Id: linear_solver_interface.h,v 1.2 2004-01-03 15:37:42 benkirk Exp $

// The libMesh Finite Element Library.
// Copyright (C) 2002-2004  <NAME>, <NAME>
  
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
  
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



#ifndef __linear_solver_interface_h__
#define __linear_solver_interface_h__


// C++ includes

// Local includes
#include "libmesh_common.h"
#include "enum_solver_package.h"
#include "enum_solver_type.h"
#include "enum_preconditioner_type.h"
#include "reference_counted_object.h"
#include "libmesh.h"

// forward declarations
template <typename T> class AutoPtr;
template <typename T> class SparseMatrix;
template <typename T> class NumericVector;





/**
 * This class provides a uniform interface for linear solvers.  This base
 * class is overloaded to provide linear solvers from different packages
 * like PETSC or LASPACK.
 *
 * @author <NAME>, 2003
 */

template <typename T>
class LinearSolverInterface : public ReferenceCountedObject<LinearSolverInterface<T> >
{
public:
  
  /**
   *  Constructor. Initializes Solver data structures
   */
  LinearSolverInterface ();
    
  /**
   * Destructor.
   */
  virtual ~LinearSolverInterface ();
  
  /**
   * Builds a \p LinearSolverInterface using the linear solver package specified by
   * \p solver_package
   */
  static AutoPtr<LinearSolverInterface<T> > build(const SolverPackage solver_package =
						  libMesh::default_solver_package());
  
  /**
   * @returns true if the data structures are
   * initialized, false otherwise.
   */
  bool initialized () const { return _is_initialized; }
  
  /**
   * Release all memory and clear data structures.
   */
  virtual void clear () {}

  /**
   * Initialize data structures if not done so already.
   */
  virtual void init () = 0;

  /**
   * Returns the type of solver to use.
   */
  SolverType solver_type () const { return _solver_type; }

  /**
   * Sets the type of solver to use.
   */
  void set_solver_type (const SolverType st)
  { _solver_type = st; }

  /**
   * Returns the type of preconditioner to use.
   */
  PreconditionerType preconditioner_type () const
  { return _preconditioner_type; }

  /**
   * Sets the type of preconditioner to use.
   */
  void set_preconditioner_type (const PreconditionerType pct)
  { _preconditioner_type = pct; }
  

  /**
   * @returns A pair containing the number of iterations taken
   * and the final residual.
   * Call the Solver solver
   */    
  virtual std::pair<unsigned int, Real> solve (SparseMatrix<T>&,
					       NumericVector<T>&,
					       NumericVector<T>&,
					       const double,
					       const unsigned int) = 0;

  
protected:

  
  /**
   * Enum stating which type of iterative solver to use.
   */
  SolverType _solver_type;

  /**
   * Enum statitng with type of preconditioner to use.
   */
  PreconditionerType _preconditioner_type;
  
  /**
   * Flag indicating if the data structures have been initialized.
   */
  bool _is_initialized;
};




/*----------------------- inline functions ----------------------------------*/
template <typename T>
inline
LinearSolverInterface<T>::LinearSolverInterface () :
  
  _solver_type         (GMRES),
  _preconditioner_type (ILU_PRECOND),
  _is_initialized      (false)
{
}



template <typename T>
inline
LinearSolverInterface<T>::~LinearSolverInterface ()
{
  this->clear ();
}



#endif // #ifdef __solver_interface_h__
<commit_msg>Added some additional documentation to the solve member.<commit_after>// $Id: linear_solver_interface.h,v 1.3 2004-08-20 13:58:02 jwpeterson Exp $

// The libMesh Finite Element Library.
// Copyright (C) 2002-2004  <NAME>, <NAME>
  
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
  
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



#ifndef __linear_solver_interface_h__
#define __linear_solver_interface_h__


// C++ includes

// Local includes
#include "libmesh_common.h"
#include "enum_solver_package.h"
#include "enum_solver_type.h"
#include "enum_preconditioner_type.h"
#include "reference_counted_object.h"
#include "libmesh.h"

// forward declarations
template <typename T> class AutoPtr;
template <typename T> class SparseMatrix;
template <typename T> class NumericVector;





/**
 * This class provides a uniform interface for linear solvers.  This base
 * class is overloaded to provide linear solvers from different packages
 * like PETSC or LASPACK.
 *
 * @author <NAME>, 2003
 */

template <typename T>
class LinearSolverInterface : public ReferenceCountedObject<LinearSolverInterface<T> >
{
public:
  
  /**
   *  Constructor. Initializes Solver data structures
   */
  LinearSolverInterface ();
    
  /**
   * Destructor.
   */
  virtual ~LinearSolverInterface ();
  
  /**
   * Builds a \p LinearSolverInterface using the linear solver package specified by
   * \p solver_package
   */
  static AutoPtr<LinearSolverInterface<T> > build(const SolverPackage solver_package =
						  libMesh::default_solver_package());
  
  /**
   * @returns true if the data structures are
   * initialized, false otherwise.
   */
  bool initialized () const { return _is_initialized; }
  
  /**
   * Release all memory and clear data structures.
   */
  virtual void clear () {}

  /**
   * Initialize data structures if not done so already.
   */
  virtual void init () = 0;

  /**
   * Returns the type of solver to use.
   */
  SolverType solver_type () const { return _solver_type; }

  /**
   * Sets the type of solver to use.
   */
  void set_solver_type (const SolverType st)
  { _solver_type = st; }

  /**
   * Returns the type of preconditioner to use.
   */
  PreconditionerType preconditioner_type () const
  { return _preconditioner_type; }

  /**
   * Sets the type of preconditioner to use.
   */
  void set_preconditioner_type (const PreconditionerType pct)
  { _preconditioner_type = pct; }
  


  /**
   * This function calls the solver
   * "_solver_type" preconditioned with the
   * "_preconditioner_type" preconditioner.  Note that this method
   * simply calls the one above and specifies the preconditioning
   * matrix as the system matrix.
   */
  virtual std::pair<unsigned int, Real> solve (SparseMatrix<T>&,  // System Matrix
					       NumericVector<T>&, // Solution vector
					       NumericVector<T>&, // RHS vector
					       const double,      // Stopping tolerance
					       const unsigned int) = 0; // N. Iterations
  
protected:

  
  /**
   * Enum stating which type of iterative solver to use.
   */
  SolverType _solver_type;

  /**
   * Enum statitng with type of preconditioner to use.
   */
  PreconditionerType _preconditioner_type;
  
  /**
   * Flag indicating if the data structures have been initialized.
   */
  bool _is_initialized;
};




/*----------------------- inline functions ----------------------------------*/
template <typename T>
inline
LinearSolverInterface<T>::LinearSolverInterface () :
  
  _solver_type         (GMRES),
  _preconditioner_type (ILU_PRECOND),
  _is_initialized      (false)
{
}



template <typename T>
inline
LinearSolverInterface<T>::~LinearSolverInterface ()
{
  this->clear ();
}



#endif // #ifdef __solver_interface_h__

{'fraction_non_alphanumeric': 0.10326859308384652, 'fraction_numerical': 0.010895310279488394, 'mean_word_length': 3.07774022211492, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2638739', 'n_tokens_mistral': 2633, 'n_tokens_neox': 2439, 'n_words': 849}