File boutmesh.hxx¶
-
class
BoutMesh
: public Mesh¶ - #include <boutmesh.hxx>
Implementation of Mesh (mostly) compatible with BOUT
Topology and communications compatible with BOUT conventions.
Public Functions
-
BoutMesh
(GridDataSource *s, Options *options = nullptr)¶
-
~BoutMesh
()¶
-
int
load
()¶ Read in the mesh from data sources.
-
comm_handle
send
(FieldGroup &g)¶ Send data between processors Does not wait for communications to complete, so wait() must be called before guard cell values are used
Example
- Parameters
g
: A group of fields to communicate
comm_handle handle = mesh->send(group); … mesh->wait(handle);
-
int
wait
(comm_handle handle)¶ Wait for a send operation to complete
- Parameters
handle
: The handle returned by send()
-
MPI_Request
sendToProc
(int xproc, int yproc, BoutReal *buffer, int size, int tag)¶ Low-level communication routine Send a buffer of data from this processor to another This must be matched by a corresponding call to receiveFromProc on the receiving processor
- Parameters
xproc
: X index of processor to send toyproc
: Y index of processor to send tobuffer
: A buffer of data to sendsize
: The length ofbuffer
tag
: A label, must be the same at receive
-
comm_handle
receiveFromProc
(int xproc, int yproc, BoutReal *buffer, int size, int tag)¶ Low-level communication routine Receive a buffer of data from another processor Must be matched by corresponding sendToProc call on the sending processor
- Parameters
xproc
: X index of sending processoryproc
: Y index of sending processorbuffer
: The buffer to fill with data. Must already be allocated of lengthsize
size
: The length ofbuffer
tag
: A label, must be the same as send
-
int
getNXPE
()¶ The number of processors in the X direction.
-
int
getNYPE
()¶ The number of processors in the Y direction.
-
int
getXProcIndex
()¶ This processor’s index in X direction.
-
int
getYProcIndex
()¶ This processor’s index in Y direction.
-
bool
firstX
()¶ Is this processor the first in X? i.e. is there a boundary to the left in X?
-
bool
lastX
()¶ Is this processor last in X? i.e. is there a boundary to the right in X?
-
int
sendXOut
(BoutReal *buffer, int size, int tag)¶ Send a buffer of data to processor at X index +1
- Parameters
buffer
: The data to send. Must be at least lengthsize
size
: The number of BoutReals to sendtag
: A label for the communication. Must be the same at receive
-
int
sendXIn
(BoutReal *buffer, int size, int tag)¶ Send a buffer of data to processor at X index -1
- Parameters
buffer
: The data to send. Must be at least lengthsize
size
: The number of BoutReals to sendtag
: A label for the communication. Must be the same at receive
-
comm_handle
irecvXOut
(BoutReal *buffer, int size, int tag)¶ Receive a buffer of data from X index +1
- Parameters
buffer
: A buffer to put the data in. Must already be allocated of lengthsize
size
: The number of BoutReals to receive and put inbuffer
tag
: A label for the communication. Must be the same as sent
-
comm_handle
irecvXIn
(BoutReal *buffer, int size, int tag)¶ Receive a buffer of data from X index -1
- Parameters
buffer
: A buffer to put the data in. Must already be allocated of lengthsize
size
: The number of BoutReals to receive and put inbuffer
tag
: A label for the communication. Must be the same as sent
-
MPI_Comm
getXcomm
(int jy) const¶ Return communicator containing all processors in X.
-
MPI_Comm
getYcomm
(int jx) const¶ Return communicator containing all processors in Y.
-
bool
periodicY
(int jx, BoutReal &ts) const¶ Is local X index
jx
periodic in Y?- Parameters
jx
: The local (on this processor) index in Xts
: The Twist-Shift angle if periodic
-
bool
periodicY
(int jx) const¶ Is local X index
jx
periodic in Y?- Parameters
jx
: The local (on this processor) index in X
-
std::pair<bool, BoutReal>
hasBranchCutLower
(int jx) const¶ Is there a branch cut at this processor’s lower boundary?
- Return
- pair<bool, BoutReal> - bool is true if there is a branch cut, BoutReal gives the total zShift for a 2pi poloidal circuit if there is a branch cut
- Parameters
jx
: The local (on this processor) index in X
-
std::pair<bool, BoutReal>
hasBranchCutUpper
(int jx) const¶ Is there a branch cut at this processor’s upper boundary?
- Return
- pair<bool, BoutReal> - bool is true if there is a branch cut, BoutReal gives the total zShift for a 2pi poloidal circuit if there is a branch cut
- Parameters
jx
: The local (on this processor) index in X
-
int
ySize
(int jx) const¶ The number of points in Y at fixed X index
jx
.
-
bool
firstY
() const¶ Is this processor first in Y? i.e. is there a boundary at lower Y?
-
bool
lastY
() const¶ Is this processor last in Y? i.e. is there a boundary at upper Y?
-
bool
firstY
(int xpos) const¶ Is this processor first in Y? i.e. is there a boundary at lower Y?
-
bool
lastY
(int xpos) const¶ Is this processor last in Y? i.e. is there a boundary at upper Y?
-
int
UpXSplitIndex
()¶ If the upper Y guard cells are split in two, return the X index where the split occurs.
-
int
DownXSplitIndex
()¶ If the lower Y guard cells are split in two, return the X index where the split occurs.
-
comm_handle
irecvYOutIndest
(BoutReal *buffer, int size, int tag)¶ Non-blocking receive. Must be followed by a call to wait()
- Parameters
buffer
: A buffer of lengthsize
which must already be allocatedsize
: The number of BoutReals expectedtag
: The tag number of the expected message
-
comm_handle
irecvYOutOutdest
(BoutReal *buffer, int size, int tag)¶ Non-blocking receive. Must be followed by a call to wait()
- Parameters
buffer
: A buffer of lengthsize
which must already be allocatedsize
: The number of BoutReals expectedtag
: The tag number of the expected message
-
comm_handle
irecvYInIndest
(BoutReal *buffer, int size, int tag)¶ Non-blocking receive. Must be followed by a call to wait()
- Parameters
buffer
: A buffer of lengthsize
which must already be allocatedsize
: The number of BoutReals expectedtag
: The tag number of the expected message
-
comm_handle
irecvYInOutdest
(BoutReal *buffer, int size, int tag)¶ Non-blocking receive. Must be followed by a call to wait()
- Parameters
buffer
: A buffer of lengthsize
which must already be allocatedsize
: The number of BoutReals expectedtag
: The tag number of the expected message
-
const RangeIterator
iterateBndryLowerY
() const¶ Iterate over the lower Y boundary.
-
const RangeIterator
iterateBndryUpperY
() const¶ Iterate over the upper Y boundary.
-
const RangeIterator
iterateBndryLowerInnerY
() const¶
-
const RangeIterator
iterateBndryLowerOuterY
() const¶
-
const RangeIterator
iterateBndryUpperInnerY
() const¶
-
const RangeIterator
iterateBndryUpperOuterY
() const¶
-
std::vector<BoundaryRegion *>
getBoundaries
()¶ Return a vector containing all the boundary regions on this processor.
-
std::vector<BoundaryRegionPar *>
getBoundariesPar
()¶ Get all the parallel (Y) boundaries on this processor.
-
void
addBoundaryPar
(BoundaryRegionPar *bndry)¶ Add a parallel(Y) boundary to this processor.
-
int
getNx
() const¶
-
int
getNy
() const¶
-
void
outputVars
(Datafile &file)¶ Add output variables to a data file These are used for post-processing
-
int
getGlobalXIndex
(int xlocal) const¶ Returns a global X index given a local index. Global index includes boundary cells, local index includes boundary or guard cells.
-
int
getGlobalXIndexNoBoundaries
(int xlocal) const¶ Returns a global X index given a local index. Global index excludes boundary cells, local index includes boundary or guard cells.
-
int
getGlobalYIndex
(int ylocal) const¶ Returns a global Y index given a local index. Global index includes boundary cells, local index includes boundary or guard cells.
-
int
getGlobalYIndexNoBoundaries
(int ylocal) const¶ Returns a global Y index given a local index. Global index excludes boundary cells, local index includes boundary or guard cells.
-
int
getGlobalZIndex
(int zlocal) const¶ Returns a global Z index given a local index. Global index includes boundary cells, local index includes boundary or guard cells.
-
int
getGlobalZIndexNoBoundaries
(int zlocal) const¶ Returns a global Z index given a local index. Global index excludes boundary cells, local index includes boundary or guard cells. Note: at the moment z-direction is always periodic, so has zero boundary cells
-
int
XLOCAL
(int xglo) const¶ Returns a local X index given a global index.
-
int
YLOCAL
(int yglo) const¶ Returns a local Y index given a global index.
Private Functions
-
int
PROC_NUM
(int xind, int yind)¶ Returns the processor number, given X and Y processor indices.
If out of range returns -1 (no processor)
-
int
YGLOBAL
(int yloc, int yproc) const¶ Global Y index given local index and processor.
-
int
YLOCAL
(int yglo, int yproc) const¶
-
int
YPROC
(int yind)¶ Return the Y processor number given a global Y index.
-
int
XPROC
(int xind)¶ Return the X processor number given a global X index.
-
void
set_connection
(int ypos1, int ypos2, int xge, int xlt, bool ts = false)¶ Add a topology connection.
Set ypos1 and ypos2 to be neighbours in the range xge <= x < xlt. Optional argument ts sets whether to use twist-shift condition
-
void
add_target
(int ypos, int xge, int xlt)¶ Add a divertor target or limiter.
ypos is the y index which will become an upper target ypos+1 will become a lower target. Target created in the range xge <= x < xlt.
-
void
topology
()¶
-
void
addBoundaryRegions
()¶ Adds 2D and 3D regions for boundaries.
-
void
free_handle
(CommHandle *h)¶
-
BoutMesh::CommHandle *
get_handle
(int xlen, int ylen)¶
-
void
clear_handles
()¶
-
void
post_receive
(CommHandle &ch)¶ Create the MPI requests to receive data. Non-blocking call.
Private Members
-
std::string
gridname
¶
-
int
nx
¶
-
int
ny
¶
-
int
nz
¶ Size of the grid in the input file.
-
int
MX
¶
-
int
MY
¶
-
int
MZ
¶ size of the grid excluding boundary regions
-
int
MYSUB
¶
-
int
MXSUB
¶
-
int
MZSUB
¶ Size of the grid on this processor.
-
int
NPES
¶ Number of processors.
-
int
MYPE
¶ Rank of this processor.
-
int
PE_YIND
¶ Y index of this processor.
-
int
NYPE
¶
-
int
NZPE
¶
-
int
MYPE_IN_CORE
¶
-
int
ixseps1
¶
-
int
ixseps2
¶
-
int
jyseps1_1
¶
-
int
jyseps2_1
¶
-
int
jyseps1_2
¶
-
int
jyseps2_2
¶
-
int
ixseps_inner
¶
-
int
ixseps_outer
¶
-
int
ixseps_upper
¶
-
int
ixseps_lower
¶
-
int
ny_inner
¶
-
bool
TS_up_in
¶
-
bool
TS_up_out
¶
-
bool
TS_down_in
¶
-
bool
TS_down_out
¶
-
int
UDATA_INDEST
¶
-
int
UDATA_OUTDEST
¶
-
int
UDATA_XSPLIT
¶
-
int
DDATA_INDEST
¶
-
int
DDATA_OUTDEST
¶
-
int
DDATA_XSPLIT
¶
-
int
IDATA_DEST
¶
-
int
ODATA_DEST
¶
-
bool
TwistShift
¶
-
bool
symmetricGlobalY
¶
-
int
zperiod
¶
-
int
MXG
¶
-
int
MYG
¶
-
int
MZG
¶
-
std::vector<BoundaryRegion *>
boundary
¶
-
std::vector<BoundaryRegionPar *>
par_boundary
¶
-
bool
async_send
¶ Switch to asyncronous sends (ISend, not Send)
-
std::list<CommHandle *>
comm_list
¶
-
MPI_Comm
comm_x
¶ Communicator containing all processors in X.
-
MPI_Comm
comm_inner
¶ Communicators in Y. Inside both separatrices; between separatrices; and outside both separatrices
-
MPI_Comm
comm_middle
¶
-
MPI_Comm
comm_outer
¶
-
struct
CommHandle
¶ Communication handle Used to keep track of communications between send and receive
Public Members
-
MPI_Request
request
[6]¶ Array of receive requests. One for each possible neighbour; one each way in X, two each way in Y
-
MPI_Request
sendreq
[6]¶ Array of send requests (for non-blocking send). One for each possible neighbour; one each way in X, two each way in Y
-
int
xbufflen
¶ Length of the buffers used to send/receive (in BoutReals)
-
int
ybufflen
¶
-
bool
in_progress
¶ Is the communication still going?
-
FieldGroup
var_list
¶ List of fields being communicated.
-
MPI_Request
-