Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_InterlacedMapUnitTest.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 <Teuchos_ConfigDefs.hpp>
12 #include <Teuchos_TimeMonitor.hpp>
13 #include <Teuchos_RCP.hpp>
14 
16 
17 // Stokhos Stochastic Galerkin
18 #include "Stokhos_Epetra.hpp"
20 
21 #ifdef HAVE_MPI
22 #include "Epetra_MpiComm.h"
23 #else
24 #include "Epetra_SerialComm.h"
25 #endif
26 #include "EpetraExt_BlockVector.h"
27 
28 TEUCHOS_UNIT_TEST(map_test, uniform_buildInterlacedMap)
29 {
30 #ifdef HAVE_MPI
32 #else
34 #endif
35 
36  int rank = comm->MyPID();
37 
38  int stochaUnks = 5;
39  Epetra_LocalMap stocha_map(stochaUnks,0,*comm);
40  Epetra_Map determ_map(-1,(rank+1)*10,0,*comm);
41 
43 
44  TEST_EQUALITY(obj_ut->NumMyElements(),determ_map.NumMyElements()*stochaUnks);
45  TEST_EQUALITY(obj_ut->NumGlobalElements(),determ_map.NumGlobalElements()*stochaUnks);
46 
47  bool result = true;
48  for(int s=0;s<stocha_map.NumMyElements();s++) {
49  for(int d=0;d<determ_map.NumMyElements();d++) {
50  result &= (obj_ut->GID(stochaUnks*d+s)==(stochaUnks*determ_map.GID(d)+s));
51  }
52  }
53  TEST_ASSERT(result);
54 }
55 
56 TEUCHOS_UNIT_TEST(map_test, copyToInterlace)
57 {
58 #ifdef HAVE_MPI
60 #else
62 #endif
63 
64  //int rank = comm->MyPID();
65  int numProc = comm->NumProc();
66 
67  int num_KL = 1;
68  int porder = 1;
69  bool full_expansion = false;
70 
73  Teuchos::RCP<Stokhos::ParallelData> sg_parallel_data;
75  {
76  if(full_expansion)
77  Cijk = basis->computeTripleProductTensor();
78  else
79  Cijk = basis->computeLinearTripleProductTensor();
80 
81  Teuchos::ParameterList parallelParams;
82  parallelParams.set("Number of Spatial Processors", numProc);
83  sg_parallel_data = Teuchos::rcp(new Stokhos::ParallelData(basis, Cijk, comm,
84  parallelParams));
85 
87  Cijk));
88  }
89  Teuchos::RCP<const EpetraExt::MultiComm> sg_comm = sg_parallel_data->getMultiComm();
90 
92  Teuchos::rcp(new Stokhos::EpetraSparse3Tensor(basis,Cijk,sg_comm));
93 
94  Epetra_Map determRowMap(-1,3,0,*comm);
95  Teuchos::RCP<Epetra_Map> determRowMap_rcp = Teuchos::rcpFromRef(determRowMap);
97  Teuchos::rcp(new Stokhos::EpetraVectorOrthogPoly(basis,epetraCijk->getStochasticRowMap(),determRowMap_rcp,epetraCijk->getMultiComm()));
98  for(int b=0;b<porder+1;b++)
99  x_vec_blocks->getBlockVector()->GetBlock(b)->Print(std::cout);
100 // for(int i=0;i<3;i++)
101 // (*x_vec_blocks->getBlockVector()->GetBlock(b))[i] = 1.0+i + (b+1)*3;
102  x_vec_blocks->getBlockVector()->Print(std::cout);
103 }
int NumGlobalElements() const
#define TEST_ASSERT(v1)
static Teuchos::RCP< Epetra_Map > buildInterlaceMap(const Epetra_BlockMap &determ_map, const Epetra_BlockMap &stocha_map)
Teuchos::RCP< const EpetraExt::MultiComm > getMultiComm() const
Get global comm.
Teuchos::RCP< EpetraExt::BlockVector > getBlockVector()
Get block vector.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual int MyPID() const =0
int NumMyElements() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const Epetra_BlockMap > getStochasticRowMap() const
Get stochastic row map.
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
int GID(int LID) const
Teuchos::RCP< const EpetraExt::MultiComm > getMultiComm() const
Get global comm.
Teuchos::RCP< const Stokhos::CompletePolynomialBasis< int, double > > buildBasis(int num_KL, int porder)
virtual int NumProc() const =0
#define TEST_EQUALITY(v1, v2)
TEUCHOS_UNIT_TEST(tAdaptivityManager, test_interface)