# Create 2 cells in the second segment. This time, we will use variable to # make the code shorter. seg1.make_cell(domain.get_vertex(1), domain.get_vertex(2), domain.get_vertex(4)) seg1.make_cell(domain.get_vertex(3), domain.get_vertex(2), domain.get_vertex(4)) # Create a new accessor for the cells of the domain and save for each cell # its surface. cell_surface_accessor = CellAccessor() # For each cell of the domain, we calculate its surface and store the surface # of the cell using the accessor. To do that, we call the 'set_value' method # of the accessor specifying the cell and the value that we want to assign to # the cell. for cell in domain.cells: cell_surface_accessor.set_value(cell, surface(cell)) # Now we want to read the value corresponding to each cell stored in the accessor. # Since the cells that have a value stored in the accessor are all the cells of the # domain, we simply iterate over the cells of the domain and get the value stored # in the accessor for that cell using the 'get_value' method of the accessor. for i, cell in enumerate(domain.cells): value = cell_surface_accessor.get_value(cell) print('Cell #%(i)d has surface %(value)f' % locals()) # Next, we want to write the mesh and the scalar data to a VTK file. To do that, # we must provide each accessor with a name for the data stored in it, preferrably # a descriptive name of what the data mean. # # Since we have stored the surface of the cells, we will call the data 'surface'. # Then, we create a dictionary associating the quantity name to the accessor that
#################################### # scale #################################### scale(domain, 2.5) #################################### # spanned_volume #################################### vol = spanned_volume(p0, p1, p5) vol = spanned_volume(*[vertex.to_point() for vertex in cell_00.vertices]) #################################### # surface #################################### cell = cell_00 sur = surface(cell) sur = surface(domain) sur = surface(segment) #################################### # volume #################################### vol = volume(cell) vol = volume(domain) vol = volume(segment)