Galeri Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Map.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Galeri: Finite Element and Matrix Generation Package
4 //
5 // Copyright 2006 ETHZ/NTESS and the Galeri contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Galeri_Maps.h"
11 #ifdef HAVE_MPI
12 #include "Epetra_MpiComm.h"
13 #include "mpi.h"
14 #else
15 #include "Epetra_SerialComm.h"
16 #endif
18 
19 using namespace Galeri;
20 
21 int main(int argc, char* argv[])
22 {
23 #ifdef HAVE_MPI
24  MPI_Init(&argc, &argv);
25  Epetra_MpiComm Comm(MPI_COMM_WORLD);
26 #else
27  Epetra_SerialComm Comm;
28 #endif
29 
30  // Creates an Epetra_Map corresponding to a 2D Cartesian grid
31  // on the unit square. For parallel runs, the nodes are divided into
32  // strips, so that the total number of subdomains is Comm.NumProc() x 1.
33 
34  // Pointer to the object to be created
35  Epetra_Map* Map = 0;
36  // Type of the object
37  std::string MapType = "Cartesian2D";
38  // Container for parameters
39  Teuchos::ParameterList GaleriList;
40  GaleriList.set("nx", 2 * Comm.NumProc());
41  GaleriList.set("ny", 2);
42  GaleriList.set("mx", Comm.NumProc());
43  GaleriList.set("my", 1);
44 
45  try
46  {
47  // Creation of the map
48 #ifndef GALERI_TEST_USE_LONGLONG_GO
49  Map = CreateMap("Cartesian2D", Comm, GaleriList);
50 #else
51  Map = CreateMap64("Cartesian2D", Comm, GaleriList);
52 #endif
53  // print out the map
54  cout << *Map;
55 
56  // To created object must be free'd using delete
57  delete Map;
58  }
59  catch (Exception& rhs)
60  {
61  if (Comm.MyPID() == 0)
62  {
63  cerr << "Caught exception: ";
64  rhs.Print();
65  }
66  }
67 
68 #ifdef HAVE_MPI
69  MPI_Finalize();
70 #endif
71 
72  return(EXIT_SUCCESS);
73 }
virtual void Print(std::ostream &os) const
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
int MyPID() const
int NumProc() const
int main(int argc, char *argv[])
Definition: CrsMatrix.cpp:29