Galeri  Development
 All Classes Files Functions Variables Pages
Creating an Epetra_Map

This file first gives an example of how to create an Epetra_Map object, then it details the supported maps and gives a list of required parameters.

A simple code that creates an Epetra_Map is as follows. First, we need to include Galeri_Maps.h, and the required Epetra and Teuchos header files.

#include "Galeri_Maps.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
#include "Epetra_Map.h"
#include "Teuchos_ParameterList.hpp"

Then, the basic instructions to create a linear map (that is, a map whose elements are linearly subdivided among the available processes) are:

Epetra_Map* Map = 0; // the map to be created
Teuchos::ParameterList List; 
List.set("n", 100); // global number of elements in the map
string MapType = "Linear";

Map = Galeri.CreateMap(MapType, Comm, List);

where Comm is an Epetra_Comm object. The created Epetra_Map must be free'd by the user using delete.

Let us see know how to create a more complex map: a Cartesian 2D map. This map contains nx $\times$ ny nodes, and corresponds to a Cartesian grid in the (X,Y) plane. The nodes are ordered along the X-axis first. If more than one processor is used, then the grid is partitioned into mx $\times$ my subdomains. Note that mx $\times$ my must be the total number of processors in the communicator.

Epetra_Map* Map = 0; // the map to be created
Teuchos::ParameterList List;
List.set("nx", 10); // 10 nodes along the X-axis
List.set("ny", 10); // 10 nodes along the Y-axis
List.set("mx", 2);  // 2 subdomains along the X-axis
List.set("my", 2);  // 2 subdomains along the Y-axis
string MapType = "Cartesian2D";

Map = Galeri.CreateMap(MapType, Comm, List);


The complete list of choices for MapType are: