packages/Matprop/xs/XS_Builder.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Build the cross sections for a speficied pn-order and over a range
 * of groups.
 *
 * This function is used to load a subset of cross sections on the file into
 * the XS database.  For example, a file may contain P5 cross sections and 23
 * groups.  The user may request a XS containing only P0 and P1 cross sections
 * over groups 3-8.  The number of groups in the generated XS is
 * \f[
   N_g = 1 + g_{\mbox{last}} - g_{\mbox{first}}
 * \f]
 *
 * The group structure of the generated XS will be over the range \c [0,G]
 * such
 * \f[
   g_{\mbox{new}} = g\_{\mbox{old}} - g_{\mbox{first}}
 * \f]
 * Note that the group truncation does \b no renormalizing or corrections.
 * Groups outside the specified range are simply ignored.  Generally, group
 * truncation is used to solve for the downscatter-only part of a problem
 * where the lower energy groups are completely decoupled from the high energy
 * groups.
 *
 * \param pn_order pn order of cross sections to load into the XS database
 *
 * \param g_first first group to include in the database
 * \param g_last last group to include in the database
 *
 * \param map map of material ids to named materials in the xml file
 */
\brief Build the cross sections for a speficied pn-order and over a range
of groups.

This function is used to load a subset of cross sections on the file into
the XS database.  For example, a file may contain P5 cross sections and 23
groups.  The user may request a XS containing only P0 and P1 cross sections
over groups 3-8.  The number of groups in the generated XS is
\f[
N_g = 1 + g_{\mbox{last}} - g_{\mbox{first}}
\f]



\param pn_order pn order of cross sections to load into the XS database

\param g_first first group to include in the database
\param g_last last group to include in the database

