inline double
compute_linear_extrap(
    D& patch_data,
    const I& i,
    const I& i_intr,
    const IntVector<NDIM>& i_shft,
    const int depth)
{
    double ret_val = patch_data(i_intr,depth);
    for (unsigned int d = 0; d < NDIM; ++d)
    {
        if (i_shft(d) != 0)
        {
            const I& i_intr0 = i_intr;
            I i_intr1 = i_intr;
            i_intr1(d) += i_shft(d);

            const double& f0 = patch_data(i_intr0,depth);
            const double& f1 = patch_data(i_intr1,depth);

            const double du = f0-f1;
            const double delta = std::abs(i(d)-i_intr(d));

            ret_val += du*delta;
        }
    }
    return ret_val;
}// compute_linear_extrap
Beispiel #2
0
inline double
compute_quadratic_extrap(D& patch_data,
                         const I& i,
                         const I& i_intr,
                         const IntVector<NDIM>& i_shft,
                         const int depth,
                         const int codim)
{
    if (codim == 1)
    {
        for (unsigned int d = 0; d < NDIM; ++d)
        {
            if (i_shft(d) != 0)
            {
                const I& i_intr0 = i_intr;

                I i_intr1 = i_intr;
                i_intr1(d) += i_shft(d);

                I i_intr2 = i_intr1;
                i_intr2(d) += i_shft(d);

                const double& f0 = patch_data(i_intr0, depth);
                const double& f1 = patch_data(i_intr1, depth);
                const double& f2 = patch_data(i_intr2, depth);

                const double x = std::abs(i(d) - i_intr(d));

                return (1.0 / 2.0 * f2 - f1 + 1.0 / 2.0 * f0) * x * x +
                       (-1.0 / 2.0 * f2 + 2.0 * f1 - 3.0 / 2.0 * f0) * x + f0;
            }
        }
    }
    else
    {
        return compute_linear_extrap(patch_data, i, i_intr, i_shft, depth);
    }
    return 0.0; // this statement should not be reached
} // compute_quadratic_extrap
inline double
compute_quadratic_extrap(
    D& patch_data,
    const I& i,
    const I& i_intr,
    const IntVector<NDIM>& i_shft,
    const int depth,
    const int codim)
{
    if (codim == 1)
    {
        for (unsigned int d = 0; d < NDIM; ++d)
        {
            if (i_shft(d) != 0)
            {
#if 1
                const I& i_intr0 = i_intr;

                I i_intr1 = i_intr;
                i_intr1(d) += i_shft(d);

                I i_intr2 = i_intr1;
                i_intr2(d) += i_shft(d);

                const double& f0 = patch_data(i_intr0,depth);
                const double& f1 = patch_data(i_intr1,depth);
                const double& f2 = patch_data(i_intr2,depth);

                const double x = std::abs(i(d)-i_intr(d));

                return (1.0/2.0*f2-f1+1.0/2.0*f0)*x*x+(-1.0/2.0*f2+2.0*f1-3.0/2.0*f0)*x+f0;
#endif

#if 0
                // NOTE: The following only works in general for the case that
                // the ghost cell width is >= 3.
                const I& i_intr0 = i_intr;

                I i_intr2 = i_intr;
                i_intr2(d) += 2*i_shft(d);

                I i_intr3 = i_intr2;
                i_intr3(d) += i_shft(d);

                const double& f0 = patch_data(i_intr0,depth);
                const double& f2 = patch_data(i_intr2,depth);
                const double& f3 = patch_data(i_intr3,depth);

                const double x = std::abs(i(d)-i_intr(d));

                return (1.0/3.0*f3-1.0/2.0*f2+1.0/6.0*f0)*x*x+(-2.0/3.0*f3+3.0/2.0*f2-5.0/6.0*f0)*x+f0;
#endif
            }
        }
    }
    else
    {
        return compute_linear_extrap(patch_data, i, i_intr, i_shft, depth);
    }
    return 0.0; // this statement should not be reached
}// compute_quadratic_extrap