Skip to content

Commit 2a51636

Browse files
committed
Make minor improvements and fix bugs
- general: fixed compatibility with Gmsh (version 4.12.2). - module -S: added -resmesh orifield,orifieldn.
1 parent 03bf33d commit 2a51636

File tree

11 files changed

+401
-17
lines changed

11 files changed

+401
-17
lines changed

VERSIONS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
New in 4.8.1-2 (24 Jan 2024):
2-
1+
New in 4.8.1 (02 Feb 2024):
32
- general: fixed compatibility with Gmsh (version 4.12.2).
3+
- module -S: added -resmesh orifield,orifieldn.
44

55
New in 4.8.0 (09 Jan 2024):
66
- module -T: fixed weibull distribution, made minor fixes.
@@ -10,7 +10,7 @@ New in 4.8.0 (09 Jan 2024):
1010
- module -V: fixed -datanodecoofact.
1111
- module -S: changed simulation.config onto simulation.cfg.
1212
- documentation: made minor fix.
13-
- general: fixed compatibility with Gmsh (version 4.12.2).
13+
- general: cleaned tests.
1414

1515
* Incompatible changes: In -M, changed default value of -order to 2.
1616

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.1-2'
15-
release = u'4.8.1-2'
14+
version = u'4.8.1'
15+
release = u'4.8.1'
1616
author = u'Romain Quey'
1717
copyright = u'Romain Quey'
1818
language = 'en'

doc/exprskeys.rst

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -582,17 +582,19 @@ Available results / keys for nodes are the following:
582582

583583
Available results / keys for elements sets are the following:
584584

