From 0e281f23ccda138a47b631e0eb96eac6231f4824 Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Thu, 29 Aug 2024 13:49:20 -0300 Subject: [PATCH 1/8] add set_information_message and set_warning_message --- src/alfasim_sdk/alfasim_sdk_api/api.h | 18 ++++++++++++++++++ .../alfasim_sdk_api/detail/api_pointers.h | 5 +++++ .../alfasim_sdk_api/detail/bootstrap_linux.h | 2 ++ .../alfasim_sdk_api/detail/bootstrap_win.h | 2 ++ 4 files changed, 27 insertions(+) diff --git a/src/alfasim_sdk/alfasim_sdk_api/api.h b/src/alfasim_sdk/alfasim_sdk_api/api.h index af807a6f..13ec7dd5 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/api.h +++ b/src/alfasim_sdk/alfasim_sdk_api/api.h @@ -620,6 +620,24 @@ DLL_EXPORT int get_deposition_thickness( void* ctx, double** out, int phase_id, enum TimestepScope ts_scope, int* size ); +/*! + Sets a warning message at the solver logger. + + @param[in] ctx ALFAsim's plugins context. + @param[in] warning_message Warning Message. + @return An #error_code value. +*/ +DLL_EXPORT int set_warning_message(const char* warning_message); + +/*! + Sets an information message at the solver logger. + + @param[in] ctx ALFAsim's plugins context. + @param[in] info_message Information Message. + @return An #error_code value. +*/ +DLL_EXPORT int set_information_message(const char* info_message); + /*! Retrieves the tracer ID given a tracer reference. A tracer reference may be obtained from the user input data (See #get_plugin_input_data_reference API function for an example). diff --git a/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h b/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h index e0b39789..db819e2e 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h @@ -82,6 +82,8 @@ using get_flow_pattern_func = int (*)( int* size ); using get_deposition_thickness_func = int (*)(void* ctx, double** out, int phase_id, enum TimestepScope ts_scope, int* size); +using set_warning_message_func = int (*)(const char* warning_message); +using set_information_message_func = int (*)(const char* information_message); using get_tracer_id_func = int (*)(void* ctx, int* tracer_id, void* reference); using get_tracer_name_size_func = int (*)(void* ctx, int* tracer_name_size, void* reference); using get_tracer_name_func = int (*)(void* ctx, char* tracer_name, void* reference, int size); @@ -146,6 +148,9 @@ struct ALFAsimSDK_API { get_deposition_thickness_func get_deposition_thickness; + set_warning_message_func set_warning_message; + set_information_message_func set_information_message; + get_tracer_id_func get_tracer_id; get_tracer_name_size_func get_tracer_name_size; get_tracer_name_func get_tracer_name; diff --git a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h index 44285089..1ac1602a 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h @@ -80,6 +80,8 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api) api->get_flow_pattern = (get_flow_pattern_func)dlsym(api->handle, "get_flow_pattern"); api->get_liqliq_flow_pattern = (get_flow_pattern_func)dlsym(api->handle, "get_liqliq_flow_pattern"); api->get_deposition_thickness = (get_deposition_thickness_func)dlsym(api->handle, "get_deposition_thickness"); + api->set_warning_message = (set_warning_message_func)dlsym(api->handle, "set_warning_message"); + api->set_information_message = (set_information_message_func)dlsym(api->handle, "set_information_message"); api->get_plugin_input_data_table_quantity = (get_plugin_input_data_table_quantity_func)dlsym(api->handle, "get_plugin_input_data_table_quantity"); api->get_tracer_id = (get_tracer_id_func)dlsym(api->handle, "get_tracer_id"); api->get_tracer_name_size = (get_tracer_name_size_func)dlsym(api->handle, "get_tracer_name_size"); diff --git a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h index 797eb24b..5ba693a9 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h @@ -104,6 +104,8 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api) api->get_flow_pattern = (get_flow_pattern_func)GetProcAddress(api->handle, "get_flow_pattern"); api->get_liqliq_flow_pattern = (get_flow_pattern_func)GetProcAddress(api->handle, "get_liqliq_flow_pattern"); api->get_deposition_thickness = (get_deposition_thickness_func)GetProcAddress(api->handle, "get_deposition_thickness"); + api->set_warning_message = (set_warning_message_func)GetProcAddress(api->handle, "set_warning_message"); + api->set_information_message = (set_information_message_func)GetProcAddress(api->handle, "set_information_message"); api->get_plugin_input_data_table_quantity = (get_plugin_input_data_table_quantity_func)GetProcAddress(api->handle, "get_plugin_input_data_table_quantity"); api->get_tracer_id = (get_tracer_id_func)GetProcAddress(api->handle, "get_tracer_id"); api->get_tracer_name_size = (get_tracer_name_size_func)GetProcAddress(api->handle, "get_tracer_name_size"); From 6f9e7effee07ad253e5278e97105ca408ec20314 Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Thu, 29 Aug 2024 13:49:36 -0300 Subject: [PATCH 2/8] add documentation --- docs/source/plugins/99_1_solver_api_reference.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/plugins/99_1_solver_api_reference.rst b/docs/source/plugins/99_1_solver_api_reference.rst index c007dd0d..9c553b2d 100644 --- a/docs/source/plugins/99_1_solver_api_reference.rst +++ b/docs/source/plugins/99_1_solver_api_reference.rst @@ -163,6 +163,11 @@ ALFAsim's Solver Data .. doxygenfunction:: get_flow_pattern +.. doxygenfunction:: set_warning_message + +.. doxygenfunction:: set_information_message + + Unit Cell Model (UCM) helpers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From e3b76462316cb6bcaa2421bca1156846deced1a4 Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Mon, 2 Sep 2024 13:30:17 -0300 Subject: [PATCH 3/8] change set_ to log_ --- docs/source/plugins/99_1_solver_api_reference.rst | 4 ++-- src/alfasim_sdk/alfasim_sdk_api/api.h | 4 ++-- src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h | 8 ++++---- src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h | 4 ++-- src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/source/plugins/99_1_solver_api_reference.rst b/docs/source/plugins/99_1_solver_api_reference.rst index 9c553b2d..203ffb48 100644 --- a/docs/source/plugins/99_1_solver_api_reference.rst +++ b/docs/source/plugins/99_1_solver_api_reference.rst @@ -163,9 +163,9 @@ ALFAsim's Solver Data .. doxygenfunction:: get_flow_pattern -.. doxygenfunction:: set_warning_message +.. doxygenfunction:: log_warning_message -.. doxygenfunction:: set_information_message +.. doxygenfunction:: log_information_message diff --git a/src/alfasim_sdk/alfasim_sdk_api/api.h b/src/alfasim_sdk/alfasim_sdk_api/api.h index 13ec7dd5..22ae761f 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/api.h +++ b/src/alfasim_sdk/alfasim_sdk_api/api.h @@ -627,7 +627,7 @@ DLL_EXPORT int get_deposition_thickness( @param[in] warning_message Warning Message. @return An #error_code value. */ -DLL_EXPORT int set_warning_message(const char* warning_message); +DLL_EXPORT int log_warning_message(const char* warning_message); /*! Sets an information message at the solver logger. @@ -636,7 +636,7 @@ DLL_EXPORT int set_warning_message(const char* warning_message); @param[in] info_message Information Message. @return An #error_code value. */ -DLL_EXPORT int set_information_message(const char* info_message); +DLL_EXPORT int log_information_message(const char* info_message); /*! Retrieves the tracer ID given a tracer reference. A tracer reference may be obtained from the diff --git a/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h b/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h index db819e2e..e40d15d3 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h @@ -82,8 +82,8 @@ using get_flow_pattern_func = int (*)( int* size ); using get_deposition_thickness_func = int (*)(void* ctx, double** out, int phase_id, enum TimestepScope ts_scope, int* size); -using set_warning_message_func = int (*)(const char* warning_message); -using set_information_message_func = int (*)(const char* information_message); +using log_warning_message_func = int (*)(const char* warning_message); +using log_information_message_func = int (*)(const char* information_message); using get_tracer_id_func = int (*)(void* ctx, int* tracer_id, void* reference); using get_tracer_name_size_func = int (*)(void* ctx, int* tracer_name_size, void* reference); using get_tracer_name_func = int (*)(void* ctx, char* tracer_name, void* reference, int size); @@ -148,8 +148,8 @@ struct ALFAsimSDK_API { get_deposition_thickness_func get_deposition_thickness; - set_warning_message_func set_warning_message; - set_information_message_func set_information_message; + log_warning_message_func log_warning_message; + log_information_message_func log_information_message; get_tracer_id_func get_tracer_id; get_tracer_name_size_func get_tracer_name_size; diff --git a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h index 1ac1602a..3fee788e 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h @@ -80,8 +80,8 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api) api->get_flow_pattern = (get_flow_pattern_func)dlsym(api->handle, "get_flow_pattern"); api->get_liqliq_flow_pattern = (get_flow_pattern_func)dlsym(api->handle, "get_liqliq_flow_pattern"); api->get_deposition_thickness = (get_deposition_thickness_func)dlsym(api->handle, "get_deposition_thickness"); - api->set_warning_message = (set_warning_message_func)dlsym(api->handle, "set_warning_message"); - api->set_information_message = (set_information_message_func)dlsym(api->handle, "set_information_message"); + api->log_warning_message = (log_warning_message_func)dlsym(api->handle, "log_warning_message"); + api->log_information_message = (log_information_message_func)dlsym(api->handle, "log_information_message"); api->get_plugin_input_data_table_quantity = (get_plugin_input_data_table_quantity_func)dlsym(api->handle, "get_plugin_input_data_table_quantity"); api->get_tracer_id = (get_tracer_id_func)dlsym(api->handle, "get_tracer_id"); api->get_tracer_name_size = (get_tracer_name_size_func)dlsym(api->handle, "get_tracer_name_size"); diff --git a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h index 5ba693a9..021dc592 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h @@ -104,8 +104,8 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api) api->get_flow_pattern = (get_flow_pattern_func)GetProcAddress(api->handle, "get_flow_pattern"); api->get_liqliq_flow_pattern = (get_flow_pattern_func)GetProcAddress(api->handle, "get_liqliq_flow_pattern"); api->get_deposition_thickness = (get_deposition_thickness_func)GetProcAddress(api->handle, "get_deposition_thickness"); - api->set_warning_message = (set_warning_message_func)GetProcAddress(api->handle, "set_warning_message"); - api->set_information_message = (set_information_message_func)GetProcAddress(api->handle, "set_information_message"); + api->log_warning_message = (log_warning_message_func)GetProcAddress(api->handle, "log_warning_message"); + api->log_information_message = (log_information_message_func)GetProcAddress(api->handle, "log_information_message"); api->get_plugin_input_data_table_quantity = (get_plugin_input_data_table_quantity_func)GetProcAddress(api->handle, "get_plugin_input_data_table_quantity"); api->get_tracer_id = (get_tracer_id_func)GetProcAddress(api->handle, "get_tracer_id"); api->get_tracer_name_size = (get_tracer_name_size_func)GetProcAddress(api->handle, "get_tracer_name_size"); From f605ca3362638d6e932e39fce99692f8c6e5139a Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Mon, 2 Sep 2024 13:36:25 -0300 Subject: [PATCH 4/8] update doc --- docs/source/plugins/99_1_solver_api_reference.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/source/plugins/99_1_solver_api_reference.rst b/docs/source/plugins/99_1_solver_api_reference.rst index 203ffb48..14e05677 100644 --- a/docs/source/plugins/99_1_solver_api_reference.rst +++ b/docs/source/plugins/99_1_solver_api_reference.rst @@ -163,11 +163,6 @@ ALFAsim's Solver Data .. doxygenfunction:: get_flow_pattern -.. doxygenfunction:: log_warning_message - -.. doxygenfunction:: log_information_message - - Unit Cell Model (UCM) helpers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -192,6 +187,13 @@ Liquid-Liquid Mechanistic Model helpers .. _var_name_parsing: +Solver Logging +~~~~~~~~~~~~~~ + +.. doxygenfunction:: log_warning_message + +.. doxygenfunction:: log_information_message + Variable Name Parsing ~~~~~~~~~~~~~~~~~~~~~ From c56dc8fd53871fee5d839b0eac4fbd36b9328ab8 Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Mon, 2 Sep 2024 14:15:43 -0300 Subject: [PATCH 5/8] update ctx and plugin_id --- src/alfasim_sdk/alfasim_sdk_api/api.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/alfasim_sdk/alfasim_sdk_api/api.h b/src/alfasim_sdk/alfasim_sdk_api/api.h index 22ae761f..d93a73db 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/api.h +++ b/src/alfasim_sdk/alfasim_sdk_api/api.h @@ -624,19 +624,21 @@ DLL_EXPORT int get_deposition_thickness( Sets a warning message at the solver logger. @param[in] ctx ALFAsim's plugins context. + @param[in] plugin_id ALFAsim's plugins id @param[in] warning_message Warning Message. @return An #error_code value. */ -DLL_EXPORT int log_warning_message(const char* warning_message); +DLL_EXPORT int log_warning_message(void* ctx, const char* plugin_id, const char* warning_message); /*! Sets an information message at the solver logger. @param[in] ctx ALFAsim's plugins context. + @param[in] plugin_id ALFAsim's plugins id @param[in] info_message Information Message. @return An #error_code value. */ -DLL_EXPORT int log_information_message(const char* info_message); +DLL_EXPORT int log_information_message(void* ctx, const char* plugin_id, const char* info_message); /*! Retrieves the tracer ID given a tracer reference. A tracer reference may be obtained from the From 24e40fc5b81b76053f703267e9441d8aae72ff9e Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Mon, 2 Sep 2024 17:26:53 -0300 Subject: [PATCH 6/8] add ctx --- src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h b/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h index e40d15d3..c69f189e 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h @@ -82,8 +82,8 @@ using get_flow_pattern_func = int (*)( int* size ); using get_deposition_thickness_func = int (*)(void* ctx, double** out, int phase_id, enum TimestepScope ts_scope, int* size); -using log_warning_message_func = int (*)(const char* warning_message); -using log_information_message_func = int (*)(const char* information_message); +using log_warning_message_func = int (*)(void* ctx, const char* plugin_id,const char* warning_message); +using log_information_message_func = int (*)(void* ctx, const char* plugin_id, const char* information_message); using get_tracer_id_func = int (*)(void* ctx, int* tracer_id, void* reference); using get_tracer_name_size_func = int (*)(void* ctx, int* tracer_name_size, void* reference); using get_tracer_name_func = int (*)(void* ctx, char* tracer_name, void* reference, int size); From 94def81b10325c244069f8492aa80acbeb9ac302 Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Mon, 2 Sep 2024 17:31:16 -0300 Subject: [PATCH 7/8] fix documentation --- src/alfasim_sdk/alfasim_sdk_api/api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alfasim_sdk/alfasim_sdk_api/api.h b/src/alfasim_sdk/alfasim_sdk_api/api.h index d93a73db..9bc2a630 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/api.h +++ b/src/alfasim_sdk/alfasim_sdk_api/api.h @@ -621,7 +621,7 @@ DLL_EXPORT int get_deposition_thickness( ); /*! - Sets a warning message at the solver logger. + Logs a warning message at the solver logger. @param[in] ctx ALFAsim's plugins context. @param[in] plugin_id ALFAsim's plugins id @@ -631,7 +631,7 @@ DLL_EXPORT int get_deposition_thickness( DLL_EXPORT int log_warning_message(void* ctx, const char* plugin_id, const char* warning_message); /*! - Sets an information message at the solver logger. + Logs an information message at the solver logger. @param[in] ctx ALFAsim's plugins context. @param[in] plugin_id ALFAsim's plugins id From f891a973b26b7f587f7d624bc510414941a03c5f Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Tue, 3 Sep 2024 10:25:33 -0300 Subject: [PATCH 8/8] add doc and update CHANGELOG.rst --- CHANGELOG.rst | 1 + src/alfasim_sdk/alfasim_sdk_api/api.h | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 18b221cb..1a71f65e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ CHANGELOG =================== * Added support to read historic data curves directly from the results of History Matching analyses. +* Added support for warning and information logging. 2024.1 (2024-05-27) diff --git a/src/alfasim_sdk/alfasim_sdk_api/api.h b/src/alfasim_sdk/alfasim_sdk_api/api.h index 9bc2a630..da72544d 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/api.h +++ b/src/alfasim_sdk/alfasim_sdk_api/api.h @@ -622,6 +622,7 @@ DLL_EXPORT int get_deposition_thickness( /*! Logs a warning message at the solver logger. + Information will be logged as follow: "Warning: {warning_message}" @param[in] ctx ALFAsim's plugins context. @param[in] plugin_id ALFAsim's plugins id