OSHUN  beta
Arbitrary Order Spherical-Harmonic 1D-3P Vlasov-Fokker-Planck-Maxwell code
Parallel_Environment_1D Class Reference

#include <parallel.h>

Collaboration diagram for Parallel_Environment_1D:

Public Member Functions

 Parallel_Environment_1D ()
 
 ~Parallel_Environment_1D ()
 
int RANK () const
 
int NODES () const
 
int BNDX () const
 
void Neighbor_ImplicitE_Communications (State1D &Y)
 
void Neighbor_Communications (State1D &Y)
 

Private Member Functions

bool error_check ()
 

Private Attributes

int rank
 
int Nnodes
 
int bndX
 
Node_ImplicitE_Communications Bfield_Data
 
Node_Communications X_Data
 

Detailed Description

Definition at line 130 of file parallel.h.

Constructor & Destructor Documentation

◆ Parallel_Environment_1D()

Parallel_Environment_1D::Parallel_Environment_1D ( )

Definition at line 1023 of file parallel.cpp.

References Input::Input_List::BoundaryCells, error_check(), Input::Input_List::globdx, Input::List(), Nnodes, Input::Input_List::NxLocal, Input::Input_List::NxLocalnobnd, rank, Input::Input_List::xmaxLocal, Input::Input_List::xminGlobal, and Input::Input_List::xminLocal.

1023  :
1024 //--------------------------------------------------------------
1025 // Constructor, domain decomposition
1026 //--------------------------------------------------------------
1027  bndX(Input::List().bndX), // Type of boundary
1028  Nnodes(Input::List().NnodesX) // Number of nodes in X-direction
1029 {
1030  // Determination of the rank and size of the run
1031  MPI_Comm_size(MPI_COMM_WORLD, &Nnodes);
1032  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
1033 
1034  if (error_check()) {MPI_Finalize(); exit(1);}
1035 
1036  // Determination of the local computational domain (i.e. the x-axis and the y-axis)
1037 
1038  for(size_t i(0); i < Input::List().xminLocal.size(); ++i) {
1039 
1044  + (Input::List().NxLocal[i]) * Input::List().globdx[i];
1045  }
1046 
1047  // Restart files will be generated when output_step % restart_step == 0
1048 // if ( ( (Input::List().n_outsteps + 1) > Input::List().n_restarts ) &&
1049 // (Input::List().n_restarts > 0) ) {
1050 // restart_step = Input::List().n_outsteps / Input::List().n_restarts ;
1051 // }
1052 // else restart_step = -1;
1053 // if ( Input::List().restart_time > Input::List().n_restarts ) {
1054 // restart_time = 0;
1055 // }
1056 // else restart_time = Input::List().restart_time;
1057 
1058 }
std::vector< double > xmaxLocal
Definition: input.h:173
std::vector< size_t > NxLocal
Definition: input.h:168
std::vector< double > xminLocal
Definition: input.h:172
std::vector< double > xminGlobal
Definition: input.h:170
std::vector< size_t > NxLocalnobnd
Definition: input.h:167
std::vector< double > globdx
Definition: input.h:174
Input_List & List()
Definition: input.cpp:1585
int BoundaryCells
Definition: input.h:50
Here is the call graph for this function:

◆ ~Parallel_Environment_1D()

Parallel_Environment_1D::~Parallel_Environment_1D ( )

Definition at line 1062 of file parallel.cpp.

1062 { }

Member Function Documentation

◆ BNDX()

int Parallel_Environment_1D::BNDX ( ) const

Definition at line 1094 of file parallel.cpp.

References bndX.

Referenced by Neighbor_Communications(), and Neighbor_ImplicitE_Communications().

1094 {return bndX;}
Here is the caller graph for this function:

◆ error_check()

bool Parallel_Environment_1D::error_check ( )
private

Definition at line 1066 of file parallel.cpp.

References Input::List(), Nnodes, Input::Input_List::NnodesX, and rank.

Referenced by Parallel_Environment_1D().

1066  {
1067 //--------------------------------------------------------------
1068 // Temporary error check
1069 //--------------------------------------------------------------
1070 
1071  // Test the number of cells
1072  if (rank == 0){
1073  if (Input::List().NxLocal[0] < 2*Input::List().BoundaryCells+2){
1074  std::cout << "Not enough cells per processor" << endl;
1075  return true;
1076  }
1077  if ( Nnodes != (Input::List().NnodesX) ) {
1078  std:: cout << "the number of nodes in the input deck is "
1079  << (Input::List().NnodesX) << ", terminating ..." << endl;
1080  return true;
1081  }
1082  }
1083  return false;
1084 }
size_t NnodesX
Definition: input.h:30
Input_List & List()
Definition: input.cpp:1585
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Neighbor_Communications()

void Parallel_Environment_1D::Neighbor_Communications ( State1D Y)

Update node "0" in the x direction

(Send) 0 –> 1

(Receive) 0 <– 1

// Update node "NODES()" in the x direction

(Receive) 0 <– 1

Update node "0" in the x direction

(Send) 0 –> 1

(Receive) 0 <– 1

// Update node "NODES()" in the x direction

Definition at line 1151 of file parallel.cpp.

References BNDX(), Node_Communications::mirror_bound_Xleft(), Node_Communications::mirror_bound_Xright(), NODES(), RANK(), Node_Communications::Recv_from_left_X(), Node_Communications::Recv_from_right_X(), Node_Communications::sameNode_bound_X(), Node_Communications::Send_left_X(), Node_Communications::Send_right_X(), and X_Data.

Referenced by main().

1151  {
1152 //--------------------------------------------------------------
1153 // Information exchange between neighbors
1154 //--------------------------------------------------------------
1155 
1156  int moduloX(RANK() % 2);
1157  int RNx((RANK() + 1) % NODES()), // This is the right neighbor
1158  LNx((RANK() - 1 + NODES()) % NODES()); // This is the left neighbor
1159 
1160  if (NODES() > 1) {
1161  //even nodes
1162 // if (moduloX==0){
1163  if (BNDX() == 0) {
1164  if (((RANK() != 0) && (RANK() != NODES() - 1))) {
1165  X_Data.Send_right_X(Y, RNx); // (Send) 0 --> 1
1166  X_Data.Recv_from_left_X(Y, LNx); // 1 --> 0 (Receive)
1167  X_Data.Send_left_X(Y, LNx); // 1 <-- 0 (Send)
1168  X_Data.Recv_from_right_X(Y, RNx); // (Receive) 0 <-- 1
1169  } else if (RANK() == 0) {
1170  X_Data.Recv_from_left_X(Y, NODES() - 1); // 1 --> 0 (Receive)
1171  X_Data.Send_left_X(Y, NODES() - 1); // 1 <-- 0 (Send)
1172  X_Data.Send_right_X(Y, RNx);
1173  X_Data.Recv_from_right_X(Y, RNx);
1174  } else if (RANK() == NODES() - 1) {
1175  X_Data.Send_right_X(Y, 0); // (Send) 0 --> 1
1176  X_Data.Recv_from_right_X(Y, 0);
1177  X_Data.Recv_from_left_X(Y, LNx); // 1 --> 0 (Receive)
1178  X_Data.Send_left_X(Y, LNx); // 1 <-- 0 (Send)
1179  }
1180  } else if (BNDX() == 1) {
1181  if (((RANK() != 0) && (RANK() != NODES() - 1))) {
1182  X_Data.Send_right_X(Y, RNx); // (Send) 0 --> 1
1183  X_Data.Recv_from_left_X(Y, LNx); // 1 --> 0 (Receive)
1184  X_Data.Send_left_X(Y, LNx); // 1 <-- 0 (Send)
1185  X_Data.Recv_from_right_X(Y, RNx); // (Receive) 0 <-- 1
1186  } else if (RANK() == 0) {
1188  X_Data.Send_right_X(Y, RNx);
1189  X_Data.Recv_from_right_X(Y, RNx);
1190  } else if (RANK() == NODES() - 1) {
1192  X_Data.Recv_from_left_X(Y, LNx); // 1 --> 0 (Receive)
1193  X_Data.Send_left_X(Y, LNx); // 1 <-- 0 (Send)
1194  }
1195 
1196  } else {
1197  cout << "Invalid Boundary." << endl;
1198  }
1199 
1200 // //odd nodes
1201 // else {
1202 // X_Data.Recv_from_left_X(Y,LNx); // 0 --> 1 (Receive)
1203 // if ((RANK()!=(NODES()-1)) || (BNDX()==0)){
1204 // X_Data.Send_right_X(Y,RNx); // (Send) 1 --> 0
1205 // X_Data.Recv_from_right_X(Y,RNx); // (Receive) 1 <-- 0
1206 // }
1207 // else {
1208 // if (BNDX()==1) {
1209 // X_Data.mirror_bound_Xright(Y); // Update node "N-1" in the x direction
1210 // }
1211 // else {
1212 // cout<<"Invalid Boundary." << endl;
1213 // }
1214 // }
1215 // X_Data.Send_left_X(Y,LNx); // 0 <-- 1 (Send)
1216 // }
1217  } else { X_Data.sameNode_bound_X(Y); }
1218 
1219 }
void Recv_from_left_X(State1D &Y, int origin)
Definition: parallel.cpp:465
void Send_left_X(State1D &Y, int dest)
Definition: parallel.cpp:544
void sameNode_bound_X(State1D &Y)
Definition: parallel.cpp:821
Node_Communications X_Data
Definition: parallel.h:167
void Recv_from_right_X(State1D &Y, int origin)
Definition: parallel.cpp:616
void Send_right_X(State1D &Y, int dest)
Definition: parallel.cpp:396
void mirror_bound_Xleft(State1D &Y)
Definition: parallel.cpp:701
void mirror_bound_Xright(State1D &Y)
Definition: parallel.cpp:759
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Neighbor_ImplicitE_Communications()

void Parallel_Environment_1D::Neighbor_ImplicitE_Communications ( State1D Y)

Definition at line 1099 of file parallel.cpp.

References Bfield_Data, BNDX(), Node_ImplicitE_Communications::mirror_bound_Xleft(), Node_ImplicitE_Communications::mirror_bound_Xright(), NODES(), RANK(), Node_ImplicitE_Communications::Recv_from_left_X(), Node_ImplicitE_Communications::Recv_from_right_X(), Node_ImplicitE_Communications::sameNode_bound_X(), Node_ImplicitE_Communications::Send_left_X(), and Node_ImplicitE_Communications::Send_right_X().

Referenced by main().

1099  {
1100 //--------------------------------------------------------------
1101 // Information exchange between neighbors
1102 //--------------------------------------------------------------
1103 
1104  int moduloX(RANK()%2);
1105  int RNx((RANK()+1)%NODES()), // This is the right neighbor
1106  LNx((RANK()-1+NODES())%NODES()); // This is the left neighbor
1107 
1108  if (NODES() > 1) {
1109  //even nodes
1110  if (moduloX==0){
1111  Bfield_Data.Send_right_X(Y,RNx); // (Send) 0 --> 1
1112  if ((RANK() != 0) || (BNDX()==0)){
1113  Bfield_Data.Recv_from_left_X(Y,LNx); // 1 --> 0 (Receive)
1114  Bfield_Data.Send_left_X(Y,LNx); // 1 <-- 0 (Send)
1115  }
1116  else {
1117  if (BNDX()==1) {
1118  Bfield_Data.mirror_bound_Xleft(Y); // Update node "0" in the x direction
1119  }
1120  else {
1121  cout<<"Invalid Boundary." << endl;
1122  }
1123  }
1124  Bfield_Data.Recv_from_right_X(Y,RNx); // (Receive) 0 <-- 1
1125  }
1126  //odd nodes
1127  else {
1128  Bfield_Data.Recv_from_left_X(Y,LNx); // 0 --> 1 (Receive)
1129  if ((RANK()!=(NODES()-1)) || (BNDX()==0)){
1130  Bfield_Data.Send_right_X(Y,RNx); // (Send) 1 --> 0
1131  Bfield_Data.Recv_from_right_X(Y,RNx); // (Receive) 1 <-- 0
1132  }
1133  else {
1134  if (BNDX()==1) {
1135  Bfield_Data.mirror_bound_Xright(Y); // Update node "N-1" in the x direction
1136  }
1137  else {
1138  cout<<"Invalid Boundary." << endl;;
1139  }
1140  }
1141  Bfield_Data.Send_left_X(Y,LNx); // 0 <-- 1 (Send)
1142  }
1143  }
1144  else { Bfield_Data.sameNode_bound_X(Y); }
1145 
1146 }
void Recv_from_left_X(State1D &Y, int origin)
Definition: parallel.cpp:136
void sameNode_bound_X(State1D &Y)
Definition: parallel.cpp:264
Node_ImplicitE_Communications Bfield_Data
Definition: parallel.h:166
void Send_right_X(State1D &Y, int dest)
Definition: parallel.cpp:114
void mirror_bound_Xleft(State1D &Y)
Definition: parallel.cpp:215
void Send_left_X(State1D &Y, int dest)
Definition: parallel.cpp:160
void mirror_bound_Xright(State1D &Y)
Definition: parallel.cpp:237
void Recv_from_right_X(State1D &Y, int origin)
Definition: parallel.cpp:182
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NODES()

int Parallel_Environment_1D::NODES ( ) const

Definition at line 1092 of file parallel.cpp.

References Nnodes.

Referenced by Output_Data::Output_Preprocessor_1D::Bx(), Output_Data::Output_Preprocessor_1D::By(), Output_Data::Output_Preprocessor_1D::Bz(), Output_Data::Output_Preprocessor_1D::Ex(), Output_Data::Output_Preprocessor_1D::Ey(), Output_Data::Output_Preprocessor_1D::Ez(), Output_Data::Output_Preprocessor_1D::f0(), Output_Data::Output_Preprocessor_1D::f10(), Output_Data::Output_Preprocessor_1D::f11(), Output_Data::Output_Preprocessor_1D::f20(), Output_Data::Output_Preprocessor_1D::fl0(), Output_Data::Output_Preprocessor_1D::Jx(), Output_Data::Output_Preprocessor_1D::Jy(), Output_Data::Output_Preprocessor_1D::Jz(), Output_Data::Output_Preprocessor_1D::n(), Neighbor_Communications(), Neighbor_ImplicitE_Communications(), Output_Data::Output_Preprocessor_1D::ni(), Output_Data::Output_Preprocessor_1D::px(), Output_Data::Output_Preprocessor_1D::Qx(), Output_Data::Output_Preprocessor_1D::Qy(), Output_Data::Output_Preprocessor_1D::Qz(), Output_Data::Output_Preprocessor_1D::T(), Output_Data::Output_Preprocessor_1D::Ti(), Output_Data::Output_Preprocessor_1D::Ux(), Output_Data::Output_Preprocessor_1D::Uy(), Output_Data::Output_Preprocessor_1D::Uz(), Output_Data::Output_Preprocessor_1D::vNx(), Output_Data::Output_Preprocessor_1D::vNy(), Output_Data::Output_Preprocessor_1D::vNz(), and Output_Data::Output_Preprocessor_1D::Z().

1092 {return Nnodes;}
Here is the caller graph for this function:

◆ RANK()

int Parallel_Environment_1D::RANK ( ) const

Definition at line 1090 of file parallel.cpp.

References rank.

Referenced by Output_Data::Output_Preprocessor_1D::Bx(), Output_Data::Output_Preprocessor_1D::By(), Output_Data::Output_Preprocessor_1D::Bz(), Output_Data::Output_Preprocessor_1D::Ex(), Output_Data::Output_Preprocessor_1D::Ey(), Output_Data::Output_Preprocessor_1D::Ez(), Output_Data::Output_Preprocessor_1D::f0(), Output_Data::Output_Preprocessor_1D::f10(), Output_Data::Output_Preprocessor_1D::f11(), Output_Data::Output_Preprocessor_1D::f20(), Output_Data::Output_Preprocessor_1D::fl0(), Output_Data::Output_Preprocessor_1D::Jx(), Output_Data::Output_Preprocessor_1D::Jy(), Output_Data::Output_Preprocessor_1D::Jz(), main(), Output_Data::Output_Preprocessor_1D::n(), Neighbor_Communications(), Neighbor_ImplicitE_Communications(), Output_Data::Output_Preprocessor_1D::ni(), Output_Data::Output_Preprocessor_1D::px(), Output_Data::Output_Preprocessor_1D::Qx(), Output_Data::Output_Preprocessor_1D::Qy(), Output_Data::Output_Preprocessor_1D::Qz(), Output_Data::Output_Preprocessor_1D::T(), Output_Data::Output_Preprocessor_1D::Ti(), Output_Data::Output_Preprocessor_1D::Ux(), Output_Data::Output_Preprocessor_1D::Uy(), Output_Data::Output_Preprocessor_1D::Uz(), Output_Data::Output_Preprocessor_1D::vNx(), Output_Data::Output_Preprocessor_1D::vNy(), Output_Data::Output_Preprocessor_1D::vNz(), and Output_Data::Output_Preprocessor_1D::Z().

1090 {return rank;}
Here is the caller graph for this function:

Field Documentation

◆ Bfield_Data

Node_ImplicitE_Communications Parallel_Environment_1D::Bfield_Data
private

Definition at line 166 of file parallel.h.

Referenced by Neighbor_ImplicitE_Communications().

◆ bndX

int Parallel_Environment_1D::bndX
private

Definition at line 163 of file parallel.h.

Referenced by BNDX().

◆ Nnodes

int Parallel_Environment_1D::Nnodes
private

Definition at line 160 of file parallel.h.

Referenced by error_check(), NODES(), and Parallel_Environment_1D().

◆ rank

int Parallel_Environment_1D::rank
private

Definition at line 159 of file parallel.h.

Referenced by error_check(), Parallel_Environment_1D(), and RANK().

◆ X_Data

Node_Communications Parallel_Environment_1D::X_Data
private

Definition at line 167 of file parallel.h.

Referenced by Neighbor_Communications().


The documentation for this class was generated from the following files: