Carmen Code
 All Classes Files Functions Variables Macros Pages
Functions
BC.cpp File Reference

This function returns the position of i, taking into account boundary conditions. More...

#include "Carmen.h"
Include dependency graph for BC.cpp:

Functions

int BC (int i, int AxisNo, int N)
 Returns the position of i taking into account the boundary conditions in the direction AxisNo. The number of points in this direction is N.
Example: for AxisNo=1 and for N=256, i must be between 0 and 255. If i=-1, the function returns 255 for periodic boundary conditions and 0 for Neumann boundary conditions. More...
 

Detailed Description

This function returns the position of i, taking into account boundary conditions.

Function Documentation

int BC ( int  i,
int  AxisNo,
int  N = (1<< ScaleNb) 
)

Returns the position of i taking into account the boundary conditions in the direction AxisNo. The number of points in this direction is N.
Example: for AxisNo=1 and for N=256, i must be between 0 and 255. If i=-1, the function returns 255 for periodic boundary conditions and 0 for Neumann boundary conditions.

Parameters
iPosition
AxisNoAxis of interest
NDefaults to (1<<ScaleNb).
Returns
int
38 {
39  int result=-999999;
40 
41  if (AxisNo > Dimension)
42  return 0;
43 
44 #if defined PARMPI
45  if (CMin[AxisNo] == 3) result=i; //Periodic
46  else
47  {
48  if (i<0) if ((coords[0]==0 && AxisNo==1) || (coords[1]==0 && AxisNo==2) || (coords[2]==0 && AxisNo==3)) result=-i-1; //Neumann
49  if (i>=N) if ((coords[0]==CartDims[0]-1 && AxisNo==1) || (coords[1]==CartDims[1]-1 && AxisNo==2)
50  || (coords[2]==CartDims[2]-1 && AxisNo==3)) result=2*N-i-1;
51  if (result==-999999) result=i; //Not the boundary, simple cell from anouther CPU
52  }
53 
54 
55 #else
56  if (CMin[AxisNo] == 3)
57  result = (i+N)%N; // Periodic
58  else if(CMin[AxisNo] == 2)
59  result = ((i+N)/N==1)? i : (2*N-i-1)%N; // Neumann
60 
61 #endif
62 
63  return result;
64 }
int coords[3]
Definition: Parameters.cpp:230
int CMin[4]
Definition: Parameters.cpp:78
int Dimension
Definition: Parameters.cpp:74
int CartDims[3]
Definition: Parameters.cpp:231

Here is the caller graph for this function: