Skip to content
Snippets Groups Projects
Commit a7c86f83 authored by Martin Bauer's avatar Martin Bauer
Browse files

Benchmark for phase field kernels

parent 9abd0e4a
No related merge requests found
......@@ -333,7 +333,7 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
if self.instruction_set['rsqrt']:
return self.instruction_set['rsqrt'].format(self._print(expr.args[0]))
else:
return "({})".format(self._print(1 / sp.sqrt(expr.args[0])))
return "({})".format(self.doprint(1 / sp.sqrt(expr.args[0])))
return super(VectorizedCustomSympyPrinter, self)._print_Function(expr)
def _print_And(self, expr):
......@@ -391,6 +391,8 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
if result:
return result
one = self.instruction_set['makeVec'].format(1.0)
if expr.exp.is_integer and expr.exp.is_number and 0 < expr.exp < 8:
return "(" + self._print(sp.Mul(*[expr.base] * expr.exp, evaluate=False)) + ")"
elif expr.exp == -1:
......@@ -398,8 +400,10 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
return self.instruction_set['/'].format(one, self._print(expr.base))
elif expr.exp == 0.5:
return self.instruction_set['sqrt'].format(self._print(expr.base))
elif expr.exp == -0.5:
root = self.instruction_set['sqrt'].format(self._print(expr.base))
return self.instruction_set['/'].format(one, root)
elif expr.exp.is_integer and expr.exp.is_number and - 8 < expr.exp < 0:
one = self.instruction_set['makeVec'].format(1.0)
return self.instruction_set['/'].format(one,
self._print(sp.Mul(*[expr.base] * (-expr.exp), evaluate=False)))
else:
......
import numpy as np
from abc import ABC, abstractmethod
from typing import Optional, Callable, Sequence, Iterable, Tuple, Dict
from typing import Optional, Callable, Sequence, Iterable, Tuple, Dict, Union
from pystencils.field import Field
......@@ -32,7 +32,7 @@ class DataHandling(ABC):
"""Returns tuple of booleans for x,y,(z) directions with True if domain is periodic in that direction."""
@abstractmethod
def add_array(self, name: str, values_per_cell: int = 1, dtype=np.float64,
def add_array(self, name: str, values_per_cell, dtype=np.float64,
latex_name: Optional[str] = None, ghost_layers: Optional[int] = None, layout: Optional[str] = None,
cpu: bool = True, gpu: Optional[bool] = None, alignment=False) -> Field:
"""Adds a (possibly distributed) array to the handling that can be accessed using the given name.
......@@ -239,7 +239,7 @@ class DataHandling(ABC):
# ------------------------------- Data access and modification -----------------------------------------------------
def fill(self, array_name: str, val, value_idx: Optional[Tuple[int, ...]] = None,
def fill(self, array_name: str, val, value_idx: Optional[Union[int, Tuple[int, ...]]] = None,
slice_obj=None, ghost_layers=False, inner_ghost_layers=False) -> None:
"""Sets all cells to the same value.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment