# ~~~ # This file is part of the dune-xt project: # https://zivgitlab.uni-muenster.de/ag-ohlberger/dune-community/dune-xt # Copyright 2009-2021 dune-xt developers and contributors. All rights reserved. # License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) # or GPL-2.0+ (http://opensource.org/licenses/gpl-license) # with "runtime exception" (http://www.dune-project.org/license.html) # Authors: # René Fritze (2018 - 2019) # Tim Keil (2018) # Tobias Leibner (2019 - 2020) # ~~~ import grids import itertools from dune.xt.codegen import typeid_to_typedef_name dim_range = [1, 3] dim_range_cols = [1] dimDomain = [1, 2, 3] multi_out = {grids.pretty_print(g[0], g[1]): g[0] for g in grids.type_and_dim(cache, dimDomain)} multi_out = { filename + '.cc': { 'types': [(filename, grid, r, rC) for r, rC in itertools.product(dim_range, dim_range_cols)] } for filename, grid in multi_out.items() }
# Copyright 2009-2018 dune-xt developers and contributors. All rights reserved. # License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) # or GPL-2.0+ (http://opensource.org/licenses/gpl-license) # with "runtime exception" (http://www.dune-project.org/license.html) # Authors: # René Fritze (2018 - 2019) # Tim Keil (2018) # Tobias Leibner (2019) # ~~~ import grids import itertools from dune.xt.codegen import typeid_to_typedef_name dim_range = [3] dim_range_cols = [3] dimDomain = [3] multi_out = { grids.pretty_print(g[0], g[1]): g[0] for g in grids.type_and_dim(cache, dimDomain) } multi_out = { filename + '.cc': { 'types': [(filename, grid, r, rC) for r, rC in itertools.product(dim_range, dim_range_cols)] } for filename, grid in multi_out.items() }
block = blocks.Block(col, length) grid_clone = grid.clone() grid_clone.maybe_add_block(block, row_index) for filled_grid in randomly_fill_row(grid_clone, row_index, block.start + block.length + 1): yield filled_grid else: yield grid_clone def build_castles(width, height): grid = grids.Grid(width, height) grid.maybe_add_block(blocks.Block(0, width), 0) candidates = set([grid]) for row_index in xrange(1, height): new_candidates = set() for grid in candidates: for filled_grid in randomly_fill_row(grid, row_index, 0): new_candidates.add(filled_grid) candidates = new_candidates castles = set() for candidate in candidates: if candidate.is_castle() is True: castles.add(candidate) return castles grid = grids.Grid(4, 3) assert grid.maybe_add_block(blocks.Block(0, 3), 0) grids.pretty_print(grid)