Skip to content

Issue 2000 - Generate thin mesh layer - #2011

Open
icui wants to merge 7 commits into
issue-1994from
issue-2000
Open

Issue 2000 - Generate thin mesh layer#2011
icui wants to merge 7 commits into
issue-1994from
issue-2000

Conversation

@icui

@icui icui commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Description

###Summary

Adds an optional thin SPECFEM++ database writer to MESHFEM3D Globe without touching the full mesh writer.

  • Introduces the SPECFEMPP_DATABASE Par_file option.
  • Writes one merged database per MPI rank.
  • Exports hex27 geometry, element context, boundaries, CSR adjacency, MPI interfaces, and resolved model configuration.
  • Keeps the existing solver database output unchanged.
  • Runs database validation through the uv examples dependency group.

Reference Geometry

Reference anchors are captured after Moho and radial-layer stretching, but before:

  • Surface topography
  • Ellipticity
  • Model-specific internal topography

A centralized specfempp_has_reference_geometry() helper determines whether reference geometry is required, including internal-topography models and SUPPRESS_INTERNAL_TOPOGRAPHY.

The database header contains an explicit HAS_REFERENCE_GEOMETRY flag so readers can determine whether the reference-node record is present without inferring it from other options.

Testing

  • Built xmeshfem3D_globe.
  • Ran the six-rank global mesh benchmark with and without reference geometry.
  • Validated database framing, geometry, connectivity, boundaries, adjacency, and MPI interfaces.

Issue Number

Closes #2000

Checklist

Please make sure to check developer documentation on specfem docs.

  • I ran the code through pre-commit to check style
  • THE DOCUMENTATION BUILDS WITHOUT WARNINGS/ERRORS
  • I have added labels to the PR (see right hand side of the PR page)
  • My code passes all the integration tests
  • I have added sufficient unittests to test my changes
  • I have added/updated documentation for the changes I am proposing
  • I have updated CMakeLists to ensure my code builds
  • My code builds across all platforms

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an optional “thin” SPECFEM++ mesh database output path in the MESHFEM3D globe mesher, gated by a new Par_file flag (SPECFEMPP_DATABASE), while keeping the existing solver database output unchanged. It also updates the global_small_mesh benchmark to exercise and validate the new thin-database output.

Changes:

  • Added SPECFEMPP_DATABASE parameter plumbing (read from Par_file, broadcast via MPI, carried through mesher control flow).
  • Added per-element context capture (reference anchors + shell bounds + crust flag) and hooks to accumulate per-region data and write a single merged output per rank.
  • Updated the globe benchmark configuration/workflow to enable ellipticity and run thin-database validation via uv “examples” dependencies.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
fortran/meshfem3d_globe/shared/shared_par.f90 Adds the SPECFEMPP_DATABASE input parameter with default .false..
fortran/meshfem3d_globe/shared/read_parameter_file.F90 Reads the new SPECFEMPP_DATABASE flag from the Par_file.
fortran/meshfem3d_globe/shared/broadcast_computed_parameters.f90 Broadcasts SPECFEMPP_DATABASE so non-root MPI ranks receive the flag.
fortran/meshfem3d_globe/shared/rules.mk Wires a new adjacency_graph shared object/module into the make-based build (currently references missing source/module).
fortran/meshfem3d_globe/shared/CMakeLists.txt Adds adjacency_graph.f90 to shared sources (currently references a missing file).
fortran/meshfem3d_globe/meshfem3D/meshfem3D_par.f90 Adds allocatable arrays to store per-element context for the thin database.
fortran/meshfem3d_globe/meshfem3D/compute_element_properties.f90 Captures reference-anchor coordinates and per-element radial bounds/crust flag for thin-db output.
fortran/meshfem3d_globe/meshfem3D/create_regions_mesh.F90 Allocates/deallocates thin-db context arrays and calls the region-accumulation hook when enabled.
fortran/meshfem3d_globe/meshfem3D/create_meshes.f90 Calls the final “write merged per-rank thin-db” hook after all regions complete.
fortran/meshfem3d_globe/meshfem3D/rules.mk Wires the new thin-db writer object/module into the make-based build (currently references missing source/module).
fortran/meshfem3d_globe/meshfem3D/CMakeLists.txt Adds save_database_specfempp.F90 to mesh sources (currently references a missing file).
benchmarks/src/dim3_globe/global_small_mesh/README.md Documents enabling SPECFEMPP_DATABASE and describes the validation coverage.
benchmarks/src/dim3_globe/global_small_mesh/DATA/Par_file Enables ELLIPTICITY and sets SPECFEMPP_DATABASE = .true. for the benchmark.
benchmarks/src/dim3_globe/global_small_mesh/CMakeLists.txt Adds a post-mesh uv run ... python check_database.py validation step (currently references a missing script).
benchmarks/src/dim3_globe/global_small_mesh/CMakeFiles/Snakefile.in Adds outputs and a check_database rule to validate the generated thin-db files (currently references a missing script).
Suppressed comments (2)

fortran/meshfem3d_globe/shared/rules.mk:99

  • shared_MODULES now expects $(FC_MODDIR)/adjacency_graph_shared.$(FC_MODEXT), but no module producing that .mod file is present in fortran/meshfem3d_globe/shared/ (and adjacency_graph.f90 itself is missing). This will cause the Makefile module dependency stage to fail.
shared_MODULES = \
	$(FC_MODDIR)/adjacency_graph_shared.$(FC_MODEXT) \
	$(FC_MODDIR)/constants.$(FC_MODEXT) \
	$(FC_MODDIR)/manager_adios.$(FC_MODEXT) \
	$(FC_MODDIR)/manager_hdf5.$(FC_MODEXT) \
	$(FC_MODDIR)/model_prem_par.$(FC_MODEXT) \

fortran/meshfem3d_globe/meshfem3D/rules.mk:150

  • meshfem3D_MODULES now expects $(FC_MODDIR)/specfempp_database_par.$(FC_MODEXT), but there is no source in this PR checkout that defines module specfempp_database_par. This will break the Makefile module dependency list and any use specfempp_database_par sites.
meshfem3D_MODULES = \
	$(FC_MODDIR)/specfempp_database_par.$(FC_MODEXT) \
	$(FC_MODDIR)/regions_mesh_par.$(FC_MODEXT) \
	$(FC_MODDIR)/regions_mesh_par2.$(FC_MODEXT) \
	$(FC_MODDIR)/mpi_interfaces_par.$(FC_MODEXT) \
	$(FC_MODDIR)/gapp2_mantle_model_constants.$(FC_MODEXT) \

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 88 to 93
moho_stretching.f90
save_arrays_solver.f90
save_arrays_solver_hdf5.F90
save_database_specfempp.F90
save_model_meshfiles.f90
save_model_meshfiles_hdf5.F90

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@icui This file is missing.

Comment on lines 14 to 18
set(MESHFEM3DG_SHARED_SOURCES
adjacency_graph.f90
assemble_MPI_scalar.f90
assemble_MPI_vector.f90
auto_ner.f90
Comment on lines 124 to 129
$O/moho_stretching.check.o \
$O/save_arrays_solver.check.o \
$O/save_arrays_solver_hdf5.check.o \
$O/save_database_specfempp.check.o \
$O/save_model_meshfiles.check.o \
$O/save_model_meshfiles_hdf5.check.o \
Comment on lines 12 to 17
file(
COPY
${CMAKE_CURRENT_SOURCE_DIR}/README.md
${CMAKE_CURRENT_SOURCE_DIR}/check_database.py
${CMAKE_CURRENT_SOURCE_DIR}/DATA
DESTINATION ${CURRENT_BENCHMARK_BUILD_DIR}
Comment on lines +40 to +46
input:
expand(
str(example_dir / "DATABASES_MPI" / "proc{rank:06d}_specfempp_database.bin"),
rank=range(nproc),
),
script=example_dir / "check_database.py",
output:
Comment on lines 35 to 39
$O/shared_par.shared_module.o \
$O/adios_manager.shared_adios_module.o \
$O/adjacency_graph.shared.o \
$O/assemble_MPI_scalar.shared.o \
$O/assemble_MPI_vector.shared.o \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants