commit a8b999b349bd90dac3ff41fc156b8e636634931c
parent 7e5465ec59e8987ea384b466519b0e1c8415f7d9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 6 Feb 2026 15:35:31 +0100
Update the mesh strategy for a line
The lines were over-meshed. The way they are meshed has therefore been
modified so that there are now far fewer vertices.
A line was divided into fixed intervals, in which a variable number of
vertices were added. The intervals are now variable in size. After a
distance from the center of the line that exceeds 3 times the width of
the line at mid-height, each new interval is twice as large as the
previous one.
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/sln_line.c b/src/sln_line.c
@@ -176,11 +176,11 @@ error:
goto exit;
}
-/* The line is regularly discretized into a set of fragments of fixed size.
- * Their discretization is finer for the fragments around the center of the
- * line and becomes coarser as the fragments move away from it. Note that a
- * line is symmetrical in its center. As a consequence, the returned list is
- * only the set of wavenumbers from the line center to its upper bound. */
+/* The line is regularly discretized into a set of fragments of variable size.
+ * Their discretization is finer for the fragments around the center of the line
+ * and becomes coarser as the fragments move away from it. Note that a line is
+ * symmetrical in its center. As a consequence, the returned list is only the
+ * set of wavenumbers from the line center to its upper bound. */
static res_T
regular_mesh_fragmented
(const struct sln_tree* tree,
@@ -192,6 +192,7 @@ regular_mesh_fragmented
double fragment_length = 0;
double fragment_nu_min = 0; /* Lower bound of the fragment */
size_t fragment_nvtx = 0; /* #vertices into the fragment */
+ size_t nfragments = 0; /* Number of fragments already meshed */
/* Miscellaneous */
const struct sln_molecule* mol_params = NULL;
@@ -225,6 +226,9 @@ regular_mesh_fragmented
(fragment_nu_min, spectral_length, fragment_nvtx, wavenumbers);
if(res != RES_OK) goto error;
+ /* After the third fragment, exponentially increase the fragment length */
+ if(++nfragments >= 3) fragment_length *= 2;
+
fragment_nu_min += fragment_length;
fragment_nvtx = MMAX(fragment_nvtx/2, 2);
}