Frame: add adaptive mesh refinement

This commit is contained in:
wyj committed 2026-08-28 23:06:53 -04:00
1 parent 4aa5f6666a
commit 48dcf4e707
7 files changed
+768 -72

No files matched your search

+20
View File
@@ -1,4 +1,5 @@
#include "geodesic.h"
#include "frame.h"
#include <math.h>
#include <stdio.h>
@@ -56,6 +57,25 @@ int main(void) {
central.status, inside_shadow.status, outside_shadow.status);
goto done;
}
/* A coarse field covering the shadow must genuinely refine: its initial
* capture/escape-discontinuous triangles are a separate trigger from the
* smooth direction-error criterion. */
FrameLensMesh mesh = {0};
const RefinementConfig refinement = {.max_level = 1,
.angle_absolute_rad = 1e-5,
.angle_relative = 1e-5,
.min_edge_pixels = 1.0,
.min_area_pixels2 = 1.0};
if (frame_lens_mesh_build_coarse(&mesh, 48, 48, 24, 40.0) ||
frame_lens_mesh_trace(&mesh, &spacetime, &observer, &trace) ||
frame_lens_mesh_refine(&mesh, &spacetime, &observer, &trace,
&refinement) ||
mesh.vertex_count <= 9 || mesh.triangle_count <= 8) {
fputs("Schwarzschild adaptive-refinement regression failed\n", stderr);
frame_lens_mesh_destroy(&mesh);
goto done;
}
frame_lens_mesh_destroy(&mesh);
result = 0;
done:
spacetime_destroy(&spacetime);