Exemplo n.º 1
0
    def _create_grid(self):

        from bempp.api import GridFactory
        from collections import OrderedDict

        vertices = self._impl.vertices
        elements = self._impl.elements

        factory = GridFactory()

        self._element_file_to_insertion_indices = OrderedDict.fromkeys(elements.keys(),value=-1)
        self._vertex_file_to_insertion_indices = OrderedDict.fromkeys(vertices.keys(),value=-1)

        vertex_insertion_count = 0
        element_insertion_count = 0

        for key in elements:
            elem = elements[key]
            elem_vertex_keys = []
            for vertex_key in elem['data']:
                if self._vertex_file_to_insertion_indices[vertex_key] ==-1:
                    factory.insert_vertex(vertices[vertex_key])
                    self._vertex_file_to_insertion_indices[vertex_key] = vertex_insertion_count
                    self._vertex_insertion_indices_to_file.append(vertex_key)
                    vertex_insertion_count += 1
                elem_vertex_keys.append(self._vertex_file_to_insertion_indices[vertex_key])
            factory.insert_element(elem_vertex_keys, domain_index=elem['domain_index'])
            self._element_file_to_insertion_indices[key] = element_insertion_count
            self._element_insertion_indices_to_file.append(key)
            element_insertion_count += 1

        return factory.finalize()
Exemplo n.º 2
0
    def setUp(self):
        """Setup the unit test."""
        from bempp.api.shapes import regular_sphere
        from bempp.api import GridFactory

        sphere = regular_sphere(3)

        self.vertices = sphere.leaf_view.vertices
        self.elements = sphere.leaf_view.elements

        self.n_elements = sphere.leaf_view.entity_count(0)
        self.n_vertices = sphere.leaf_view.entity_count(2)

        self.elem_permutation = range(self.n_elements)[::-1]
        self.vertex_permutation = range(self.n_vertices)[::-1]

        #pylint: disable=no-member
        self.domain_indices = np.random.randint(10, size=self.n_elements)

        factory = GridFactory()
        for index in self.vertex_permutation:
            factory.insert_vertex(self.vertices[:, index])
        for i, index in enumerate(self.elem_permutation):
            elem = [
                self.vertex_permutation[self.elements[0, index]],
                self.vertex_permutation[self.elements[1, index]],
                self.vertex_permutation[self.elements[2, index]]
            ]
            factory.insert_element(elem, self.domain_indices[i])

        self.grid = factory.finalize()
    def _create_grid(self):

        from bempp.api import GridFactory
        from collections import OrderedDict

        vertices = self._impl.vertices
        elements = self._impl.elements

        factory = GridFactory()

        self._element_file_to_insertion_indices = OrderedDict.fromkeys(elements.keys(),value=-1)
        self._vertex_file_to_insertion_indices = OrderedDict.fromkeys(vertices.keys(),value=-1)

        vertex_insertion_count = 0
        element_insertion_count = 0

        for key in elements:
            elem = elements[key]
            elem_vertex_keys = []
            for vertex_key in elem['data']:
                if self._vertex_file_to_insertion_indices[vertex_key] ==-1:
                    factory.insert_vertex(vertices[vertex_key])
                    self._vertex_file_to_insertion_indices[vertex_key] = vertex_insertion_count
                    self._vertex_insertion_indices_to_file.append(vertex_key)
                    vertex_insertion_count += 1
                elem_vertex_keys.append(self._vertex_file_to_insertion_indices[vertex_key])
            factory.insert_element(elem_vertex_keys, domain_index=elem['domain_index'])
            self._element_file_to_insertion_indices[key] = element_insertion_count
            self._element_insertion_indices_to_file.append(key)
            element_insertion_count += 1

        return factory.finalize()
Exemplo n.º 4
0
    def setUp(self):
        from bempp.api.shapes import regular_sphere
        from bempp.api import GridFactory

        sphere = regular_sphere(3)

        self.vertices = sphere.leaf_view.vertices
        self.elements = sphere.leaf_view.elements

        self.n_elements = sphere.leaf_view.entity_count(0)
        self.n_vertices = sphere.leaf_view.entity_count(2)

        self.elem_permutation = range(self.n_elements)[::-1]
        self.vertex_permutation = range(self.n_vertices)[::-1]

        self.domain_indices = np.random.randint(10, size=self.n_elements)

        factory = GridFactory()
        for index in self.vertex_permutation:
            factory.insert_vertex(self.vertices[:, index])
        for i, index in enumerate(self.elem_permutation):
            elem = [self.vertex_permutation[self.elements[0, index]],
                    self.vertex_permutation[self.elements[1, index]],
                    self.vertex_permutation[self.elements[2, index]]]
            factory.insert_element(elem, self.domain_indices[i])

        self.grid = factory.finalize()