from viennagrid.algorithms import * #################################### # Domain setup #################################### domain = Domain(config.triangular_2d) p0 = Point(0, 0) p1 = Point(1, 0) p2 = Point(2, 0) p3 = Point(2, 1) p4 = Point(1, 1) p5 = Point(0, 1) domain.make_vertex(p0) # Vertex with ID #0 domain.make_vertex(p1) # Vertex with ID #1 domain.make_vertex(p2) # Vertex with ID #2 domain.make_vertex(p3) # Vertex with ID #3 domain.make_vertex(p4) # Vertex with ID #4 domain.make_vertex(p5) # Vertex with ID #5 segmentation = Segmentation(domain) seg0 = segmentation.make_segment() seg1 = segmentation.make_segment() cell_00 = seg0.make_cell(domain.vertices[0], domain.vertices[1], domain.vertices[5]) cell_01 = seg0.make_cell(domain.vertices[1], domain.vertices[4], domain.vertices[5]) cell_10 = seg1.make_cell(domain.vertices[1], domain.vertices[2], domain.vertices[4])
# of the cells using accessors. Finally, we will write the mesh and the scalar data # to a VTK file and we will read it again from the mesh file, just to illustrate # how to read and write data stored using accessors. from viennagrid import Domain, Point, Segmentation from viennagrid import config from viennagrid import io from viennagrid import accessors from viennagrid.algorithms import surface # Create an empty domain domain = Domain(config.triangular_2d) # Add vertices to the domain. These vertices will then be used to define # cells. domain.make_vertex(Point(0, 0)) # Vertex with ID #0 domain.make_vertex(Point(1, 0)) # Vertex with ID #1 domain.make_vertex(Point(2, 0)) # Vertex with ID #2 domain.make_vertex(Point(2, 1)) # Vertex with ID #3 domain.make_vertex(Point(1, 1)) # Vertex with ID #4 domain.make_vertex(Point(0, 1)) # Vertex with ID #5 # Create a segmentation of the domain segmentation = Segmentation(domain) # Create 2 segments in the segmentation of the domain seg0 = segmentation.make_segment() seg1 = segmentation.make_segment() # Create 2 cells in the first segment. Since the domain is a triangular domain, # cells are triangles and three vertices must be specified to create a cell.