585-
========================================== ================================================================ ==================================
586-
**Key** **Descriptor** **Apply to**
587-
:data:`ori` average orientation elset, mesh
588-
:data:`gos` grain orientation spread [#gos]_ elset
589-
:data:`anisogos` grain orientation spread computed from :data:`oridisanisoangles` elset
590-
:data:`oridisanisoangles` orientation distribution principal angles elset, mesh
591-
:data:`oridisanisoaxes` orientation distribution principal axes elset, mesh
592-
:data:`oridisanisofact` orientation distribution factor elset, mesh
593-
:data:`odf(<var>=<value>,...)` ODF defined at elements of orientation space (see also below) tess, tesr, mesh, cell, elt, elset
594-
:data:`odfn(<var>=<value>,...)` ODF defined at nodes of orientation space (see also below) tess, tesr, mesh
595-
========================================== ================================================================ ==================================
585+
========================================== ========================================================================== ===================================
586+
**Key** **Descriptor** **Apply to**
587+
:data:`ori` average orientation elset, mesh
588+
:data:`gos` grain orientation spread [#gos]_ elset
589+
:data:`anisogos` grain orientation spread computed from :data:`oridisanisoangles` elset
590+
:data:`oridisanisoangles` orientation distribution principal angles elset, mesh
591+
:data:`oridisanisoaxes` orientation distribution principal axes elset, mesh
592+
:data:`oridisanisofact` orientation distribution factor elset, mesh
593+
:data:`odf(<var>=<value>,...)` ODF defined at elements of orientation space (see also below) tess, tesr, mesh, cell, elt, elset
594+
:data:`odfn(<var>=<value>,...)` ODF defined at nodes of orientation space (see also below) tess, tesr, mesh
595+
:data:`orifield(var=<var>,...)` :data:`<var>` field defined at elements of orientation space (see below) mesh
596+
:data:`orifieldn(var=<var>,...)` :data:`<var>` field defined at nodes of orientation space (see below) mesh
597+
========================================== ========================================================================== ===================================
596598

597599
The ODF (:data:`odf` or :data:`odfn`) of a tessellation or mesh is computed over orientation space (provided using :option:`-orispace`) from the orientations of the (tessellation) cells or (mesh) elsets. The (optional) parameters are:
598600

@@ -604,6 +606,15 @@ The ODF (:data:`odf` or :data:`odfn`) of a tessellation or mesh is computed over
604606

605607
For a cell, element or elset, :data:`odf` returns the value of the ODF of the tessellation or mesh at the corresponding orientation (and simulation step).
606608

609+
The :data:`orifield` and :data:`orifieldn` of a mesh is computed over orientation space (provided using :option:`-orispace`) from the values of the (mesh) elsets. The mandatory parameter is:
610+
611+
- :data:`var`: the variable, which must be defined for elsets (i.e., have its files in the simulation directory);
612+
613+
and the optional parameters are:
614+
615+
- :data:`theta`: the standard deviation of the kernel (in degrees);
616+
- :data:`weight`: the weight of an elset, which can be a real value or an expression based on the :ref:`mesh_keys` (for elsets) -- by default, the volumes of the elsets are used.
617+
607618
.. _rotations_and_orientations:
608619

609620
Rotations and Orientations

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.1-2\")
10+
set(NEPER_VERSION \"4.8.1\")
1111
project(neper)
1212
1313
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)

src/neper_s/nes_pproc/nes_pproc_entity/nes_pproc_entity_builtin/nes_pproc_entity_builtin2.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ nes_pproc_entity_builtin_elsets (struct SIM *pSim, struct TESS *pTess,
6464
&SimRes);
6565
}
6666

67+
else if (!strncmp (res, "orifield", 8))
68+
{
69+
// if mesh, we compute the odf over orientation space
70+
if (!strcmp (entity, "mesh"))
71+
nes_pproc_entity_builtin_elsets_orifield (pSim, pTess, pNodes, Mesh,
72+
entity, res, &SimRes);
73+
}
74+
6775
else
6876
nes_pproc_entity_builtin_elsets_gen (pSim, pNodes, Mesh, entity, res,
6977
members, memberqty, &SimRes);

src/neper_s/nes_pproc/nes_pproc_entity/nes_pproc_entity_builtin/nes_pproc_entity_builtin3.cpp

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,3 +1143,124 @@ nes_pproc_entity_builtin_elsets_gen (struct SIM *pSim,
11431143

11441144
return;
11451145
}
1146+
1147+
void
1148+
nes_pproc_entity_builtin_elsets_orifield (struct SIM *pSim, struct TESS *pTess,
1149+
struct NODES *pNodes, struct MESH *Mesh,
1150+
char *entity, char *res, struct SIMRES *pSimRes)
1151+
{
1152+
int i, step, size, status;
1153+
double **elsetdata = ut_alloc_2d (Mesh[(*pTess).Dim].ElsetQty + 1, 4);
1154+
double *elsetdata1d = ut_alloc_1d (Mesh[(*pTess).Dim].ElsetQty + 1);
1155+
double ***evect = ut_alloc_3d (Mesh[(*pTess).Dim].ElsetQty + 1, 3, 3);
1156+
double **eval = ut_alloc_2d (Mesh[(*pTess).Dim].ElsetQty + 1, 3);
1157+
char *prev = ut_alloc_1d_char (1000);
1158+
char *filename = NULL;
1159+
FILE *file = NULL;
1160+
struct OL_SET OSet;
1161+
struct ODF Odf;
1162+
char *fct = NULL, **vars = NULL, **vals = NULL;
1163+
char *weight = NULL;
1164+
char *var = NULL;
1165+
char *thetastring = ut_alloc_1d_char (100);
1166+
struct SIMRES SimRes2;
1167+
1168+
neut_simres_set_zero (&SimRes2);
1169+
1170+
ut_string_function (res, &fct, &vars, &vals, &size);
1171+
1172+
neut_sim_orispace (*pSim, &Odf, (char*) "R");
1173+
1174+
ut_print_progress (stdout, 0, (*pSim).StepQty + 1, (char*) "%3.0f%%", prev);
1175+
1176+
for (step = 0; step <= (*pSim).StepQty; step++)
1177+
{
1178+
neut_sim_setstep (pSim, step);
1179+
neut_sim_simres (*pSim, (char*) "elsets", (char*) "ori", &SimRes2);
1180+
1181+
neut_simres_setstep (pSimRes, step);
1182+
neut_simres_setstep (&SimRes2, step);
1183+
1184+
status = neut_mesh_elsetori (Mesh[(*pTess).Dim], elsetdata);
1185+
if (status)
1186+
ut_print_message (2, 0, (char*) "Failed to read elset oris.\n");
1187+
1188+
file = ut_file_open ((*pSimRes).file, (char*) "W");
1189+
1190+
neut_mesh_elsets_olset (*pNodes, Mesh[(*pTess).Dim], elsetdata,
1191+
NULL, Mesh[(*pTess).Dim].ElsetQty, &OSet);
1192+
ut_string_string (Mesh[(*pTess).Dim].ElsetCrySym, &(OSet.crysym));
1193+
1194+
int user_sigma = 0;
1195+
ut_string_string ("1", &weight);
1196+
for (i = 0; i < size; i++)
1197+
{
1198+
if (!strcmp (vars[i], "theta"))
1199+
{
1200+
Odf.sigma = atof (vals[i]);
1201+
Odf.sigma *= M_PI / 180;
1202+
user_sigma = 1;
1203+
}
1204+
else if (!strcmp (vars[i], "weight"))
1205+
ut_string_string (vals[i], &weight);
1206+
else if (!strcmp (vars[i], "var"))
1207+
ut_string_string (vals[i], &var);
1208+
}
1209+
if (!user_sigma)
1210+
neut_odf_setsigma (&Odf, (char*) "avthetaeq", OSet.size, OSet.crysym);
1211+
1212+
sprintf (thetastring, " (theta = %9.6f°) ", Odf.sigma * 180 / M_PI);
1213+
ut_print_clearline (stdout, strlen (thetastring) - 1);
1214+
printf ("%s", thetastring);
1215+
1216+
ut_print_progress (stdout, 0, (*pSim).StepQty + 1, (char*) "%3.0f%%", prev);
1217+
1218+
// Setting weights
1219+
for (i = 0; i < size; i++)
1220+
if (!strcmp (vars[i], "weight"))
1221+
neut_mesh_entity_expr_val (*pNodes, Mesh, pTess,
1222+
NULL, NULL, NULL, NULL, (char*) "elset", weight,
1223+
OSet.weight, NULL);
1224+
1225+
neut_sim_simres (*pSim, (char*) "elset", var, &SimRes2);
1226+
ut_array_1d_fnscanf (SimRes2.file, elsetdata1d + 1, Mesh[(*pTess).Dim].ElsetQty, (char *) "R");
1227+
1228+
if (!strcmp (fct, "orifield"))
1229+
{
1230+
neut_odf_orifield_comp ((char *) "m", !strcmp (weight, "1") ? (char *) "5" : (char *) "all", &OSet, elsetdata1d + 1, &Odf);
1231+
1232+
for (i = 0; i < Odf.odfqty; i++)
1233+
fprintf (file, REAL_PRINT_FORMAT "\n", Odf.odf[i]);
1234+
}
1235+
else if (!strcmp (fct, "orifieldn"))
1236+
{
1237+
neut_odf_orifield_comp ((char *) "n", !strcmp (weight, "1") ? (char *) "5" : (char *) "all", &OSet, elsetdata1d + 1, &Odf);
1238+
for (i = 0; i < Odf.odfnqty; i++)
1239+
fprintf (file, REAL_PRINT_FORMAT "\n", Odf.odfn[i]);
1240+
}
1241+
1242+
ut_file_close (file, (*pSimRes).file, "W");
1243+
1244+
ut_print_progress (stdout, step + 1, (*pSim).StepQty + 1, (char *) "%3.0f%%", prev);
1245+
}
1246+
1247+
neut_sim_setstep (pSim, 0);
1248+
neut_sim_addres (pSim, entity, res, NULL);
1249+
neut_sim_fprintf ((*pSim).simdir, *pSim, (char *) "W");
1250+
1251+
// neut_odf_free (&Odf);
1252+
ut_free_1d_char (&filename);
1253+
ut_free_3d (&evect, Mesh[(*pTess).Dim].ElsetQty + 1, 3);
1254+
ut_free_2d (&eval, Mesh[(*pTess).Dim].ElsetQty + 1);
1255+
ut_free_2d (&elsetdata, Mesh[(*pTess).Dim].ElsetQty + 1);
1256+
ut_free_1d (&elsetdata1d);
1257+
ut_free_1d_char (&prev);
1258+
ut_free_1d_char (&weight);
1259+
ut_free_1d_char (&var);
1260+
ut_free_1d_char (&thetastring);
1261+
ut_free_2d_char (&vars, size);
1262+
ut_free_2d_char (&vals, size);
1263+
neut_simres_free (&SimRes2);
1264+
1265+
return;
1266+
}

src/neper_s/nes_pproc/nes_pproc_entity/nes_pproc_entity_builtin/nes_pproc_entity_builtin_.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ extern void nes_pproc_entity_builtin_elsets_odf (struct SIM *pSim, struct TESS *
5252
struct NODES *pNodes, struct MESH *Mesh,
5353
char *entity, char *res, struct SIMRES *pSimRes);
5454

55+
extern void nes_pproc_entity_builtin_elsets_orifield (struct SIM *pSim, struct TESS *pTess,
56+
struct NODES *pNodes, struct MESH *Mesh,
57+
char *entity, char *res, struct SIMRES *pSimRes);
58+
5559
extern void nes_pproc_entity_builtin_elsets_readodf (struct SIM *pSim, struct TESS Tess,
5660
struct MESH *Mesh, char *entity, char *res,
5761
struct SIMRES *pSimRes);

src/neut/neut_odf/neut_odf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ extern void neut_odf_convolve (struct ODF *pOdf, char *kernel);
2424
extern void neut_odf_deconvolve (struct ODF *pOdf, char *kernel);
2525

2626
extern void neut_odf_elt_ori (struct ODF Odf, int elt, gsl_rng *r, double *q);
27+
extern void neut_odf_orifield_comp (char *mode, char *neigh, struct OL_SET *pOSet,
28+
double *oridata, struct ODF *pOdf);
2729

2830
#endif /* NEUT_ODF_H */
2931

src/neut/neut_odf/neut_odf1.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
extern double neut_odf_comp_elts (char *neigh, struct OL_SET *pOSet, QCLOUD nanocloud, my_kd_tree_t *nano_index, struct ODF *pOdf, int verbosity);
99
extern double neut_odf_comp_nodes (char *neigh, struct OL_SET *pOSet, QCLOUD nano_cloud, my_kd_tree_t *nano_index, struct ODF *pOdf, int verbosity);
10+
extern double neut_odf_orifield_comp_elts (char *neigh, struct OL_SET *pOSet, QCLOUD nano_cloud,
11+
my_kd_tree_t *nano_index, double *oridata, struct ODF *pOdf);
12+
extern double neut_odf_orifield_comp_nodes (char *neigh, struct OL_SET *pOSet, QCLOUD nano_cloud,
13+
my_kd_tree_t *nano_index, double *oridata, struct ODF *pOdf);
1014

1115
void
1216
neut_odf_set_zero (struct ODF *pOdf)
@@ -311,3 +315,24 @@ neut_odf_elt_ori (struct ODF Odf, int elt, gsl_rng *r, double *q)
311315

312316
return;
313317
}
318+
319+
void
320+
neut_odf_orifield_comp (char *mode, char *neigh, struct OL_SET *pOSet,
321+
double *oridata, struct ODF *pOdf)
322+
{
323+
my_kd_tree_t *nano_index = nullptr;
324+
nanoflann::SearchParams params;
325+
QCLOUD nano_cloud;
326+
327+
neut_oset_kdtree (pOSet, &nano_cloud, &nano_index);
328+
329+
if (strstr (mode, "m") || strstr (mode, "n"))
330+
neut_odf_orifield_comp_elts (neigh, pOSet, nano_cloud, nano_index, oridata, pOdf);
331+
332+
if (strstr (mode, "n"))
333+
neut_odf_orifield_comp_nodes (neigh, pOSet, nano_cloud, nano_index, oridata, pOdf);
334+
335+
delete nano_index;
336+
337+
return;
338+
}

0 commit comments

Comments
 (0)