Beispiel #1
0
void 
solve_with_f90(PArray<MultiFab>& rhs, PArray<MultiFab>& phi, 
               Array< PArray<MultiFab> >& grad_phi_edge, 
               const Array<Geometry>& geom, int base_level, int finest_level, Real tol, Real abs_tol)
{
    int nlevs = finest_level - base_level + 1;

    int mg_bc[2*BL_SPACEDIM];

    // This tells the solver that we are using periodic bc's
    if (Geometry::isAllPeriodic())
    {
        for (int dir = 0; dir < BL_SPACEDIM; ++dir)
        {
            mg_bc[2*dir + 0] = 0;
            mg_bc[2*dir + 1] = 0;
        }
    } else {
	BoxLib::Abort("non periodic boundraies not supported here");
    }

    // Have to do some packing because these arrays does not always start with base_level
    PArray<Geometry> geom_p(nlevs);
    PArray<MultiFab> rhs_p(nlevs);
    PArray<MultiFab> phi_p(nlevs);
    for (int ilev = 0; ilev < nlevs; ++ilev) {
	geom_p.set(ilev, &geom[ilev+base_level]);
	rhs_p.set (ilev,  &rhs[ilev+base_level]);
	phi_p.set (ilev,  &phi[ilev+base_level]);
    }
    
    // Refinement ratio is hardwired to 2 here.
    IntVect crse_ratio = (base_level == 0) ? 
	IntVect::TheZeroVector() : IntVect::TheUnitVector() * 2;

    FMultiGrid fmg(geom_p, base_level, crse_ratio);

    if (base_level == 0) {
	fmg.set_bc(mg_bc, phi[base_level]);
    } else {
	fmg.set_bc(mg_bc, phi[base_level-1], phi[base_level]);
    }

    fmg.set_const_gravity_coeffs();

    int always_use_bnorm = 0;
    int need_grad_phi = 1;
    fmg.set_verbose(1);
    fmg.solve(phi_p, rhs_p, tol, abs_tol, always_use_bnorm, need_grad_phi);
   
    for (int ilev = 0; ilev < nlevs; ++ilev)
    {
	int amr_level = ilev + base_level;
	fmg.get_fluxes(grad_phi_edge[amr_level], ilev);
    }
}
Beispiel #2
0
std::unique_ptr<spacelib::area> AreaParser::result()
{
    GiNaC::parser lhs_p, rhs_p;
    if(!m_str.empty())
    {
        m_lhs = lhs_p(m_str[0].toStdString());
        m_rhs = rhs_p(m_str[1].toStdString());
    }

    // Get all the variables.
    std::vector<GiNaC::symbol> syms;
    for(const auto& sym : lhs_p.get_syms())
    { syms.push_back(GiNaC::ex_to<GiNaC::symbol>(sym.second)); }
    for(const auto& sym : rhs_p.get_syms())
    { syms.push_back(GiNaC::ex_to<GiNaC::symbol>(sym.second)); }

    return std::make_unique<spacelib::area>(
                GiNaC::relational(m_lhs, m_rhs, m_op),
                syms);
}
Beispiel #3
0
//==============================================================================
/// Construct a simple scaling factor conversion.
/// 
/// \param [in] factor The scaling factor.
/// 
Conversion::AutoPtr Conversion::ScaleFactor( double factor )
{
    Conversion::AutoPtr lhs_p( new Constant( factor ) );
    Conversion::AutoPtr rhs_p( new Value );
    return Conversion::AutoPtr( new MultOp( lhs_p, rhs_p ) );
}