|
24 | 24 | TRIXI_FPTR_LOAD_NODE_WEIGHTS, |
25 | 25 | TRIXI_FTPR_LOAD_PRIMITIVE_VARS, |
26 | 26 | TRIXI_FTPR_LOAD_ELEMENT_AVERAGED_PRIMITIVE_VARS, |
| 27 | + TRIXI_FTPR_REGISTER_DATA, |
27 | 28 | TRIXI_FTPR_VERSION_LIBRARY, |
28 | 29 | TRIXI_FTPR_VERSION_LIBRARY_MAJOR, |
29 | 30 | TRIXI_FTPR_VERSION_LIBRARY_MINOR, |
|
32 | 33 | TRIXI_FTPR_VERSION_JULIA_EXTENDED, |
33 | 34 | TRIXI_FTPR_EVAL_JULIA, |
34 | 35 | TRIXI_FTPR_GET_T8CODE_FOREST, |
| 36 | + TRIXI_FPTR_GET_SIMULATION_TIME, |
35 | 37 |
|
36 | 38 | // The last one is for the array size |
37 | 39 | TRIXI_NUM_FPTRS |
@@ -60,14 +62,16 @@ static const char* trixi_function_pointer_names[] = { |
60 | 62 | [TRIXI_FPTR_LOAD_NODE_WEIGHTS] = "trixi_load_node_weights_cfptr", |
61 | 63 | [TRIXI_FTPR_LOAD_PRIMITIVE_VARS] = "trixi_load_primitive_vars_cfptr", |
62 | 64 | [TRIXI_FTPR_LOAD_ELEMENT_AVERAGED_PRIMITIVE_VARS] = "trixi_load_element_averaged_primitive_vars_cfptr", |
| 65 | + [TRIXI_FTPR_REGISTER_DATA] = "trixi_register_data_cfptr", |
63 | 66 | [TRIXI_FTPR_VERSION_LIBRARY] = "trixi_version_library_cfptr", |
64 | 67 | [TRIXI_FTPR_VERSION_LIBRARY_MAJOR] = "trixi_version_library_major_cfptr", |
65 | 68 | [TRIXI_FTPR_VERSION_LIBRARY_MINOR] = "trixi_version_library_minor_cfptr", |
66 | 69 | [TRIXI_FTPR_VERSION_LIBRARY_PATCH] = "trixi_version_library_patch_cfptr", |
67 | 70 | [TRIXI_FTPR_VERSION_JULIA] = "trixi_version_julia_cfptr", |
68 | 71 | [TRIXI_FTPR_VERSION_JULIA_EXTENDED] = "trixi_version_julia_extended_cfptr", |
69 | 72 | [TRIXI_FTPR_EVAL_JULIA] = "trixi_eval_julia_cfptr", |
70 | | - [TRIXI_FTPR_GET_T8CODE_FOREST] = "trixi_get_t8code_forest_cfptr" |
| 73 | + [TRIXI_FTPR_GET_T8CODE_FOREST] = "trixi_get_t8code_forest_cfptr", |
| 74 | + [TRIXI_FPTR_GET_SIMULATION_TIME] = "trixi_get_simulation_time_cfptr" |
71 | 75 | }; |
72 | 76 |
|
73 | 77 | // Track initialization/finalization status to prevent unhelpful errors |
@@ -691,6 +695,58 @@ void trixi_load_element_averaged_primitive_vars(int handle, int variable_id, dou |
691 | 695 | } |
692 | 696 |
|
693 | 697 |
|
| 698 | +/** |
| 699 | + * @anchor trixi_register_data_api_c |
| 700 | + * |
| 701 | + * @brief Store data vector in current simulation's registry |
| 702 | + * |
| 703 | + * A reference to the passed data array `data` will be stored in the registry of the |
| 704 | + * simulation given by `simstate_handle` at given `index`. The registry object has to be |
| 705 | + * created in `init_simstate()` of the running libelixir and can be used throughout the |
| 706 | + * simulation. |
| 707 | + * |
| 708 | + * The registry object has to exist, has to be of type `LibTrixiDataRegistry`, and has to |
| 709 | + * hold enough data references such that access at `index` is valid. |
| 710 | + * Memory storage remains on the user side. It must not be deallocated as long as it might |
| 711 | + * be accessed via the registry. The size of `data` has to match `size`. |
| 712 | + * |
| 713 | + * @param[in] handle simulation handle |
| 714 | + * @param[in] index index in registry where data vector will be stored |
| 715 | + * @param[in] size size of given data vector |
| 716 | + * @param[in] data data vector to store |
| 717 | + */ |
| 718 | +void trixi_register_data(int handle, int index, int size, const double * data) { |
| 719 | + |
| 720 | + // Get function pointer |
| 721 | + void (*register_data)(int, int, int, const double *) = |
| 722 | + trixi_function_pointers[TRIXI_FTPR_REGISTER_DATA]; |
| 723 | + |
| 724 | + // Call function |
| 725 | + register_data(handle, index, size, data); |
| 726 | +} |
| 727 | + |
| 728 | + |
| 729 | +/** |
| 730 | + * @anchor trixi_get_simulation_time_api_c |
| 731 | + * |
| 732 | + * @brief Return current physical time. |
| 733 | + * |
| 734 | + * @param[in] handle simulation handle |
| 735 | + * |
| 736 | + * @return physical time |
| 737 | + */ |
| 738 | +double trixi_get_simulation_time(int handle) { |
| 739 | + |
| 740 | + // Get function pointer |
| 741 | + double (*get_simulation_time)(int) = |
| 742 | + trixi_function_pointers[TRIXI_FPTR_GET_SIMULATION_TIME]; |
| 743 | + |
| 744 | + // Call function |
| 745 | + return get_simulation_time(handle); |
| 746 | +} |
| 747 | + |
| 748 | + |
| 749 | + |
694 | 750 | /******************************************************************************************/ |
695 | 751 | /* T8code */ |
696 | 752 | /******************************************************************************************/ |
|
0 commit comments