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
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
my
subdomains. Note that mx
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:
Linear:
subdivides linearly the elements of the map among the available processes. This is the simplex map.Cartesian2D:
this map contains nx
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
my
subdomains. Note that mx
my
must be the total number of processors in the communicator.Cartesian3D:
for maps corresponding to a 3D Cartesian grid. The number of nodes along the Z-axis is specified by parameter nz
, and the number of processes along the Z-axis by parameter mz
;Interlaced:
Elements are subdivided so that element i
is assigned to process i%NumProcs
Random:
assigns each node to a random processor.