Example #1
0
BaseFab<Real>&
BaseFab<Real>::plus (const BaseFab<Real>& src,
                     const Box&           srcbox,
                     const Box&           destbox,
                     int                  srccomp,
                     int                  destcomp,
                     int                  numcomp)
{
    BL_ASSERT(destbox.ok());
    BL_ASSERT(src.box().contains(srcbox));
    BL_ASSERT(box().contains(destbox));
    BL_ASSERT(destbox.sameSize(srcbox));
    BL_ASSERT(srccomp >= 0 && srccomp+numcomp <= src.nComp());
    BL_ASSERT(destcomp >= 0 && destcomp+numcomp <= nComp());

    const int* destboxlo  = destbox.loVect();
    const int* destboxhi  = destbox.hiVect();
    const int* _th_plo    = loVect();
    const int* _th_phi    = hiVect();
    const int* _x_lo      = srcbox.loVect();
    const int* _x_plo     = src.loVect();
    const int* _x_phi     = src.hiVect();
    Real*       _th_p     = dataPtr(destcomp);
    const Real* _x_p      = src.dataPtr(srccomp);

    FORT_FASTPLUS(_th_p,
                  ARLIM(_th_plo),
                  ARLIM(_th_phi),
                  D_DECL(destboxlo[0],destboxlo[1],destboxlo[2]),
                  D_DECL(destboxhi[0],destboxhi[1],destboxhi[2]),
                  _x_p,
                  ARLIM(_x_plo),
                  ARLIM(_x_phi),
                  D_DECL(_x_lo[0],_x_lo[1],_x_lo[2]),
                  &numcomp);
    return *this;
}
Example #2
0
OSM_cSizeDist::OSM_cSizeDist( OSM_Stream& S )

  : OSM_HasType( S )        // same OSM type as Stream
{
    int size, comp;

    // Initialize cumulative passing Vector
    cDist.dimension( nSize() );

    // Calculate tons per hour in size distribution
    tph = S.sum();

    // Add all component size distributions of S into cDist[]
    cDist = 0;
    for( comp=0; comp<nComp(); comp++ )
        cDist.loadSum( cDist, S[comp] );

    // Convert to cumulative passing distribution (tph basis)

    for( size=0; size<nSize()-1; size++ )
        cDist[size] = cDist[size+1];

    cDist[nSize()-1] = 0;
    for( size=nSize()-2; size>=0; size-- )
        cDist[size] += cDist[size+1];

    // Scale cumulative distribution by tph (percent basis)
    if( tph > 0 )
    {
        cDist.loadProduct( cDist, (100/tph) );
    }
    else
    {
        cDist = 0;
    }
}
Example #3
0
int OSM_Model400::calculate( )
{
    // Return value, assume successful
    int retVal = 0;

    // Vectors for internal component streams
    OSM_Vector x( nSize() );       // net crusher contents
    OSM_Vector y( nSize() );       // material classified for breakage
    OSM_Vector z( nSize() );       // breakage products of y

    // Calculate classification function: C[]
    calculateC( );

    // Create contents matrix if required
    if( contents.rows()!=nComp() || contents.columns()!=nSize() )
    {
        contents.dimension( nComp(), nSize() );
    }

    //-- Main Loop - loop over components in the feed -----------------------

    for( int comp=0; comp<nComp(); comp++ )
    {
        // Aliases to component vectors
        OSM_Vector& feedC = feed()[comp];
        OSM_Vector& prodC = product()[comp];
        OSM_Vector& x     = contents[comp];

        if( feedC.sum() > 0 )                   // Component present ?
        {
            calculateA( comp );                 // Make appearance function
            double misconvergence = 1e20;       // Force misconvergence
            long iteration = 0;                 // No iterations yet

            //-- Iteration Loop - until converged or maximum iterations -----

            while( misconvergence>tolerance && iteration<maxIteration )
            {
                // classify material for breakage y = C(x)
                y.loadProduct( C, x );

                // obtain breakage products z = A(y)
                makeDaughters( y, z );

                // obtain next iteration of recycle: x = feed + z
                misconvergence = x.loadSumWithCompare( feedC, z );

                // a successful iteration (hopefully)
                iteration++;
            }
            // product component by balance
            prodC.loadSubtraction( x, y );
        }
        else
        {
            // product component is 0
            prodC = 0;
        }
    }
    // indicate success
    return retVal;
}
Example #4
0
OSM_Stream::OSM_Stream( OSM_Type& sType, double* compMatrix)
  : OSM_HasType( sType )
{
	dimension( nComp(), nSize(), compMatrix );
}