\param map map of material ids to named materials in the xml file
\ brief Build the cross sections for a speficied pn - order and over a range of groups . This function is used to load a subset of cross sections on the file into the XS database . For example a file may contain P5 cross sections and 23 groups . The user may request a XS containing only P0 and P1 cross sections over groups 3 - 8 . The number of groups in the generated XS is \ f [ N_g = 1 + g_ { \ mbox { last }} - g_ { \ mbox { first }} \ f ] \ param pn_order pn order of cross sections to load into the XS database \ param g_first first group to include in the database \ param g_last last group to include in the database \ param map map of material ids to named materials in the xml file
void XS_Builder::build(const Matid_Map &map,
                       int              pn_order,
                       int              g_first,
                       int              g_last)
{
    REQUIRE(map.completed());
    REQUIRE(1 + g_last - g_first <= d_num_groups);
    REQUIRE(pn_order <= d_pn_order);
    int num_groups = 1 + g_last - g_first;
    CHECK(num_groups >= 0);
    int g_end = g_last + 1;
    CHECK(g_end - g_first == num_groups);
    d_xs = Teuchos::rcp(new XS);
    d_xs->set(pn_order, num_groups);
    if (!d_velocity.empty())
    {
        OneDArray v(d_velocity.begin() + g_first,
                    d_velocity.begin() + g_end);
        d_xs->set_velocities(v);
    }
    if (!d_bounds.empty())
    {
        OneDArray b(d_bounds.begin() + g_first,
                    d_bounds.begin() + g_end + 1);
        d_xs->set_bounds(b);
    }
    for (Matid_Map::const_iterator itr = map.begin();
         itr != map.end(); ++itr)
    {
        int matid                 = itr->first;
        const std_string &matname = itr->second;
        CHECK(d_plxs->isSublist(matname));
        const ParameterList &mpl = d_plxs->sublist(matname);
        for (int t = 0; t < XS::END_XS_TYPES; ++t)
        {
            if (mpl.isParameter(totals_labels[t]))
            {
                const OneDArray &sig_file = mpl.get<OneDArray>(totals_labels[t]);
                OneDArray sigma(sig_file.begin() + g_first,
                                sig_file.begin() + g_end);
                CHECK(sigma.size() == num_groups);
                d_xs->add(matid, t, sigma);
            }
        }
        for (int n = 0; n <= pn_order; ++n)
        {
            if (mpl.isParameter(scat_labels[n]))
            {
                const TwoDArray &sig_file = mpl.get<TwoDArray>(scat_labels[n]);
                TwoDArray sigma(num_groups, num_groups, 0.0);
                for (int g = 0; g < num_groups; ++g)
                {
                    for (int gp = 0; gp < num_groups; ++gp)
                    {
                        sigma(g, gp) = sig_file(g+g_first, gp+g_first);
                    }
                }
                d_xs->add(matid, n, sigma);
            }
        }
    }
    d_xs->complete();
}
void XS_Builder :: build ( const Matid_Map & map , int pn_order , int g_first , int g_last ) { REQUIRE ( map . completed ( ) ) ; REQUIRE ( 1 + g_last - g_first <= d_num_groups ) ; REQUIRE ( pn_order <= d_pn_order ) ; int num_groups = 1 + g_last - g_first ; CHECK ( num_groups >= 0 ) ; int g_end = g_last + 1 ; CHECK ( g_end - g_first == num_groups ) ; d_xs = Teuchos :: rcp ( new XS ) ; d_xs -> set ( pn_order , num_groups ) ; if ( ! d_velocity . empty ( ) ) { OneDArray v ( d_velocity . begin ( ) + g_first , d_velocity . begin ( ) + g_end ) ; d_xs -> set_velocities ( v ) ; } if ( ! d_bounds . empty ( ) ) { OneDArray b ( d_bounds . begin ( ) + g_first , d_bounds . begin ( ) + g_end + 1 ) ; d_xs -> set_bounds ( b ) ; } for ( Matid_Map :: const_iterator itr = map . begin ( ) ; itr != map . end ( ) ; ++ itr ) { int matid = itr -> first ; const std_string & matname = itr -> second ; CHECK ( d_plxs -> isSublist ( matname ) ) ; const ParameterList & mpl = d_plxs -> sublist ( matname ) ; for ( int t = 0 ; t < XS :: END_XS_TYPES ; ++ t ) { if ( mpl . isParameter ( totals_labels [ t ] ) ) { const OneDArray & sig_file = mpl . get < OneDArray > ( totals_labels [ t ] ) ; OneDArray sigma ( sig_file . begin ( ) + g_first , sig_file . begin ( ) + g_end ) ; CHECK ( sigma . size ( ) == num_groups ) ; d_xs -> add ( matid , t , sigma ) ; } } for ( int n = 0 ; n <= pn_order ; ++ n ) { if ( mpl . isParameter ( scat_labels [ n ] ) ) { const TwoDArray & sig_file = mpl . get < TwoDArray > ( scat_labels [ n ] ) ; TwoDArray sigma ( num_groups , num_groups , 0.0 ) ; for ( int g = 0 ; g < num_groups ; ++ g ) { for ( int gp = 0 ; gp < num_groups ; ++ gp ) { sigma ( g , gp ) = sig_file ( g + g_first , gp + g_first ) ; } } d_xs -> add ( matid , n , sigma ) ; } } } d_xs -> complete ( ) ; }
\brief Build the cross sections for a speficied pn-order and over a range
 of groups.
\ brief Build the cross sections for a speficied pn - order and over a range of groups .
// number of groups in the produced XS // create g-end (1 past the last valid entry) // make a new xs database // truncate and add the velocities // add the velocities // truncate and add the bounds // add the velocities // iterate through the map and assign the cross sections // get the material name and integer id that it will be assigned to in // the cross section database // get the sublist // loop through existing totals // check to see if the parameter exists in the xml file // read the 1D cross sections from the parameterlist // truncate the range // add the cross sections to the xs database // loop through Pn moments and add scattering // add all the moments that exist in the xml file // read the 2D scattering cross sections from the // parameterList // truncate the range // add the cross sections to the xs database // complete the cross sections