libMesh::PetscPreconditioner< T > Class Template Reference

#include <petsc_preconditioner.h>

Inheritance diagram for libMesh::PetscPreconditioner< T >:

Public Member Functions

 PetscPreconditioner (const libMesh::Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
 
virtual ~PetscPreconditioner ()
 
virtual void apply (const NumericVector< T > &x, NumericVector< T > &y)
 
virtual void clear ()
 
virtual void init ()
 
PC pc ()
 
bool initialized () const
 
virtual void setup ()
 
void set_matrix (SparseMatrix< Number > &mat)
 
PreconditionerType type () const
 
void set_type (const PreconditionerType pct)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static void set_petsc_preconditioner_type (const PreconditionerType &preconditioner_type, PC &pc)
 
static Preconditioner< T > * build (const libMesh::Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD, const SolverPackage solver_package=libMesh::default_solver_package())
 
static std::string get_info ()
 
static void print_info (std::ostream &out=libMesh::out)
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Protected Types

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts
 

Protected Member Functions

void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Protected Attributes

PC _pc
 
Mat _mat
 
SparseMatrix< T > * _matrix
 
PreconditionerType _preconditioner_type
 
bool _is_initialized
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic
< unsigned int > 
_n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 

Static Private Member Functions

static void set_petsc_subpreconditioner_type (PCType type, PC &pc)
 
static void set_petsc_subpreconditioner_type (const PCType type, PC &pc)
 

Detailed Description

template<typename T>
class libMesh::PetscPreconditioner< T >

This class provides an interface to the suite of preconditioners available from Petsc.

Author
Derek Gaston, 2009

Definition at line 60 of file petsc_preconditioner.h.

Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information. The log is identified by the class name.

Definition at line 113 of file reference_counter.h.

Constructor & Destructor Documentation

template<typename T >
libMesh::PetscPreconditioner< T >::PetscPreconditioner ( const libMesh::Parallel::Communicator &comm  LIBMESH_CAN_DEFAULT_TO_COMMWORLD)
inline

Constructor. Initializes PetscPreconditioner data structures

Definition at line 138 of file petsc_preconditioner.h.

138  :
139  Preconditioner<T>(comm),
140  _pc(PETSC_NULL)
141 {
142 }
template<typename T >
libMesh::PetscPreconditioner< T >::~PetscPreconditioner ( )
inlinevirtual

Destructor.

Definition at line 148 of file petsc_preconditioner.h.

149 {
150  this->clear ();
151 }

Member Function Documentation

template<typename T >
void libMesh::PetscPreconditioner< T >::apply ( const NumericVector< T > &  x,
NumericVector< T > &  y 
)
virtual

Computes the preconditioned vector "y" based on input "x". Usually by solving Py=x to get the action of P^-1 x.

Implements libMesh::Preconditioner< T >.

Definition at line 44 of file petsc_preconditioner.C.

References libMesh::ierr, and libMesh::PetscVector< T >::vec().

45 {
46  PetscVector<T> & x_pvec = libmesh_cast_ref<PetscVector<T>&>(const_cast<NumericVector<T>&>(x));
47  PetscVector<T> & y_pvec = libmesh_cast_ref<PetscVector<T>&>(const_cast<NumericVector<T>&>(y));
48 
49  Vec x_vec = x_pvec.vec();
50  Vec y_vec = y_pvec.vec();
51 
52  int ierr = PCApply(_pc,x_vec,y_vec);
53  LIBMESH_CHKERRABORT(ierr);
54 }
template<typename T>
Preconditioner< T > * libMesh::Preconditioner< T >::build ( const libMesh::Parallel::Communicator &comm  LIBMESH_CAN_DEFAULT_TO_COMMWORLD,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
staticinherited

Builds a Preconditioner using the linear solver package specified by solver_package

Definition at line 38 of file preconditioner.C.

References libMesh::comm, libMesh::EIGEN_SOLVERS, libMesh::err, libMeshEnums::PETSC_SOLVERS, and libMesh::TRILINOS_SOLVERS.

40 {
41  // Build the appropriate solver
42  switch (solver_package)
43  {
44 
45 /*
46 #ifdef LIBMESH_HAVE_LASPACK
47  case LASPACK_SOLVERS:
48  {
49  AutoPtr<Preconditioner<T> > ap(new LaspackPreconditioner<T>(comm));
50  return ap;
51  }
52 #endif
53 */
54 
55 #ifdef LIBMESH_HAVE_PETSC
56  case PETSC_SOLVERS:
57  {
58  return new PetscPreconditioner<T>(comm);
59  }
60 #endif
61 
62 #ifdef LIBMESH_HAVE_TRILINOS
63  case TRILINOS_SOLVERS:
64  return new TrilinosPreconditioner<T>(comm);
65 #endif
66 
67 #ifdef LIBMESH_HAVE_EIGEN
68  case EIGEN_SOLVERS:
69  return new EigenPreconditioner<T>(comm);
70 #endif
71 
72  default:
73  libMesh::err << "ERROR: Unrecognized solver package: "
74  << solver_package
75  << std::endl;
76  libmesh_error();
77  }
78 
79  return NULL;
80 }
template<typename T >
void libMesh::PetscPreconditioner< T >::clear ( )
virtual

Release all memory and clear data structures.

Reimplemented from libMesh::Preconditioner< T >.

Definition at line 104 of file petsc_preconditioner.C.

References libMesh::ierr.

105 {
106  if (_pc)
107  {
108  int ierr = LibMeshPCDestroy(&_pc);
109  LIBMESH_CHKERRABORT(ierr);
110  }
111 }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
a reference to the Parallel::Communicator object used by this mesh.

Definition at line 86 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ParallelMesh::add_elem(), libMesh::ImplicitSystem::add_matrix(), libMesh::ParallelMesh::add_node(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().

87  { return _communicator; }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = true;
103  return;
104 }
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 163 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 176 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
template<typename T >
void libMesh::PetscPreconditioner< T >::init ( )
virtual

Initialize data structures if not done so already.

Reimplemented from libMesh::Preconditioner< T >.

Definition at line 60 of file petsc_preconditioner.C.

References libMesh::libMeshPrivateData::_is_initialized, libMesh::comm, libMesh::err, libMesh::ierr, and libMesh::PetscMatrix< T >::mat().

61 {
62  if(!this->_matrix)
63  {
64  libMesh::err << "ERROR: No matrix set for PetscPreconditioner, but init() called" << std::endl;
65  libmesh_error();
66  }
67 
68  // Clear the preconditioner in case it has been created in the past
69  if (!this->_is_initialized)
70  {
71  // Should probably use PCReset(), but it's not working at the moment so we'll destroy instead
72  if (_pc)
73  {
74  int ierr = LibMeshPCDestroy(&_pc);
75  LIBMESH_CHKERRABORT(ierr);
76  }
77 
78  int ierr = PCCreate(this->comm().get(),&_pc);
79  LIBMESH_CHKERRABORT(ierr);
80 
81  PetscMatrix<T> * pmatrix = libmesh_cast_ptr<PetscMatrix<T>*, SparseMatrix<T> >(this->_matrix);
82 
83  _mat = pmatrix->mat();
84  }
85 
86  int ierr = PCSetOperators(_pc,_mat,_mat,SAME_NONZERO_PATTERN);
87  LIBMESH_CHKERRABORT(ierr);
88 
89  // Set the PCType. Note: this used to be done *before* the call to
90  // PCSetOperators(), and only when !_is_initialized, but
91  // 1.) Some preconditioners (those employing sub-preconditioners,
92  // for example) have to call PCSetUp(), and can only do this after
93  // the operators have been set.
94  // 2.) It should be safe to call set_petsc_preconditioner_type()
95  // multiple times.
97 
98  this->_is_initialized = true;
99 }
template<typename T>
bool libMesh::Preconditioner< T >::initialized ( ) const
inlineinherited
Returns
true if the data structures are initialized, false otherwise.

Definition at line 89 of file preconditioner.h.

89 { return _is_initialized; }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

80  { return _n_objects; }
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
the number of processors in the group.

Definition at line 92 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::UnstructuredMesh::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

93  { return libmesh_cast_int<processor_id_type>(_communicator.size()); }
template<typename T >
PC libMesh::PetscPreconditioner< T >::pc ( )
inline

Returns the actual Petsc PC struct. Useful for more advanced purposes

Definition at line 95 of file petsc_preconditioner.h.

References libMesh::PetscPreconditioner< T >::_pc.

95 { return _pc; }
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

89 {
91 }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
the rank of this processor in the group.

Definition at line 98 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::DofMap::build_sparsity(), libMesh::ParallelMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO_Helper::create(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements_discontinuous(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
template<typename T >
void libMesh::Preconditioner< T >::set_matrix ( SparseMatrix< Number > &  mat)
inherited

Sets the matrix P to be preconditioned.

Definition at line 176 of file preconditioner.h.

References libMesh::libMeshPrivateData::_is_initialized.

177 {
178  //If the matrix is changing then we (probably) need to reinitialize.
179  _is_initialized = false;
180  _matrix = &mat;
181 }
template<typename T >
void libMesh::PetscPreconditioner< T >::set_petsc_preconditioner_type ( const PreconditionerType &  preconditioner_type,
PC &  pc 
)
static

Tells PETSC to use the user-specified preconditioner

Definition at line 117 of file petsc_preconditioner.C.

References libMeshEnums::AMG_PRECOND, libMeshEnums::ASM_PRECOND, libMeshEnums::BLOCK_JACOBI_PRECOND, libMesh::CHKERRABORT(), libMeshEnums::CHOLESKY_PRECOND, libMesh::comm, libMesh::communicator, libMeshEnums::EISENSTAT_PRECOND, libMesh::err, libMeshEnums::ICC_PRECOND, libMeshEnums::IDENTITY_PRECOND, libMesh::ierr, libMeshEnums::ILU_PRECOND, libMeshEnums::JACOBI_PRECOND, libMeshEnums::LU_PRECOND, libMesh::PetscObjectGetComm(), libMeshEnums::SHELL_PRECOND, libMesh::Parallel::Communicator::size(), libMeshEnums::SOR_PRECOND, and libMeshEnums::USER_PRECOND.

Referenced by libMesh::PetscLinearSolver< T >::init().

118 {
119  int ierr = 0;
120 
121  // get the communicator from the PETSc object
123  PetscObjectGetComm((PetscObject)pc, &comm);
124  Parallel::Communicator communicator(comm);
125 
126  switch (preconditioner_type)
127  {
128  case IDENTITY_PRECOND:
129  ierr = PCSetType (pc, (char*) PCNONE); CHKERRABORT(comm,ierr); break;
130 
131  case CHOLESKY_PRECOND:
132  ierr = PCSetType (pc, (char*) PCCHOLESKY); CHKERRABORT(comm,ierr); break;
133 
134  case ICC_PRECOND:
135  ierr = PCSetType (pc, (char*) PCICC); CHKERRABORT(comm,ierr); break;
136 
137  case ILU_PRECOND:
138  {
139  // In serial, just set the ILU preconditioner type
140  if (communicator.size())
141  {
142  ierr = PCSetType (pc, (char*) PCILU);
143  CHKERRABORT(comm,ierr);
144  }
145  else
146  {
147  // But PETSc has no truly parallel ILU, instead you have to set
148  // an actual parallel preconditioner (e.g. block Jacobi) and then
149  // assign ILU sub-preconditioners.
150  ierr = PCSetType (pc, (char*) PCBJACOBI);
151  CHKERRABORT(comm,ierr);
152 
153  // Set ILU as the sub preconditioner type
155  }
156  break;
157  }
158 
159  case LU_PRECOND:
160  {
161  // In serial, just set the LU preconditioner type
162  if (communicator.size())
163  {
164  ierr = PCSetType (pc, (char*) PCLU);
165  CHKERRABORT(comm,ierr);
166  }
167  else
168  {
169  // But PETSc has no truly parallel LU, instead you have to set
170  // an actual parallel preconditioner (e.g. block Jacobi) and then
171  // assign LU sub-preconditioners.
172  ierr = PCSetType (pc, (char*) PCBJACOBI);
173  CHKERRABORT(comm,ierr);
174 
175  // Set ILU as the sub preconditioner type
177  }
178  break;
179  }
180 
181  case ASM_PRECOND:
182  {
183  // In parallel, I think ASM uses ILU by default as the sub-preconditioner...
184  // I tried setting a different sub-preconditioner here, but apparently the matrix
185  // is not in the correct state (at this point) to call PCSetUp().
186  ierr = PCSetType (pc, (char*) PCASM);
187  CHKERRABORT(comm,ierr);
188  break;
189  }
190 
191  case JACOBI_PRECOND:
192  ierr = PCSetType (pc, (char*) PCJACOBI); CHKERRABORT(comm,ierr); break;
193 
195  ierr = PCSetType (pc, (char*) PCBJACOBI); CHKERRABORT(comm,ierr); break;
196 
197  case SOR_PRECOND:
198  ierr = PCSetType (pc, (char*) PCSOR); CHKERRABORT(comm,ierr); break;
199 
200  case EISENSTAT_PRECOND:
201  ierr = PCSetType (pc, (char*) PCEISENSTAT); CHKERRABORT(comm,ierr); break;
202 
203  case AMG_PRECOND:
204  ierr = PCSetType (pc, (char*) PCHYPRE); CHKERRABORT(comm,ierr); break;
205 
206 #if !(PETSC_VERSION_LESS_THAN(2,1,2))
207  // Only available for PETSC >= 2.1.2
208  case USER_PRECOND:
209  ierr = PCSetType (pc, (char*) PCMAT); CHKERRABORT(comm,ierr); break;
210 #endif
211 
212  case SHELL_PRECOND:
213  ierr = PCSetType (pc, (char*) PCSHELL); CHKERRABORT(comm,ierr); break;
214 
215  default:
216  libMesh::err << "ERROR: Unsupported PETSC Preconditioner: "
217  << preconditioner_type << std::endl
218  << "Continuing with PETSC defaults" << std::endl;
219  }
220 
221  // Set additional options if we are doing AMG and
222  // HYPRE is available
223 #ifdef LIBMESH_HAVE_PETSC_HYPRE
224  if (preconditioner_type == AMG_PRECOND)
225  {
226  ierr = PCHYPRESetType(pc, "boomeramg");
227  CHKERRABORT(comm,ierr);
228  }
229 #endif
230 
231  // Let the commandline override stuff
232  // FIXME: Unless we are doing AMG???
233  if (preconditioner_type != AMG_PRECOND)
234  {
235  ierr = PCSetFromOptions(pc);
236  CHKERRABORT(comm,ierr);
237  }
238 }
template<typename T >
static void libMesh::PetscPreconditioner< T >::set_petsc_subpreconditioner_type ( PCType  type,
PC &  pc 
)
staticprivate

Some PETSc preconditioners (ILU, LU) don't work in parallel. This function is called from set_petsc_preconditioner_type() to set additional options for those so-called sub-preconditioners. This method ends up being static so that it can be called from set_petsc_preconditioner_type(). Not sure why set_petsc_preconditioner_type() needs to be static though...

template<typename T >
static void libMesh::PetscPreconditioner< T >::set_petsc_subpreconditioner_type ( const PCType  type,
PC &  pc 
)
staticprivate
template<typename T >
void libMesh::Preconditioner< T >::set_type ( const PreconditionerType  pct)
inherited

Sets the type of preconditioner to use.

Definition at line 185 of file preconditioner.h.

References libMesh::libMeshPrivateData::_is_initialized.

186 {
187  //If the preconditioner type changes we (probably) need to reinitialize.
188  _is_initialized = false;
189  _preconditioner_type = pct;
190 }
template<typename T>
virtual void libMesh::Preconditioner< T >::setup ( )
inlinevirtualinherited

This is called every time the "operator might have changed".

This is essentially where you need to fill in your preconditioning matrix.

Definition at line 114 of file preconditioner.h.

114 {}
template<typename T>
PreconditionerType libMesh::Preconditioner< T >::type ( ) const
inlineinherited

Returns the type of preconditioner to use.

Definition at line 124 of file preconditioner.h.

125  { return _preconditioner_type; }

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 137 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

template<typename T>
bool libMesh::Preconditioner< T >::_is_initialized
protectedinherited

Flag indicating if the data structures have been initialized.

Definition at line 148 of file preconditioner.h.

Referenced by libMesh::Preconditioner< Number >::initialized().

template<typename T >
Mat libMesh::PetscPreconditioner< T >::_mat
protected

Petsc Matrix that's been pulled out of the _matrix object. This happens during init...

Definition at line 113 of file petsc_preconditioner.h.

template<typename T>
SparseMatrix<T>* libMesh::Preconditioner< T >::_matrix
protectedinherited

The matrix P... ie the matrix to be preconditioned. This is often the actual system matrix of a linear sytem.

Definition at line 138 of file preconditioner.h.

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

template<typename T >
PC libMesh::PetscPreconditioner< T >::_pc
protected

Preconditioner context

Definition at line 107 of file petsc_preconditioner.h.

Referenced by libMesh::PetscPreconditioner< T >::pc().

template<typename T>
PreconditionerType libMesh::Preconditioner< T >::_preconditioner_type
protectedinherited

Enum statitng with type of preconditioner to use.

Definition at line 143 of file preconditioner.h.

Referenced by libMesh::Preconditioner< Number >::type().


The documentation for this class was generated from the following files:

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:01 UTC

Hosted By:
SourceForge.net Logo