示例#1
0
def get_entity_map(mesh, trace_mesh, subdomains=None, tags=None):
    '''
    Make sure that trace mesh has with it the data for mapping cells of
    TV to facets of V
    '''
    mesh_id = mesh.id()
    tags = set((0, )) if tags is None else set(tags)

    # There is map but we might be missing entry for the mesh
    if hasattr(trace_mesh, 'parent_entity_map'):
        assert hasattr(trace_mesh, 'tagged_cells')
        # Check if we have the map embedding into mesh
        if mesh_id not in trace_mesh.parent_entity_map:
            info('\tMissing map for mesh %d' % mesh_id)
            parent_entity_map = build_embedding_map(trace_mesh, mesh,
                                                    subdomains, tags)
            trace_mesh.parent_entity_map[mesh_id] = parent_entity_map
        else:
            needed_tags = trace_mesh.tagged_cells - tags
            if needed_tags:
                info('\tMissing map for tags %r of mesh %d' %
                     (needed_tags, mesh_id))
                parent_entity_map = build_embedding_map(
                    trace_mesh, mesh, subdomains, tags)
                # Add new
                for edim in trace_mesh.parent_entity_map[mesh_id]:
                    trace_mesh.parent_entity_map[mesh_id][edim].update(
                        parent_entity_map[edim])
    # Compute from scratch and rememeber for future
    else:
        info('\tComputing embedding map for mesh %d' % mesh_id)

        parent_entity_map = build_embedding_map(trace_mesh, mesh, subdomains,
                                                tags)
        # If success we attach it to the mesh (to prevent future recomputing)
        trace_mesh.parent_entity_map = {mesh_id: parent_entity_map}

        # Just made a map for those tags so attach
        if hasattr(trace_mesh, 'tagged_cells'):
            assert not trace_mesh.tagged_cells
            trace_mesh.tagged_cells.update(tags)
        else:
            trace_mesh.tagged_cells = tags
    return True
示例#2
0
def get_entity_map(mesh, trace_mesh):
    '''
    Make sure that trace mesh has with it the data for mapping cells of
    TV to facets of V
    '''
    mesh_id = mesh.id()

    # There is map but we might be missing entry for the mesh
    if hasattr(trace_mesh, 'parent_entity_map'):
        # Check if we have the map embedding into mesh
        if mesh_id not in trace_mesh.parent_entity_map:
            print '\tMissing map for mesh %d' % mesh_id
            parent_entity_map = build_embedding_map(trace_mesh, mesh)
            trace_mesh.parent_entity_map[mesh_id] = parent_entity_map
    # Compute from scratch and rememeber for future
    else:
        print '\tComputing embedding map for mesh %d' % mesh_id

        parent_entity_map = build_embedding_map(trace_mesh, mesh)
        # If success we attach it to the mesh (to prevent future recomputing)
        trace_mesh.parent_entity_map = {mesh_id: parent_entity_map}
    return True
示例#3
0
def get_entity_map(mesh, trace_mesh):
    '''
    Make sure that trace mesh has with it the data for mapping cells of
    TV to facets of V
    '''
    mesh_id = mesh.id()

    # There is map but we might be missing entry for the mesh
    if hasattr(trace_mesh, 'parent_entity_map'):
        # Check if we have the map embedding into mesh
        if mesh_id not in trace_mesh.parent_entity_map:
            print '\tMissing map for mesh %d' % mesh_id
            parent_entity_map = build_embedding_map(trace_mesh, mesh)
            trace_mesh.parent_entity_map[mesh_id] = parent_entity_map
    # Compute from scratch and rememeber for future
    else:
        print '\tComputing embedding map for mesh %d' % mesh_id

        parent_entity_map = build_embedding_map(trace_mesh, mesh)
        # If success we attach it to the mesh (to prevent future recomputing)
        trace_mesh.parent_entity_map = {mesh_id: parent_entity_map}
    return True
示例#4
0
            subdomains[cell] = int(interior.inside(x, False))

        foo = MeshFunction('size_t', outer_mesh,
                           outer_mesh.topology().dim() - 1, 0)
        gamma.mark(foo, 1)

        ifacet_iter = SubsetIterator(foo, 1)

        timer = Timer('x')
        timer.start()
        submeshes, interface, colormap = mortar_meshes(subdomains, (0, 1),
                                                       ifacet_iter)
        print '\t', timer.stop()
    x = interface.parent_entity_map

    maps = [build_embedding_map(interface, meshi) for meshi in submeshes]
    for i in range(len(maps)):
        assert interface.parent_entity_map[submeshes[i].id()][1] == maps[i][1]

    exit()

    n = 16
    # 2d Construction
    outer_mesh = RectangleMesh(Point(-1, -1), Point(1, 1), n, n)
    fs = [
        CompiledSubDomain(
            'std::max(fabs(x[0] - 0.25), fabs(x[1] - 0.25)) < 0.25'),
        CompiledSubDomain(
            'std::max(fabs(x[0] + 0.25), fabs(x[1] - 0.25)) < 0.25'),
        CompiledSubDomain(
            'std::max(fabs(x[0] + 0.25), fabs(x[1] + 0.25)) < 0.25'),
示例#5
0
        # Awkward marking
        for cell in cells(outer_mesh):
            x = cell.midpoint().array()            
            subdomains[cell] = int(interior.inside(x, False))
        
        foo = MeshFunction('size_t', outer_mesh, outer_mesh.topology().dim()-1, 0)
        gamma.mark(foo, 1)

        ifacet_iter = SubsetIterator(foo, 1)
        
        timer = Timer('x'); timer.start()
        submeshes, interface, colormap = mortar_meshes(subdomains, (0, 1), ifacet_iter)
        print '\t', timer.stop()
    x = interface.parent_entity_map

    maps = [build_embedding_map(interface, meshi) for meshi in submeshes]
    for i in range(len(maps)):
        assert interface.parent_entity_map[submeshes[i].id()][1] == maps[i][1]

    exit()
    
    n = 16
    # 2d Construction
    outer_mesh = RectangleMesh(Point(-1, -1), Point(1, 1), n, n)
    fs = [CompiledSubDomain('std::max(fabs(x[0] - 0.25), fabs(x[1] - 0.25)) < 0.25'),
          CompiledSubDomain('std::max(fabs(x[0] + 0.25), fabs(x[1] - 0.25)) < 0.25'),
          CompiledSubDomain('std::max(fabs(x[0] + 0.25), fabs(x[1] + 0.25)) < 0.25'),
          CompiledSubDomain('std::max(fabs(x[0] - 0.25), fabs(x[1] + 0.25)) < 0.25')]
    
    subdomains = MeshFunction('size_t', outer_mesh, outer_mesh.topology().dim(), 0)