hog.operator_generation.pystencils_extensions module#

hog.operator_generation.pystencils_extensions.create_field_access(name: str, dtype: BasicType | type, idx: Expr) Access#
hog.operator_generation.pystencils_extensions.create_generic_fields(names: List[str], dtype: BasicType | type) List[Field]#
hog.operator_generation.pystencils_extensions.create_micro_element_loops(dim: int, micro_edges_per_macro_edge: int) Dict[FaceType | CellType, LoopOverCoordinate]#
hog.operator_generation.pystencils_extensions.fuse_loops_over_simplex(loops: List[LoopOverCoordinate], dim_to_fuse: int, max_dim: int) Tuple[LoopOverCoordinate, List[Node]]#

Takes a list of simplex loops over max_dim dimensions and fuses them at dim_to_fuse. E.g. for dim_to_fuse == 0: L_z(L_y(L_x_1(…))) + L_z(L_y(L_x_2(…))) = L_z(L_y([L_x_1(…), L_x_2(…)]))

hog.operator_generation.pystencils_extensions.get_innermost_loop(ast_node: Node, shift_to_outer: int = 0, return_all_inner: bool = False) List[LoopOverCoordinate]#

Returns the (innermost + shift_to_outer) loop of the given ast node. If there are more than one, throws an exception. For example, get_innermost_loop(ast_node, 1) returns the loop one further out from the innermost loop. An exception is raised if shift_to_outer is larger than the overall loop depth.

hog.operator_generation.pystencils_extensions.loop_over_simplex(dim: int, width: int, cut_innermost: int = 0) LoopOverCoordinate#

Arranges loop (ast-)nodes implementing an iteration over a structured simplex of arbitrary dimension.

The width is the size in each direction. For dim = 1, this is just a one dimensional loop. Dim = 2 gives a loop over a structured triangle. Illustrated for width == 5 below:

^ + + + +

second coordinate | + + + + +

-> first coordinate

This is implemented by a dependency of all loop counters on all other _outside_ loop counters. In C, a two dim loop would look like this:

// y-direction for ( int idx_1 = 0; idx_1 < width; idx_1++ ) {

// x-direction for ( int idx_0 = 0; idx_0 < width - idx_1; idx_0++ ) {

// body

}

}

Returns the outermost loop ast node. The cut_innermost parameter restricts the innermost loop to a range of width - sum(outer_loop_counter_symbols) - cut_innermost

hog.operator_generation.pystencils_extensions.loop_over_simplex_facet(dim: int, width: int, facet_id: int) LoopOverCoordinate#

Loops over one boundary facet of a simplex (e.g., one edge in 2D, one face in 3D).

The facet is specified by an integer. It is required that

0 ≤ facet_id ≤ dim

Let [x_0, x_1, …, x_(dim-1)] be the coordinate of one element that is looped over.

For facet_id < dim, we have that

x_(dim - 1 - facet_id) = 0

and the remaining boundary is selected with facet_id == dim.

So in 2D for example, we get

facet_id = 0: (x_0, 0 ) facet_id = 1: (0, x_1) facet_id = 2: the xy- (or “diagonal”) boundary

hog.operator_generation.pystencils_extensions.remove_blocks(ast_node: Node) None#

Traverses the node and removes all obsolete blocks