def __init__(self, nodes, elements, edges, mesh_files): """ Test case for a Lagrange mesh. Tries to test an Argyris mesh. """ for mesh_file in mesh_files: self.nodes = nodes # The mesh classes try to flatten nodes if possible. Do it here too. if np.all(self.nodes[:, -1] == self.nodes[0, -1]): self.nodes = self.nodes[:,0:-1] self.elements = elements self.edges = edges mesh = meshes.mesh_factory(*mesh_file) parsed_mesh = parsers.parser_factory(*mesh_file) npt.assert_equal(self.nodes, mesh.nodes) npt.assert_equal(self.elements, mesh.elements) if parsed_mesh.edges: assert set(self.edges) == reduce(lambda a, b : a + b, mesh.edge_collections.values()) npt.assert_almost_equal(meshtools.project_nodes(lambda x : x[0:2], self.elements, self.nodes), self.nodes[:,0:2], decimal=10) if parsed_mesh.edges: assert set(map(lambda x : x[0:-1], self.edges)) == \ set(map(lambda x : x[0:-1], meshtools.extract_boundary_edges(self.elements))) # Test Argyris stuff. if self.elements.shape[1] == 6: TestArgyrisCase(mesh_file, parsed_mesh)
def __init__(self, nodes, elements, edges, mesh_files): """ Test case for a parsed mesh. Tries to test an Argyris mesh. """ for mesh_file in mesh_files: self.nodes = nodes self.elements = elements self.edges = edges parsed_mesh = parsers.parser_factory(*mesh_file) npt.assert_almost_equal(self.nodes, parsed_mesh.nodes) npt.assert_equal(self.elements, parsed_mesh.elements) if parsed_mesh.edges: assert np.all(self.edges == parsed_mesh.edges) npt.assert_almost_equal(meshtools.project_nodes(lambda x : x[0:2], self.elements, self.nodes), self.nodes[:, 0:2], decimal=10) if parsed_mesh.edges: assert set(map(lambda x : x[0:-1], self.edges)) == \ set(map(lambda x : x[0:-1], meshtools.extract_boundary_edges(self.elements))) # Test Argyris stuff. if self.elements.shape[1] == 6: TestArgyrisCase(mesh_file, parsed_mesh)
def __init__(self, parsed_mesh, borders=None, default_border="land", ignore_given_edges=False, projection=None): if borders is None: borders = {} self.elements = parsed_mesh.elements self.nodes = meshtools.project_nodes(projection, parsed_mesh.elements, parsed_mesh.nodes, attempt_flatten=True) self.edge_collections = \ meshtools.organize_edges(parsed_mesh.edges, borders=borders, default_border=default_border) if max(map(len, self.edge_collections.values())) == 0 \ or ignore_given_edges: self.edge_collections = {default_border: set(meshtools.extract_boundary_edges(self.elements))} if len(np.unique(self.elements)) != self.nodes.shape[0]: self._fix_unused_nodes() self.boundary_nodes = {} interior_nodes = set(range(1, len(self.nodes)+1)) for name, edge_collection in self.edge_collections.items(): self.boundary_nodes[name] = \ np.fromiter(set(node for edge in edge_collection for node in edge[0:-1]), int) interior_nodes -= set(self.boundary_nodes[name]) self.interior_nodes = np.fromiter(interior_nodes, int) self.order = _element_order(self.elements.shape[1]) self.mean_stepsize = self._get_stepsize()
def __init__(self, nodes, elements, edges, mesh_files): """ Test case for a Lagrange mesh. Tries to test an Argyris mesh. """ for mesh_file in mesh_files: self.nodes = nodes # The mesh classes try to flatten nodes if possible. Do it here too. if np.all(self.nodes[:, -1] == self.nodes[0, -1]): self.nodes = self.nodes[:, 0:-1] self.elements = elements self.edges = edges mesh = meshes.mesh_factory(*mesh_file) parsed_mesh = parsers.parser_factory(*mesh_file) npt.assert_equal(self.nodes, mesh.nodes) npt.assert_equal(self.elements, mesh.elements) if parsed_mesh.edges: assert set(self.edges) == reduce( lambda a, b: a + b, mesh.edge_collections.values()) npt.assert_almost_equal(meshtools.project_nodes( lambda x: x[0:2], self.elements, self.nodes), self.nodes[:, 0:2], decimal=10) if parsed_mesh.edges: assert set(map(lambda x : x[0:-1], self.edges)) == \ set(map(lambda x : x[0:-1], meshtools.extract_boundary_edges(self.elements))) # Test Argyris stuff. if self.elements.shape[1] == 6: TestArgyrisCase(mesh_file, parsed_mesh)
def __init__(self, nodes, elements, edges, mesh_files): """ Test case for a parsed mesh. Tries to test an Argyris mesh. """ for mesh_file in mesh_files: self.nodes = nodes self.elements = elements self.edges = edges parsed_mesh = parsers.parser_factory(*mesh_file) npt.assert_almost_equal(self.nodes, parsed_mesh.nodes) npt.assert_equal(self.elements, parsed_mesh.elements) if parsed_mesh.edges: assert np.all(self.edges == parsed_mesh.edges) npt.assert_almost_equal(meshtools.project_nodes( lambda x: x[0:2], self.elements, self.nodes), self.nodes[:, 0:2], decimal=10) if parsed_mesh.edges: assert set(map(lambda x : x[0:-1], self.edges)) == \ set(map(lambda x : x[0:-1], meshtools.extract_boundary_edges(self.elements))) # Test Argyris stuff. if self.elements.shape[1] == 6: TestArgyrisCase(mesh_file, parsed_mesh)
def __init__(self, parsed_mesh, borders=None, default_border="land", ignore_given_edges=False, projection=None): if borders is None: borders = {} self.elements = parsed_mesh.elements self.nodes = meshtools.project_nodes(projection, parsed_mesh.elements, parsed_mesh.nodes, attempt_flatten=True) self.edge_collections = \ meshtools.organize_edges(parsed_mesh.edges, borders=borders, default_border=default_border) if max(map(len, self.edge_collections.values())) == 0 \ or ignore_given_edges: self.edge_collections = { default_border: set(meshtools.extract_boundary_edges(self.elements)) } if len(np.unique(self.elements)) != self.nodes.shape[0]: self._fix_unused_nodes() self.boundary_nodes = {} interior_nodes = set(range(1, len(self.nodes) + 1)) for name, edge_collection in self.edge_collections.items(): self.boundary_nodes[name] = \ np.fromiter(set(node for edge in edge_collection for node in edge[0:-1]), int) interior_nodes -= set(self.boundary_nodes[name]) self.interior_nodes = np.fromiter(interior_nodes, int) self.order = _element_order(self.elements.shape[1]) self.mean_stepsize = self._get_stepsize()