The terra::io::XDMFOutput class implements a combined format for storing simulation data that can be visualized in Paraview, and can also be loaded back into the simulation (i.e., it serves as a checkpoint).
Refer to the terra::io::XDMFOutput class documentation for more details. It is quite exhaustively documented.
Have a look at the terra::util::Table class for writing all sorts of tabular data. Also, just for writing to the console this class can be useful. Consider this for writing to CSV or JSON files.
Radial profiles can be read from CSV files. Have a look at the functions terra::shell::interpolate_radial_profile_into_subdomains() and terra::shell::interpolate_radial_profile_into_subdomains_from_csv() for more details.
A small tool for reading and visualizing radial profiles is provided in apps/tools/visualize_radial_profiles.cpp.
Sometimes a physical quantity depends on two independent variables that are known at every mesh node — a common example in mantle dynamics is density (or viscosity, heat capacity, …) as a function of pressure and temperature. Such relationships are often pre-tabulated on a regular 2D grid and need to be evaluated at every node during a simulation.
This is different from the terra::util::Table class described above, which is a generic key-value store for logging and analysis. The lookup table described here is a compact, device-capable structure designed for fast bilinear interpolation inside Kokkos kernels.
The relevant types and functions live in terra/io/lookup_table_2d_reader.hpp:
x_min, y_min), spacings (dx, dy), point counts (nx, ny), and how the flat file data maps to 2D indices via stride_x / stride_y.operator()(x, y) performs bilinear interpolation and clamps queries that fall outside the table domain to the nearest boundary value.The file format is deliberately flexible: columns may be separated by spaces, tabs, commas, or any mixture thereof, and lines starting with # are treated as comments.
An annotated example is provided at data/lookup_tables/density_p_T_example.dat. It maps pressure (3 points, 0–10 GPa) and temperature (4 points, 1000–2500 K) to density, and is laid out with pressure as the outer loop (x-outer):
A small visualization tool is provided in apps/tools/visualize_lookup_table_2d.cpp. It reads one or more columns from a table file, maps each mesh node to a (pressure, temperature) pair via a selectable source function, evaluates the lookup table at every node, and writes the result as XDMF. Two source functions are available: cartesian (pressure linear in Cartesian x, temperature linear in Cartesian y) and radial (pressure linear in radius, temperature linear in colatitude). Run with --help for the full list of options.
Have a look at the functions terra::shell::radial_profiles() and terra::shell::radial_profiles_to_table() that compute radial profiles of the shell (min/max/avg) on the device and write them to a table (terra::util::Table) if desired. This way if can easily be written to console, JSON, or CSV files.