### 18.8.3. User CEL Example 3: Integrated Quantity Boundary Conditions

#### 18.8.3.1. Problem Setup

One application of the integrated quantity functions would be to set a boundary inlet temperature based on some average outflow values from a domain. In this way, you could set up a boundary condition, which acts like a thermostat control for a room. This requires the use of a User CEL Function to set the inflow temperature, and one of the arguments, which is passed to the subroutine, is the average outflow temperature.

##### 18.8.3.1.1. Creating the User Function

Further information on creating a User CEL Function in CFX-Pre is available in User Functions in the CFX-Pre User's Guide.

First, you should first create a User Routine with the following settings:

- Routine Name: `INLET T`

- Option: `User CEL Function`

- Calling Name: `inlet_t`

- Library Name: `InletTemperature`

- Library Path: `/home/cfxuser/shared_libraries`

Next, you should create a User Function with the following settings.

- Function Name: `INLET T`

- User Routine Name: `INLET T`

- Argument List: `[K], [Pa]`

- Result Units: `[K]`

In this example, the user subroutine `InletTemperature.F` is stored in the shared library `libInletTemperature.so` (the prefix and suffix may vary depending on your platform), which can be found under the `/home/cfxuser/shared_libraries/<architecture>` directory. The new User CEL Function can now be used to set the feedback loop for the inlet temperature as follows:

- On the Inlet Boundary Condition Values form set the Heat Transfer option to `Static Temperature` and enter the expression:

  `INLET_T(areaAve(T)@Outflow,areaAve(p)@Outflow)`

Note that the integrated quantity is passed into the inlet temperature function as an argument. The CFX-Solver recalculates these values during the coefficient loop so that the value is always up to date. For details, see Boundary Details: Inlet in the CFX-Pre User's Guide.

#### 18.8.3.2. User Fortran Routine

The routine `InletTemperature.F` has the following form (note that this is not a complete routine, the purpose of this example is to demonstrate the quantities that can be passed to the subroutine).

    #include "cfx5ext.h"
    dllexport(inlet_t)
          SUBROUTINE INLET_T (NLOC,NRET,NARG,RET,ARGS,CRESLT,CZ,DZ,IZ,LZ,RZ)
    C
    C ------------------------------
    C        Argument list
    C ------------------------------
          INTEGER NLOC, NRET, NARG
          CHARACTER CRESLT*(*)
          REAL    RET(1:NLOC,1:NRET), ARGS(1:NLOC,1:NARG)
    C
    C------------------------------------------------------------------
    C ‘Static Temperature‘ is stored in RET(1:NLOC,1)
    C ‘areaAve(T@Outflow)‘ is stored in ARGS(1:NLOC,1)
    C ‘areaAve(p@Outflow)‘ is stored in ARGS(1:NLOC,2)
    C------------------------------------------------------------------
    C
    C ------------------------------
    C    Executable statements
    C ------------------------------
    C
          ...
          END

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