MOAB: Mesh Oriented datABase  (version 5.2.1)
ProcConfig.cpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #include "moab/ProcConfig.hpp"
00017 #include "moab/gs.hpp"
00018 
00019 namespace moab
00020 {
00021 
00022 //! Constructor
00023 ProcConfig::ProcConfig( MPI_Comm proc_comm1 ) : procComm( proc_comm1 ), crystalData( 0 )
00024 {
00025 #ifdef MOAB_HAVE_MPI
00026     int rank, size;
00027     MPI_Comm_rank( procComm, &rank );
00028     procRank = (unsigned int)rank;
00029     MPI_Comm_size( procComm, &size );
00030     procSize = (unsigned int)size;
00031 #else
00032     procRank = 0;
00033     procSize = 1;
00034 #endif
00035 }
00036 
00037 gs_data::crystal_data* ProcConfig::crystal_router( bool construct_if_missing )
00038 {
00039 #ifdef MOAB_HAVE_MPI
00040     if( !crystalData && construct_if_missing ) { crystalData = new gs_data::crystal_data( procComm ); }
00041 #endif
00042 
00043     return crystalData;
00044 }
00045 
00046 ProcConfig::~ProcConfig()
00047 {
00048     if( crystalData )
00049     {
00050 #ifdef MOAB_HAVE_MPI
00051         crystalData->reset();
00052 #endif
00053         delete crystalData;
00054         crystalData = 0;
00055     }
00056 }
00057 
00058 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines