Skip to content

Commit 463a8c2

Browse files
committed
Improve -morphooptiini
When a tess is loaded, the cell orientations and ids are transported if defined.
1 parent 96d64d4 commit 463a8c2

File tree

8 files changed

+93
-42
lines changed

8 files changed

+93
-42
lines changed

VERSIONS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
New in 4.8.2-9 (25 Mar 2024):
1+
New in 4.8.2-10 (25 Mar 2024):
22
- module -T: added -transform "cut(cube)", added -morphooptiini ori and id,
33
improved -transform "cut(cubei)", made minor fixes and improvements.
44
- module -M: made minor improvements.

doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import sphinx_rtd_theme
1212

1313
project = u'Neper'
14-
version = u'4.8.2-9'
15-
release = u'4.8.2-9'
14+
version = u'4.8.2-10'
15+
release = u'4.8.2-10'
1616
author = u'Romain Quey'
1717
copyright = u'Romain Quey'
1818
language = 'en'

doc/neper_t.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ These options can be used to set the cell morphology.
288288

289289
- :data:`file(<file_name>)`: values from a :ref:`data_file`.
290290

291-
Alternatively, :data:`file(<file_name>)` can be used to load the seed coordinates and weights from a unique :ref:`tess_file` (thereby replicating the tessellation).
291+
Alternatively, :data:`file(<file_name>)` can be used to load the seed coordinates, weights, orientations and ids (if defined) from a unique :ref:`tess_file` (thereby replicating the tessellation).
292292

293293
**Default value**: :data:`default`.
294294

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(POLICY CMP0077)
77
cmake_policy(SET CMP0077 NEW)
88
endif()
99

10-
set(NEPER_VERSION \"4.8.2-9\")
10+
set(NEPER_VERSION \"4.8.2-10\")
1111
project(neper)
1212

1313
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)

src/neper_t/net_domain/net_domain2.c

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -394,49 +394,69 @@ net_domain_cell (char *filename, int cell, struct POLY *pPoly)
394394
void
395395
net_domain_transform (struct TESS *pPoly, int dim, char *string)
396396
{
397-
int dir, status;
397+
int i, dir;
398398
double *v = ol_r_alloc ();
399399
double theta;
400400
double **g = ol_g_alloc ();
401401
double *eq = ut_alloc_1d (4);
402402
double *coo = ut_alloc_1d (3);
403+
char *fct = NULL;
404+
char **vars = NULL;
405+
int varqty = 0;
406+
407+
ut_string_function (string, &fct, NULL, &vars, &varqty);
403408

404-
if (!strncmp (string, "rotate(", 7))
409+
if (!strcmp (fct, "rotate"))
405410
{
411+
if ((dim == 3 && varqty != 4) || (dim == 2 && varqty != 1))
412+
ut_print_message (2, 3, "Failed to parse expression `%s'.\n", string);
413+
406414
ut_array_1d_set_3 (v, 0., 0., 1.);
407-
status =
408-
sscanf (string, "rotate(%lf,%lf,%lf,%lf)", v, v + 1, v + 2, &theta);
409-
if (status != 1 && status != 4)
410-
abort ();
415+
416+
for (i = 0; i < varqty - 1; i++)
417+
ut_string_real (vars[i], v + i);
418+
ut_string_real (vars[varqty - 1], &theta);
419+
411420
ol_r_set_unit (v);
412421
ol_rtheta_g (v, theta, g);
413422
neut_tess_rotate (pPoly, g);
414423
}
415424

416-
else if (!strncmp (string, "translate(", 10))
425+
else if (!strcmp (fct, "translate"))
417426
{
418-
ut_array_1d_set (v, 3, 0.);
419-
status = sscanf (string, "translate(%lf,%lf,%lf)", v, v + 1, v + 2);
420-
if (status < dim)
427+
if (varqty != dim)
421428
ut_print_message (2, 3, "Failed to parse expression `%s'.\n", string);
429+
430+
ut_array_1d_set (v, 3, 0.);
431+
432+
for (i = 0; i < dim; i++)
433+
ut_string_real (vars[i], v + i);
434+
422435
neut_tess_shift (pPoly, v[0], v[1], v[2]);
423436
}
424437

425-
else if (!strncmp (string, "scale(", 6))
438+
else if (!strcmp (fct, "scale"))
426439
{
427-
ut_array_1d_set (v, 3, 1.);
428-
status = sscanf (string, "scale(%lf,%lf,%lf)", v, v + 1, v + 2);
429-
if (status < dim)
440+
if (varqty != dim)
430441
ut_print_message (2, 3, "Failed to parse expression `%s'.\n", string);
442+
443+
ut_array_1d_set (v, 3, 1.);
444+
445+
for (i = 0; i < dim; i++)
446+
ut_string_real (vars[i], v + i);
447+
431448
neut_tess_scale (pPoly, v[0], v[1], v[2]);
432449
}
433450

434-
else if (!strncmp (string, "split(", 6))
451+
else if (!strcmp (fct, "split"))
435452
{
453+
if (varqty != 1)
454+
ut_print_message (2, 3, "Failed to parse expression `%s'.\n", string);
455+
436456
double **bbox = ut_alloc_2d (3, 2);
437457
char *domtype = NULL;
438458
neut_tess_bbox (*pPoly, bbox);
439-
dir = string[6] - 'x';
459+
dir = vars[0][0] - 'x';
440460
if (dir < 0 || dir > 2)
441461
ut_print_message (2, 3, "Cannot read `%s'.\n", string);
442462

@@ -456,6 +476,7 @@ net_domain_transform (struct TESS *pPoly, int dim, char *string)
456476
ol_g_free (g);
457477
ut_free_1d (&eq);
458478
ut_free_1d (&coo);
479+
ut_free_2d_char (&vars, varqty);
459480

460481
return;
461482
}

src/neper_t/net_tess/net_tess_opt/net_tess_opt_init/net_tess_opt_init_sset/net_tess_opt_init_sset_id/net_tess_opt_init_sset_id1.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,26 @@ net_tess_opt_init_sset_id (int TessId, struct SEEDSET *SSet, char* idexpr, struc
99
{
1010
(void) TessId;
1111
(void) SSet;
12+
FILE *fp = NULL;
13+
struct TESS Tmp;
1214

1315
if (ut_string_isfilename (idexpr))
1416
{
15-
(*pTOpt).SSet.SeedId = ut_alloc_1d_int ((*pTOpt).CellQty);
16-
ut_array_1d_int_fnscanf (idexpr, (*pTOpt).SSet.SeedId + 1, (*pTOpt).CellQty, "r");
17+
if (ut_file_testformat (idexpr, "tess"))
18+
{
19+
neut_tess_set_zero (&Tmp);
20+
fp = ut_file_open (idexpr, "R");
21+
neut_tess_fscanf (fp, &Tmp);
22+
(*pTOpt).SSet.SeedId = ut_alloc_1d_int ((*pTOpt).CellQty + 1);
23+
ut_array_1d_int_memcpy (Tmp.CellId + 1, (*pTOpt).CellQty, (*pTOpt).SSet.SeedId + 1);
24+
ut_file_close (fp, idexpr, "R");
25+
neut_tess_free (&Tmp);
26+
}
27+
else
28+
{
29+
(*pTOpt).SSet.SeedId = ut_alloc_1d_int ((*pTOpt).CellQty);
30+
ut_array_1d_int_fnscanf (idexpr, (*pTOpt).SSet.SeedId + 1, (*pTOpt).CellQty, "r");
31+
}
1732
}
1833

1934
return;

src/neper_t/net_tess/net_tess_opt/net_tess_opt_init/net_tess_opt_init_sset/net_tess_opt_init_sset_ori/net_tess_opt_init_sset_ori1.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,29 @@ void
88
net_tess_opt_init_sset_ori (int TessId, struct SEEDSET *SSet, char* oriexpr, struct TOPT *pTOpt)
99
{
1010
int i;
11+
FILE *fp = NULL;
12+
struct TESS Tmp;
1113

1214
if (ut_string_isfilename (oriexpr))
1315
{
14-
struct OL_SET OSet;
15-
ol_set_zero (&OSet);
16-
net_ori_file (oriexpr, &OSet);
17-
net_ori_memcpy (OSet, &(*pTOpt).SSet);
18-
ol_set_free (&OSet);
16+
if (ut_file_testformat (oriexpr, "tess"))
17+
{
18+
neut_tess_set_zero (&Tmp);
19+
fp = ut_file_open (oriexpr, "R");
20+
neut_tess_fscanf (fp, &Tmp);
21+
(*pTOpt).SSet.SeedOri = ut_alloc_2d ((*pTOpt).CellQty + 1, 4);
22+
ut_array_2d_memcpy (Tmp.CellOri + 1, (*pTOpt).CellQty, 4, (*pTOpt).SSet.SeedOri + 1);
23+
ut_file_close (fp, oriexpr, "R");
24+
neut_tess_free (&Tmp);
25+
}
26+
else
27+
{
28+
struct OL_SET OSet;
29+
ol_set_zero (&OSet);
30+
net_ori_file (oriexpr, &OSet);
31+
net_ori_memcpy (OSet, &(*pTOpt).SSet);
32+
ol_set_free (&OSet);
33+
}
1934
}
2035

2136
else

tests/T/domain_rotate2/ref.tess

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
*crysym
1111
triclinic
1212
*seed
13-
1 0.588079382832 0.389046853444 0.000000000000 0.000000000000
14-
2 0.452028974213 0.195589598124 0.000000000000 0.000000000000
13+
1 0.602036083412 0.371465669344 0.000000000000 0.000000000000
14+
2 0.444427680676 0.147353964587 0.000000000000 0.000000000000
1515
*ori
1616
rodrigues:active
1717
-2.444015198417 0.618305125773 2.829029762200
1818
0.441042954395 0.731096527047 -0.307369633254
1919
**vertex
2020
6
21-
1 1.000000000000 0.000000000000 0.000000000000 0
22-
2 1.000000000000 1.000000000000 0.000000000000 0
23-
3 0.000000000000 1.000000000000 0.000000000000 0
24-
4 -0.000000000000 0.658050611345 0.000000000000 0
25-
5 0.935716889234 0.000000000000 -0.000000000000 0
26-
6 0.000000000000 0.000000000000 0.000000000000 0
21+
1 1.079227965340 0.094420212327 0.000000000000 0
22+
2 0.905579787673 1.079227965340 0.000000000000 0
23+
3 -0.079227965340 0.905579787673 0.000000000000 0
24+
4 -0.034444538694 0.651600354319 -0.000000000000 0
25+
5 0.822266824332 0.049111030174 -0.000000000000 0
26+
6 0.094420212327 -0.079227965340 0.000000000000 0
2727
**edge
2828
7
2929
1 3 4 0
@@ -37,24 +37,24 @@
3737
2
3838
1 5 3 2 1 5 4
3939
5 -4 -2 -3 5 -1
40-
-0.000000000000 -0.000000000000 0.000000000000 -1.000000000000
40+
-0.000000000000 -0.000000000000 -0.000000000000 -1.000000000000
4141
0 -1 0.000000000000 0.000000000000 0.000000000000
4242
2 3 6 4 5
4343
3 -6 -5 -7
44-
-0.000000000000 -0.000000000000 0.000000000000 -1.000000000000
44+
-0.000000000000 -0.000000000000 -0.000000000000 -1.000000000000
4545
0 -1 0.000000000000 0.000000000000 0.000000000000
4646
**domain
4747
*general
4848
cube
4949
*vertex
5050
4
51-
1 0.000000000000 0.000000000000 0.000000000000 x0y0
51+
1 0.094420212327 -0.079227965340 0.000000000000 x0y0
5252
1 6
53-
2 1.000000000000 0.000000000000 0.000000000000 x1y0
53+
2 1.079227965340 0.094420212327 0.000000000000 x1y0
5454
1 1
55-
3 1.000000000000 1.000000000000 0.000000000000 x1y1
55+
3 0.905579787673 1.079227965340 0.000000000000 x1y1
5656
1 2
57-
4 0.000000000000 1.000000000000 0.000000000000 x0y1
57+
4 -0.079227965340 0.905579787673 0.000000000000 x0y1
5858
1 3
5959
*edge
6060
4

0 commit comments

Comments
 (0)