summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2018-12-28 10:01:32 +0100
committerAnton Khirnov <anton@khirnov.net>2018-12-28 10:01:32 +0100
commita1d2fadd1a9d2d0f93778fc72d8693234ae7772e (patch)
treee65be88515d5439e7670f6ce7ef0e1546aa2fc8b
parentad74fec04e74c2523dedab6e5b4e9dfce5ce850b (diff)
mg2d: do not select the first coarser level too close to the finest one
-rw-r--r--mg2d.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/mg2d.c b/mg2d.c
index 8b70f40..fd775e4 100644
--- a/mg2d.c
+++ b/mg2d.c
@@ -535,8 +535,16 @@ static int mg_levels_alloc(MG2DContext *ctx, size_t domain_size)
if (!priv->root)
return -ENOMEM;
- cur = priv->root;
+ // choose the domain size for the first child
+ // the children all have sizes 2**n + 1
+ // but we skip the closest lower one if it is too close
+ if (domain_size <= 2)
+ return 0;
domain_size = (1 << log2i(domain_size - 2)) + 1;
+ if ((double)priv->root->solver->domain_size[0] / domain_size < 1.5)
+ domain_size = (domain_size >> 1) + 1;
+
+ cur = priv->root;
for (int i = 0; i < LEVELS_MAX && domain_size > 4; i++) {
cur->child = mg_level_alloc(domain_size);
if (!cur->child)