Skip to content

Commit

Permalink
Make minor improvements and fix bugs
Browse files Browse the repository at this point in the history
- general: fixed compatibility with Gmsh (version 4.12.2).
- module -S: added -resmesh orifield,orifieldn.
  • Loading branch information
rquey committed Feb 2, 2024
1 parent 03bf33d commit 2a51636
Show file tree
Hide file tree
Showing 11 changed files with 401 additions and 17 deletions.
6 changes: 3 additions & 3 deletions VERSIONS
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
New in 4.8.1-2 (24 Jan 2024):

New in 4.8.1 (02 Feb 2024):
- general: fixed compatibility with Gmsh (version 4.12.2).
- module -S: added -resmesh orifield,orifieldn.

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

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

Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import sphinx_rtd_theme

project = u'Neper'
version = u'4.8.1-2'
release = u'4.8.1-2'
version = u'4.8.1'
release = u'4.8.1'
author = u'Romain Quey'
copyright = u'Romain Quey'
language = 'en'
Expand Down
33 changes: 22 additions & 11 deletions doc/exprskeys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -582,17 +582,19 @@ Available results / keys for nodes are the following:

Available results / keys for elements sets are the following:

========================================== ================================================================ ==================================
**Key** **Descriptor** **Apply to**
:data:`ori` average orientation elset, mesh
:data:`gos` grain orientation spread [#gos]_ elset
:data:`anisogos` grain orientation spread computed from :data:`oridisanisoangles` elset
:data:`oridisanisoangles` orientation distribution principal angles elset, mesh
:data:`oridisanisoaxes` orientation distribution principal axes elset, mesh
:data:`oridisanisofact` orientation distribution factor elset, mesh
:data:`odf(<var>=<value>,...)` ODF defined at elements of orientation space (see also below) tess, tesr, mesh, cell, elt, elset
:data:`odfn(<var>=<value>,...)` ODF defined at nodes of orientation space (see also below) tess, tesr, mesh
========================================== ================================================================ ==================================
========================================== ========================================================================== ===================================
**Key** **Descriptor** **Apply to**
:data:`ori` average orientation elset, mesh
:data:`gos` grain orientation spread [#gos]_ elset
:data:`anisogos` grain orientation spread computed from :data:`oridisanisoangles` elset
:data:`oridisanisoangles` orientation distribution principal angles elset, mesh
:data:`oridisanisoaxes` orientation distribution principal axes elset, mesh
:data:`oridisanisofact` orientation distribution factor elset, mesh
:data:`odf(<var>=<value>,...)` ODF defined at elements of orientation space (see also below) tess, tesr, mesh, cell, elt, elset
:data:`odfn(<var>=<value>,...)` ODF defined at nodes of orientation space (see also below) tess, tesr, mesh
:data:`orifield(var=<var>,...)` :data:`<var>` field defined at elements of orientation space (see below) mesh
:data:`orifieldn(var=<var>,...)` :data:`<var>` field defined at nodes of orientation space (see below) mesh
========================================== ========================================================================== ===================================

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:

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

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).

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:

- :data:`var`: the variable, which must be defined for elsets (i.e., have its files in the simulation directory);

and the optional parameters are:

- :data:`theta`: the standard deviation of the kernel (in degrees);
- :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.

.. _rotations_and_orientations:

Rotations and Orientations
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

set(NEPER_VERSION \"4.8.1-2\")
set(NEPER_VERSION \"4.8.1\")
project(neper)

if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ nes_pproc_entity_builtin_elsets (struct SIM *pSim, struct TESS *pTess,
&SimRes);
}

else if (!strncmp (res, "orifield", 8))
{
// if mesh, we compute the odf over orientation space
if (!strcmp (entity, "mesh"))
nes_pproc_entity_builtin_elsets_orifield (pSim, pTess, pNodes, Mesh,
entity, res, &SimRes);
}

else
nes_pproc_entity_builtin_elsets_gen (pSim, pNodes, Mesh, entity, res,
members, memberqty, &SimRes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,3 +1143,124 @@ nes_pproc_entity_builtin_elsets_gen (struct SIM *pSim,

return;
}

void
nes_pproc_entity_builtin_elsets_orifield (struct SIM *pSim, struct TESS *pTess,
struct NODES *pNodes, struct MESH *Mesh,
char *entity, char *res, struct SIMRES *pSimRes)
{
int i, step, size, status;
double **elsetdata = ut_alloc_2d (Mesh[(*pTess).Dim].ElsetQty + 1, 4);
double *elsetdata1d = ut_alloc_1d (Mesh[(*pTess).Dim].ElsetQty + 1);
double ***evect = ut_alloc_3d (Mesh[(*pTess).Dim].ElsetQty + 1, 3, 3);
double **eval = ut_alloc_2d (Mesh[(*pTess).Dim].ElsetQty + 1, 3);
char *prev = ut_alloc_1d_char (1000);
char *filename = NULL;
FILE *file = NULL;
struct OL_SET OSet;
struct ODF Odf;
char *fct = NULL, **vars = NULL, **vals = NULL;
char *weight = NULL;
char *var = NULL;
char *thetastring = ut_alloc_1d_char (100);
struct SIMRES SimRes2;

neut_simres_set_zero (&SimRes2);

ut_string_function (res, &fct, &vars, &vals, &size);

neut_sim_orispace (*pSim, &Odf, (char*) "R");

ut_print_progress (stdout, 0, (*pSim).StepQty + 1, (char*) "%3.0f%%", prev);

for (step = 0; step <= (*pSim).StepQty; step++)
{
neut_sim_setstep (pSim, step);
neut_sim_simres (*pSim, (char*) "elsets", (char*) "ori", &SimRes2);

neut_simres_setstep (pSimRes, step);
neut_simres_setstep (&SimRes2, step);

status = neut_mesh_elsetori (Mesh[(*pTess).Dim], elsetdata);
if (status)
ut_print_message (2, 0, (char*) "Failed to read elset oris.\n");

file = ut_file_open ((*pSimRes).file, (char*) "W");

neut_mesh_elsets_olset (*pNodes, Mesh[(*pTess).Dim], elsetdata,
NULL, Mesh[(*pTess).Dim].ElsetQty, &OSet);
ut_string_string (Mesh[(*pTess).Dim].ElsetCrySym, &(OSet.crysym));

int user_sigma = 0;
ut_string_string ("1", &weight);
for (i = 0; i < size; i++)
{
if (!strcmp (vars[i], "theta"))
{
Odf.sigma = atof (vals[i]);
Odf.sigma *= M_PI / 180;
user_sigma = 1;
}
else if (!strcmp (vars[i], "weight"))
ut_string_string (vals[i], &weight);
else if (!strcmp (vars[i], "var"))
ut_string_string (vals[i], &var);
}
if (!user_sigma)
neut_odf_setsigma (&Odf, (char*) "avthetaeq", OSet.size, OSet.crysym);

sprintf (thetastring, " (theta = %9.6f°) ", Odf.sigma * 180 / M_PI);
ut_print_clearline (stdout, strlen (thetastring) - 1);
printf ("%s", thetastring);

ut_print_progress (stdout, 0, (*pSim).StepQty + 1, (char*) "%3.0f%%", prev);

// Setting weights
for (i = 0; i < size; i++)
if (!strcmp (vars[i], "weight"))
neut_mesh_entity_expr_val (*pNodes, Mesh, pTess,
NULL, NULL, NULL, NULL, (char*) "elset", weight,
OSet.weight, NULL);

neut_sim_simres (*pSim, (char*) "elset", var, &SimRes2);
ut_array_1d_fnscanf (SimRes2.file, elsetdata1d + 1, Mesh[(*pTess).Dim].ElsetQty, (char *) "R");

if (!strcmp (fct, "orifield"))
{
neut_odf_orifield_comp ((char *) "m", !strcmp (weight, "1") ? (char *) "5" : (char *) "all", &OSet, elsetdata1d + 1, &Odf);

for (i = 0; i < Odf.odfqty; i++)
fprintf (file, REAL_PRINT_FORMAT "\n", Odf.odf[i]);
}
else if (!strcmp (fct, "orifieldn"))
{
neut_odf_orifield_comp ((char *) "n", !strcmp (weight, "1") ? (char *) "5" : (char *) "all", &OSet, elsetdata1d + 1, &Odf);
for (i = 0; i < Odf.odfnqty; i++)
fprintf (file, REAL_PRINT_FORMAT "\n", Odf.odfn[i]);
}

ut_file_close (file, (*pSimRes).file, "W");

ut_print_progress (stdout, step + 1, (*pSim).StepQty + 1, (char *) "%3.0f%%", prev);
}

neut_sim_setstep (pSim, 0);
neut_sim_addres (pSim, entity, res, NULL);
neut_sim_fprintf ((*pSim).simdir, *pSim, (char *) "W");

// neut_odf_free (&Odf);
ut_free_1d_char (&filename);
ut_free_3d (&evect, Mesh[(*pTess).Dim].ElsetQty + 1, 3);
ut_free_2d (&eval, Mesh[(*pTess).Dim].ElsetQty + 1);
ut_free_2d (&elsetdata, Mesh[(*pTess).Dim].ElsetQty + 1);
ut_free_1d (&elsetdata1d);
ut_free_1d_char (&prev);
ut_free_1d_char (&weight);
ut_free_1d_char (&var);
ut_free_1d_char (&thetastring);
ut_free_2d_char (&vars, size);
ut_free_2d_char (&vals, size);
neut_simres_free (&SimRes2);

return;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ extern void nes_pproc_entity_builtin_elsets_odf (struct SIM *pSim, struct TESS *
struct NODES *pNodes, struct MESH *Mesh,
char *entity, char *res, struct SIMRES *pSimRes);

extern void nes_pproc_entity_builtin_elsets_orifield (struct SIM *pSim, struct TESS *pTess,
struct NODES *pNodes, struct MESH *Mesh,
char *entity, char *res, struct SIMRES *pSimRes);

extern void nes_pproc_entity_builtin_elsets_readodf (struct SIM *pSim, struct TESS Tess,
struct MESH *Mesh, char *entity, char *res,
struct SIMRES *pSimRes);
Expand Down
2 changes: 2 additions & 0 deletions src/neut/neut_odf/neut_odf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extern void neut_odf_convolve (struct ODF *pOdf, char *kernel);
extern void neut_odf_deconvolve (struct ODF *pOdf, char *kernel);

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

#endif /* NEUT_ODF_H */

Expand Down
25 changes: 25 additions & 0 deletions src/neut/neut_odf/neut_odf1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

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);
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);
extern double neut_odf_orifield_comp_elts (char *neigh, struct OL_SET *pOSet, QCLOUD nano_cloud,
my_kd_tree_t *nano_index, double *oridata, struct ODF *pOdf);
extern double neut_odf_orifield_comp_nodes (char *neigh, struct OL_SET *pOSet, QCLOUD nano_cloud,
my_kd_tree_t *nano_index, double *oridata, struct ODF *pOdf);

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

return;
}

void
neut_odf_orifield_comp (char *mode, char *neigh, struct OL_SET *pOSet,
double *oridata, struct ODF *pOdf)
{
my_kd_tree_t *nano_index = nullptr;
nanoflann::SearchParams params;
QCLOUD nano_cloud;

neut_oset_kdtree (pOSet, &nano_cloud, &nano_index);

if (strstr (mode, "m") || strstr (mode, "n"))
neut_odf_orifield_comp_elts (neigh, pOSet, nano_cloud, nano_index, oridata, pOdf);

if (strstr (mode, "n"))
neut_odf_orifield_comp_nodes (neigh, pOSet, nano_cloud, nano_index, oridata, pOdf);

delete nano_index;

return;
}
Loading

0 comments on commit 2a51636

Please sign in to comment.