packages/SPn/spn/FV_Gather.cc
//---------------------------------------------------------------------------//
// PUBLIC FUNCTIONS
//---------------------------------------------------------------------------//
/*!
 * \brief Gather data on all blocks.
 *
 * \param eqn equation order of diffusion coefficients in range [0,4)
 */
PUBLIC FUNCTIONS
\brief Gather data on all blocks.

\param eqn equation order of diffusion coefficients in range [0,4)
PUBLIC FUNCTIONS \ brief Gather data on all blocks . \ param eqn equation order of diffusion coefficients in range [ 0 4 )
void FV_Gather::gather(int eqn)
{
    using def::I; using def::J; using def::PROBLEM_BOUNDARY;
    REQUIRE(eqn >= 0 && eqn < Dimensions::max_num_equations());
    if (d_domains == 1) return;
    post_receives();
    fill_I_face(eqn, d_outgoing_I[LO], 0);
    fill_J_face(eqn, d_outgoing_J[LO], 0);
    fill_I_face(eqn, d_outgoing_I[HI], d_mesh->num_cells_dim(I) - 1);
    fill_J_face(eqn, d_outgoing_J[HI], d_mesh->num_cells_dim(J) - 1);
    if (!d_outgoing_I[LO].is_null())
    {
        CHECK(!d_incoming_I[LO].is_null());
        CHECK(d_neighbor_I[LO] != PROBLEM_BOUNDARY);
        profugus::send(
            d_outgoing_I[LO]->data_pointer(), d_outgoing_I[LO]->data_size(),
            d_neighbor_I[LO], 452);
    }
    if (!d_outgoing_J[LO].is_null())
    {
        CHECK(!d_incoming_J[LO].is_null());
        CHECK(d_neighbor_J[LO] != PROBLEM_BOUNDARY);
        profugus::send(
            d_outgoing_J[LO]->data_pointer(), d_outgoing_J[LO]->data_size(),
            d_neighbor_J[LO], 453);
    }
    if (!d_outgoing_I[HI].is_null())
    {
        CHECK(!d_incoming_I[HI].is_null());
        CHECK(d_neighbor_I[HI] != PROBLEM_BOUNDARY);
        profugus::send(
            d_outgoing_I[HI]->data_pointer(), d_outgoing_I[HI]->data_size(),
            d_neighbor_I[HI], 450);
    }
    if (!d_outgoing_J[HI].is_null())
    {
        CHECK(!d_incoming_J[HI].is_null());
        CHECK(d_neighbor_J[HI] != PROBLEM_BOUNDARY);
        profugus::send(
            d_outgoing_J[HI]->data_pointer(), d_outgoing_J[HI]->data_size(),
            d_neighbor_J[HI], 451);
    }
    d_request_I[LO].wait();
    d_request_I[HI].wait();
    d_request_J[LO].wait();
    d_request_J[HI].wait();
    ENSURE(!d_request_I[LO].inuse());
    ENSURE(!d_request_I[HI].inuse());
    ENSURE(!d_request_J[LO].inuse());
    ENSURE(!d_request_J[HI].inuse());
}
void FV_Gather :: gather ( int eqn ) { using def :: I ; using def :: J ; using def :: PROBLEM_BOUNDARY ; REQUIRE ( eqn >= 0 && eqn < Dimensions :: max_num_equations ( ) ) ; if ( d_domains == 1 ) return ; post_receives ( ) ; fill_I_face ( eqn , d_outgoing_I [ LO ] , 0 ) ; fill_J_face ( eqn , d_outgoing_J [ LO ] , 0 ) ; fill_I_face ( eqn , d_outgoing_I [ HI ] , d_mesh -> num_cells_dim ( I ) - 1 ) ; fill_J_face ( eqn , d_outgoing_J [ HI ] , d_mesh -> num_cells_dim ( J ) - 1 ) ; if ( ! d_outgoing_I [ LO ] . is_null ( ) ) { CHECK ( ! d_incoming_I [ LO ] . is_null ( ) ) ; CHECK ( d_neighbor_I [ LO ] != PROBLEM_BOUNDARY ) ; profugus :: send ( d_outgoing_I [ LO ] -> data_pointer ( ) , d_outgoing_I [ LO ] -> data_size ( ) , d_neighbor_I [ LO ] , 452 ) ; } if ( ! d_outgoing_J [ LO ] . is_null ( ) ) { CHECK ( ! d_incoming_J [ LO ] . is_null ( ) ) ; CHECK ( d_neighbor_J [ LO ] != PROBLEM_BOUNDARY ) ; profugus :: send ( d_outgoing_J [ LO ] -> data_pointer ( ) , d_outgoing_J [ LO ] -> data_size ( ) , d_neighbor_J [ LO ] , 453 ) ; } if ( ! d_outgoing_I [ HI ] . is_null ( ) ) { CHECK ( ! d_incoming_I [ HI ] . is_null ( ) ) ; CHECK ( d_neighbor_I [ HI ] != PROBLEM_BOUNDARY ) ; profugus :: send ( d_outgoing_I [ HI ] -> data_pointer ( ) , d_outgoing_I [ HI ] -> data_size ( ) , d_neighbor_I [ HI ] , 450 ) ; } if ( ! d_outgoing_J [ HI ] . is_null ( ) ) { CHECK ( ! d_incoming_J [ HI ] . is_null ( ) ) ; CHECK ( d_neighbor_J [ HI ] != PROBLEM_BOUNDARY ) ; profugus :: send ( d_outgoing_J [ HI ] -> data_pointer ( ) , d_outgoing_J [ HI ] -> data_size ( ) , d_neighbor_J [ HI ] , 451 ) ; } d_request_I [ LO ] . wait ( ) ; d_request_I [ HI ] . wait ( ) ; d_request_J [ LO ] . wait ( ) ; d_request_J [ HI ] . wait ( ) ; ENSURE ( ! d_request_I [ LO ] . inuse ( ) ) ; ENSURE ( ! d_request_I [ HI ] . inuse ( ) ) ; ENSURE ( ! d_request_J [ LO ] . inuse ( ) ) ; ENSURE ( ! d_request_J [ HI ] . inuse ( ) ) ; }
PUBLIC FUNCTIONS
 \brief Gather data on all blocks.
PUBLIC FUNCTIONS \ brief Gather data on all blocks .
// return immediately if only running on 1 domain (although it works // without this, we use if for efficiency only) // post receives // fill low faces with local diffusion coefficients // send out data on low sides // send out data on high sides // wait on all of the posted receives