Fluids

Fluids

Compiling UDF in batch mode on cluster

    • Atul Singh
      Subscriber

      Hi,

      Doing the granular bed example from the tutorial to compile and run it on the cluster.

      1) Did the example as it is on my local windows installation, and it worked fine.
      2) Moved it to the cluster, ran the same set of commands, and appraently the compilation log looks as follows (this also comes in the output console file)

      for d in lnamd64/[23]*; do \
        ( \
          cd $d; \
          rm -rf *.{c,h,cpp,hpp}; \
          for f in ../../src/*.{c,h,cpp,hpp} ../../src/makefile ../../src/user.udf; do \
            if [ -f $f -a ! -f `basename $f` ]; then \
              echo "# linking to" $f "in" $d; \
              ln -s $f .; \
            fi; \
          done; \
          echo ""; \
          echo "# building library in" $d; \
          if [ "" = "1" ]; then \
          echo "# using gcc64"; \
          make ARCHC=gcc64 -k>makelog 2>&1; \
          else \
          if [ "" = "1" ]; then \
              echo "# using gcc"; \
              make ARCHC=gcc -k>makelog 2>&1; \
          else \
              make -k>makelog 2>&1; \
          fi; \
          fi;\
          cat makelog; \
        ) \
      done
      # linking to ../../src/conduct.c in lnamd64/2ddp_host
      # linking to ../../src/makefile in lnamd64/2ddp_host

      # building library in lnamd64/2ddp_host
      make[1]: Entering directory `/mainfs/scratch/aus1n19/for_davidB/udfexample/libudf/lnamd64/2ddp_host'
      # Generating udf_names.c because of makefile conduct.c yes
      sed: can't read yes: No such file or directory
      make[1]: *** [udf_names.c] Error 2
      make[1]: Target `default' not remade because of errors.
      make[1]: Leaving directory `/mainfs/scratch/aus1n19/for_davidB/udfexample/libudf/lnamd64/2ddp_host'
      # linking to ../../src/conduct.c in lnamd64/2ddp_node
      # linking to ../../src/makefile in lnamd64/2ddp_node

      # building library in lnamd64/2ddp_node
      make[1]: Entering directory `/scratch/aus1n19/udfexample/libudf/lnamd64/2ddp_node'
      # Generating udf_names.c because of makefile conduct.c yes
      sed: can't read yes: No such file or directory
      make[1]: *** [udf_names.c] Error 2
      make[1]: Target `default' not remade because of errors.
      make[1]: Leaving directory `/mainfs/scratch/aus1n19/for_davidB/udfexample/libudf/lnamd64/2ddp_node'

       

      tried doing this on fluent 22.2 as well as fluent 19.4. Same result for both of them. Any pointers how can I make it work. The journal looks as follows,
      should help you copy paste, although I doubt it you would be that helpful.

      /file/read-case /scratch/aus1n19/for_davidB/udfexample/fluid-bed.msh

      /mesh/check

      /define/operating-conditions/gravity yes 0 -9.81
      /define/models/unsteady-1st-order yes
      q


      /define/models/multiphase/model eulerian


      /define/models/energy? yes no no no no


      /define/models/viscous laminar yes

       

      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; UDF step ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      ; insert the c file name inplace of conduct.c file
      ; If you have multiple udf files, just add them next to each other so they all are compiled in one libudf folder
      ; e.g. /define/user-defined/compiled-functions/compile libudf yes yes file1.c file2.c file3.c , ,
      ;/define/user-defined/use-built-in-compiler? yes

      /define/user-defined/compiled-functions/compile libudf yes yes conduct.c , ,
      /define/user-defined/compiled-functions/load libudf
      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


      ;; Now use the compiled udf
      ;; in this case in materials

      ; the comma immediately after "user-defined" takes the default thermal conductivity available from udf 
      ; Insert your own keyword from your udf, whichever method you used. 
      /define/materials/change-create air air yes constant 1.2 yes constant 994 yes user-defined , , , , , , ,

      ; Here immediately after  "user-defined" a word needs to be input, otherwise, the default may be used if a comma is not replaced with the routine. 
      /define/materials/change-create aluminum solids yes constant 2660 yes constant 737 yes user-defined conduct_solid::libudf yes

       

      /define/models/multiphase/number-of-phases 2
      /define/models/multiphase/eulerian no yes explicit , , 
      /define/phases/set-domain-properties change-phases-name solids air
      /define/phases/set-domain-properties phase-domains air material no

      /define/phases/set-domain-properties phase-domains solids diam constant 0.0005
      /define/phases/set-domain-properties phase-domains solids granular yes
      /define/phases/set-domain-properties phase-domains solids granular-properties viscosity syamlal-obrien
      /define/phases/set-domain-properties phase-domains solids granular-properties bulk lun-et
      /define/phases/set-domain-properties phase-domains solids granular-properties granular-temperature constant 1e-5

      /define/phases/set-domain-properties/interaction-domains/forces drag yes syamlal-obrien
      /define/phases/set-domain-properties/interaction-domains/heat-mass-reactions heat-coeff yes gunn

      /define/boundary-conditions velo-in v_uniform air yes yes no 0.25 no ,  ,  ,  , 293 
      /define/boundary-conditions velo-in v_uniform solids no no yes yes no 0 no 293 no 0

      /define/boundary-conditions velo-in v_jet air no no yes yes no 0.25 no 293 no 0
      /define/boundary-conditions velo-in v_jet solids no no yes yes no 0 no 293 no 0

       

      /define/boundary-condition p-outlet poutlet air no 293
      /define/boundary-conditions p-outlet poutlet solids no 293 yes no 0

      /define/boundary-conditions wall wall_hot solids , no , no yes temperature no 373 no no ,

      /define/boundary-conditions wall wall_hot air 0 no , no no no , no no ,

      ;24=coupled 20=simple 21=simplec 22=piso 
      solve/set/p-v-coupling 24 no

      ; turbulent dissipation rate, 0=first order upwind, 1=second order upwind 2=power law 4=quick 6=muscl
      ; for volume fraction 5=Modified Hric, 28=Compressive, 8=CICSAM, 16=Geo-Reconstruct
      ;/solve/set/discretization-scheme epsilon 1
      ;/solve/set/discretization-scheme k 1
      /solve/set/discretization-scheme pressure 1
      /solve/set/discretization-scheme momentum 1
      /solve/set/discretization-scheme temperature 4
      /solve/set/discretization-scheme mp 16 ;quick unavailable for fluent 22.2

      /solve/set/p-v-controls 200 0.2 0.5

      /define/custom-field-functions/define "t_mix" air_temperature * air_vof + solids_temperature * solids_vof

      /define/custom-field-functions/define "k_mix" air_thermal_conductivity_lam * air_vof + solids_thermal_conductivity_lam * solids_vof

      /define/custom-field-functions/define "avg_htc" -k_mix * (t_mix-373)/(58.5*10^(-6))/80

      /surface/point-surface y=0.24 0.28494 0.24

      /solve/report-definitions add surf-mon-1 surface-facetavg field mixture avg_htc surface-names y=0.24 , report-type surface-facetavg
      q


      /solve/report-files/add surf-mon-1-rfile file-name htc-024.out itr-index 1 name surf-mon-1-rfile report-defs surf-mon-1 , frequency 1
      q

      /mesh/adapt/cell-registers/add region_0 type hex inside yes max 0.3 0.5 min 0 0
      q
      q

      /solve/initialize/initialize-flow
      /solve/patch/solids , region_0 , mp no 0.598
      q

      /solve/set/transient-controls/number-of-time-steps 12000
      q

      /solve/set/transient-controls/max-iterations-per-time-step 50
      q

      it 12000

      /file/write-case-data ,

      /display/objects/create contour press-contour surfaces-list default-interior , field mixture pressure coloring banded contour-lines yes

      /report/surface-integrals/area-weighted-avg wall_hot , solids temperature yes temp_wall_hot.srp

       

      /display/set/contours/filled-contours yes
      /display/set/picture/driver png
      /display/set/picture/landscape yes
      /display/set/picture/use-window-resolution? no
      /display/set/picture/x-resolution 1240
      /display/set/picture/y-resolution 780

      /plot/residuals yes yes yes yes yes yes yes
      /display/save-picture residuals%i.jpg


      /display/set/lights/headlight-on? no
      /display/set/lights/lights-on? no

      /display/objects/create contour press-contour surfaces-list default-interior , field mixture pressure coloring banded contour-lines yes
      q
      /display/objects/add-to-graphics/ press-contour
      q
      /display/objects/edit press-contour color-map size 30 format "%0.4f"
      q

      /display/set/windows/scale/format "%0.4f"
      /display/views/restore-view front
      /display/views/auto-scale
      /display/views/camera/zoom-camera 0.9
      ;/display/view/camera/roll-camera -90

      /display save-picture press-contoursave%i.jpg

      /report/system/time-stats

      /report/system/proc-stats

      exit
      OK

    • Federico Alzamora Previtali
      Subscriber

      Hello Atul, 

      from the following lines

      make[1]: Entering directory `/mainfs/scratch/aus1n19/for_davidB/udfexample/libudf/lnamd64/2ddp_host'
      # Generating udf_names.c because of makefile conduct.c yes
      sed: can't read yes: No such file or directory

      I think it is looking for a file with name 'yes'. I think you only need one 'yes' in the compiling command:

      /define/user-defined/compiled-functions/compile libudf yes conduct.c , ,

      Please try this and let me know how it goes!

    • Atul Singh
      Subscriber

      So, I was able to compile the udf, although I have an issue in one of those adapt/cell-registers command mentioned above.

      It works fine on the windows testing phase, but, fails on the batch submission. Could you help?

      This is the console output on the batch submission,




      same command on the windows run, is


      So I know this thing works there, but not on the cluster. Could you help?
      Example is example 24 of fluent 22 manual.

      /file/read-case /scratch/aus1n19/for_davidB/udfexample/fluid-bed.msh

      /mesh/check

      /define/operating-conditions/gravity yes 0 -9.81
      /define/models/unsteady-1st-order yes
      q


      /define/models/multiphase/model eulerian


      /define/models/energy? yes no no no no


      /define/models/viscous laminar yes


      ;=============================== UDF step =======================================;
      ;================================================================================;
      ; insert  .c file name inplace of conduct.c file
      ; If you have multiple udf files, just add them next to each other so they all are compiled in one libudf folder
      ; e.g. /define/user-defined/compiled-functions/compile libudf yes yes file1.c file2.c file3.c , ,
      ;/define/user-defined/use-built-in-compiler? yes

      /define/user-defined/compiled-functions/compile libudf yes conduct.c , ,
      /define/user-defined/compiled-functions/load libudf
      ;================================================================================;


      ;; Now use the compiled udf
      ;; in this case in materials


      ;======================= Using UDF to assign a property================================;
      ;======================================================================================;
      ; the comma immediately after "user-defined" in the command below takes the default thermal conductivity available from udf 
      ; Insert your own keyword from your udf, whichever method you used. 
      /define/materials/change-create air air yes constant 1.2 yes constant 994 yes user-defined , , , , , , ,

      ; Here immediately after  "user-defined" a word needs to be input, otherwise, the default may be used if a comma is not replaced with the routine. 
      /define/materials/change-create aluminum solids yes constant 2660 yes constant 737 yes user-defined conduct_solid::libudf yes

       

      /define/models/multiphase/number-of-phases 2
      /define/models/multiphase/eulerian no yes explicit , , 
      /define/phases/set-domain-properties change-phases-name solids air
      /define/phases/set-domain-properties phase-domains air material no

      /define/phases/set-domain-properties phase-domains solids diam constant 0.0005
      /define/phases/set-domain-properties phase-domains solids granular yes
      /define/phases/set-domain-properties phase-domains solids granular-properties viscosity syamlal-obrien
      /define/phases/set-domain-properties phase-domains solids granular-properties bulk-viscosity lun-et-al
      /define/phases/set-domain-properties phase-domains solids granular-properties granular-temperature constant 1e-5

      ;/define/phases/set-domain-properties/interaction-domain/forces drag yes syamlal-obrien
      /define/phases/set-domain-properties/interaction-domain/forces drag yes symmetric yes none
      /define/phases/set-domain-properties/interaction-domain/heat-mass-reactions heat-coeff yes gunn

      /define/boundary-conditions velo-in v_uniform air yes yes no 0.25 no ,  ,  ,  , 293 
      /define/boundary-conditions velo-in v_uniform solids no no yes yes no 0 no 293 no ,

      /define/boundary-conditions velo-in v_jet air no no yes yes no 0.25 no 293
      /define/boundary-conditions velo-in v_jet solids no no yes yes no , , , , ,

       

      /define/boundary-condition p-outlet poutlet air no 293
      /define/boundary-conditions p-outlet poutlet solids no 293 yes no 0

      /define/boundary-conditions wall wall_hot solids , no , no yes temperature no 373 no no ,

      /define/boundary-conditions wall wall_hot air 0 no , no no no , no no ,

      ;24=coupled 20=simple 21=simplec 22=piso 
      solve/set/p-v-coupling 24 no

      ; turbulent dissipation rate, 0=first order upwind, 1=second order upwind 2=power law 4=quick 6=muscl
      ; for volume fraction 5=Modified Hric, 28=Compressive, 8=CICSAM, 16=Geo-Reconstruct
      ;/solve/set/discretization-scheme epsilon 1
      ;/solve/set/discretization-scheme k 1
      /solve/set/discretization-scheme pressure 1
      /solve/set/discretization-scheme mom 1
      /solve/set/discretization-scheme temperature 4
      /solve/set/discretization-scheme mp 16 ;quick unavailable for fluent 22.2

      /solve/set/p-v-controls 200 0.2 0.5

      /define/custom-field-functions/define "t_mix" air_temperature * air_vof + solids_temperature * solids_vof

      /define/custom-field-functions/define "k_mix" air_thermal_conductivity_lam * air_vof + solids_thermal_conductivity_lam * solids_vof

      /define/custom-field-functions/define "avg_htc" -k_mix * (t_mix-373)/(58.5*10^(-6))/80

      /surface/point-surface y=0.24 0.28494 0.24

      /solve/report-definitions add surf-mon-1 surface-facetavg field mixture avg_htc surface-names y=0.24 , report-type surface-facetavg
      q


      /solve/report-files/add surf-mon-1-rfile file-name htc-024.out itr-index 1 name surf-mon-1-rfile report-defs surf-mon-1 , frequency 1
      q

      /mesh/adapt/cell-registers/add region_0 type hex inside yes max 0.3 0.5 min 0 0
      q
      q

      /solve/initialize/initialize-flow
      /solve/patch/solids , region_0 , mp no 0.598
      q

      /solve/set/transient-controls/number-of-time-steps 300
      q
      /solve/set/transient-controls/time-step-size 0.00015

      /solve/set/transient-controls/max-iterations-per-time-step 50
      q

      it 300

      /file/write-case-data ,

      ;/display/objects/create contour press-contour surfaces-list default-interior , field mixture pressure coloring banded

      ;/report/surface-integrals/area-weighted-avg wall_hot , solids temperature yes temp_wall_hot.srp


      ;/display/set/contours/filled-contours yes
      ;/display/set/picture/driver png
      ;/display/set/picture/landscape yes
      ;/display/set/picture/use-window-resolution? no
      ;/display/set/picture/x-resolution 1240
      ;/display/set/picture/y-resolution 780
      ;
      ;/plot/residuals yes yes yes yes yes yes yes
      ;/display/save-picture residuals%i.jpg


      ;/display/set/lights/headlight-on? no
      ;/display/set/lights/lights-on? no

      /display/objects/create contour press-contour surfaces-list default-interior , field mixture pressure coloring banded
      q
      q
      q

      ;/display/objects/add-to-graphics/ press-contour
      ;q
      /display/objects/edit press-contour color-map size 30 format "%0.4f"
      q
      q

      ;/display/set/windows/scale/format "%0.4f"
      ;/display/views/restore-view front
      ;/display/views/auto-scale
      ;/display/views/camera/zoom-camera 0.9

      /display save-picture press-contoursave%i.jpg

      ;/report/system/time-stats

      ;/report/system/proc-stats


      exit
      OK

       

    • Federico Alzamora Previtali
      Subscriber

      Try entering the full command (TUI might be auto-completing your arguments).

      /mesh/adapt/cell-registers/add region_0 type hexahedron inside yes max-point 0.3 0.5 min-point 0 0

      "inside" might need to be replaced as "inside?", I invite you to try this.

      One way to test what the full command should be is to write it in the TUI as multiple lines. The TUI will then suggest to you the full input.

      For example,

      /mesh/adapt/cell-registers/add

      region_0

      type

      hexahedron

      inside?

      yes

      max-point

      0.3

      0.5

      min-point

      0

      0

    • Atul Singh
      Subscriber

      Sure it works, but now i have a courant nunmber greatr than 250.

      How is that possible if i am using the default settings as in the pdf.

    • Federico Alzamora Previtali
      Subscriber

      I have not seen the workshop. You are setting the time step size to 0.00015 seconds, hence the Courant number will depend on this number the mesh that you are using.

    • Rob
      Ansys Employee

      A more general comment on the journal. Be very careful with the syntax to ensure you use the full commands

      /file.... is correct,   file.... may cause all subsequent lines to fail if the command doesn't quite work. 

    • Atul Singh
      Subscriber

      I meant the issue is that with 0.00015 time step, the same case will run just fine on the windows session. But throw an error in the batch mode.

    • Rob
      Ansys Employee

      Are you using the same number of cores? What's the mesh quality like? 

Viewing 8 reply threads
  • You must be logged in to reply to this topic.