Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
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 )
00041     {
00042         crystalData = new gs_data::crystal_data( procComm );
00043     }
00044 #endif
00045 
00046     return crystalData;
00047 }
00048 
00049 ProcConfig::~ProcConfig()
00050 {
00051     if( crystalData )
00052     {
00053 #ifdef MOAB_HAVE_MPI
00054         crystalData->reset();
00055 #endif
00056         delete crystalData;
00057         crystalData = 0;
00058     }
00059 }
00060 
00061 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines