libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
Public 成员函数 | Private 属性 | 所有成员列表
libMesh::LibMeshInit类 参考

The LibMeshInit class, when constructed, initializes the dependent libraries (e.g. 更多...

#include <libmesh.h>

Public 成员函数

 LibMeshInit (int argc, const char *const *argv, MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD, int n_threads=-1)
 Initialize the library for use, with the command line options provided. 更多...
 
 LibMeshInit (int argc, const char *const *argv, int COMM_WORLD_IN=0, int n_threads=-1)
 
virtual ~LibMeshInit ()
 Destructor. 更多...
 
const Parallel::Communicator & comm () const
 Returns a Communicator created from the TIMPIInit object we hold, which will be a compatibility shim if MPI is not enabled. 更多...
 
Parallel::Communicator & comm ()
 

Private 属性

TIMPI::TIMPIInit * _timpi_init
 
Parallel::Communicator * _comm
 
vtkMPIController * _vtk_mpi_controller
 

详细描述

The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.

MPI or PETSC) and does the command line parsing needed by libMesh. The LibMeshInit destructor closes those libraries properly.

For most users, a single LibMeshInit object should be created at the start of your main() function.

All libMesh functionality should be used only when a LibMeshInit object exists. Dependent library functionality, likewise, except in codes which manually initialize those libraries before LibMeshInit creation and finalize them after LibMeshInit destruction.

Since "it is best not to perform much more than a return rc after calling MPI_Finalize", applications which want to do anything after LibMeshInit destruction should manage MPI initialization and finalization manually.

在文件 libmesh.h80 行定义.

构造及析构函数说明

libMesh::LibMeshInit::LibMeshInit ( int  argc,
const char *const *  argv,
MPI_Comm  COMM_WORLD_IN = MPI_COMM_WORLD,
int  n_threads = -1 
)

Initialize the library for use, with the command line options provided.

This will e.g. call MPI_Init if MPI is available and enabled and has not already been initialized; similar initialization may take place for Petsc, Slepc, multithreading support, libMesh Singleton objects, the libMesh::out/err IO streams, and any libMesh handlers for floating-point exceptions, signals, and/or C++ aborts.

You must create a LibMeshInit object before using any of the library functionality. This method may take an optional parameter to use a user-specified MPI communicator.

libMesh::LibMeshInit::LibMeshInit ( int  argc,
const char *const *  argv,
int  COMM_WORLD_IN = 0,
int  n_threads = -1 
)
libMesh::LibMeshInit::~LibMeshInit ( )
virtual

Destructor.

Cleans up libMesh Singleton objects, and thread manager if threading is in use. Prints reference count and performance logging information if enabled. Restores pre-LibMeshInit terminate handler and floating-point-exception handling. Finalizes any of Slepc, Petsc, and MPI which were initialized by LibMeshInit.

在文件 libmesh.C668 行定义.

参考 _comm, libMesh::libMeshPrivateData::_is_initialized, _timpi_init, _vtk_mpi_controller, libMesh::Singleton::cleanup(), libMesh::closed(), comm(), libMesh::enableFPE(), libMesh::err, libMesh::ReferenceCounter::n_objects(), libMesh::old_terminate_handler, libMesh::on_command_line(), libMesh::out, libMesh::perflog , 以及 libMesh::ReferenceCounter::print_info().

669 {
670  // Every processor had better be ready to exit at the same time.
671  // This would be a libmesh_parallel_only() function, except that
672  // libmesh_parallel_only() uses libmesh_assert() which throws an
673  // exception() which causes compilers to scream about exceptions
674  // inside destructors.
675 
676  // Even if we're not doing parallel_only debugging, we don't want
677  // one processor to try to exit until all others are done working.
678  this->comm().barrier();
679 
680  // We can't delete, finalize, etc. more than once without
681  // reinitializing in between
682  libmesh_exceptionless_assert(!libMesh::closed());
683 
684  // Delete reference counted singleton(s)
686 
687  // Clear the thread task manager we started
688  task_scheduler.reset();
689 
690  // Force the \p ReferenceCounter to print
691  // its reference count information. This allows
692  // us to find memory leaks. By default the
693  // \p ReferenceCounter only prints its information
694  // when the last created object has been destroyed.
695  // That does no good if we are leaking memory!
697 
698 
699  // Print an informative message if we detect a memory leak
700  if (ReferenceCounter::n_objects() != 0)
701  {
702  libMesh::err << "Memory leak detected!"
703  << std::endl;
704 
705 #if !defined(LIBMESH_ENABLE_REFERENCE_COUNTING) || defined(NDEBUG)
706 
707  libMesh::err << "Compile in DEBUG mode with --enable-reference-counting"
708  << std::endl
709  << "for more information"
710  << std::endl;
711 #endif
712 
713  }
714 
715  // print the perflog to individual processor's file.
716  libMesh::perflog.print_log();
717 
718  // Now clear the logging object, we don't want it to print
719  // a second time during the PerfLog destructor.
720  libMesh::perflog.clear();
721 
722  // Reconnect the output streams
723  // (don't do this, or we will get messages from objects
724  // that go out of scope after the following return)
725  //std::cout.rdbuf(std::cerr.rdbuf());
726 
727 
728  // Set the initialized() flag to false
730 
731  if (libMesh::on_command_line ("--redirect-stdout") ||
732  libMesh::on_command_line ("--redirect-output"))
733  {
734  // If stdout/stderr were redirected to files, reset them now.
735  libMesh::out.rdbuf (out_buf);
736  libMesh::err.rdbuf (err_buf);
737  }
738 
739  // If we built our own output streams, we want to clean them up.
740  if (libMesh::on_command_line ("--separate-libmeshout"))
741  {
742  delete libMesh::out.get();
743  delete libMesh::err.get();
744 
745  libMesh::out.reset(std::cout);
746  libMesh::err.reset(std::cerr);
747  }
748 
749 #ifdef LIBMESH_ENABLE_EXCEPTIONS
750  // Reset the old terminate handler; maybe the user code wants to
751  // keep doing C++ stuff after closing libMesh stuff.
752  std::set_terminate(old_terminate_handler);
753 #endif
754 
755 
756  if (libMesh::on_command_line("--enable-fpe"))
757  libMesh::enableFPE(false);
758 
759 #if defined(LIBMESH_HAVE_PETSC)
760  // Allow the user to bypass PETSc finalization
761  if (!libMesh::on_command_line ("--disable-petsc")
762 #if defined(LIBMESH_HAVE_MPI)
763  && !libMesh::on_command_line ("--disable-mpi")
764 #endif
765  )
766  {
767 # if defined(LIBMESH_HAVE_SLEPC)
768  if (libmesh_initialized_slepc)
769  SlepcFinalize();
770 # else
771  if (libmesh_initialized_petsc)
772  PetscFinalize();
773 # endif
774  }
775 #endif
776 
777 #if defined(LIBMESH_HAVE_MPI) && defined(LIBMESH_HAVE_VTK)
778  _vtk_mpi_controller->Finalize(/*finalized_externally=*/1);
779  _vtk_mpi_controller->Delete();
780 #endif
781 
782  delete this->_comm;
783 
784 #if defined(LIBMESH_HAVE_MPI)
785  // Allow the user to bypass MPI finalization
786  if (!libMesh::on_command_line ("--disable-mpi"))
787  {
788  delete this->_timpi_init;
789  }
790 #else
791  delete this->_timpi_init;
792 #endif
793 }
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:268
static unsigned int n_objects()
Prints the number of outstanding (created, but not yet destroyed) objects.
static void print_info(std::ostream &out_stream=libMesh::out)
Prints the reference information, by default to libMesh::out.
vtkMPIController * _vtk_mpi_controller
Definition: libmesh.h:138
bool _is_initialized
Flag that tells if init() has been called.
Definition: libmesh.C:242
std::terminate_handler old_terminate_handler
Definition: libmesh.C:275
OStreamProxy out
const Parallel::Communicator & comm() const
Returns a Communicator created from the TIMPIInit object we hold, which will be a compatibility shim ...
Definition: libmesh.h:118
TIMPI::TIMPIInit * _timpi_init
Definition: libmesh.h:125
void enableFPE(bool on)
Toggle floating point exceptions – courtesy of Cody Permann &amp; MOOSE team.
Definition: libmesh.C:800
OStreamProxy err
PerfLog perflog
A PerfLog object to log performance.
static void cleanup()
Cleanup function.
bool on_command_line(std::string arg)
Definition: libmesh.C:872
Parallel::Communicator * _comm
Definition: libmesh.h:132

成员函数说明

const Parallel::Communicator& libMesh::LibMeshInit::comm ( ) const
inline

Returns a Communicator created from the TIMPIInit object we hold, which will be a compatibility shim if MPI is not enabled.

在文件 libmesh.h118 行定义.

参考 _comm.

参考自 ~LibMeshInit().

118 { return *_comm; }
Parallel::Communicator * _comm
Definition: libmesh.h:132
Parallel::Communicator& libMesh::LibMeshInit::comm ( )
inline

在文件 libmesh.h120 行定义.

参考 _comm.

120 { return *_comm; }
Parallel::Communicator * _comm
Definition: libmesh.h:132

类成员变量说明

Parallel::Communicator* libMesh::LibMeshInit::_comm
private

在文件 libmesh.h132 行定义.

参考自 comm() , 以及 ~LibMeshInit().

TIMPI::TIMPIInit* libMesh::LibMeshInit::_timpi_init
private

在文件 libmesh.h125 行定义.

参考自 ~LibMeshInit().

vtkMPIController* libMesh::LibMeshInit::_vtk_mpi_controller
private

在文件 libmesh.h138 行定义.

参考自 ~LibMeshInit().


该类的文档由以下文件生成: