From 1c3ee068b557b4ee84eafa3ede276438bcf1d732 Mon Sep 17 00:00:00 2001 From: Romain QUEY Date: Fri, 13 Sep 2024 15:44:04 +0200 Subject: [PATCH] Fix 2D regularization of cut tessellations Fixed case where a domedge of a tessellation has no domver, as when a tess is cut by a full circle. See https://github.com/neperfepx/neper/issues/724#issuecomment-1647516827. --- VERSIONS | 5 +- doc/conf.py | 4 +- src/CMakeLists.txt | 2 +- .../net_reg_merge_del/net_reg_merge_del2.c | 2 +- .../net_reg_merge_del/net_reg_merge_del3.c | 55 ++++++++++++++++--- .../net_reg_merge_del/net_reg_merge_del_.h | 2 +- 6 files changed, 54 insertions(+), 16 deletions(-) diff --git a/VERSIONS b/VERSIONS index bfc338e12..5f3f41322 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,6 +1,7 @@ -New in 4.9.1-4 (27 Aug 2024): +New in 4.9.1-5 (13 Sep 2024): - module -T: added -n ... -morpho lamellae and (the equivalent) - -morpho lamellar(n=...)", added tessellation key length(d_x,dd_y,d_z). + -morpho lamellar(n=...)", made minor fix to regularization of + 2D cut domain, added tessellation key length(d_x,dd_y,d_z). - made minor fixes and improvements. New in 4.9.0 (15 May 2024): diff --git a/doc/conf.py b/doc/conf.py index ad44944e8..8a3c55b83 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -11,8 +11,8 @@ import sphinx_rtd_theme project = u'Neper' -version = u'4.9.1-4' -release = u'4.9.1-4' +version = u'4.9.1-5' +release = u'4.9.1-5' author = u'Romain Quey' copyright = u'Romain Quey' language = 'en' diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2bef1c1f2..26106989d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ if(POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif() -set(NEPER_VERSION \"4.9.1-4\") +set(NEPER_VERSION \"4.9.1-5\") project(neper) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1) diff --git a/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del2.c b/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del2.c index e99c30e02..1c3930f61 100644 --- a/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del2.c +++ b/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del2.c @@ -196,7 +196,7 @@ int UpdateVerCoo (struct TESS *pTess, int delver, int newver, int verbosity) { if ((*pTess).Dim == 2) - return UpdateVerCooBary (pTess, delver, newver); + return UpdateVerCooBary (pTess, delver, newver, verbosity); else if ((*pTess).Dim == 3) return UpdateVerCooMiniFF (pTess, newver, verbosity); else diff --git a/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del3.c b/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del3.c index dda1caacb..81c862e6d 100644 --- a/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del3.c +++ b/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del3.c @@ -271,7 +271,7 @@ UpdateEdgeLength (struct TESS *pTess, int ver) } int -UpdateVerCooBary (struct TESS *pTess, int delver, int newver) +UpdateVerCooBary (struct TESS *pTess, int delver, int newver, int verbosity) { int i, domedge, domedgeqty, domver1, domver2, eqqty; int *domedges = NULL; @@ -284,11 +284,21 @@ UpdateVerCooBary (struct TESS *pTess, int delver, int newver) vers[0] = delver; vers[1] = newver; + if (verbosity) + printf ("delver = %d newver = %d\n", delver, newver); + neut_tess_vers_alldomedges (*pTess, vers, 2, &domedges, &domedgeqty); - eqqty = domedgeqty + 1; - eqs = ut_alloc_2d (eqqty, 4); + if (verbosity) + { + printf ("domedgeqty = %d\n", domedgeqty); + printf ("domedges = "); + ut_array_1d_int_fprintf (stdout, domedges, domedgeqty, "%d"); + } + + eqs = ut_alloc_2d (domedgeqty + 1, 4); + eqqty = 1; ut_array_1d_memcpy ((*pTess).FaceEq[1], 4, eqs[0]); if (domedgeqty > 0) @@ -297,21 +307,48 @@ UpdateVerCooBary (struct TESS *pTess, int delver, int newver) domedge = domedges[i]; domver1 = (*pTess).DomEdgeVerNb[domedge][0]; domver2 = (*pTess).DomEdgeVerNb[domedge][1]; - ut_space_points_uvect ((*pTess).DomVerCoo[domver1], - (*pTess).DomVerCoo[domver2], v); - ut_vector_vectprod (v, eqs[0] + 1, n); - ut_space_point_normal_plane ((*pTess).DomVerCoo[domver1], n, - eqs[i + 1]); + if (verbosity) + printf ("domedge = %d domver1 = %d domver2 = %d\n", domedge, domver1, domver2); + if (domver1 > 0 && domver2 > 0) + { + eqqty++; + ut_space_points_uvect ((*pTess).DomVerCoo[domver1], + (*pTess).DomVerCoo[domver2], v); + ut_vector_vectprod (v, eqs[0] + 1, n); + ut_space_point_normal_plane ((*pTess).DomVerCoo[domver1], n, + eqs[i + 1]); + } } + if (verbosity) + { + printf ("eqqty = %d\n", eqqty); + printf ("eqs = "); + ut_array_2d_fprintf (stdout, eqs, eqqty, 4, "%f"); + } + ut_array_1d_memcpy ((*pTess).VerCoo[delver], 3, ptcoo[0]); ut_array_1d_memcpy ((*pTess).VerCoo[newver], 3, ptcoo[1]); + if (verbosity) + { + printf ("ptcoo[0] = "); + ut_array_1d_fprintf (stdout, ptcoo[0], 3, "%f"); + printf ("ptcoo[1] = "); + ut_array_1d_fprintf (stdout, ptcoo[1], 3, "%f"); + } + ut_space_points_bary_constrained (ptcoo, NULL, 2, eqs, eqqty, (*pTess).VerCoo[newver]); + if (verbosity) + { + printf ("(*pTess).VerCoo[newver] = "); + ut_array_1d_fprintf (stdout, (*pTess).VerCoo[newver], 3, "%f"); + } + ut_free_2d (&ptcoo, 2); - ut_free_2d (&eqs, eqqty); + ut_free_2d (&eqs, domedgeqty + 1); ut_free_1d (&v); ut_free_1d (&n); diff --git a/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del_.h b/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del_.h index 3e7f2f441..1c6fa55c7 100644 --- a/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del_.h +++ b/src/neper_t/net_reg/net_reg_merge/net_reg_merge_del/net_reg_merge_del_.h @@ -39,5 +39,5 @@ extern void UpdateVerState (struct TESS *, int, int, int); extern void UpdateVerEdge (struct TESS *, int, int, int, int); extern int UpdateVerBound (struct TESS *, int, int); extern int UpdateVerCoo (struct TESS *, int, int, int); -extern int UpdateVerCooBary (struct TESS *, int, int); +extern int UpdateVerCooBary (struct TESS *, int, int, int); extern int UpdateVerCooMiniFF (struct TESS *, int, int);