commit 3eb6f036bf4aa674e9633c12e2184e9ec40e3e2b
parent cdcf1498af81f88763be76d33edf22e4888d933c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 19 Mar 2026 17:07:53 +0100
Change to the behaviour of the sln_mesh_eval function
Previously, the function returned the first or last value of the mesh if
the wave number in question lay below or above the mesh domain,
respectively. Now, in such situations, the value returned is 0, as, in
reality, the mesh node only influences the spectral domain on which it
is defined
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/sln_tree.c b/src/sln_tree.c
@@ -676,8 +676,12 @@ sln_mesh_eval(const struct sln_mesh* mesh, const double wavenumber)
/* Handle special cases */
if(n == 1) return mesh->vertices[0].ka;
- if(nu <= mesh->vertices[0].wavenumber) return mesh->vertices[0].ka;
- if(nu >= mesh->vertices[n-1].wavenumber) return mesh->vertices[n-1].ka;
+ if(nu < mesh->vertices[0].wavenumber
+ || nu > mesh->vertices[n-1].wavenumber) {
+ return 0;
+ }
+ if(nu == mesh->vertices[0].wavenumber) return mesh->vertices[0].ka;
+ if(nu == mesh->vertices[1].wavenumber) return mesh->vertices[1].ka;
/* Dichotomic search of the mesh vertex whose wavenumber is greater than or
* equal to the submitted wavenumber 'nu' */
diff --git a/src/test_sln_mesh.c b/src/test_sln_mesh.c
@@ -59,9 +59,9 @@ main(int argc, char** argv)
mesh.vertices = vertices;
mesh.nvertices = sizeof(vertices)/sizeof(vertices[0]);
- CHK(sln_mesh_eval(&mesh, 10) == 20);
+ CHK(sln_mesh_eval(&mesh, 10) == 0);
CHK(sln_mesh_eval(&mesh, 20) == 20);
- CHK(sln_mesh_eval(&mesh, 201) == 180);
+ CHK(sln_mesh_eval(&mesh, 201) == 0);
CHK(sln_mesh_eval(&mesh, 200) == 180);
FOR_EACH(i, 0, 100) {