From 022042071b715ee1f7939a2530367087a08d0ec2 Mon Sep 17 00:00:00 2001 From: Alexandre Barbosa Bruno Date: Wed, 28 Aug 2024 10:45:15 -0300 Subject: [PATCH] Add a possibility to plugin user gets wall properties (#398) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add get_wall_properties * add get_wall_material_names * add get_wall_material_type --------- Co-authored-by: Martin PrĂ¼sse Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../plugins/99_1_solver_api_reference.rst | 8 ++ src/alfasim_sdk/alfasim_sdk_api/api.h | 107 ++++++++++++++++++ .../alfasim_sdk_api/detail/api_pointers.h | 23 ++++ .../alfasim_sdk_api/detail/bootstrap_linux.h | 3 + .../alfasim_sdk_api/detail/bootstrap_win.h | 3 + 5 files changed, 144 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..a491ca3d 100644 --- a/docs/source/plugins/99_1_solver_api_reference.rst +++ b/docs/source/plugins/99_1_solver_api_reference.rst @@ -149,6 +149,14 @@ ALFAsim's Solver Data .. doxygenfunction:: get_simulation_quantity +.. doxygenfunction:: get_wall_properties + +.. warning:: + Changing the contents retrieved by this function (`out` array) has **UNDEFINED BEHAVIOR**. + The plugin must **NEVER** change the contents returned by this function. + +.. doxygenfunction:: get_wall_material_type + .. doxygenfunction:: get_tracer_id .. doxygenfunction:: get_tracer_name_size diff --git a/src/alfasim_sdk/alfasim_sdk_api/api.h b/src/alfasim_sdk/alfasim_sdk_api/api.h index af807a6f..740d2029 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/api.h +++ b/src/alfasim_sdk/alfasim_sdk_api/api.h @@ -812,6 +812,113 @@ DLL_EXPORT int get_liq_liq_flow_pattern_input_variable( void* ctx, double* out, const char* var_name, int phase_id ); +/*! + Gets the properties of the materials presented in each layer of wall for a given control volume. + The properties will be given an array data pointer. This method also provide the + size of the given arrays. + + IMPORTANT: + The given wall can be a fluid or solid, be aware of this when you start to use the properties. + List of fluid properties: + - Volumetric Thermal Expansion + - Dynamic Viscosity + + List of `prop_name`: + - `"layer_thickness"`: Wall Layer Thickness [m] + - `"rho"`: Wall Density [kg/m3] + - `"cp"`: Wall Specific Heat Capacity [J/kg.K] + - `"volumetric_thermal_expansion"`: Wall Volumetric Thermal Expansion [1/K] + - `"mu"`: Wall dynamic viscosity [Pa.s] + - `"k"` : Wall Thermal Conductivity [W/m.degC] + + Example of usage: + + ~~~~~{.cpp} + + [prop_wall_4] + [prop_wall_3] [prop_wall_3] + [prop_wall_2] [prop_wall_2] [prop_wall_2] + [prop_wall_1] [prop_wall_1] [prop_wall_1] + [prop_wall_0] [prop_wall_0] [prop_wall_0] + | | | + --[control_volume_1]--[control_volume_2]--[control_volume_3]--> (Pipe) + ~~~~~ + + ~~~~~{.cpp} + errcode = get_wall_properties( + ctx, &prop_values, "layer_thickness", control_volume_id, &size_wall); + ~~~~~ + + @param[in] ctx ALFAsim's plugins context. + @param[out] prop_values Properties in each layer of the wall array. + @param[in] prop_name String with the property name. See the list of possible values above. + @param[in] control_volume_id Control volume id. + @param[out] size Size of the `prop_values` array. + @return An #error_code value. +*/ +DLL_EXPORT int get_wall_properties(void* ctx, double** prop_values, const char* prop_name, int control_volume_id, int* size); + + +/*! + Gets the names of the materials presented in each layer of the wall for a given control volume. + The names will be given as an array of char pointers. + + Example of usage: + + ~~~~~{.cpp} + + [material_name_4] + [material_name_3] [material_name_3] + [material_name_2] [material_name_2] [material_name_2] + [material_name_1] [material_name_1] [material_name_1] + [material_name_0] [material_name_0] [material_name_0] + | | | + --[control_volume_1]--[control_volume_2]--[control_volume_3]--> (Pipe) + ~~~~~ + + ~~~~~{.cpp} + errcode = get_wall_material_names( + ctx, &material_names_in_wall, control_volume_id, &size_wall); + ~~~~~ + + @param[in] ctx ALFAsim's plugins context. + @param[out] material_names_in_wall Names of the material presented in the wall. + @param[in] control_volume_id Control volume id. + @param[out] size Size of the `material_names_in_wall` array. + @return An #error_code value. +*/ +DLL_EXPORT int get_wall_material_names(void* ctx, char*** material_names_in_wall, int control_volume_id, int* size); + +/*! + Gets the information if the each layer in the wall is fluid or not for a given control volume. + This method also provide the size of the given arrays. + + ~~~~~{.cpp} + + Example of usage: + + [wall_material_type_4] + [wall_material_type_3] [wall_material_type_3] + [wall_material_type_2] [wall_material_type_2] [wall_material_type_2] + [wall_material_type_1] [wall_material_type_1] [wall_material_type_1] + [wall_material_type_0] [wall_material_type_0] [wall_material_type_0] + | | | + --[control_volume_1]------[control_volume_2]------[control_volume_3]--> (Pipe) + ~~~~~ + + ~~~~~{.cpp} + errcode = get_wall_material_type( + ctx, &wall_material, control_volume_id, &size_wall); + ~~~~~ + + @param[in] ctx ALFAsim's plugins context. + @param[out] wall_material_type Informs if the wall layer material type [1 - is fluid; 0 - is not fluid] + @param[in] control_volume Control volume id. + @param[out] size Size of the `wall_material_type` array. + @return An #error_code value. +*/ +DLL_EXPORT int get_wall_material_type(void* ctx, int** wall_material_type, int control_volume_id, int* size); + /*! Gets the current input data for liquid effective viscosity calculation. Any available variable by this function is considered for a control volume, which means that there are variables with one 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..d9fcc3c0 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h @@ -74,6 +74,25 @@ using get_wall_interfaces_temperature_func = int (*)( enum TimestepScope ts_scope, int* size ); +using get_wall_properties_func = int (*) ( + void* ctx, + double** prop_values, + const char* prop_name, + int control_volume_id, + int* size + ); +using get_wall_material_names_func = int (*) ( + void* ctx, + char*** wall_names, + int control_volume_id, + int* size + ); +using get_wall_material_type_func = int (*) ( + void* ctx, + int** wall_material_type, + int control_volume_id, + int* size + ); using get_flow_pattern_func = int (*)( void* ctx, int** out, @@ -154,6 +173,10 @@ struct ALFAsimSDK_API { get_wall_interfaces_temperature_func get_wall_interfaces_temperature; + get_wall_properties_func get_wall_properties; + get_wall_material_names_func get_wall_material_names; + get_wall_material_type_func get_wall_material_type; + get_input_variable_func get_ucm_friction_factor_input_variable; get_ucm_fluid_geometrical_properties_func get_ucm_fluid_geometrical_properties; get_input_variable_func get_liq_liq_flow_pattern_input_variable; 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..c4a7a7de 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h @@ -77,6 +77,9 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api) api->get_simulation_tracer_array = (get_simulation_tracer_array_func)dlsym(api->handle, "get_simulation_tracer_array"); api->get_simulation_quantity = (get_simulation_quantity_func)dlsym(api->handle, "get_simulation_quantity"); api->get_wall_interfaces_temperature = (get_wall_interfaces_temperature_func)dlsym(api->handle, "get_wall_interfaces_temperature"); + api->get_wall_properties = (get_wall_properties_func)dlsym(api->handle, "get_wall_properties"); + api->get_wall_material_names = (get_wall_material_names_func)dlsym(api->handle, "get_wall_material_names"); + api->get_wall_material_type = (get_wall_material_type_func)dlsym(api->handle, "get_wall_material_type"); 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"); 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..03f70831 100644 --- a/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h +++ b/src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h @@ -101,6 +101,9 @@ inline int alfasim_sdk_open(ALFAsimSDK_API* api) api->get_simulation_tracer_array = (get_simulation_tracer_array_func)GetProcAddress(api->handle, "get_simulation_tracer_array"); api->get_simulation_quantity = (get_simulation_quantity_func)GetProcAddress(api->handle, "get_simulation_quantity"); api->get_wall_interfaces_temperature = (get_wall_interfaces_temperature_func)GetProcAddress(api->handle, "get_wall_interfaces_temperature"); + api->get_wall_properties = (get_wall_properties_func)GetProcAddress(api->handle, "get_wall_properties"); + api->get_wall_material_names = (get_wall_material_names_func)GetProcAddress(api->handle, "get_wall_material_names"); + api->get_wall_material_type = (get_wall_material_type_func)GetProcAddress(api->handle, "get_wall_material_type"); 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");