Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_ParallelData.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Stokhos_ConfigDefs.h"
11 #include "Stokhos_ParallelData.hpp"
12 #ifdef HAVE_MPI
13 #include "EpetraExt_MultiMpiComm.h"
14 #else
15 #include "EpetraExt_MultiSerialComm.h"
16 #endif
17 
22  const Teuchos::RCP<const Epetra_Comm>& globalComm,
23  Teuchos::ParameterList& params)
24 {
25  int num_global_stoch_blocks = basis->size();
26 
27  int num_spatial_procs = params.get("Number of Spatial Processors", -1);
28 
29  // Build multi-comm
31  Stokhos::buildMultiComm(*globalComm, num_global_stoch_blocks,
32  num_spatial_procs);
33 
34  // Get stochastic and spatial comm's
37 
38  if (Cijk != Teuchos::null) {
39  // Build Epetra Cijk
40  epetraCijk =
43 
44  // Rebalance graphs
45  bool use_isorropia = params.get("Rebalance Stochastic Graph", false);
46  if (use_isorropia)
47  epetraCijk->rebalance(params.sublist("Isorropia"));
48 
49  // Transform to local indices
50  epetraCijk->transformToLocal();
51  }
52 }
53 
58  const Teuchos::RCP<const EpetraExt::MultiComm>& globalMultiComm_,
59  Teuchos::ParameterList& params) :
60  globalMultiComm(globalMultiComm_)
61 {
62  // Get stochastic and spatial comm's
65 
66  if (Cijk != Teuchos::null) {
67  // Build Epetra Cijk
68  epetraCijk =
71 
72  // Rebalance graphs
73  bool use_isorropia = params.get("Rebalance Stochastic Graph", false);
74  if (use_isorropia)
75  epetraCijk->rebalance(params.sublist("Isorropia"));
76 
77  // Transform to local indices
78  epetraCijk->transformToLocal();
79  }
80 }
81 
84  int num_global_stochastic_blocks,
85  int num_spatial_procs)
86 {
88 
89 #ifdef HAVE_MPI
90  if (num_spatial_procs == -1) {
91  // By default, use all procs for spatial parallelism
92  //MPI_Comm_size(MPI_COMM_WORLD, &num_spatial_procs);
93  num_spatial_procs = globalComm.NumProc();
94  }
95  const Epetra_MpiComm& globalMpiComm =
96  dynamic_cast<const Epetra_MpiComm&>(globalComm);
97  globalMultiComm =
98  Teuchos::rcp(new EpetraExt::MultiMpiComm(globalMpiComm.Comm(),
99  num_spatial_procs,
100  num_global_stochastic_blocks,
102 #else
103  globalMultiComm =
104  Teuchos::rcp(new EpetraExt::MultiSerialComm(num_global_stochastic_blocks));
105 #endif
106 
107  return globalMultiComm;
108 }
109 
112  const Teuchos::RCP<const EpetraExt::MultiComm>& globalMultiComm)
113 {
114  return Teuchos::rcp(&(globalMultiComm->SubDomainComm()), false);
115 }
116 
119  const Teuchos::RCP<const EpetraExt::MultiComm>& globalMultiComm)
120 {
121  return Teuchos::rcp(&(globalMultiComm->TimeDomainComm()), false);
122 }
T & get(ParameterList &l, const std::string &name)
Teuchos::RCP< const Epetra_Comm > getStochasticComm(const Teuchos::RCP< const EpetraExt::MultiComm > &globalMultiComm)
ParallelData(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &basis, const Teuchos::RCP< const Stokhos::Sparse3Tensor< int, double > > &Cijk, const Teuchos::RCP< const Epetra_Comm > &globalComm, Teuchos::ParameterList &params)
Constructor.
Teuchos::RCP< const EpetraExt::MultiComm > globalMultiComm
Multi-comm.
RCP< ParameterList > sublist(const RCP< ParameterList > &paramList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Teuchos::RCP< const EpetraExt::MultiComm > buildMultiComm(const Epetra_Comm &globalComm, int num_global_stochastic_blocks, int num_spatial_procs=-1)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const Epetra_Comm > stoch_comm
Stochastic comm.
Teuchos::RCP< const Epetra_Comm > spatial_comm
Spatial comm.
MPI_Comm Comm() const
virtual int NumProc() const =0
Teuchos::RCP< const Epetra_Comm > getSpatialComm(const Teuchos::RCP< const EpetraExt::MultiComm > &globalMultiComm)
Teuchos::RCP< Stokhos::EpetraSparse3Tensor > epetraCijk
Epetra Cijk.