Skip to content

Commit

Permalink
Add a possibility to plugin user gets wall properties (#398)
Browse files Browse the repository at this point in the history
* add get_wall_properties

* add get_wall_material_names

* add get_wall_material_type

---------

Co-authored-by: Martin Prüsse <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent 25b2fbf commit 0220420
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/source/plugins/99_1_solver_api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
107 changes: 107 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/detail/api_pointers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions src/alfasim_sdk/alfasim_sdk_api/detail/bootstrap_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 0220420

Please sign in to comment.