Exemple #1
0
/*************************************************************************
*    MeshOpt 类的构造函数.	 	                                *
*************************************************************************/
MeshOpt::MeshOpt(const string& object_name,
                 tbox::Pointer<tbox::Database> input_db,
                 tbox::Pointer< appu::DeformingGridInputUtilities2 > grid_tool,
                 tbox::Pointer<geom::MultiblockDeformingGridGeometry<NDIM> > grid_geom)
{
#ifdef DEBUG_CHECK_ASSERTIONS
    assert(!object_name.empty());
    assert(!input_db.isNull());
    assert(!grid_geom.isNull());
    assert(!grid_tool.isNull());
#endif

    d_grid_geometry = grid_geom;
    d_grid_tool = grid_tool;

    getFromInput(input_db);

    d_flag = 0;


    // 为影像区的宽度赋值.
    d_zeroghosts = hier::IntVector<NDIM>(0);
    d_oneghosts  = hier::IntVector<NDIM>(1);

    // 创建所有变量及数据片索引号, 注册可视化数据片.
    registerModelVariables();

}
FACPreconditioner::FACPreconditioner(
    const std::string& object_name,
    Pointer<FACPreconditionerStrategy> fac_strategy,
    tbox::Pointer<tbox::Database> input_db)
    : d_object_name(object_name),
      d_is_initialized(false),
      d_fac_strategy(fac_strategy),
      d_hierarchy(NULL),
      d_coarsest_ln(0),
      d_finest_ln(0),
      d_cycle_type(V_CYCLE),
      d_num_pre_sweeps(1),
      d_num_post_sweeps(1),
      d_f(),
      d_r(),
      d_do_log(false)
{
    /*
     * Register this class with the FACPreconditionerStrategy object.
     */
    d_fac_strategy->setFACPreconditioner(Pointer<FACPreconditioner>(this,false));

    /*
     * Initialize object with data read from input database.
     */
    if (!input_db.isNull())
    {
        getFromInput(input_db);
    }
    return;
}// FACPreconditioner
void
FACPreconditioner::getFromInput(
    tbox::Pointer<tbox::Database> db)
{
    if (db.isNull()) return;

    MGCycleType cycle_type = string_to_enum<MGCycleType>(db->getStringWithDefault("cycle_type", enum_to_string<MGCycleType>(d_cycle_type)));
    setMGCycleType(cycle_type);

    int num_pre_sweeps = db->getIntegerWithDefault("num_pre_sweeps", d_num_pre_sweeps);
    setNumPreSmoothingSweeps(num_pre_sweeps);

    int num_post_sweeps = db->getIntegerWithDefault("num_post_sweeps", d_num_post_sweeps);
    setNumPostSmoothingSweeps(num_post_sweeps);

    bool logging = db->getBoolWithDefault("enable_logging", d_do_log);
    enableLogging(logging);
    return;
}// getFromInput