1 #ifndef FIELD_DECOMPOSITION_HPP
2 #define FIELD_DECOMPOSITION_HPP
11 template<
class Device>
58 if(n_phi_domains==1) n_ghost_planes = 0;
66 mpi =
MyMPI(comm, n_phi_domains);
67 printf(
"\nrank %d mpi.my_rank=%d",
SML_COMM_RANK, mpi.my_rank);
76 exit_XGC(
"\nError in field_decomposition: n_ranks must be divisible by n_phi_domains");
80 if(nplanes_per_phi_domain*n_phi_domains != nplanes)
81 exit_XGC(
"\nError in field_decomposition: n_phi_domains must divide evenly into nplanes");
84 exit_XGC(
"\nError in field_decomposition: total XGC ranks must be divisible by field_decomp_param n_ranks");
93 int first_owned_node_r = nodes_per_pol_domain*i_pol;
94 int n_owned_nodes_r = (i_pol==n_pol_domains-1 ? (nnodes - first_owned_node_r) : nodes_per_pol_domain);
96 int first_owned_plane_r = nodes_per_phi_domain*i_phi;
97 int n_owned_planes_r = (i_phi==n_phi_domains-1 ? (nplanes - first_owned_plane_r) : nodes_per_phi_domain);
100 all_first_node(i) = std::max(first_owned_node_r - n_ghost_vertices, 0);
101 all_last_node(i) = std::min(first_owned_node_r + n_owned_nodes_r - 1 + n_ghost_vertices, nnodes-1);
104 if((n_owned_planes_r + 2*n_ghost_planes) >= nplanes){
111 printf(
"\nall_first_plane(%d) = (first_owned_plane_r - n_ghost_planes)modnplanes = (%d - %d)mod %d = %d \n", i, first_owned_plane_r, n_ghost_planes, nplanes,
all_first_plane(i));
136 KOKKOS_INLINE_FUNCTION
int find_domain_owner(
int global_plane_index,
int nplanes_total,
int global_node_index,
int nnodes_total)
const{
139 int intpl_pid = global_plane_index/planes_per_phi_domain;
143 int plane_pid = global_node_index/n_vertices_per_pol_domain;
int n_ranks
Number of ranks the field will be divided between.
Definition: field_decomposition.hpp:21
int n_phi_domains
Number of domains in the phi direction.
Definition: field_decomposition.hpp:22
int first_plane
First plane belonging to this rank, including ghost planes.
Definition: field_decomposition.hpp:35
MPI_Comm SML_COMM_WORLD
Definition: my_mpi.cpp:4
View< int *, CLayout, HostType > all_last_node
Last node of each rank.
Definition: field_decomposition.hpp:42
int first_owned_plane
First plane belonging to this rank, NOT including ghost planes.
Definition: field_decomposition.hpp:29
int n_ghost_planes
Number of ghost planes on each side of domain.
Definition: field_decomposition.hpp:24
int nplanes_owned
Number of planes belonging to this rank, NOT including ghost planes.
Definition: field_decomposition.hpp:30
T get(const string ¶m, const T default_val, int val_ind=0)
Definition: NamelistReader.hpp:373
FieldDecomposition()
Definition: field_decomposition.hpp:46
KOKKOS_INLINE_FUNCTION int find_domain_owner(int global_plane_index, int nplanes_total, int global_node_index, int nnodes_total) const
Definition: field_decomposition.hpp:136
Definition: NamelistReader.hpp:193
View< int *, CLayout, HostType > map_from_global_intpl
Rank in this communicator for each rank global intpl.
Definition: field_decomposition.hpp:40
int n_ghost_vertices
Number of ghost vertices on each side of domain.
Definition: field_decomposition.hpp:25
FieldDecomposition(NLReader::NamelistReader &nlr, int nplanes, int nnodes)
Definition: field_decomposition.hpp:49
KOKKOS_INLINE_FUNCTION unsigned positive_modulo(int value, unsigned m)
Definition: globals.hpp:208
Definition: my_mpi.hpp:19
void use_namelist(const string &namelist)
Definition: NamelistReader.hpp:355
int all_n_nodes(int local_pid) const
Definition: field_decomposition.hpp:149
int n_pol_domains
Number of domains in the poloidal plane.
Definition: field_decomposition.hpp:23
int last_plane
Last plane belonging to this rank, including ghost planes.
Definition: field_decomposition.hpp:36
int SML_COMM_RANK
Definition: my_mpi.cpp:5
Definition: field_decomposition.hpp:12
int n_planes
Number of planes belonging to this rank, including ghost planes.
Definition: field_decomposition.hpp:37
View< int *, CLayout, HostType > all_first_plane
First plane of each rank.
Definition: field_decomposition.hpp:43
int all_n_planes(int local_pid, int nplanes) const
Definition: field_decomposition.hpp:153
void exit_XGC(std::string msg)
Definition: globals.hpp:37
View< int *, CLayout, HostType > all_last_plane
Last plane of each rank.
Definition: field_decomposition.hpp:44
int n_nodes
Number of nodes belonging to this rank, including ghost nodes.
Definition: field_decomposition.hpp:34
int first_owned_node
First mesh node belonging to this rank, NOT including ghost nodes.
Definition: field_decomposition.hpp:27
View< int *, CLayout, HostType > all_first_node
First node of each rank.
Definition: field_decomposition.hpp:41
int first_node
First mesh node belonging to this rank, including ghost nodes.
Definition: field_decomposition.hpp:32
int last_node
Last node belonging to this rank, including ghost nodes.
Definition: field_decomposition.hpp:33
int nnodes_owned
Number of nodes belonging to this rank, NOT including ghost nodes.
Definition: field_decomposition.hpp:28