UDFs and Tables¶
User-Defined Functions (UDF) and Tables are customizations written by the user to extend or modify physics within the model beyond the built-in implementation. UDFs and Tables are incorporated into the model using the UDF Editor and Table Editor, found on the selections or parameters in the property grid with a UDF/Table edit button. These customizations are embedded in the model as part of the M-Star pre-processing file (.msb) and require no external linking or compiling.
UDF Editor and Table Editor
UDF Editor and Table Editor: Enables users to define and manage UDFs and tables directly within the software. The customizable settings and selections on the property grid offer a UDF/Table edit button. Not all settings and selections can be customized via runtime UDFs or custom tables; however, these settings can be adjusted between simulations using parameter sweeps.
UDFs
A UDF is a reusable script written in C syntax that the software executes at each simulation time step. UDFs can process input values and return outputs, enabling custom functions such as chemical reactions, custom rheology, custom particle forces, etc. UDFs in M-Star CFD are compiled and executed at runtime and can be classified into two categories:
System UDF: Operates at a global level, performs calculations that apply to the entire simulation domain or system. It is evaluated once per simulation time step (or at specific intervals) and modifies the overall system behavior or global parameters.
Local UDF: Operates on a voxel-by-voxel or particle-by-particle basis across the entire simulation domain. It is evaluated at each voxel or particle during every simulation time step (or at specific intervals) and influences localized properties or behaviors within the system.
Both System and Local UDFs share similar syntax and use the same internal code editor.
Tables
A table is a spreadsheet that represents experimental or empirical data without requiring a predefined mathematical rule. The solver reads or interpolates the data at runtime. Tables are used for lookup tables, particle size distributions, motion tables, pump curve data, etc. Tables can be classified into two categories:
Two-Column Tables: A two-column table represents a set of ordered pairs (x;y) with a one-to-one relationship between the independent and dependent variables. The physical values represented by the independent and dependent variables are identified in the table header.
Multi-Column Tables: A multi-column table represents a set of ordered tuples (x:y;z; …) with a one-to-many relationship between the independent and dependent variables. The physical values represented by the independent and dependent variables are identified in the table header.
Both table types use the same Table Editor.
Related
Computing Blend Time on any Model: How-To guide using both GPU and CPU expressions.