示例#1
0
def collect_statistics(my_core, root_set, tar_meshset, display_options):
    """
    Collects statistics for a range of different areas
   
    inputs
    ------
    my_core : a MOAB Core instance
    root_set : the root set for a file
    tar_meshset : the meshset for the triangle aspect ratio statistic
    
    outputs
    -------
    stats : a dictionary containing statistics for a variety of different areas
    """
    
    stats = {}
    data = {}
    
    dagmc_tags = dagmc_stats.get_dagmc_tags(my_core)
    
    entity_types = [types.MBVERTEX, types.MBTRI, types.MBENTITYSET]
    native_ranges = dagmc_stats.get_native_ranges(my_core, root_set, entity_types)     # get Ranges of various entities
    
    entityset_ranges = dagmc_stats.get_entityset_ranges(my_core, root_set,
                                                        dagmc_tags['geom_dim'])
    if display_options['NR']:
        stats['native_ranges'] = native_ranges
    if display_options['ER']:
        stats['entity_ranges'] = entityset_ranges
    if display_options['SPV'] or display_options['SPV_data']:
        spv_key = 'S_P_V'
        data[spv_key] = dagmc_stats.get_surfaces_per_volume(
                                    my_core, entityset_ranges)
        stats[spv_key] = get_stats(data[spv_key].values())
    if display_options['TPS'] or display_options['SPV']:
        tps_key = 'T_P_S'
        data[tps_key] = dagmc_stats.get_triangles_per_surface(
                                    my_core, entityset_ranges)
        stats[tps_key] = get_stats(data[tps_key].values())
    if display_options['TPV']:
        tpv_key = 'T_P_V'
        data[tpv_key] = dagmc_stats.get_triangles_per_vertex(
                                    my_core, native_ranges)
        stats[tpv_key] = get_stats(data[tpv_key])
    if display_options['TAR'] or (tar_meshset != my_core.get_root_set()):
        tar_key = 'T_A_R'
        data[tar_key] = dagmc_stats.get_triangle_aspect_ratio(
                                    my_core, tar_meshset, dagmc_tags['geom_dim'])
        stats[tar_key] = get_stats(data[tar_key])
    if display_options['SPV_data']:
        data['SPV_Entity'] = entity_specific_stats.get_spv_data(my_core,
                                                                entityset_ranges, dagmc_tags['global_id'])
    if display_options['TPS_data']:
        data['TPS_Entity'] = entity_specific_stats.get_tps_data(my_core,
                                                                entityset_ranges, dagmc_tags['global_id'])
    return stats, data
示例#2
0
def test_get_surfaces_per_volume():
    """
    Tests different aspects of the get_surfaces_per_volume function
    """
    dagmc_tags = dagmc_stats.get_dagmc_tags(my_core)
    entityset_ranges = dagmc_stats.get_entityset_ranges(my_core, root_set, dagmc_tags['geom_dim'])
    s_p_v_data = dagmc_stats.get_surfaces_per_volume(my_core, entityset_ranges)
    known_volumes = my_core.get_entities_by_type_and_tag(root_set, types.MBENTITYSET, dagmc_tags['geom_dim'], [3])
    for eh in range(known_volumes.size()):
        surfs = my_core.get_child_meshsets(known_volumes[eh]).size()
        assert(surfs == s_p_v_data[eh])
示例#3
0
def test_get_triangles_per_surface():
    """
    Tests some parts of the get_triangles_per_surface function
    """
    dagmc_tags = dagmc_stats.get_dagmc_tags(my_core)
    entityset_ranges = dagmc_stats.get_entityset_ranges(
        my_core, root_set, dagmc_tags['geom_dim'])
    t_p_s_data = dagmc_stats.get_triangles_per_surface(
        my_core, entityset_ranges)
    surfaces = my_core.get_entities_by_type_and_tag(
        root_set, types.MBENTITYSET, dagmc_tags['geom_dim'], [2]).size()
    assert(len(t_p_s_data) == surfaces)
    triangles = my_core.get_entities_by_type(root_set, types.MBTRI).size()
    assert(sum(t_p_s_data) == triangles)
示例#4
0
def test_get_entityset_ranges():
    """
    Tests different aspects of the get_entityset_ranges function
    """
    dagmc_tags = dagmc_stats.get_dagmc_tags(my_core)
    entityset_ranges = dagmc_stats.get_entityset_ranges(my_core, root_set, dagmc_tags['geom_dim'])
    node_range = my_core.get_entities_by_type_and_tag(root_set, types.MBENTITYSET, dagmc_tags['geom_dim'], [0])
    assert(node_range == entityset_ranges['Nodes'])
    curve_range = my_core.get_entities_by_type_and_tag(root_set, types.MBENTITYSET, dagmc_tags['geom_dim'], [1])
    assert(curve_range == entityset_ranges['Curves'])
    surface_range = my_core.get_entities_by_type_and_tag(root_set, types.MBENTITYSET, dagmc_tags['geom_dim'], [2])
    assert(surface_range ==entityset_ranges['Surfaces'])
    volume_range = my_core.get_entities_by_type_and_tag(root_set, types.MBENTITYSET, dagmc_tags['geom_dim'], [3])
    assert(volume_range == entityset_ranges['Volumes'])