## Chapter 18: User Fortran

This chapter discusses:

- User CEL Functions and Routines
- User Junction Box Routines
- Shared Libraries
- User Parameters
- Utility Routines for User Functions
- CFX Memory Management System (MMS)
- User Fortran in ANSYS Workbench
- User CEL Examples
- User Junction Box Examples
- Using CFX-4 Routines in CFX
- State Point Evaluation
- Calculating the Particle Drag Coefficient

To add additional features and physical models to CFX, you can write your own subroutines in Fortran and have the CFX-Solver call these routines through a source code interface. You may also want to implement customized physical models that would never be available in CFX due to confidentiality considerations.

CFX supports user subroutines written in Fortran 77 or Fortran 90. A list of supported compilers for each platform is available. Using Fortran 77 whenever possible is recommended.

Two different kinds of user routines are available in CFX:

- User defined CEL (CFX Expression Language) functions can be used within a CEL expression, following the standard CEL rules. For details, see User CEL Functions and Routines.

- Junction box routines can be used at several places in the CFX-Solver to run user code. For details, see User Junction Box Routines.

The following tasks can be accomplished with user subroutines in CFX:

- Input of user data (for example, data required for profile boundary conditions or externally generated sources).

- User-specified boundary conditions (for example, profile boundary conditions).

- User-specified initial conditions (for example, externally generated flow fields, random distribution or disturbance of existing solutions).

- User-specified source terms (for example, externally generated body forces or general additional source terms used to implement new physical models).

- Junction box routines called every timestep, which acts as a general interface between the CFX-Solver and other software (for example, structure mechanic codes). Junction boxes also offer an interface for advanced monitoring and solution output.

- User particle routines are used to specify sources of momentum, heat and mass transfer, and can also be used to specify injection regions for particles. The structure of particle user routines is the same. An example of this functionality is available. For details, see Structure of User CEL Functions, Particle User Sources, and User Defined Injection Regions.

Note that CFX includes features such as advanced monitoring of solution variables or global values and extended CEL functionality, which may reduce your need for user subroutines.

To use junction box routines, you will need to be familiar with the CFX MMS (Memory Management System) to set up and pass around user data for access in any subroutine. For details, see CFX Memory Management System (MMS).

Shared libraries enable subroutines to be reused without recompilation for successive CFX-Solver runs or even for different applications. The location of a shared library is specified in CFX-Pre. During execution of the CFX-Solver, the user subroutines are loaded from the specified shared libraries. For details, see Shared Libraries.

Release 18.2 - © ANSYS, Inc. All rights reserved.