diff --git a/python/waLBerla/tools/config/__init__.py b/python/waLBerla/tools/config/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3fa8afd43fabe8fadaffdd41f391d6cd541a3d7f --- /dev/null +++ b/python/waLBerla/tools/config/__init__.py @@ -0,0 +1,4 @@ +from .prm_files import toPrm, fromPrm +from .setup import block_decomposition + +__all__ = ['toPrm', 'fromPrm', 'block_decomposition'] diff --git a/python/waLBerla/tools/config.py b/python/waLBerla/tools/config/prm_files.py similarity index 100% rename from python/waLBerla/tools/config.py rename to python/waLBerla/tools/config/prm_files.py diff --git a/python/waLBerla/tools/config/setup.py b/python/waLBerla/tools/config/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..a4a934dafcd57fcd94df7e4dfdf807f0355c26b4 --- /dev/null +++ b/python/waLBerla/tools/config/setup.py @@ -0,0 +1,17 @@ +def _factors(n): + while n > 1: + for i in range(2, n + 1): + if n % i == 0: + n //= i + yield i + break + + +def block_decomposition(processes): + """Compute a 3D factorization of 'processes' in a 3 factors returned as tuple""" + result = [1, 1, 1] + for factor in _factors(processes): + min_idx = result.index(min(result)) + result[min_idx] *= factor + assert result[0] * result[1] * result[2] == processes + return tuple(result)