Using Tools > Working with User Code > User Code Examples > A User-Coded Boundary Profile

Your Ad Here




A User-Coded Boundary Profile

Suppose that you wish to specify the temperature on a boundary to be the same as the temperature in the neighboring cell. You could create a user function called zeroGradT which takes the temperature and face-cell index fields as arguments and returns the boundary temperature.

In C the following could be coded in a file zeroGradT.c:

  #include "Real.h"
    
  /* Set boundary temperature equal to cell temperature */
  void
  zeroGradT(Real *result, int size, int (*fc)[2], Real *T)
  {
    int i;
  
  /* Loop through all entities applying T_boundary = T_cell *
   * fc[i][0] is the cell next to i                         */
    for (i = 0; i != size; ++i)
    {
      result[i] = T[fc[i][0]];
    }
  }

The equivalent in Fortran 90 could be a file zeroGradT.f:

C Set boundary temperature equal to cell temperature
      subroutine zeroGradT(result,size,fc,T)
      use StarRealMod
      implicit none
      integer, intent(in) :: size
      real(StarReal), intent(out) :: result(size)
      integer, intent(in) :: fc(2,*)
      real(StarReal), intent(in) :: T(*)
      integer i
C Loop through all entities applying T_boundary = T_cell
C fc(1,i) is the cell next to i
      do i = 1,size
        result(i) = T(fc(1,i))
      end do
      
      return
      end

This user function can then be registered with STAR-CCM+.

Return to CD-adapco STAR-CCM+ Index


Your Ad Here