packages/SPn/spn_driver/Problem_Builder.cc
//---------------------------------------------------------------------------//
// PRIVATE IMPLEMENTATION
//---------------------------------------------------------------------------//
/*!
 * \brief Build/partition the mesh.
 */
PRIVATE IMPLEMENTATION
\brief Build/partition the mesh.
PRIVATE IMPLEMENTATION \ brief Build / partition the mesh .
void Problem_Builder::build_mesh()
{
    using def::I; using def::J; using def::K;
    REQUIRE(d_coredb->isParameter("axial list"));
    REQUIRE(d_coredb->isParameter("axial height"));
    REQUIRE(d_assblydb->isParameter("assembly list"));
    REQUIRE(d_assblydb->isParameter("pin pitch"));
    REQUIRE(d_db->isParameter("radial mesh"));
    REQUIRE(d_db->isParameter("axial mesh"));
    REQUIRE(d_db->isParameter("symmetry"));
    const auto &axial_list   = d_coredb->get<OneDArray_str>("axial list");
    const auto &axial_height = d_coredb->get<OneDArray_dbl>("axial height");
    CHECK(!axial_list.empty());
    CHECK(axial_list.size() == axial_height.size());
    const auto &core_map = d_coredb->get<TwoDArray_int>(axial_list[0]);
    int num_axial_levels = axial_list.size();
    d_Na[I]              = core_map.getNumCols();
    d_Na[J]              = core_map.getNumRows();
    const auto &assbly_list = d_assblydb->get<OneDArray_str>("assembly list");
    const auto &assbly_map  = d_assblydb->get<TwoDArray_int>(assbly_list[0]);
    d_Np[I] = assbly_map.getNumCols();
    d_Np[J] = assbly_map.getNumRows();
    double pitch = d_assblydb->get<double>("pin pitch");
    CHECK(pitch > 0.0);
    double dx = d_Na[I] * d_Np[I] * pitch;
    double dy = d_Na[J] * d_Np[J] * pitch;
    double dz = std::accumulate(axial_height.begin(), axial_height.end(), 0.0);
    int radial_mesh        = d_db->get<int>("radial mesh");
    const auto &axial_mesh = d_db->get<OneDArray_int>("axial mesh");
    CHECK(axial_mesh.size() == axial_height.size());
    int ncx = radial_mesh * d_Np[I] * d_Na[I];
    int ncy = radial_mesh * d_Np[J] * d_Na[J];
    d_db->set("num_cells_i", ncx);
    d_db->set("delta_x", pitch / static_cast<double>(radial_mesh));
    d_db->set("num_cells_j", ncy);
    d_db->set("delta_y", pitch / static_cast<double>(radial_mesh));
    int ncz = std::accumulate(axial_mesh.begin(), axial_mesh.end(), 0);
    OneDArray_dbl z_edges(ncz + 1, 0.0);
    int ctr      = 0;
    double delta = 0.0;
    for (int k = 0; k < num_axial_levels; ++k)
    {
        delta = axial_height[k] / axial_mesh[k];
        for (int n = 0; n < axial_mesh[k]; ++n)
        {
            CHECK(ctr + 1 < z_edges.size());
            z_edges[ctr+1] = z_edges[ctr] + delta;
            ++ctr;
        }
    }
    CHECK(ctr == ncz);
    CHECK(profugus::soft_equiv(dz, z_edges.back(), 1.0e-12));
    d_db->set("z_edges", z_edges);
    profugus::Partitioner p(d_db);
    p.build();
    d_mesh    = p.get_mesh();
    d_indexer = p.get_indexer();
    d_gdata   = p.get_global_data();
    ENSURE(!d_mesh.is_null());
    ENSURE(!d_indexer.is_null());
    ENSURE(!d_gdata.is_null());
}
void Problem_Builder :: build_mesh ( ) { using def :: I ; using def :: J ; using def :: K ; REQUIRE ( d_coredb -> isParameter ( " " ) ) ; REQUIRE ( d_coredb -> isParameter ( " " ) ) ; REQUIRE ( d_assblydb -> isParameter ( " " ) ) ; REQUIRE ( d_assblydb -> isParameter ( " " ) ) ; REQUIRE ( d_db -> isParameter ( " " ) ) ; REQUIRE ( d_db -> isParameter ( " " ) ) ; REQUIRE ( d_db -> isParameter ( " " ) ) ; const auto & axial_list = d_coredb -> get < OneDArray_str > ( " " ) ; const auto & axial_height = d_coredb -> get < OneDArray_dbl > ( " " ) ; CHECK ( ! axial_list . empty ( ) ) ; CHECK ( axial_list . size ( ) == axial_height . size ( ) ) ; const auto & core_map = d_coredb -> get < TwoDArray_int > ( axial_list [ 0 ] ) ; int num_axial_levels = axial_list . size ( ) ; d_Na [ I ] = core_map . getNumCols ( ) ; d_Na [ J ] = core_map . getNumRows ( ) ; const auto & assbly_list = d_assblydb -> get < OneDArray_str > ( " " ) ; const auto & assbly_map = d_assblydb -> get < TwoDArray_int > ( assbly_list [ 0 ] ) ; d_Np [ I ] = assbly_map . getNumCols ( ) ; d_Np [ J ] = assbly_map . getNumRows ( ) ; double pitch = d_assblydb -> get < double > ( " " ) ; CHECK ( pitch > 0.0 ) ; double dx = d_Na [ I ] * d_Np [ I ] * pitch ; double dy = d_Na [ J ] * d_Np [ J ] * pitch ; double dz = std :: accumulate ( axial_height . begin ( ) , axial_height . end ( ) , 0.0 ) ; int radial_mesh = d_db -> get < int > ( " " ) ; const auto & axial_mesh = d_db -> get < OneDArray_int > ( " " ) ; CHECK ( axial_mesh . size ( ) == axial_height . size ( ) ) ; int ncx = radial_mesh * d_Np [ I ] * d_Na [ I ] ; int ncy = radial_mesh * d_Np [ J ] * d_Na [ J ] ; d_db -> set ( " " , ncx ) ; d_db -> set ( " " , pitch / static_cast < double > ( radial_mesh ) ) ; d_db -> set ( " " , ncy ) ; d_db -> set ( " " , pitch / static_cast < double > ( radial_mesh ) ) ; int ncz = std :: accumulate ( axial_mesh . begin ( ) , axial_mesh . end ( ) , 0 ) ; OneDArray_dbl z_edges ( ncz + 1 , 0.0 ) ; int ctr = 0 ; double delta = 0.0 ; for ( int k = 0 ; k < num_axial_levels ; ++ k ) { delta = axial_height [ k ] / axial_mesh [ k ] ; for ( int n = 0 ; n < axial_mesh [ k ] ; ++ n ) { CHECK ( ctr + 1 < z_edges . size ( ) ) ; z_edges [ ctr + 1 ] = z_edges [ ctr ] + delta ; ++ ctr ; } } CHECK ( ctr == ncz ) ; CHECK ( profugus :: soft_equiv ( dz , z_edges . back ( ) , 1.0e-12 ) ) ; d_db -> set ( " " , z_edges ) ; profugus :: Partitioner p ( d_db ) ; p . build ( ) ; d_mesh = p . get_mesh ( ) ; d_indexer = p . get_indexer ( ) ; d_gdata = p . get_global_data ( ) ; ENSURE ( ! d_mesh . is_null ( ) ) ; ENSURE ( ! d_indexer . is_null ( ) ) ; ENSURE ( ! d_gdata . is_null ( ) ) ; }
PRIVATE IMPLEMENTATION
 \brief Build/partition the mesh.
PRIVATE IMPLEMENTATION \ brief Build / partition the mesh .
// get the axial core map and heights // build the mesh dimensions (all axial core maps have the same radial // dimensions, so we can just use the first core map here) // get the core dimensions (radially in assemblies, axially in levels); // remember the twoD arrays are entered [j][i] (i moves fastest in // COLUMN-MAJOR---FORTRAN---style, so it goes in the column index) // all assemblies have the same radial dimensions, so use the first one to // get the core dimensions // get pins (same caveats on ordering as for the core map) // get the pin pitch // get the core dimensions // get the mesh dimensions // set the mesh radial mesh dimensions // set the mesh axial dimensions // iterate through axial levels and build the mesh // get the width of cells in this level // iterate through axial cells on this level // set the axial mesh // partition the mesh // assign mesh objects