LibMeshInit Class Reference

#include <libmesh.h>

List of all members.

Public Member Functions

 LibMeshInit (int &argc, char **&argv, MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD)
 LibMeshInit (int &argc, char **&argv)
 ~LibMeshInit ()


Detailed Description

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. This object replaces the previous libMesh::init()/libMeshclose() methods, which are now deprecated.

Definition at line 57 of file libmesh.h.


Constructor & Destructor Documentation

LibMeshInit::LibMeshInit ( int &  argc,
char **&  argv,
MPI_Comm  COMM_WORLD_IN = MPI_COMM_WORLD 
)

Initialize the library for use, with the command line options provided. This will e.g. call PetscInitialize if PETSC is available. 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.

Definition at line 382 of file libmesh.C.

References libMesh::_init(), EXTERN_C_FOR_PETSC_END::_ofstream, EXTERN_C_FOR_PETSC_END::cerr_buf(), EXTERN_C_FOR_PETSC_END::cout_buf(), libMesh::on_command_line(), and libMesh::processor_id().

00384 {
00385   libMesh::_init(argc, argv, COMM_WORLD_IN);
00386 
00387   // Honor the --redirect-stdout command-line option.
00388   // When this is specified each processor sends
00389   // std::cout/std::cerr messages to
00390   // stdout.processor.####
00391   if (libMesh::on_command_line ("--redirect-stdout"))
00392     {
00393       char filechar[80];
00394       sprintf (filechar, "stdout.processor.%04d",
00395                libMesh::processor_id());
00396       _ofstream.reset (new std::ofstream (filechar));
00397       // Redirect, saving the original streambufs!
00398       cout_buf = std::cout.rdbuf (_ofstream->rdbuf());
00399       cerr_buf = std::cerr.rdbuf (_ofstream->rdbuf());
00400     }
00401 }

LibMeshInit::LibMeshInit ( int &  argc,
char **&  argv 
)

Definition at line 377 of file libmesh.C.

References libMesh::_init().

00378 {
00379   libMesh::_init(argc, argv);
00380 }

LibMeshInit::~LibMeshInit (  ) 

Definition at line 404 of file libmesh.C.

00405 {
00406   libMesh::_close();
00407 }


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

Site Created By: libMesh Developers
Last modified: November 25 2009 03:44:34.

Hosted By:
SourceForge.net Logo