General

General

Using porous media UDF with ANSYS Fluent adjoint solver

    • FAQFAQ
      Participant

      You can use a user-defined function (UDF) to define the porosity and the resistance terms for porous media in ANSYS Fluent. The adjoint solver is fully compatible when using porous media either without energy or with the equilibrium thermal model. When calculating the resistance with a UDF, ensure that the resistance is never equal to zero. During the adjoint calculation there is a step where a variable is divided by the effective resistance. If your UDF returns exactly 0 in a cell for all resistance components, you get messages like -1.#IND0e+00, 1.#QNANe+00 or simply NAN for all adjoint residuals in the first iterations followed by divergence or even a segmentation fault. To avoid this behavior, add a control statement to ensure the resistance is always a positive value (e.g. 1e-10). If you are not sure if the calculated values are valid, you can write the results of the resistance UDFs into UDMs (user-defined memory locations). See the ANSYS Fluent Customization Manual for details on how to use UDMs.