├── examples ├── Test-Convergence │ ├── .gitignore │ ├── Test-Convergence.pdf │ ├── Makefile │ ├── probes.prm │ ├── visu.prm │ ├── input.i3d │ └── test-convergence.sh ├── Taylor-Green-Vortex │ ├── SS │ │ ├── Makefile │ │ └── input.i3d │ └── input.i3d ├── Dbg-schemes │ ├── plot_outputs.py │ ├── input.i3d │ ├── test │ └── test1 ├── User │ └── input.i3d ├── Mixing-layer │ └── input.i3d ├── Jet │ └── input.i3d ├── Channel-Flow │ ├── input_WALE_LES.i3d │ └── input.i3d ├── Periodic-hill │ ├── input.i3d │ └── paraview_incompact3d.f90 ├── Lock-exchange │ └── input.i3d ├── Turbulent-Boundary-Layer │ └── input.i3d ├── Cylinder │ └── input.i3d └── Sandbox │ └── README.md ├── .gitignore ├── .dir-locals.el ├── indent.sh ├── .github └── workflows │ └── Build.yml ├── decomp2d ├── factor.inc ├── io_read_one.inc ├── io_read_var.inc ├── io_write_var.inc ├── mem_split.f90 ├── io_write_one.inc ├── mem_merge.f90 ├── io_write_plane.inc ├── halo.inc ├── glassman.f90 ├── fft_common.inc ├── fft_common_3d.inc ├── io_write_every.inc ├── alloc.inc └── fft_generic.f90 ├── CHANGELOG.md ├── scripts ├── dbg-schemes.py └── testgithub_incompact3d.sh ├── src ├── BC-User.f90 ├── BC-Mixing-layer.f90 ├── post.f90 ├── xcompact3d.f90 └── BC-Channel-flow.f90 ├── Makefile └── README.md /examples/Test-Convergence/.gitignore: -------------------------------------------------------------------------------- 1 | *.tex 2 | *.el 3 | run 4 | s4 -------------------------------------------------------------------------------- /examples/Test-Convergence/Test-Convergence.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fschuch/Xcompact3d/HEAD/examples/Test-Convergence/Test-Convergence.pdf -------------------------------------------------------------------------------- /examples/Taylor-Green-Vortex/SS/Makefile: -------------------------------------------------------------------------------- 1 | run: 2 | mpirun -np 16 ~/xcompact3d_developers/incompact3d input.i3d 3 | 4 | clean: 5 | rm -rf *.dat ux* uy* uz* pp* vort* qcrit* *.xdmf 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.out 2 | *.o 3 | *.mod 4 | *.xdmf 5 | *.nc 6 | *.bin 7 | *.info 8 | *.csv 9 | .#* 10 | *.jpg 11 | *.pdf 12 | *.png 13 | *.svg 14 | *.swp 15 | *.dat 16 | *~ 17 | xcompact3d 18 | .DS_Store 19 | TAGS 20 | lint.txt 21 | \#*\# 22 | *.log 23 | -------------------------------------------------------------------------------- /examples/Test-Convergence/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # FILE: Makefile for Test-Convergence 3 | # DESCRIPTION: Governs running Test-Convergence test cases for Xcompact3D. 4 | # AUTHOR: Paul Bartholomew 5 | # 6 | 7 | NP = 1 8 | TEST = ALL 9 | 10 | -------------------------------------------------------------------------------- /examples/Test-Convergence/probes.prm: -------------------------------------------------------------------------------- 1 | 0 #nprobes 2 | # x, y, z 3 | 4.,0.006310,0.5 4 | 4.,0.010000,0.5 5 | 4.,0.015849,0.5 6 | 4.,0.025119,0.5 7 | 4.,0.039811,0.5 8 | 4.,0.063096,0.5 9 | 4.,0.100000,0.5 10 | 4.,0.158489,0.5 11 | 4.,0.251189,0.5 12 | 4.,0.398107,0.5 13 | 4.,0.630957,0.5 14 | 4.,1.000000,0.5 15 | 4.,1.584893,0.5 16 | -------------------------------------------------------------------------------- /examples/Dbg-schemes/plot_outputs.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Spyder Editor 4 | 5 | This is a temporary script file. 6 | """ 7 | 8 | import numpy as np 9 | import matplotlib.pyplot as plt 10 | 11 | # Test 11 12 | A11=np.genfromtxt('/home/gdeskos/xcompact3d_developers/examples/Dbg-schemes/filter_z0210064',delimiter='') 13 | y=A11[:,0] 14 | ftheo=A11[:,1] 15 | fcomp=A11[:,2] 16 | ftheop=A11[:,3] 17 | fcompp=A11[:,4] 18 | 19 | plt.plot(y,ftheop,'-bs') 20 | plt.plot(y,fcompp,'-ok') 21 | plt.plot(y,ftheo,'-gs') 22 | plt.plot(y,fcomp,'-or') 23 | plt.show() -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((nil . ((eval . (setq flycheck-fortran-gfortran-executable "mpif90")) 2 | (eval . (setq flycheck-fortran-args "-fcray-pointer -cpp")) 3 | (eval . (setq flycheck-gfortran-include-path 4 | ;; Find this file and use it as the project root directory. 5 | (list (file-name-directory 6 | (let ((d (dir-locals-find-file "."))) 7 | (if (stringp d) 8 | d 9 | (car d))))))) 10 | (eval . (setq flycheck-gfortran-language-standard "f2003")) 11 | (eval . (setq fortran-comment-indent-style 'relative))))) 12 | -------------------------------------------------------------------------------- /indent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # FILE: indent.sh 5 | # AUTHOR: Paul Bartholomew 6 | # DESCRIPTION: Use emacs to indent files 7 | # 8 | 9 | # decomp2d/ 10 | for f in decomp2d/*.f90 11 | do 12 | echo "Indenting ${f}" 13 | emacs -batch ${f} --eval '(indent-region (point-min) (point-max) nil)' -f save-buffer 2> /dev/null 14 | done 15 | for f in decomp2d/*.inc 16 | do 17 | echo "Indenting ${f}" 18 | emacs -batch ${f} --eval '(indent-region (point-min) (point-max) nil)' -f save-buffer 2> /dev/null 19 | done 20 | 21 | # src/ 22 | for f in src/*.f90 23 | do 24 | echo "Indenting ${f}" 25 | emacs -batch ${f} --eval '(indent-region (point-min) (point-max) nil)' -f save-buffer 2> /dev/null 26 | done 27 | -------------------------------------------------------------------------------- /.github/workflows/Build.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Build 4 | 5 | # Controls when the action will run. Triggers the workflow on push or pull request 6 | # events but only for the master branch 7 | on: 8 | push: 9 | branches: [ master ] 10 | pull_request: 11 | branches: [ master ] 12 | 13 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 14 | jobs: 15 | # This workflow contains a single job called "build" 16 | build: 17 | # The type of runner that the job will run on 18 | runs-on: ubuntu-latest 19 | 20 | # Steps represent a sequence of tasks that will be executed as part of the job 21 | steps: 22 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 23 | - uses: actions/checkout@v2 24 | 25 | # Runs a single command using the runners shell 26 | - name: Install requirements 27 | run: | 28 | sudo apt-get update; sudo apt-get install -y gfortran openmpi-bin libopenmpi-dev 29 | 30 | # Runs a set of commands using the runners shell 31 | - name: Compile 32 | run: make 33 | -------------------------------------------------------------------------------- /examples/Test-Convergence/visu.prm: -------------------------------------------------------------------------------- 1 | # 2 | # INCOMPACT 3D parameters - Visualization - requires compilation flag -DVISU 3 | # 4 | 1 #save_ux # Save ux field to file?(0:no, 1:yes) 5 | 1 #save_uy # Save uy field to file? (0:no, 1:yes) 6 | 0 #save_uz # Save uz field to file? (0:no, 1:yes) 7 | 0 #save_phi # Save phi(1,2,3..) fields to file?(0:no, 1:yes) 8 | 0 #save_uxm # Save uy averaged field to file?(0:no, 1:yes) 9 | 0 #save_uym # Save uy averaged field to file?(0:no, 1:yes) 10 | 0 #save_uzm # Save uz averaged field to file?(0:no, 1:yes) 11 | 0 #save_phim # Save phi averaged (1,2,3..) fields to file? (0:no, 1:yes) 12 | 0 #save_pre # Save pressure field to file? (0:no, 1:yes) 13 | 0 #save_prem # Save pressure averaged field to file? (0:no, 1:yes) 14 | 0 #save_ibm # Save IBM field to file? (0:no, 1:yes, to save just ibm0000, 2:yes, to save every snapshot) 15 | # 16 | # Extra Visualization - requires compilation flag -DVISUEXTRA 17 | # 18 | 0 #save_w # Save vorticity field to file?(0:no, 1:yes) 19 | 0 #save_w1 # Save vorticity 1 field to file? (0:no, 1:yes) 20 | 0 #save_w2 # Save vorticity 2 field to file? (0:no, 1:yes) 21 | 0 #save_w3 # Save vorticity 3 field to file? (0:no, 1:yes) 22 | 0 #save_qc # Save Q-criteria field to file? (0:no, 1:yes) 23 | 0 #save_pc # Save P-criteria field to file? (0:no, 1:yes) 24 | 0 #save_V # Save P-criteria field to file? (0:no, 1:yes) 25 | 0 #save_dudx # 26 | 0 #save_dudy # 27 | 0 #save_dudz # 28 | 0 #save_dvdx # 29 | 0 #save_dvdy # 30 | 0 #save_dvdz # 31 | 0 #save_dwdx # 32 | 0 #save_dwdy # 33 | 0 #save_dwdz # 34 | 0 #save_dphidx# 35 | 0 #save_dphidy# 36 | 0 #save_dphidz# 37 | 0 #save_dmap # Save deposit map? (0:no, 1:yes) 38 | 0 #save_tmap # Save tau wall map? (0:no, 1:yes) 39 | -------------------------------------------------------------------------------- /decomp2d/factor.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! A few utility routines to find factors of integer numbers 13 | 14 | subroutine findfactor(num, factors, nfact) 15 | 16 | implicit none 17 | 18 | integer, intent(IN) :: num 19 | integer, intent(OUT), dimension(*) :: factors 20 | integer, intent(OUT) :: nfact 21 | integer :: i, m 22 | 23 | ! find the factors <= sqrt(num) 24 | m = int(sqrt(real(num))) 25 | nfact = 1 26 | do i=1,m 27 | if (num/i*i == num) then 28 | factors(nfact) = i 29 | nfact = nfact + 1 30 | end if 31 | end do 32 | nfact = nfact - 1 33 | 34 | ! derive those > sqrt(num) 35 | if (factors(nfact)**2/=num) then 36 | do i=nfact+1, 2*nfact 37 | factors(i) = num / factors(2*nfact-i+1) 38 | end do 39 | nfact = nfact * 2 40 | else 41 | do i=nfact+1, 2*nfact-1 42 | factors(i) = num / factors(2*nfact-i) 43 | end do 44 | nfact = nfact * 2 - 1 45 | endif 46 | 47 | return 48 | 49 | end subroutine findfactor 50 | 51 | 52 | subroutine primefactors(num, factors, nfact) 53 | 54 | implicit none 55 | 56 | integer, intent(IN) :: num 57 | integer, intent(OUT), dimension(*) :: factors 58 | integer, intent(INOUT) :: nfact 59 | 60 | integer :: i, n 61 | 62 | i = 2 63 | nfact = 1 64 | n = num 65 | do 66 | if (mod(n,i) == 0) then 67 | factors(nfact) = i 68 | nfact = nfact + 1 69 | n = n / i 70 | else 71 | i = i + 1 72 | end if 73 | if (n == 1) then 74 | nfact = nfact - 1 75 | exit 76 | end if 77 | end do 78 | 79 | return 80 | 81 | end subroutine primefactors 82 | 83 | -------------------------------------------------------------------------------- /decomp2d/io_read_one.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'mpiio_read_one_...' in io.f90 14 | 15 | ! Using MPI-IO to write a distributed 3D array into a file 16 | 17 | if (present(opt_decomp)) then 18 | decomp = opt_decomp 19 | else 20 | call get_decomp_info(decomp) 21 | end if 22 | 23 | ! determine subarray parameters 24 | sizes(1) = decomp%xsz(1) 25 | sizes(2) = decomp%ysz(2) 26 | sizes(3) = decomp%zsz(3) 27 | 28 | if (ipencil == 1) then 29 | subsizes(1) = decomp%xsz(1) 30 | subsizes(2) = decomp%xsz(2) 31 | subsizes(3) = decomp%xsz(3) 32 | starts(1) = decomp%xst(1)-1 ! 0-based index 33 | starts(2) = decomp%xst(2)-1 34 | starts(3) = decomp%xst(3)-1 35 | else if (ipencil == 2) then 36 | subsizes(1) = decomp%ysz(1) 37 | subsizes(2) = decomp%ysz(2) 38 | subsizes(3) = decomp%ysz(3) 39 | starts(1) = decomp%yst(1)-1 40 | starts(2) = decomp%yst(2)-1 41 | starts(3) = decomp%yst(3)-1 42 | else if (ipencil == 3) then 43 | subsizes(1) = decomp%zsz(1) 44 | subsizes(2) = decomp%zsz(2) 45 | subsizes(3) = decomp%zsz(3) 46 | starts(1) = decomp%zst(1)-1 47 | starts(2) = decomp%zst(2)-1 48 | starts(3) = decomp%zst(3)-1 49 | endif 50 | 51 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 52 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 53 | call MPI_TYPE_COMMIT(newtype,ierror) 54 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, & 55 | MPI_MODE_RDONLY, MPI_INFO_NULL, & 56 | fh, ierror) 57 | disp = 0_MPI_OFFSET_KIND 58 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 59 | newtype,'native',MPI_INFO_NULL,ierror) 60 | call MPI_FILE_READ_ALL(fh, var, & 61 | subsizes(1)*subsizes(2)*subsizes(3), & 62 | data_type, MPI_STATUS_IGNORE, ierror) 63 | call MPI_FILE_CLOSE(fh,ierror) 64 | call MPI_TYPE_FREE(newtype,ierror) 65 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | 12 | 1. CHANGELOG.md by [@fschuch](https://github.com/fschuch). 13 | 1. Xdmf writer included back, making easy to visualize the binary fields in other tools, by [@fschuch](https://github.com/fschuch). 14 | 1. Sandbox flow configuration ([BC-Sandbox.f90](./src/BC-Sandbox.f90)), by [@fschuch](https://github.com/fschuch). 15 | 1. Immersed boundary method for Scalar field(s), together with a new Lagrangian Interpolator for no-flux BC at solid/fluid interface, by [@fschuch](https://github.com/fschuch). 16 | 1. Module Probes ([tools.f90](./src/tools.f90)), so now it can be used for any flow configuration, by [@fschuch](https://github.com/fschuch). 17 | 18 | ### Changed 19 | 20 | 1. Enumeration, directory structure and filename format for binary outputs by [@fschuch](https://github.com/fschuch), details in [#3](https://github.com/fschuch/Xcompact3d/issues/3). 21 | 1. Subroutine `read_geomcomplex` [genepsi3d.f90](./src/genepsi3d.f90) was modified ir order to be compatible with the new [xcompact3d_toolbox](https://github.com/fschuch/xcompact3d_toolbox), by [@fschuch](https://github.com/fschuch). 22 | 1. README was recovered from previous public repository, by [@fschuch](https://github.com/fschuch). 23 | 1. CI changed from Travis to GitHub actions, by [@fschuch](https://github.com/fschuch). 24 | 25 | ### Removed 26 | 27 | 1. `subroutine VISU_PRE` ([visu.f90](./src/visu.f90)) is obsolete, since pressure is written at `subroutine write_snapshot` ([visu.f90](./src/visu.f90)), by [@fschuch](https://github.com/fschuch). 28 | 29 | ### Fixed 30 | 31 | 1. Calling `write_snapshot` and `postprocess_case` for `itime=0`, by [@fschuch](https://github.com/fschuch). 32 | 1. [#2](https://github.com/fschuch/Xcompact3d/issues/4) Lock-exchange configuration does not work when `ilmn = .False.`, by [@fschuch](https://github.com/fschuch). 33 | 1. [#4](https://github.com/fschuch/Xcompact3d/issues/4) Wrong derivative routine (and Boundary Conditions) for scalar field, by [@fschuch](https://github.com/fschuch). 34 | 1. [#6](https://github.com/fschuch/Xcompact3d/issues/6) Not computing gravitational term, by [@fschuch](https://github.com/fschuch). 35 | 36 | [Unreleased]: https://github.com/xcompact3d/Incompact3d/compare/dev...fschuch:master 37 | -------------------------------------------------------------------------------- /decomp2d/io_read_var.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'read_var_...' in io.f90 14 | 15 | ! Using MPI-IO to read a distributed 3D variable from a file. File 16 | ! operations (open/close) need to be done in calling application. This 17 | ! allows multiple variables to be read from a single file. Together 18 | ! with the corresponding write operation, this is the perfect solution 19 | ! for applications to perform restart/checkpointing. 20 | 21 | if (present(opt_decomp)) then 22 | decomp = opt_decomp 23 | else 24 | call get_decomp_info(decomp) 25 | end if 26 | 27 | ! Create file type and set file view 28 | sizes(1) = decomp%xsz(1) 29 | sizes(2) = decomp%ysz(2) 30 | sizes(3) = decomp%zsz(3) 31 | if (ipencil == 1) then 32 | subsizes(1) = decomp%xsz(1) 33 | subsizes(2) = decomp%xsz(2) 34 | subsizes(3) = decomp%xsz(3) 35 | starts(1) = decomp%xst(1)-1 ! 0-based index 36 | starts(2) = decomp%xst(2)-1 37 | starts(3) = decomp%xst(3)-1 38 | else if (ipencil == 2) then 39 | subsizes(1) = decomp%ysz(1) 40 | subsizes(2) = decomp%ysz(2) 41 | subsizes(3) = decomp%ysz(3) 42 | starts(1) = decomp%yst(1)-1 43 | starts(2) = decomp%yst(2)-1 44 | starts(3) = decomp%yst(3)-1 45 | else if (ipencil == 3) then 46 | subsizes(1) = decomp%zsz(1) 47 | subsizes(2) = decomp%zsz(2) 48 | subsizes(3) = decomp%zsz(3) 49 | starts(1) = decomp%zst(1)-1 50 | starts(2) = decomp%zst(2)-1 51 | starts(3) = decomp%zst(3)-1 52 | endif 53 | 54 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 55 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 56 | call MPI_TYPE_COMMIT(newtype,ierror) 57 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 58 | newtype,'native',MPI_INFO_NULL,ierror) 59 | call MPI_FILE_READ_ALL(fh, var, & 60 | subsizes(1)*subsizes(2)*subsizes(3), & 61 | data_type, MPI_STATUS_IGNORE, ierror) 62 | call MPI_TYPE_FREE(newtype,ierror) 63 | 64 | ! update displacement for the next read operation 65 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 66 | if (data_type == complex_type) then 67 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 68 | end if 69 | -------------------------------------------------------------------------------- /decomp2d/io_write_var.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'write_var_...' in io.f90 14 | 15 | ! Using MPI-IO to write a distributed 3D variable to a file. File 16 | ! operations (open/close) need to be done in calling application. This 17 | ! allows multiple variables to be written to a single file. Together 18 | ! with the corresponding read operation, this is the perfect solution 19 | ! for applications to perform restart/checkpointing. 20 | 21 | if (present(opt_decomp)) then 22 | decomp = opt_decomp 23 | else 24 | call get_decomp_info(decomp) 25 | end if 26 | 27 | ! Create file type and set file view 28 | sizes(1) = decomp%xsz(1) 29 | sizes(2) = decomp%ysz(2) 30 | sizes(3) = decomp%zsz(3) 31 | if (ipencil == 1) then 32 | subsizes(1) = decomp%xsz(1) 33 | subsizes(2) = decomp%xsz(2) 34 | subsizes(3) = decomp%xsz(3) 35 | starts(1) = decomp%xst(1)-1 ! 0-based index 36 | starts(2) = decomp%xst(2)-1 37 | starts(3) = decomp%xst(3)-1 38 | else if (ipencil == 2) then 39 | subsizes(1) = decomp%ysz(1) 40 | subsizes(2) = decomp%ysz(2) 41 | subsizes(3) = decomp%ysz(3) 42 | starts(1) = decomp%yst(1)-1 43 | starts(2) = decomp%yst(2)-1 44 | starts(3) = decomp%yst(3)-1 45 | else if (ipencil == 3) then 46 | subsizes(1) = decomp%zsz(1) 47 | subsizes(2) = decomp%zsz(2) 48 | subsizes(3) = decomp%zsz(3) 49 | starts(1) = decomp%zst(1)-1 50 | starts(2) = decomp%zst(2)-1 51 | starts(3) = decomp%zst(3)-1 52 | endif 53 | 54 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 55 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 56 | call MPI_TYPE_COMMIT(newtype,ierror) 57 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 58 | newtype,'native',MPI_INFO_NULL,ierror) 59 | call MPI_FILE_WRITE_ALL(fh, var, & 60 | subsizes(1)*subsizes(2)*subsizes(3), & 61 | data_type, MPI_STATUS_IGNORE, ierror) 62 | call MPI_TYPE_FREE(newtype,ierror) 63 | 64 | ! update displacement for the next write operation 65 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 66 | if (data_type == complex_type) then 67 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 68 | end if 69 | -------------------------------------------------------------------------------- /examples/Test-Convergence/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Domain decomposition 8 | p_row = 0 ! Row partition 9 | p_col = 0 ! Column partition 10 | 11 | ! Mesh 12 | nx = 128 ! X-direction nodes 13 | ny = 128 ! Y-direction nodes 14 | nz = 8 ! Z-direction nodes 15 | 16 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 17 | beta = 0.3 ! Refinement parameter (beta) 18 | 19 | ! Domain 20 | xlx = 6.28318530718 ! Lx (Size of the box in x-direction) 21 | yly = 6.28318530718 ! Ly (Size of the boy in y-direction) 22 | zlz = 6.28318530718 ! Lz (Size of the boz in z-direction) 23 | 24 | ! Flow parameters 25 | itype = 8 ! Type of Flow 26 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 27 | re = 1600. ! nu=1/re (Kinematic Viscosity) 28 | u1 = 8. ! u1 (max velocity) (for inflow condition) 29 | u2 = 8. ! u2 (min velocity) (for inflow condition) 30 | init_noise = 0.0 ! Turbulence intensity (1=100%) !! Initial condition 31 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 32 | 33 | ! Boundary conditions 34 | nclx1 = 0 35 | nclxn = 0 36 | ncly1 = 0 37 | nclyn = 0 38 | nclz1 = 0 39 | nclzn = 0 40 | 41 | ! Time stepping 42 | dt = 0.0005 ! Time step 43 | ifirst = 1 ! First iteration 44 | ilast = 5000 ! Last iteration 45 | 46 | ! Enable modelling tools 47 | iturbmod=0 ! if 0 then DNS 48 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 49 | iibm=0 ! Flag for immersed boundary method 50 | 51 | /End 52 | 53 | !==================== 54 | &NumOptions 55 | !==================== 56 | ! Spatial derivatives 57 | iorder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 58 | 59 | ! Time scheme 60 | itimescheme = 1 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 61 | /End 62 | 63 | !================= 64 | &InOutParam 65 | !================= 66 | 67 | ! Basic I/O 68 | irestart = 0 ! Read initial flow field ? 69 | icheckpoint = 50000 ! Frequency for writing backup file 70 | nvisu = 1 ! Size for visualisation collection 71 | ioutput = 250 ! Frequency for visualization 72 | /End 73 | 74 | !================= 75 | &Statistics 76 | !================= 77 | 78 | spinup_time = 50000. ! Time after which statistics are collected (in seconds) 79 | nstat = 1 ! Size arrays for statistic collection 80 | 81 | /End 82 | -------------------------------------------------------------------------------- /decomp2d/mem_split.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain duplicated code that gathers data from source to 13 | ! MPI_ALLTOALLV send buffer. It is 'included' by two subroutines in 14 | ! decomp_2d.f90 15 | 16 | ! Note: 17 | ! in --> source array 18 | ! out --> send buffer 19 | ! pos --> pointer for the send buffer 20 | ! - for normal ALLTOALLV, points to the beginning of send buffer (=1) 21 | ! - for shared memory code, note the send buffer is shared by all cores 22 | ! on same node, so 'pos' points to the correct location for this core 23 | 24 | integer, intent(IN) :: ndir 25 | integer, intent(IN) :: iproc 26 | integer, dimension(0:iproc-1), intent(IN) :: dist 27 | TYPE(DECOMP_INFO), intent(IN) :: decomp 28 | 29 | integer :: i,j,k, m,i1,i2,pos 30 | 31 | #ifndef SHM 32 | pos = 1 33 | #endif 34 | do m=0,iproc-1 35 | if (m==0) then 36 | i1 = 1 37 | i2 = dist(0) 38 | else 39 | i1 = i2+1 40 | i2 = i1+dist(m)-1 41 | endif 42 | 43 | if (ndir==1) then 44 | #ifdef SHM 45 | pos = decomp%x1disp_o(m) + 1 46 | #endif 47 | do k=1,n3 48 | do j=1,n2 49 | do i=i1,i2 50 | out(pos) = in(i,j,k) 51 | pos = pos + 1 52 | enddo 53 | enddo 54 | enddo 55 | else if (ndir==2) then 56 | #ifdef SHM 57 | pos = decomp%y2disp_o(m) + 1 58 | #endif 59 | do k=1,n3 60 | do j=i1,i2 61 | do i=1,n1 62 | out(pos) = in(i,j,k) 63 | pos = pos + 1 64 | enddo 65 | enddo 66 | enddo 67 | else if (ndir==3) then 68 | #ifdef SHM 69 | pos = decomp%z2disp_o(m) + 1 70 | #endif 71 | do k=i1,i2 72 | do j=1,n2 73 | do i=1,n1 74 | out(pos) = in(i,j,k) 75 | pos = pos + 1 76 | enddo 77 | enddo 78 | enddo 79 | else if (ndir==4) then 80 | #ifdef SHM 81 | pos = decomp%y1disp_o(m) + 1 82 | #endif 83 | do k=1,n3 84 | do j=i1,i2 85 | do i=1,n1 86 | out(pos) = in(i,j,k) 87 | pos = pos + 1 88 | enddo 89 | enddo 90 | enddo 91 | endif 92 | enddo 93 | -------------------------------------------------------------------------------- /decomp2d/io_write_one.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'mpiio_write_one_...' in io.f90 14 | 15 | ! Using MPI-IO to write a distributed 3D array into a file 16 | 17 | if (present(opt_decomp)) then 18 | decomp = opt_decomp 19 | else 20 | call get_decomp_info(decomp) 21 | end if 22 | 23 | ! determine subarray parameters 24 | sizes(1) = decomp%xsz(1) 25 | sizes(2) = decomp%ysz(2) 26 | sizes(3) = decomp%zsz(3) 27 | 28 | if (ipencil == 1) then 29 | subsizes(1) = decomp%xsz(1) 30 | subsizes(2) = decomp%xsz(2) 31 | subsizes(3) = decomp%xsz(3) 32 | starts(1) = decomp%xst(1)-1 ! 0-based index 33 | starts(2) = decomp%xst(2)-1 34 | starts(3) = decomp%xst(3)-1 35 | else if (ipencil == 2) then 36 | subsizes(1) = decomp%ysz(1) 37 | subsizes(2) = decomp%ysz(2) 38 | subsizes(3) = decomp%ysz(3) 39 | starts(1) = decomp%yst(1)-1 40 | starts(2) = decomp%yst(2)-1 41 | starts(3) = decomp%yst(3)-1 42 | else if (ipencil == 3) then 43 | subsizes(1) = decomp%zsz(1) 44 | subsizes(2) = decomp%zsz(2) 45 | subsizes(3) = decomp%zsz(3) 46 | starts(1) = decomp%zst(1)-1 47 | starts(2) = decomp%zst(2)-1 48 | starts(3) = decomp%zst(3)-1 49 | endif 50 | 51 | #ifdef T3PIO 52 | call MPI_INFO_CREATE(info, ierror) 53 | gs = ceiling(real(sizes(1),mytype)*real(sizes(2),mytype)* & 54 | real(sizes(3),mytype)/1024./1024.) 55 | call t3pio_set_info(MPI_COMM_WORLD, info, "./", ierror, & 56 | GLOBAL_SIZE=gs, factor=1) 57 | #endif 58 | 59 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 60 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 61 | call MPI_TYPE_COMMIT(newtype,ierror) 62 | #ifdef T3PIO 63 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, & 64 | MPI_MODE_CREATE+MPI_MODE_WRONLY, info, fh, ierror) 65 | #else 66 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, & 67 | MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, & 68 | fh, ierror) 69 | #endif 70 | filesize = 0_MPI_OFFSET_KIND 71 | call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting 72 | disp = 0_MPI_OFFSET_KIND 73 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 74 | newtype,'native',MPI_INFO_NULL,ierror) 75 | call MPI_FILE_WRITE_ALL(fh, var, & 76 | subsizes(1)*subsizes(2)*subsizes(3), & 77 | data_type, MPI_STATUS_IGNORE, ierror) 78 | call MPI_FILE_CLOSE(fh,ierror) 79 | call MPI_TYPE_FREE(newtype,ierror) 80 | #ifdef T3PIO 81 | call MPI_INFO_FREE(info,ierror) 82 | #endif 83 | -------------------------------------------------------------------------------- /decomp2d/mem_merge.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain duplicated code that scatters data from the 13 | ! MPI_ALLTOALLV receive buffer to destinations. It is 'included' by two 14 | ! subroutines in decomp_2d.f90 15 | 16 | ! Note: 17 | ! in --> receive buffer 18 | ! out --> destination array 19 | ! pos --> pointer for the receive buffer 20 | ! - for normal ALLTOALLV, points to the beginning of receive buffer (=1) 21 | ! - for shared memory code, note the receive buffer is shared by all cores 22 | ! on same node, so 'pos' points to the correct location for this core 23 | 24 | integer, intent(IN) :: ndir 25 | integer, intent(IN) :: iproc 26 | integer, dimension(0:iproc-1), intent(IN) :: dist 27 | TYPE(DECOMP_INFO), intent(IN) :: decomp 28 | 29 | integer :: i,j,k, m,i1,i2,pos 30 | 31 | #ifndef SHM 32 | pos = 1 33 | #endif 34 | do m=0,iproc-1 35 | if (m==0) then 36 | i1 = 1 37 | i2 = dist(0) 38 | else 39 | i1 = i2+1 40 | i2 = i1+dist(m)-1 41 | endif 42 | 43 | if (ndir==1) then 44 | #ifdef SHM 45 | pos = decomp%y1disp_o(m) + 1 46 | #endif 47 | do k=1,n3 48 | do j=i1,i2 49 | do i=1,n1 50 | out(i,j,k) = in(pos) 51 | pos = pos + 1 52 | enddo 53 | enddo 54 | enddo 55 | else if (ndir==2) then 56 | #ifdef SHM 57 | pos = decomp%z2disp_o(m) + 1 58 | #endif 59 | do k=i1,i2 60 | do j=1,n2 61 | do i=1,n1 62 | out(i,j,k) = in(pos) 63 | pos = pos + 1 64 | enddo 65 | enddo 66 | enddo 67 | else if (ndir==3) then 68 | #ifdef SHM 69 | pos = decomp%y2disp_o(m) + 1 70 | #endif 71 | do k=1,n3 72 | do j=i1,i2 73 | do i=1,n1 74 | out(i,j,k) = in(pos) 75 | pos = pos + 1 76 | enddo 77 | enddo 78 | enddo 79 | else if (ndir==4) then 80 | #ifdef SHM 81 | pos = decomp%x1disp_o(m) + 1 82 | #endif 83 | do k=1,n3 84 | do j=1,n2 85 | do i=i1,i2 86 | out(i,j,k) = in(pos) 87 | pos = pos + 1 88 | enddo 89 | enddo 90 | enddo 91 | endif 92 | enddo 93 | -------------------------------------------------------------------------------- /examples/User/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (0=User, 1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 0 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=65 ! X-direction nodes 16 | ny=65 ! Y-direction nodes 17 | nz=65 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.3 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 1. ! Lx (Size of the box in x-direction) 23 | yly = 1. ! Ly (Size of the boy in y-direction) 24 | zlz = 1. ! Lz (Size of the boz in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 1 28 | nclxn = 1 29 | ncly1 = 1 30 | nclyn = 1 31 | nclz1 = 1 32 | nclzn = 1 33 | 34 | ! Flow parameters 35 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 36 | re = 1600. ! nu=1/re (Kinematic Viscosity) 37 | u1 = 1. ! u1 (max velocity) (for inflow condition) 38 | u2 = 1. ! u2 (min velocity) (for inflow condition) 39 | init_noise = 0.0 ! Turbulence intensity (1=100%) !! Initial condition 40 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 41 | 42 | ! Time stepping 43 | dt = 0.001 ! Time step 44 | ifirst = 1 ! First iteration 45 | ilast = 100 ! Last iteration 46 | 47 | ! Enable modelling tools 48 | ilesmod=0 ! if 0 then DNS 49 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 50 | iibm=0 ! Flag for immersed boundary method 51 | 52 | ! Enable io 53 | ivisu=1 ! Store snapshots 54 | ipost=1 ! Do online postprocessing 55 | 56 | /End 57 | 58 | !==================== 59 | &NumOptions 60 | !==================== 61 | 62 | ! Spatial derivatives 63 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 64 | isecondder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 65 | 66 | ! Time scheme 67 | itimescheme = 5 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 68 | 69 | ! Dissipation control 70 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 71 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 72 | 73 | /End 74 | 75 | !================= 76 | &InOutParam 77 | !================= 78 | 79 | ! Basic I/O 80 | irestart = 0 ! Read initial flow field ? 81 | icheckpoint = 5000 ! Frequency for writing backup file 82 | ioutput = 1000 ! Frequency for visualization 83 | nvisu = 1 ! Size for visualisation collection 84 | 85 | /End 86 | 87 | !================= 88 | &Statistics 89 | !================= 90 | 91 | spinup_time = 0. ! Time after which statistics are collected (in seconds) 92 | nstat = 1 ! Size arrays for statistic collection 93 | 94 | /End 95 | 96 | !####################### 97 | ! OPTIONAL PARAMETERS 98 | !####################### 99 | -------------------------------------------------------------------------------- /scripts/dbg-schemes.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | import math 4 | import os 5 | import csv 6 | 7 | prm = '../BC-dbg-schemes.prm' 8 | 9 | class Error(object): 10 | def __init__(self, dir,jLes,bc,n): 11 | self.dir = dir 12 | self.jLes = jLes 13 | self.bc = bc 14 | self.n = n 15 | filename = "schemes_"+dir+str(jLes)+bc+str(n).zfill(4) 16 | with open(filename, 'r') as f: 17 | data = list(csv.reader(f, delimiter=' ', skipinitialspace=True, 18 | quoting=csv.QUOTE_NONNUMERIC)) 19 | data = np.transpose(data) 20 | self.dfdx = np.amax(data[1]) 21 | self.dfdxp = np.amax(data[2]) 22 | self.dfdxx = np.amax(data[3]) 23 | self.dfdxxp = np.amax(data[4]) 24 | del data 25 | 26 | results = {} 27 | 28 | for bc in ["00", "11", "22"]: 29 | 30 | for i,dir in enumerate(["x", "y", "z"]): 31 | os.system("sed -i \'/#ncl"+dir+"1/c\\"+bc[0]+" #ncl"+dir+"1' "+prm) 32 | os.system("sed -i \'/#ncl"+dir+"n/c\\"+bc[1]+" #ncl"+dir+"n' "+prm) 33 | os.system("sed -i \'/#ncl"+dir+"1/c\\"+bc[0]+" #ncl"+dir+"1' "+prm) 34 | os.system("sed -i \'/#ncl"+dir+"n/c\\"+bc[1]+" #ncl"+dir+"n' "+prm) 35 | os.system("sed -i \'/#ncl"+dir+"1/c\\"+bc[0]+" #ncl"+dir+"1' "+prm) 36 | os.system("sed -i \'/#ncl"+dir+"n/c\\"+bc[1]+" #ncl"+dir+"n' "+prm) 37 | 38 | if bc == "00": 39 | points = [16, 32, 64, 128, 256]#, 512, 1024, 2048] 40 | else: 41 | points = [17, 33, 65, 129, 257]#, 513, 1025, 2049] 42 | for n in points: 43 | for i,dir in enumerate(["x"]): 44 | os.system("sed -i \'/#nx/c\\"+str(points[0])+" #nx' "+prm) 45 | os.system("sed -i \'/#ny/c\\"+str(points[0])+" #ny' "+prm) 46 | os.system("sed -i \'/#nz/c\\"+str(points[0])+" #nz' "+prm) 47 | os.system("sed -i \'/#n"+dir+"/c\\"+str(n)+" #n"+dir+"' "+prm) 48 | for j,jLes in enumerate([0,1]): 49 | os.system("sed -i \'/#jLES/c\\"+str(jLes)+" #jLES' "+prm) 50 | os.system("mpirun -n 1 ../incompact3d") 51 | 52 | filename = "schemes_"+dir+str(jLes)+bc+str(n).zfill(4) 53 | results[filename] = Error(dir,jLes,bc,n) 54 | print(filename) 55 | 56 | 57 | plt.figure(figsize=(16,9), dpi=120) 58 | 59 | color = {} 60 | color["00"] = 'C0' 61 | color["11"] = 'C1' 62 | color["22"] = 'C0' 63 | 64 | for key, data in results.items(): 65 | plt.scatter(data.n,data.dfdx, color=color[data.bc]) 66 | plt.scatter(data.n,data.dfdxp, color=color[data.bc]) 67 | plt.scatter(data.n,data.dfdxx, color=color[data.bc]) 68 | plt.scatter(data.n,data.dfdxxp, color=color[data.bc]) 69 | 70 | 71 | error_n = np.arange(10, 1000, .5) 72 | 73 | error_y = (error_n)**(-6) 74 | plt.plot(error_n,error_y*10000) 75 | error_y = (error_n)**(-6) 76 | plt.plot(error_n,error_y*10000000) 77 | error_y = (error_n)**(-3) 78 | plt.plot(error_n,error_y*1000) 79 | error_y = (error_n)**(-3) 80 | plt.plot(error_n,error_y*400000) 81 | 82 | plt.xlabel(r'$n_1$') 83 | plt.ylabel('Error') 84 | 85 | plt.xscale('log') 86 | plt.yscale('log') 87 | 88 | plt.xlim(10,1000) 89 | plt.ylim(.00000000000001,100) 90 | 91 | plt.savefig('max_error.png', format='png') 92 | plt.close('all') 93 | -------------------------------------------------------------------------------- /examples/Taylor-Green-Vortex/SS/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 2 9 | 10 | ! Domain decomposition 11 | p_row=4 ! Row partition 12 | p_col=4 ! Column partition 13 | 14 | ! Mesh 15 | nx=65 ! X-direction nodes 16 | ny=65 ! Y-direction nodes 17 | nz=65 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 3.14159265358979 ! Lx (Size of the box in x-direction) 23 | yly = 3.14159265358979 ! Ly (Size of the boy in y-direction) 24 | zlz = 3.14159265358979 ! Lz (Size of the boz in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 1 28 | nclxn = 1 29 | ncly1 = 1 30 | nclyn = 1 31 | nclz1 = 1 32 | nclzn = 1 33 | 34 | ! Flow parameters 35 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 36 | re = 10000. ! nu=1/re (Kinematic Viscosity) 37 | u1 = 8. ! u1 (max velocity) (for inflow condition) 38 | u2 = 8. ! u2 (min velocity) (for inflow condition) 39 | init_noise = 0.0 ! Turbulence intensity (1=100%) !! Initial condition 40 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 41 | 42 | ! Time stepping 43 | dt = 0.0005 ! Time step 44 | ifirst = 1 ! First iteration 45 | ilast = 40000 ! Last iteration 46 | 47 | ! Enable modelling tools 48 | ilesmod=1 ! if 0 then DNS 49 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 50 | iibm=0 ! Flag for immersed boundary method 51 | 52 | ! Enable io 53 | ivisu=1 ! Store snapshots 54 | ipost=1 ! Do online postprocessing 55 | 56 | /End 57 | 58 | !==================== 59 | &NumOptions 60 | !==================== 61 | 62 | ! Spatial derivatives 63 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 64 | isecondder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 65 | 66 | ! Time scheme 67 | itimescheme = 5 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 68 | 69 | ! Dissipation control 70 | nu0nu = 0 ! Ratio between hyperviscosity/viscosity at nu 71 | cnu = 0 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 72 | 73 | /End 74 | 75 | !================= 76 | &InOutParam 77 | !================= 78 | 79 | ! Basic I/O 80 | irestart = 0 ! Read initial flow field ? 81 | icheckpoint = 5000 ! Frequency for writing backup file 82 | ioutput = 1000 ! Frequency for visualization 83 | nvisu = 1 ! Size for visualisation collection 84 | 85 | /End 86 | 87 | !================= 88 | &Statistics 89 | !================= 90 | 91 | spinup_time = 0. ! Time after which statistics are collected (in seconds) 92 | nstat = 1 ! Size arrays for statistic collection 93 | 94 | /End 95 | 96 | !####################### 97 | ! OPTIONAL PARAMETERS 98 | !####################### 99 | 100 | !================= 101 | &LESModel 102 | !================= 103 | jles=1 104 | smagcst=0.165 105 | walecst=0.5 106 | iwall=0 107 | /End 108 | 109 | !========= 110 | &CASE 111 | !========= 112 | 113 | /End 114 | -------------------------------------------------------------------------------- /examples/Taylor-Green-Vortex/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 2 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=65 ! X-direction nodes 16 | ny=65 ! Y-direction nodes 17 | nz=65 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 3.14159265358979 ! Lx (Size of the box in x-direction) 23 | yly = 3.14159265358979 ! Ly (Size of the boy in y-direction) 24 | zlz = 3.14159265358979 ! Lz (Size of the boz in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 1 28 | nclxn = 1 29 | ncly1 = 1 30 | nclyn = 1 31 | nclz1 = 1 32 | nclzn = 1 33 | 34 | ! Flow parameters 35 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 36 | re = 1600. ! nu=1/re (Kinematic Viscosity) 37 | u1 = 8. ! u1 (max velocity) (for inflow condition) 38 | u2 = 8. ! u2 (min velocity) (for inflow condition) 39 | init_noise = 0.0 ! Turbulence intensity (1=100%) !! Initial condition 40 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 41 | 42 | ! Time stepping 43 | dt = 0.001 ! Time step 44 | ifirst = 1 ! First iteration 45 | ilast = 20 ! Last iteration 46 | 47 | ! Enable modelling tools 48 | ilesmod=0 ! if 0 then DNS 49 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 50 | iibm=0 ! Flag for immersed boundary method 51 | 52 | ! Enable io 53 | ivisu=1 ! Store snapshots 54 | ipost=1 ! Do online postprocessing 55 | 56 | /End 57 | 58 | !==================== 59 | &NumOptions 60 | !==================== 61 | 62 | ! Spatial derivatives 63 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 64 | isecondder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 65 | 66 | ! Time scheme 67 | itimescheme = 5 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 68 | 69 | ! Dissipation control 70 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 71 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 72 | 73 | /End 74 | 75 | !================= 76 | &InOutParam 77 | !================= 78 | 79 | ! Basic I/O 80 | irestart = 0 ! Read initial flow field ? 81 | icheckpoint = 5 ! Frequency for writing backup file 82 | ioutput = 1000 ! Frequency for visualization 83 | nvisu = 1 ! Size for visualisation collection 84 | 85 | /End 86 | 87 | !================= 88 | &Statistics 89 | !================= 90 | 91 | spinup_time = 0 ! Time after which statistics are collected (in seconds) 92 | nstat = 1 ! Size arrays for statistic collection 93 | 94 | /End 95 | 96 | !####################### 97 | ! OPTIONAL PARAMETERS 98 | !####################### 99 | 100 | !================= 101 | &LESModel 102 | !================= 103 | jles=1 104 | smagcst=0.1 105 | walecst=0.5 106 | iwall=0 107 | /End 108 | 109 | !================= 110 | &CASE 111 | !================= 112 | tgv_twod = .FALSE. 113 | /End 114 | -------------------------------------------------------------------------------- /examples/Mixing-layer/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes, 7=Mixing layer) 8 | itype = 7 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=256 ! X-direction nodes 16 | ny=501 ! Y-direction nodes 17 | nz=8 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 30.7 ! Lx (Size of the box in x-direction) 23 | yly = 60.0 ! Ly (Size of the boy in y-direction) 24 | zlz = 1.0 ! Lz (Size of the boz in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 0 28 | nclxn = 0 29 | ncly1 = 1 30 | nclyn = 1 31 | nclz1 = 0 32 | nclzn = 0 33 | 34 | ! Flow parameters 35 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 36 | re = 400. ! nu=1/re (Kinematic Viscosity) 37 | init_noise = 0.0 ! Turbulence intensity (1=100%) !! Initial condition 38 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 39 | 40 | ! Time stepping 41 | dt = 0.01 ! Time step 42 | ifirst = 1 ! First iteration 43 | ilast = 20000 ! Last iteration 44 | 45 | ! Enable modelling tools 46 | ilesmod=0 ! if 0 then DNS 47 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 48 | iibm=0 ! Flag for immersed boundary method 49 | ilmn=.TRUE. ! Flag for Low Mach Number flow 50 | 51 | ! Enable io 52 | ivisu=1 ! Store snapshots 53 | ipost=1 ! Do online postprocessing 54 | 55 | /End 56 | 57 | !==================== 58 | &NumOptions 59 | !==================== 60 | 61 | ! Spatial derivatives 62 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 63 | isecondder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 64 | 65 | ! Time scheme 66 | itimescheme = 5 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 67 | 68 | ! Dissipation control 69 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 70 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 71 | 72 | /End 73 | 74 | !================= 75 | &InOutParam 76 | !================= 77 | 78 | ! Basic I/O 79 | irestart = 0 ! Read initial flow field ? 80 | icheckpoint = 500 ! Frequency for writing backup file 81 | ioutput = 100 ! Frequency for visualization 82 | nvisu = 1 ! Size for visualisation collection 83 | 84 | /End 85 | 86 | !================= 87 | &Statistics 88 | !================= 89 | 90 | spinup_time = 0. ! Time after which statistics are collected (in seconds) 91 | nstat = 1 ! Size arrays for statistic collection 92 | 93 | /End 94 | 95 | !================= 96 | &LMN 97 | !================= 98 | 99 | dens1 = 0.5 ! Density of 'hot' stream (y > 0) 100 | dens2 = 1.0 ! Density of 'cold' stream (y < 0) 101 | 102 | prandtl = 0.75 ! Prandtl number 103 | 104 | ivarcoeff = .FALSE. ! Solve variable-coefficient Poisson equation 105 | 106 | /End 107 | 108 | !####################### 109 | ! OPTIONAL PARAMETERS 110 | !####################### 111 | -------------------------------------------------------------------------------- /examples/Dbg-schemes/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 6 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=64 ! X-direction nodes 16 | ny=64 ! Y-direction nodes 17 | nz=64 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.3 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 1. ! Lx (Size of the box in x-direction) 23 | yly = 1. ! Ly (Size of the box in y-direction) 24 | zlz = 1. ! Lz (Size of the box in z-direction) 25 | 26 | ! Flow parameters 27 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 28 | re = 5000. ! nu=1/re (Kinematic Viscosity) 29 | u1 = 8. ! u1 (max velocity) (for inflow condition) 30 | u2 = 8. ! u2 (min velocity) (for inflow condition) 31 | init_noise = 0.0 ! Turbulence intensity (1=100%) !! Initial condition 32 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 33 | 34 | ! Boundary conditions 35 | nclx1 = 2 36 | nclxn = 2 37 | ncly1 = 2 38 | nclyn = 2 39 | nclz1 = 2 40 | nclzn = 2 41 | 42 | ! Time stepping 43 | dt = 0.0005 ! Time step 44 | ifirst = 1 ! First iteration 45 | ilast = 1 ! Last iteration 46 | 47 | ! Enable modelling tools 48 | ilesmod=0 ! if 0 then DNS 49 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 50 | iibm=0 ! Flag for immersed boundary method 51 | 52 | /End 53 | 54 | !==================== 55 | &NumOptions 56 | !==================== 57 | 58 | ! Spatial derivatives 59 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 60 | isecondder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 61 | 62 | ! Time scheme 63 | itimescheme = 2 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 64 | 65 | ! Dissipation control 66 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 67 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 68 | 69 | /End 70 | 71 | !================= 72 | &InOutParam 73 | !================= 74 | 75 | ! Basic I/O 76 | irestart = 0 ! Read initial flow field ? 77 | icheckpoint = 500 ! Frequency for writing backup file 78 | ioutput = 100 ! Frequency for visualization 79 | nvisu = 1 ! Size for visualisation collection 80 | 81 | /End 82 | 83 | !================= 84 | &Statistics 85 | !================= 86 | 87 | spinup_time = 5000. ! Time after which statistics are collected (in seconds) 88 | nstat = 1 ! Size arrays for statistic collection 89 | 90 | /End 91 | 92 | !######################## 93 | ! OPTIONAL PARAMETERS 94 | !####################### 95 | 96 | !================ 97 | &ScalarParam 98 | !================ 99 | 100 | numscalar = 1 ! How many scalars? 101 | Sc = 0.2 ! Schmidt number 102 | 103 | /End 104 | 105 | !================ 106 | &LESModel 107 | !================ 108 | 109 | iles = 4 ! LES Model (1: Phys Smag, 2: Phys WALE, 3: Phys dyn. Smag, 4: iSVV, 5: dyn SEV) 110 | smagcst = 0.14 ! Smagorinsky constant 111 | walecst = 0.5 ! WALES Model Coefficient 112 | 113 | iwall = 0 ! Enable wall modeling 114 | 115 | /End 116 | 117 | !================ 118 | &WallModel 119 | !================ 120 | 121 | SmagWallDamp = 1 ! Smagorinsky damping function for ABL if 1 122 | 123 | /End 124 | -------------------------------------------------------------------------------- /examples/Jet/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes, 7=Mixing layer, 8=Jet) 8 | itype = 8 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=129 ! X-direction nodes 16 | ny=257 ! Y-direction nodes 17 | nz=129 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 10. ! Lx (Size of the box in x-direction) 23 | yly = 20. ! Ly (Size of the boy in y-direction) 24 | zlz = 10. ! Lz (Size of the boz in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 2 28 | nclxn = 2 29 | ncly1 = 2 30 | nclyn = 2 31 | nclz1 = 2 32 | nclzn = 2 33 | 34 | ! Flow parameters 35 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 36 | re = 1000. ! nu=1/re (Kinematic Viscosity) 37 | u1 = 1. ! u1 (max velocity) (for inflow condition) 38 | u2 = 0.02 ! u2 (min velocity) (for inflow condition) 39 | init_noise = 0.05 ! Turbulence intensity (1=100%) !! Initial condition 40 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 41 | 42 | ! Time stepping 43 | dt = 0.004 ! Time step 44 | ifirst = 1 ! First iteration 45 | ilast = 1 !18000 ! Last iteration 46 | 47 | ! Enable modelling tools 48 | ilesmod=0 ! if 0 then DNS 49 | numscalar=2 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 50 | iibm=0 ! Flag for immersed boundary method 51 | ilmn=.TRUE. ! Flag for Low Mach Number flow 52 | 53 | ! Enable io 54 | ivisu=1 ! Store snapshots 55 | ipost=1 ! Do online postprocessing 56 | 57 | /End 58 | 59 | !==================== 60 | &NumOptions 61 | !==================== 62 | 63 | ! Spatial derivatives 64 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 65 | isecondder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 66 | 67 | ! Time scheme 68 | itimescheme = 5 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 69 | 70 | ! Dissipation control 71 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 72 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 73 | 74 | /End 75 | 76 | !================= 77 | &InOutParam 78 | !================= 79 | 80 | ! Basic I/O 81 | irestart = 0 ! Read initial flow field ? 82 | icheckpoint = 500 ! Frequency for writing backup file 83 | ioutput = 1 !125 ! Frequency for visualization 84 | nvisu = 1 ! Size for visualisation collection 85 | 86 | /End 87 | 88 | !================= 89 | &Statistics 90 | !================= 91 | 92 | spinup_time = 0. ! Time after which statistics are collected (in seconds) 93 | nstat = 1 ! Size arrays for statistic collection 94 | 95 | /End 96 | 97 | !================= 98 | &LMN 99 | !================= 100 | 101 | ilmn_solve_temp = .TRUE. ! Solve for temperature instead of density 102 | prandtl = 0.7 ! Prandtl number 103 | 104 | !! Set species 105 | primary_species = 1 106 | 107 | massfrac(1) = .TRUE. 108 | massfrac(2) = .TRUE. 109 | 110 | mol_weight(1) = 1.0 111 | mol_weight(2) = 2.0 112 | 113 | /End 114 | 115 | !================= 116 | &ScalarParam 117 | !================= 118 | 119 | !! Schmidt numbers 120 | sc(1) = 1.0 121 | sc(2) = 1.0 122 | 123 | /End 124 | 125 | !####################### 126 | ! OPTIONAL PARAMETERS 127 | !####################### 128 | -------------------------------------------------------------------------------- /examples/Test-Convergence/test-convergence.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # FILE: test-convergence.sh 4 | # DESCRIPTION: Runs convergence tests. 5 | # AUTHOR: Paul Bartholomew 6 | # 7 | 8 | echo "==============================================================" 9 | echo " Running convergence tests for xcompact3d" 10 | echo " Author: Paul Bartholomew " 11 | echo "==============================================================" 12 | 13 | CWD=$(pwd) 14 | 15 | MESHES=( 16 ) 16 | SSCHEMES=( 1 ) 17 | FAILURES="The following tests failed to run:\n" 18 | 19 | echo "Running case:" 20 | for msh in "${MESHES[@]}" 21 | do 22 | for sscheme in "${SSCHEMES[@]}" 23 | do 24 | if [ "${msh}" == "128" ]; then 25 | DELTAT=( 4e-3 2e-3 1e-3 5e-4 ) 26 | TSCHEMES=( 1 2 3 4 ) 27 | else 28 | DELTAT=( 5e-4 ) 29 | TSCHEMES=( 1 ) 30 | fi 31 | for tscheme in "${TSCHEMES[@]}" 32 | do 33 | if [ "${tscheme}" == "1" ]; then 34 | XBCS=( "00" "11" "22" "12" "21" ) 35 | YBCS=( "00" "11" "22" "12" "21" ) 36 | else 37 | XBCS=( "00" ) 38 | YBCS=( "00" ) 39 | fi 40 | for dt in "${DELTAT[@]}" 41 | do 42 | # Calculate number of steps to t=2.5 43 | NSTEP=$(echo "print(int(0.01 / ${dt}))" | python3) 44 | 45 | # Loop over boundary conditions 46 | for ncx in "${XBCS[@]}" 47 | do 48 | for ncy in "${YBCS[@]}" 49 | do 50 | # Set mesh size accoring to BCs 51 | if [ "${ncx}" = "00" ]; then 52 | mshx=${msh} 53 | else 54 | let mshx=${msh}+1 55 | fi 56 | if [ "${ncy}" = "00" ]; then 57 | mshy=${msh} 58 | else 59 | let mshy=${msh}+1 60 | fi 61 | 62 | # Setup working directory 63 | cd ${CWD} 64 | WORK=s${sscheme}/t${tscheme}/b${ncx}${ncy}/n${msh}/dt${dt} 65 | echo "- ${WORK}" 66 | mkdir -p ${WORK} 67 | cp input.i3d ${WORK} 68 | cp incompact3d ${WORK} 69 | cp probes.prm ${WORK} 70 | cp visu.prm ${WORK} 71 | cd ${WORK} 72 | 73 | # Modify input.i3d and run 74 | sed -i "s/nx = .*/nx = ${mshx} /g" input.i3d 75 | sed -i "s/ny = .*/ny = ${mshx} /g" input.i3d 76 | sed -i "s/dt = .*/dt = ${dt} /g" input.i3d 77 | sed -i "s/ilast = .*/ilast = ${NSTEP} /g" input.i3d 78 | sed -i "s/iorder = .*/iorder = ${sscheme} /g" input.i3d 79 | sed -i "s/itimescheme = .*/itimescheme = ${tscheme} /g" input.i3d 80 | sed -i "s/nclx1 = .*/nclx1 = ${ncx:0:1} /g" input.i3d 81 | sed -i "s/nclxn = .*/nclxn = ${ncx:1:1} /g" input.i3d 82 | sed -i "s/ncly1 = .*/ncly1 = ${ncy:0:1} /g" input.i3d 83 | sed -i "s/nclyn = .*/nclyn = ${ncy:1:1} /g" input.i3d 84 | 85 | mpiexec -np 4 ./incompact3d > OUTPUT.log 86 | if [ "$?" != "0" ]; then 87 | FAILURES="${FAILURES}${WORK}\n" 88 | fi 89 | done 90 | done 91 | done 92 | done 93 | done 94 | done 95 | 96 | echo "--------------------------------------------------------------" 97 | echo -e ${FAILURES} 98 | -------------------------------------------------------------------------------- /decomp2d/io_write_plane.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'mpiio_write_plane_3d_...' in io.f90 14 | 15 | ! It is much easier to implement if all mpi ranks participate I/O. 16 | ! Transpose the 3D data if necessary. 17 | 18 | if (present(opt_decomp)) then 19 | decomp = opt_decomp 20 | else 21 | call get_decomp_info(decomp) 22 | end if 23 | 24 | if (iplane==1) then 25 | allocate(wk(decomp%xsz(1),decomp%xsz(2),decomp%xsz(3))) 26 | if (ipencil==1) then 27 | wk = var 28 | else if (ipencil==2) then 29 | call transpose_y_to_x(var,wk,decomp) 30 | else if (ipencil==3) then 31 | allocate(wk2(decomp%ysz(1),decomp%ysz(2),decomp%ysz(3))) 32 | call transpose_z_to_y(var,wk2,decomp) 33 | call transpose_y_to_x(wk2,wk,decomp) 34 | deallocate(wk2) 35 | end if 36 | allocate(wk2d(1,decomp%xsz(2),decomp%xsz(3))) 37 | do k=1,decomp%xsz(3) 38 | do j=1,decomp%xsz(2) 39 | wk2d(1,j,k)=wk(n,j,k) 40 | end do 41 | end do 42 | sizes(1) = 1 43 | sizes(2) = decomp%ysz(2) 44 | sizes(3) = decomp%zsz(3) 45 | subsizes(1) = 1 46 | subsizes(2) = decomp%xsz(2) 47 | subsizes(3) = decomp%xsz(3) 48 | starts(1) = 0 49 | starts(2) = decomp%xst(2)-1 50 | starts(3) = decomp%xst(3)-1 51 | 52 | else if (iplane==2) then 53 | allocate(wk(decomp%ysz(1),decomp%ysz(2),decomp%ysz(3))) 54 | if (ipencil==1) then 55 | call transpose_x_to_y(var,wk,decomp) 56 | else if (ipencil==2) then 57 | wk = var 58 | else if (ipencil==3) then 59 | call transpose_z_to_y(var,wk,decomp) 60 | end if 61 | allocate(wk2d(decomp%ysz(1),1,decomp%ysz(3))) 62 | do k=1,decomp%ysz(3) 63 | do i=1,decomp%ysz(1) 64 | wk2d(i,1,k)=wk(i,n,k) 65 | end do 66 | end do 67 | sizes(1) = decomp%xsz(1) 68 | sizes(2) = 1 69 | sizes(3) = decomp%zsz(3) 70 | subsizes(1) = decomp%ysz(1) 71 | subsizes(2) = 1 72 | subsizes(3) = decomp%ysz(3) 73 | starts(1) = decomp%yst(1)-1 74 | starts(2) = 0 75 | starts(3) = decomp%yst(3)-1 76 | 77 | else if (iplane==3) then 78 | allocate(wk(decomp%zsz(1),decomp%zsz(2),decomp%zsz(3))) 79 | if (ipencil==1) then 80 | allocate(wk2(decomp%ysz(1),decomp%ysz(2),decomp%ysz(3))) 81 | call transpose_x_to_y(var,wk2,decomp) 82 | call transpose_y_to_z(wk2,wk,decomp) 83 | deallocate(wk2) 84 | else if (ipencil==2) then 85 | call transpose_y_to_z(var,wk,decomp) 86 | else if (ipencil==3) then 87 | wk = var 88 | end if 89 | allocate(wk2d(decomp%zsz(1),decomp%zsz(2),1)) 90 | do j=1,decomp%zsz(2) 91 | do i=1,decomp%zsz(1) 92 | wk2d(i,j,1)=wk(i,j,n) 93 | end do 94 | end do 95 | sizes(1) = decomp%xsz(1) 96 | sizes(2) = decomp%ysz(2) 97 | sizes(3) = 1 98 | subsizes(1) = decomp%zsz(1) 99 | subsizes(2) = decomp%zsz(2) 100 | subsizes(3) = 1 101 | starts(1) = decomp%zst(1)-1 102 | starts(2) = decomp%zst(2)-1 103 | starts(3) = 0 104 | end if 105 | 106 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 107 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 108 | call MPI_TYPE_COMMIT(newtype,ierror) 109 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, & 110 | MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, & 111 | fh, ierror) 112 | filesize = 0_MPI_OFFSET_KIND 113 | call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting 114 | disp = 0_MPI_OFFSET_KIND 115 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 116 | newtype,'native',MPI_INFO_NULL,ierror) 117 | call MPI_FILE_WRITE_ALL(fh, wk2d, & 118 | subsizes(1)*subsizes(2)*subsizes(3), & 119 | data_type, MPI_STATUS_IGNORE, ierror) 120 | call MPI_FILE_CLOSE(fh,ierror) 121 | call MPI_TYPE_FREE(newtype,ierror) 122 | 123 | deallocate(wk,wk2d) 124 | -------------------------------------------------------------------------------- /examples/Channel-Flow/input_WALE_LES.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 3 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=128 ! X-direction nodes 16 | ny=65 ! Y-direction nodes 17 | nz=64 ! Z-direction nodes 18 | istret = 2 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 12. ! Lx (Size of the box in x-direction) 23 | yly = 2. ! Ly (Size of the box in y-direction) 24 | zlz = 4. ! Lz (Size of the box in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 0 28 | nclxn = 0 29 | ncly1 = 2 30 | nclyn = 2 31 | nclz1 = 0 32 | nclzn = 0 33 | 34 | ! Flow parameters 35 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 36 | re = 4200. ! nu=1/re (Kinematic Viscosity) 37 | u1 = 1. ! u1 (max velocity) (for inflow condition) 38 | u2 = 1. ! u2 (min velocity) (for inflow condition) 39 | init_noise = 0.125 ! Turbulence intensity (1=100%) !! Initial condition 40 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 41 | 42 | ! Time stepping 43 | dt = 0.0025 ! Time step 44 | ifirst = 1 ! First iteration 45 | ilast = 300000 ! Last iteration 46 | 47 | ! Enable modelling tools 48 | ilesmod=1 ! if 0 then DNS 49 | numscalar = 0 ! How many scalars? (Set to zero to disable scalars) 50 | iibm=0 ! Flag for immersed boundary method 51 | 52 | /End 53 | 54 | !==================== 55 | &NumOptions 56 | !==================== 57 | 58 | ! Spatial derivatives 59 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 60 | isecondder = 5 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 61 | ipinter = 3 ! interpolation scheme (1: classic, 2: optimized, 3: optimized agressive) 62 | 63 | ! Time scheme 64 | itimescheme = 5 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4, 7-->CN2+AB3) 65 | 66 | ! Dissipation control 67 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 68 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 69 | 70 | /End 71 | 72 | !================= 73 | &InOutParam 74 | !================= 75 | 76 | ! Basic I/O 77 | irestart = 0 ! Read initial flow field ? 78 | icheckpoint = 5000 ! Frequency for writing backup file 79 | ioutput = 1000 ! Frequency for visualization 80 | nvisu = 1 ! Size for visualisation collection 81 | 82 | /End 83 | 84 | !================= 85 | &Statistics 86 | !================= 87 | 88 | wrotation = 0.12 ! rotation speed to trigger turbulence 89 | spinup_time = 10000 ! number of time steps with a rotation to trigger turbulence 90 | nstat = 1 ! Size arrays for statistic collection 91 | initstat = 100000 ! Time steps after which statistics are collected 92 | 93 | /End 94 | 95 | !######################## 96 | ! OPTIONAL PARAMETERS 97 | !####################### 98 | 99 | !================ 100 | &ScalarParam 101 | !================ 102 | 103 | Sc(1) = 1.0 ! Schmidt number 104 | 105 | nclxS1 = 2 106 | nclxSn = 2 107 | nclyS1 = 2 108 | nclySn = 1 109 | nclzS1 = 1 110 | nclzSn = 1 111 | 112 | /End 113 | 114 | !================ 115 | &LESModel 116 | !================ 117 | 118 | jles = 2 ! LES Model (1: Phys Smag, 2: Phys WALE, 3: Phys dyn. Smag, 4: iSVV, 5: dyn SEV) 119 | smagcst = 0.14 ! Smagorinsky constant 120 | walecst = 0.325 ! WALES Model Coefficient 121 | iwall = 0 ! Enable wall modeling 122 | 123 | /End 124 | 125 | !================ 126 | &WallModel 127 | !================ 128 | 129 | SmagWallDamp = 1 ! Smagorinsky damping function for ABL if 1 130 | 131 | /End 132 | 133 | &CASE 134 | /End 135 | -------------------------------------------------------------------------------- /examples/Periodic-hill/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 4 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=256 ! X-direction nodes 16 | ny=257 ! Y-direction nodes 17 | nz=8 ! Z-direction nodes 18 | istret = 2 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 2. ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 9. ! Lx (Size of the box in x-direction) 23 | yly = 3.036 ! Ly (Size of the box in y-direction) 24 | zlz = 0.5 ! Lz (Size of the box in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 0 28 | nclxn = 0 29 | ncly1 = 2 30 | nclyn = 2 31 | nclz1 = 0 32 | nclzn = 0 33 | 34 | 35 | ! Flow parameters 36 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 37 | re = 700. ! nu=1/re (Kinematic Viscosity) 38 | u1 = 1. ! u1 (max velocity) (for inflow condition) 39 | u2 = 1. ! u2 (min velocity) (for inflow condition) 40 | init_noise = 0.125 ! Turbulence intensity (1=100%) !! Initial condition 41 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 42 | 43 | ! Time stepping 44 | dt = 0.0005 ! Time step 45 | ifirst = 1 ! First iteration 46 | ilast = 10 ! Last iteration 47 | 48 | ! Enable modelling tools 49 | ilesmod=0 ! if 0 then DNS 50 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 51 | iibm=2 ! Flag for immersed boundary method 52 | 53 | /End 54 | 55 | !==================== 56 | &NumOptions 57 | !==================== 58 | 59 | ! Spatial derivatives 60 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 61 | isecondder = 5 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 62 | ipinter = 3 ! interpolation scheme (1: classic, 2: optimized, 3: optimized agressive) 63 | 64 | ! Time scheme 65 | itimescheme = 3 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 66 | 67 | ! Dissipation control 68 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 69 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 70 | 71 | /End 72 | 73 | !================= 74 | &InOutParam 75 | !================= 76 | 77 | ! Basic I/O 78 | irestart = 0 ! Read initial flow field ? 79 | icheckpoint = 5 ! Frequency for writing backup file 80 | ioutput = 1 ! Frequency for visualization 81 | nvisu = 1 ! Size for visualisation collection 82 | 83 | /End 84 | 85 | !================= 86 | &Statistics 87 | !================= 88 | 89 | nstat = 1 ! Size arrays for statistic collection 90 | initstat = 6 ! Time steps after which statistics are collected 91 | 92 | 93 | /End 94 | 95 | !######################## 96 | ! OPTIONAL PARAMETERS 97 | !####################### 98 | 99 | !================ 100 | &ScalarParam 101 | !================ 102 | 103 | numscalar = 0 ! How many scalars? 104 | Sc = 0.2 ! Schmidt number 105 | 106 | /End 107 | 108 | !================ 109 | &LESModel 110 | !================ 111 | 112 | iles = 0 ! LES Model (1: Phys Smag, 2: Phys WALE, 3: Phys dyn. Smag, 4: iSVV, 5: dyn SEV) 113 | smagcst = 0.14 ! Smagorinsky constant 114 | walecst = 0.5 ! WALES Model Coefficient 115 | iwall = 0 ! Enable wall modeling 116 | 117 | /End 118 | 119 | !================ 120 | &WallModel 121 | !================ 122 | 123 | SmagWallDamp = 1 ! Smagorinsky damping function for ABL if 1 124 | 125 | /End 126 | 127 | 128 | !================ 129 | &ibmstuff 130 | !================ 131 | 132 | nraf=10 !level of refinement for iibm==2 to find the surface of the immersed object 133 | nobjmax=2 !number of immersed objects (DO NOT USE ZERO OBJECTS) 134 | 135 | /End 136 | -------------------------------------------------------------------------------- /decomp2d/halo.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 13 | ! Halo cell support for neighbouring pencils to exchange data 14 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 15 | subroutine update_halo_real(in, out, level, opt_decomp, opt_global) 16 | 17 | implicit none 18 | 19 | integer, intent(IN) :: level ! levels of halo cells required 20 | real(mytype), dimension(:,:,:), intent(IN) :: in 21 | real(mytype), allocatable, dimension(:,:,:), intent(OUT) :: out 22 | TYPE(DECOMP_INFO), optional :: opt_decomp 23 | logical, optional :: opt_global 24 | 25 | TYPE(DECOMP_INFO) :: decomp 26 | logical :: global 27 | 28 | ! starting/ending index of array with halo cells 29 | integer :: xs, ys, zs, xe, ye, ze 30 | 31 | integer :: i, j, k, s1, s2, s3, ierror 32 | integer :: data_type 33 | 34 | integer :: icount, ilength, ijump 35 | integer :: halo12, halo21, halo31, halo32 36 | integer, dimension(4) :: requests 37 | integer, dimension(MPI_STATUS_SIZE,4) :: status 38 | integer :: tag_e, tag_w, tag_n, tag_s, tag_t, tag_b 39 | 40 | data_type = real_type 41 | 42 | #include "halo_common.inc" 43 | 44 | return 45 | end subroutine update_halo_real 46 | 47 | 48 | subroutine update_halo_complex(in, out, level, opt_decomp, opt_global) 49 | 50 | implicit none 51 | 52 | integer, intent(IN) :: level ! levels of halo cells required 53 | complex(mytype), dimension(:,:,:), intent(IN) :: in 54 | complex(mytype), allocatable, dimension(:,:,:), intent(OUT) :: out 55 | TYPE(DECOMP_INFO), optional :: opt_decomp 56 | logical, optional :: opt_global 57 | 58 | TYPE(DECOMP_INFO) :: decomp 59 | logical :: global 60 | 61 | ! starting/ending index of array with halo cells 62 | integer :: xs, ys, zs, xe, ye, ze 63 | 64 | integer :: i, j, k, s1, s2, s3, ierror 65 | integer :: data_type 66 | 67 | integer :: icount, ilength, ijump 68 | integer :: halo12, halo21, halo31, halo32 69 | integer, dimension(4) :: requests 70 | integer, dimension(MPI_STATUS_SIZE,4) :: status 71 | integer :: tag_e, tag_w, tag_n, tag_s, tag_t, tag_b 72 | 73 | data_type = complex_type 74 | 75 | #include "halo_common.inc" 76 | 77 | return 78 | end subroutine update_halo_complex 79 | 80 | 81 | 82 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 83 | ! To support halo-cell exchange: 84 | ! find the MPI ranks of neighbouring pencils 85 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 86 | subroutine init_neighbour 87 | 88 | integer :: ierror 89 | 90 | ! For X-pencil 91 | neighbour(1,1) = MPI_PROC_NULL ! east 92 | neighbour(1,2) = MPI_PROC_NULL ! west 93 | call MPI_CART_SHIFT(DECOMP_2D_COMM_CART_X, 0, 1, & 94 | neighbour(1,4), neighbour(1,3), ierror) ! north & south 95 | call MPI_CART_SHIFT(DECOMP_2D_COMM_CART_X, 1, 1, & 96 | neighbour(1,6), neighbour(1,5), ierror) ! top & bottom 97 | 98 | ! For Y-pencil 99 | call MPI_CART_SHIFT(DECOMP_2D_COMM_CART_Y, 0, 1, & 100 | neighbour(2,2), neighbour(2,1), ierror) ! east & west 101 | neighbour(2,3) = MPI_PROC_NULL ! north 102 | neighbour(2,4) = MPI_PROC_NULL ! south 103 | call MPI_CART_SHIFT(DECOMP_2D_COMM_CART_Y, 1, 1, & 104 | neighbour(2,6), neighbour(2,5), ierror) ! top & bottom 105 | 106 | ! For Z-pencil 107 | call MPI_CART_SHIFT(DECOMP_2D_COMM_CART_Z, 0, 1, & 108 | neighbour(3,2), neighbour(3,1), ierror) ! east & west 109 | call MPI_CART_SHIFT(DECOMP_2D_COMM_CART_Z, 1, 1, & 110 | neighbour(3,4), neighbour(3,3), ierror) ! north & south 111 | neighbour(3,5) = MPI_PROC_NULL ! top 112 | neighbour(3,6) = MPI_PROC_NULL ! bottom 113 | 114 | return 115 | end subroutine init_neighbour 116 | -------------------------------------------------------------------------------- /examples/Channel-Flow/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 3 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=128 ! X-direction nodes 16 | ny=65 ! Y-direction nodes 17 | nz=64 ! Z-direction nodes 18 | istret = 2 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 8. ! Lx (Size of the box in x-direction) 23 | yly = 2. ! Ly (Size of the box in y-direction) 24 | zlz = 4. ! Lz (Size of the box in z-direction) 25 | 26 | ! Flow parameters 27 | re = 4200. ! nu=1/re (Kinematic Viscosity) 28 | icpg = 0 ! if icpg=1, then re is friction Reynolds number 29 | 30 | ! Time stepping 31 | dt = 0.005 ! Time step 32 | ifirst = 1 ! First iteration 33 | ilast = 100000 ! Last iteration 34 | 35 | ! Enable modelling tools 36 | ilesmod=0 ! if 0 then DNS 37 | numscalar = 0 ! How many scalars? (Set to zero to disable scalars) 38 | iibm=0 ! Flag for immersed boundary method 39 | 40 | ! Boundary and initial conditions 41 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 42 | u1 = 1. ! u1 (max velocity) (for inflow condition) 43 | u2 = 1. ! u2 (min velocity) (for inflow condition) 44 | init_noise = 0.125 ! Turbulence intensity (1=100%) !! Initial condition 45 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 46 | 47 | nclx1 = 0 48 | nclxn = 0 49 | ncly1 = 2 50 | nclyn = 2 51 | nclz1 = 0 52 | nclzn = 0 53 | 54 | /End 55 | 56 | !==================== 57 | &NumOptions 58 | !==================== 59 | 60 | ! Spatial derivatives 61 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 62 | isecondder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 63 | ipinter = 1 ! interpolation scheme (1: classic, 2: optimized, 3: optimized agressive) 64 | 65 | ! Time scheme 66 | itimescheme = 5 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4, 7-->CN2+AB3) 67 | 68 | ! Dissipation control 69 | fpi2 = 1.0 70 | nu0nu = 1.0 ! Ratio between hyperviscosity/viscosity at nu 71 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 72 | 73 | /End 74 | 75 | !================= 76 | &InOutParam 77 | !================= 78 | 79 | ! Basic I/O 80 | irestart = 0 ! Read initial flow field ? 81 | icheckpoint = 5000 ! Frequency for writing backup file 82 | ioutput = 1000 ! Frequency for visualization 83 | nvisu = 1 ! Size for visualisation collection 84 | 85 | /End 86 | 87 | !================= 88 | &Statistics 89 | !================= 90 | 91 | wrotation = 0.12 ! rotation speed to trigger turbulence 92 | spinup_time = 5000 ! number of time steps with a rotation to trigger turbulence 93 | nstat = 1 ! Size arrays for statistic collection 94 | initstat = 40000 ! Time steps after which statistics are collected 95 | 96 | /End 97 | 98 | !######################## 99 | ! OPTIONAL PARAMETERS 100 | !####################### 101 | 102 | !================ 103 | &ScalarParam 104 | !================ 105 | 106 | Sc(1) = 1.0 ! Schmidt number 107 | 108 | nclxS1 = 0 109 | nclxSn = 0 110 | nclyS1 = 2 111 | nclySn = 2 112 | nclzS1 = 0 113 | nclzSn = 0 114 | 115 | /End 116 | 117 | !================ 118 | &LESModel 119 | !================ 120 | 121 | iles = 0 ! LES Model (1: Phys Smag, 2: Phys WALE, 3: Phys dyn. Smag, 4: iSVV, 5: dyn SEV) 122 | smagcst = 0.14 ! Smagorinsky constant 123 | walecst = 0.5 ! WALES Model Coefficient 124 | iwall = 0 ! Enable wall modeling 125 | 126 | /End 127 | 128 | !================ 129 | &WallModel 130 | !================ 131 | 132 | SmagWallDamp = 0 ! Smagorinsky damping function for ABL if 1 133 | 134 | /End 135 | 136 | &CASE 137 | /End 138 | -------------------------------------------------------------------------------- /examples/Dbg-schemes/test: -------------------------------------------------------------------------------- 1 | =========================================================== 2 | ======================Incompact3d========================== 3 | ===Copyright (c) 2018 Eric Lamballais and Sylvain Laizet=== 4 | ===Modified by Felipe Schuch and Ricardo Frantz============ 5 | =========================================================== 6 | Git version : 05f2620 7 | 8 | (lx,ly,lz)= 1.0000000000000000 1.0000000000000000 1.0000000000000000 9 | (nx,ny,nz)= 32 32 32 10 | (dx,dy,dz)= 3.2258064516129031E-002 3.2258064516129031E-002 3.2258064516129031E-002 11 | (nx*ny*nz)= 32768 12 | (p_row,p_col)= 1 1 13 | 14 | Numerical precision: Double 15 | Boundary condition : (nclx1 ,nclxn )=(2,2) 16 | (ncly1 ,nclyn )=(2,2) 17 | (nclz1 ,nclzn )=(2,2) 18 | High and low speed : u1= 2.00 and u2= 1.00 19 | Reynolds number Re : 5000.00000000 20 | Time step dt : 0.00050000 21 | Spatial scheme : 1.00000000 22 | : DNS 23 | Temporal scheme : Adams-bashforth 2 24 | Scalar : off 25 | Immersed boundary : off 26 | 27 | Initializing variables... 28 | TOTO 1 0.0000000000000000 -7.4218750000000014E-003 1.0000000000000000 29 | TOTO 2 0.0000000000000000 -7.4218750000000014E-003 0.91895781162023060 30 | TOTO 3 0.0000000000000000 -7.4218750000000014E-003 0.68896691907568663 31 | TOTO 4 0.0000000000000000 -7.4218750000000014E-003 0.34730525284482028 32 | TOTO 5 0.0000000000000000 -7.4218750000000014E-003 -5.0649168838712642E-002 33 | TOTO 6 0.0000000000000000 -7.4218750000000014E-003 -0.44039415155763439 34 | TOTO 7 0.0000000000000000 -7.4218750000000014E-003 -0.75875812269279086 35 | TOTO 8 0.0000000000000000 -7.4218750000000014E-003 -0.95413925640004882 36 | TOTO 9 0.0000000000000000 -7.4218750000000014E-003 -0.99486932339189516 37 | TOTO 10 0.0000000000000000 -7.4218750000000014E-003 -0.87434661614458242 38 | TOTO 11 0.0000000000000000 -7.4218750000000014E-003 -0.61210598254766269 39 | TOTO 12 0.0000000000000000 -7.4218750000000014E-003 -0.25065253225872047 40 | TOTO 13 0.0000000000000000 -7.4218750000000014E-003 0.15142777750457667 41 | TOTO 14 0.0000000000000000 -7.4218750000000014E-003 0.52896401032696161 42 | TOTO 15 0.0000000000000000 -7.4218750000000014E-003 0.82076344120727629 43 | TOTO 16 0.0000000000000000 -7.4218750000000014E-003 0.97952994125249448 44 | TOTO 17 0.0000000000000000 -7.4218750000000014E-003 0.97952994125249460 45 | TOTO 18 0.0000000000000000 -7.4218750000000014E-003 0.82076344120727707 46 | TOTO 19 0.0000000000000000 -7.4218750000000014E-003 0.52896401032696361 47 | TOTO 20 0.0000000000000000 -7.4218750000000014E-003 0.15142777750457717 48 | TOTO 21 0.0000000000000000 -7.4218750000000014E-003 -0.25065253225872086 49 | TOTO 22 0.0000000000000000 -7.4218750000000014E-003 -0.61210598254766158 50 | TOTO 23 0.0000000000000000 -7.4218750000000014E-003 -0.87434661614458220 51 | TOTO 24 0.0000000000000000 -7.4218750000000014E-003 -0.99486932339189516 52 | TOTO 25 0.0000000000000000 -7.4218750000000014E-003 -0.95413925640004882 53 | TOTO 26 0.0000000000000000 -7.4218750000000014E-003 -0.75875812269279208 54 | TOTO 27 0.0000000000000000 -7.4218750000000014E-003 -0.44039415155763600 55 | TOTO 28 0.0000000000000000 -7.4218750000000014E-003 -5.0649168838712906E-002 56 | TOTO 29 0.0000000000000000 -7.4218750000000014E-003 0.34730525284482006 57 | TOTO 30 0.0000000000000000 -7.4218750000000014E-003 0.68896691907568630 58 | TOTO 31 0.0000000000000000 -7.4218750000000014E-003 0.91895781162023049 59 | TOTO 32 0.0000000000000000 -7.4218750000000014E-003 1.0000000000000000 60 | -------------------------------------------------------------------------------- /examples/Dbg-schemes/test1: -------------------------------------------------------------------------------- 1 | =========================================================== 2 | ======================Incompact3d========================== 3 | ===Copyright (c) 2018 Eric Lamballais and Sylvain Laizet=== 4 | ===Modified by Felipe Schuch and Ricardo Frantz============ 5 | =========================================================== 6 | Git version : 05f2620 7 | 8 | (lx,ly,lz)= 1.0000000000000000 1.0000000000000000 1.0000000000000000 9 | (nx,ny,nz)= 32 32 32 10 | (dx,dy,dz)= 3.1250000000000000E-002 3.1250000000000000E-002 3.1250000000000000E-002 11 | (nx*ny*nz)= 32768 12 | (p_row,p_col)= 1 1 13 | 14 | Numerical precision: Double 15 | Boundary condition : (nclx1 ,nclxn )=(0,0) 16 | (ncly1 ,nclyn )=(0,0) 17 | (nclz1 ,nclzn )=(0,0) 18 | High and low speed : u1= 2.00 and u2= 1.00 19 | Reynolds number Re : 5000.00000000 20 | Time step dt : 0.00050000 21 | Spatial scheme : 1.00000000 22 | : DNS 23 | Temporal scheme : Adams-bashforth 2 24 | Scalar : off 25 | Immersed boundary : off 26 | 27 | Initializing variables... 28 | TOTO 1 0.0000000000000000 -7.4218750000000014E-003 1.0000000000000000 29 | TOTO 2 0.0000000000000000 -7.4218750000000014E-003 0.92387953251128674 30 | TOTO 3 0.0000000000000000 -7.4218750000000014E-003 0.70710678118654757 31 | TOTO 4 0.0000000000000000 -7.4218750000000014E-003 0.38268343236508984 32 | TOTO 5 0.0000000000000000 -7.4218750000000014E-003 6.1232339957367660E-017 33 | TOTO 6 0.0000000000000000 -7.4218750000000014E-003 -0.38268343236508973 34 | TOTO 7 0.0000000000000000 -7.4218750000000014E-003 -0.70710678118654746 35 | TOTO 8 0.0000000000000000 -7.4218750000000014E-003 -0.92387953251128674 36 | TOTO 9 0.0000000000000000 -7.4218750000000014E-003 -1.0000000000000000 37 | TOTO 10 0.0000000000000000 -7.4218750000000014E-003 -0.92387953251128685 38 | TOTO 11 0.0000000000000000 -7.4218750000000014E-003 -0.70710678118654768 39 | TOTO 12 0.0000000000000000 -7.4218750000000014E-003 -0.38268343236509034 40 | TOTO 13 0.0000000000000000 -7.4218750000000014E-003 -1.8369701987210297E-016 41 | TOTO 14 0.0000000000000000 -7.4218750000000014E-003 0.38268343236509000 42 | TOTO 15 0.0000000000000000 -7.4218750000000014E-003 0.70710678118654735 43 | TOTO 16 0.0000000000000000 -7.4218750000000014E-003 0.92387953251128652 44 | TOTO 17 0.0000000000000000 -7.4218750000000014E-003 1.0000000000000000 45 | TOTO 18 0.0000000000000000 -7.4218750000000014E-003 0.92387953251128674 46 | TOTO 19 0.0000000000000000 -7.4218750000000014E-003 0.70710678118654768 47 | TOTO 20 0.0000000000000000 -7.4218750000000014E-003 0.38268343236509045 48 | TOTO 21 0.0000000000000000 -7.4218750000000014E-003 3.0616169978683831E-016 49 | TOTO 22 0.0000000000000000 -7.4218750000000014E-003 -0.38268343236508989 50 | TOTO 23 0.0000000000000000 -7.4218750000000014E-003 -0.70710678118654668 51 | TOTO 24 0.0000000000000000 -7.4218750000000014E-003 -0.92387953251128641 52 | TOTO 25 0.0000000000000000 -7.4218750000000014E-003 -1.0000000000000000 53 | TOTO 26 0.0000000000000000 -7.4218750000000014E-003 -0.92387953251128674 54 | TOTO 27 0.0000000000000000 -7.4218750000000014E-003 -0.70710678118654713 55 | TOTO 28 0.0000000000000000 -7.4218750000000014E-003 -0.38268343236509056 56 | TOTO 29 0.0000000000000000 -7.4218750000000014E-003 -4.2862637970157361E-016 57 | TOTO 30 0.0000000000000000 -7.4218750000000014E-003 0.38268343236508978 58 | TOTO 31 0.0000000000000000 -7.4218750000000014E-003 0.70710678118654657 59 | TOTO 32 0.0000000000000000 -7.4218750000000014E-003 0.92387953251128641 60 | -------------------------------------------------------------------------------- /examples/Lock-exchange/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 1 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=181 ! X-direction nodes 16 | ny=31 ! Y-direction nodes 17 | nz=31 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 18.0 ! Lx (Size of the box in x-direction) 23 | yly = 2.0 ! Ly (Size of the boy in y-direction) 24 | zlz = 2.0 ! Lz (Size of the boz in z-direction) 25 | 26 | ! Gravity vector 27 | gravx = 0.0 28 | gravy = -1.0 29 | gravz = 0.0 30 | 31 | ! Boundary conditions 32 | nclx1 = 1 33 | nclxn = 1 34 | ncly1 = 2 35 | nclyn = 1 36 | nclz1 = 1 37 | nclzn = 1 38 | 39 | ! Flow parameters 40 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 41 | re = 2236.0 ! nu=1/re (Kinematic Viscosity) 42 | init_noise = 0.01 ! Turbulence intensity (1=100%) !! Initial condition 43 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 44 | 45 | ! Time stepping 46 | dt = 0.0048 ! Time step 47 | ifirst = 1 ! First iteration 48 | ilast = 50000 ! Last iteration 49 | 50 | ! Enable modelling tools 51 | ilesmod=1 ! if 0 then DNS 52 | numscalar=1 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 53 | iibm=0 ! Flag for immersed boundary method 54 | ilmn = .FALSE. ! Enable low Mach number 55 | 56 | ! Enable io 57 | ivisu=1 ! Store snapshots 58 | ipost=1 ! Do online postprocessing 59 | 60 | /End 61 | 62 | !==================== 63 | &NumOptions 64 | !==================== 65 | 66 | ! Spatial derivatives 67 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 68 | isecondder = 5 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 69 | ipinter = 3 70 | 71 | ! Time scheme 72 | itimescheme = 2 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 73 | 74 | ! Dissipation control 75 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 76 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 77 | 78 | /End 79 | 80 | !================= 81 | &InOutParam 82 | !================= 83 | 84 | ! Basic I/O 85 | irestart = 0 ! Read initial flow field ? 86 | icheckpoint = 5000 ! Frequency for writing backup file 87 | ioutput = 250 ! Frequency for visualization 88 | nvisu = 1 ! Size for visualisation collection 89 | iprocessing = 20 90 | 91 | /End 92 | 93 | !================= 94 | &Statistics 95 | !================= 96 | 97 | spinup_time = 0. ! Time after which statistics are collected (in seconds) 98 | nstat = 1 ! Size arrays for statistic collection 99 | 100 | /End 101 | 102 | !================= 103 | &LMN 104 | !================= 105 | 106 | dens1 = 1.0 ! Density of 'hot' stream (y > 0) 107 | dens2 = 0.998 ! Density of 'cold' stream (y < 0) 108 | 109 | Fr = 0.04472136 110 | 111 | prandtl = 0.75 ! Prandtl number 112 | 113 | ivarcoeff = .FALSE. ! Solve variable-coefficient Poisson equation 114 | 115 | ibirman_eos = .TRUE. 116 | 117 | /End 118 | 119 | !================= 120 | &ScalarParam 121 | !================= 122 | 123 | !! Schmidt numbers 124 | sc(1) = 1.0 125 | 126 | !! Richardson numbers 127 | ri(1) = 1.0 128 | 129 | !! Settling velocities 130 | uset(1) = 0.02 131 | 132 | !! Initial concentrations 133 | cp(1) = 1.0 134 | 135 | ! Boundary conditions 136 | nclxS1 = 1 137 | nclxSn = 1 138 | nclyS1 = 2 139 | nclySn = 2 140 | nclzS1 = 1 141 | nclzSn = 1 142 | 143 | /End 144 | 145 | !####################### 146 | ! OPTIONAL PARAMETERS 147 | !####################### 148 | 149 | !================= 150 | &LESModel 151 | !================= 152 | 153 | jles=4 154 | 155 | /End 156 | 157 | !================= 158 | &CASE 159 | !================= 160 | 161 | pfront = 1.0 162 | 163 | /End 164 | -------------------------------------------------------------------------------- /examples/Turbulent-Boundary-Layer/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes, 9=Turbulent-Boundary-Layer) 8 | itype = 9 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=129 ! X-direction nodes 16 | ny=129 ! Y-direction nodes 17 | nz=32 ! Z-direction nodes 18 | istret = 3 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.7 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 50. ! Lx (Size of the box in x-direction) 23 | yly = 20. ! Ly (Size of the box in y-direction) 24 | zlz = 5. ! Lz (Size of the box in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 2 28 | nclxn = 2 29 | ncly1 = 2 30 | nclyn = 2 31 | nclz1 = 0 32 | nclzn = 0 33 | 34 | ! Flow parameters 35 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 36 | re = 1250. ! nu=1/re (Kinematic Viscosity) 37 | u1 = 1. ! u1 (max velocity) (for inflow condition) 38 | u2 = 1. ! u2 (min velocity) (for inflow condition) 39 | init_noise = 0.0 ! Turbulence intensity (1=100%) !! Initial condition 40 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 41 | 42 | ! Time stepping 43 | dt = 0.01 ! Time step 44 | ifirst = 10001 ! First iteration 45 | ilast = 25000 ! Last iteration 46 | 47 | ! Enable modelling tools 48 | ilesmod=1 ! if 0 then DNS 49 | numscalar = 1 ! How many scalars? (Set to zero to disable scalars) 50 | iibm=0 ! Flag for immersed boundary method 51 | 52 | /End 53 | 54 | !==================== 55 | &NumOptions 56 | !==================== 57 | 58 | ! Spatial derivatives 59 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 60 | isecondder = 5 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 61 | ipinter = 1 ! interpolation scheme (1: classic, 2: optimized, 3: optimized agressive) 62 | 63 | ! Time scheme 64 | itimescheme = 7 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4, 7->Semi-implicit) 65 | 66 | ! Dissipation control 67 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 68 | cnu = 0.33 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 69 | 70 | /End 71 | 72 | !================= 73 | &InOutParam 74 | !================= 75 | 76 | ! Basic I/O 77 | irestart = 1 ! Read initial flow field ? 78 | icheckpoint = 500 ! Frequency for writing backup file 79 | ioutput = 500 ! Frequency for visualization 80 | nvisu = 1 ! Size for visualisation collection 81 | 82 | /End 83 | 84 | !================= 85 | &Statistics 86 | !================= 87 | 88 | wrotation = 0.12 ! rotation speed to trigger turbulence 89 | spinup_time = 0 !10000 ! number of time steps with a rotation to trigger turbulence 90 | nstat = 1 ! Size arrays for statistic collection 91 | initstat = 31250 ! Time steps after which statistics are collected 92 | 93 | /End 94 | 95 | !######################## 96 | ! OPTIONAL PARAMETERS 97 | !####################### 98 | 99 | !================ 100 | &ScalarParam 101 | !================ 102 | 103 | Sc(1) = 1.0 ! Schmidt number 104 | 105 | nclxS1 = 2 106 | nclxSn = 2 107 | nclyS1 = 2 108 | nclySn = 2 109 | nclzS1 = 0 110 | nclzSn = 0 111 | 112 | /End 113 | 114 | !================ 115 | &LESModel 116 | !================ 117 | 118 | jles = 4 ! LES Model (1: Phys Smag, 2: Phys WALE, 3: Phys dyn. Smag, 4: iSVV, 5: dyn SEV) 119 | smagcst = 0.14 ! Smagorinsky constant 120 | walecst = 0.5 ! WALES Model Coefficient 121 | iwall = 0 ! Enable wall modeling 122 | 123 | /End 124 | 125 | !================ 126 | &WallModel 127 | !================ 128 | 129 | SmagWallDamp = 1 ! Smagorinsky damping function for ABL if 1 130 | 131 | /End 132 | 133 | 134 | !================ 135 | &Tripping 136 | !================ 137 | itrip=1 !1 to activate the tripping for TBL, 0 otherwise for LBL 138 | A_tr = 0.356625 !to be use with care, value is mesh-dependent 139 | !xs_tr_tbl=1.402033 140 | !ys_tr_tbl=0.350508 141 | !ts_tr_tbl=1.402033 142 | !x0_tr_tbl=3.505082 143 | 144 | /End 145 | 146 | &CASE 147 | /End 148 | -------------------------------------------------------------------------------- /examples/Cylinder/input.i3d: -------------------------------------------------------------------------------- 1 | ! -*- mode: f90 -*- 2 | 3 | !=================== 4 | &BasicParam 5 | !=================== 6 | 7 | ! Flow type (1=Lock-exchange, 2=TGV, 3=Channel, 4=Periodic hill, 5=Cylinder, 6=dbg-schemes) 8 | itype = 5 9 | 10 | ! Domain decomposition 11 | p_row=0 ! Row partition 12 | p_col=0 ! Column partition 13 | 14 | ! Mesh 15 | nx=65 ! X-direction nodes 16 | ny=33 ! Y-direction nodes 17 | nz=8 ! Z-direction nodes 18 | istret = 0 ! y mesh refinement (0:no, 1:center, 2:both sides, 3:bottom) 19 | beta = 0.259065151 ! Refinement parameter (beta) 20 | 21 | ! Domain 22 | xlx = 15. ! Lx (Size of the box in x-direction) 23 | yly = 10. ! Ly (Size of the box in y-direction) 24 | zlz = 3. ! Lz (Size of the box in z-direction) 25 | 26 | ! Boundary conditions 27 | nclx1 = 2 28 | nclxn = 2 29 | ncly1 = 1 30 | nclyn = 1 31 | nclz1 = 0 32 | nclzn = 0 33 | 34 | 35 | ! Flow parameters 36 | iin = 1 ! Inflow conditions (1: classic, 2: turbinit) 37 | re = 300. ! nu=1/re (Kinematic Viscosity) 38 | u1 = 1. ! u1 (max velocity) (for inflow condition) 39 | u2 = 1. ! u2 (min velocity) (for inflow condition) 40 | init_noise = 0.125 ! Turbulence intensity (1=100%) !! Initial condition 41 | inflow_noise = 0.0 ! Turbulence intensity (1=100%) !! Inflow condition 42 | 43 | ! Time stepping 44 | dt = 0.0025 ! Time step 45 | ifirst = 1 ! First iteration 46 | ilast = 90000 ! Last iteration 47 | 48 | ! Enable modelling tools 49 | ilesmod=1 ! if 0 then DNS 50 | iscalar=0 ! If iscalar=0 (no scalar), if iscalar=1 (scalar) 51 | iibm=1 ! Flag for immersed boundary method 52 | 53 | /End 54 | 55 | !==================== 56 | &NumOptions 57 | !==================== 58 | 59 | ! Spatial derivatives 60 | ifirstder = 4 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact) 61 | isecondder = 5 ! (1->2nd central, 2->4th central, 3->4th compact, 4-> 6th compact, 5->hyperviscous 6th) 62 | ipinter = 3 ! interpolation scheme (1: classic, 2: optimized, 3: optimized agressive) 63 | 64 | ! Time scheme 65 | itimescheme = 3 ! Time integration scheme (1->Euler,2->AB2, 3->AB3, 4->AB4,5->RK3,6->RK4) 66 | 67 | ! Dissipation control 68 | nu0nu = 4.0 ! Ratio between hyperviscosity/viscosity at nu 69 | cnu = 0.44 ! Ratio between hypervisvosity at k_m=2/3pi and k_c= pi 70 | 71 | /End 72 | 73 | !================= 74 | &InOutParam 75 | !================= 76 | 77 | ! Basic I/O 78 | irestart = 0 ! Read initial flow field ? 79 | icheckpoint = 100 ! Frequency for writing backup file 80 | ioutput = 100 ! Frequency for visualization 81 | nvisu = 1 ! Size for visualisation collection 82 | 83 | /End 84 | 85 | !================= 86 | &Statistics 87 | !================= 88 | 89 | nstat = 1 ! Size arrays for statistic collection 90 | initstat = 6 ! Time steps after which statistics are collected 91 | 92 | /End 93 | 94 | !######################## 95 | ! OPTIONAL PARAMETERS 96 | !####################### 97 | 98 | !================ 99 | &ScalarParam 100 | !================ 101 | 102 | numscalar = 0 ! How many scalars? 103 | Sc = 0.2 ! Schmidt number 104 | 105 | /End 106 | 107 | !================ 108 | &LESModel 109 | !================ 110 | 111 | jles = 0 ! LES Model (1: Phys Smag, 2: Phys WALE, 3: Phys dyn. Smag, 4: iSVV, 5: dyn SEV) 112 | smagcst = 0.14 ! Smagorinsky constant 113 | walecst = 0.5 ! WALES Model Coefficient 114 | iwall = 0 ! Enable wall modeling 115 | 116 | /End 117 | 118 | !================ 119 | &WallModel 120 | !================ 121 | 122 | SmagWallDamp = 1 ! Smagorinsky damping function for ABL if 1 123 | 124 | /End 125 | 126 | 127 | !================ 128 | &ibmstuff 129 | !================ 130 | 131 | cex=5. !when simulating a cylinder x coordinate of the center 132 | cey=5. !when simulating a cylinder y coordinate of the center 133 | ra=0.5 !when simulating a cylinder, radius 134 | nraf=10 !level of refinement for iibm==2 to find the surface of the immersed object 135 | nobjmax=2 !number of immersed objects (DO NOT USE ZERO OBJECTS) 136 | iforces=1 137 | nvol=1 !Number of volumes for computing force balance 138 | 139 | /End 140 | 141 | &ForceCVs 142 | 143 | xld(1) = 4.0 !X left for volume control 144 | xrd(1) = 6.0 !X right for volume control 145 | yld(1) = 4.0 !Y bottom for volume control 146 | yud(1) = 6.0 !Y top for volume control 147 | 148 | /End 149 | 150 | &CASE 151 | /End 152 | -------------------------------------------------------------------------------- /src/BC-User.f90: -------------------------------------------------------------------------------- 1 | !################################################################################ 2 | !This file is part of Xcompact3d. 3 | ! 4 | !Xcompact3d 5 | !Copyright (c) 2012 Eric Lamballais and Sylvain Laizet 6 | !eric.lamballais@univ-poitiers.fr / sylvain.laizet@gmail.com 7 | ! 8 | ! Xcompact3d is free software: you can redistribute it and/or modify 9 | ! it under the terms of the GNU General Public License as published by 10 | ! the Free Software Foundation. 11 | ! 12 | ! Xcompact3d is distributed in the hope that it will be useful, 13 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ! GNU General Public License for more details. 16 | ! 17 | ! You should have received a copy of the GNU General Public License 18 | ! along with the code. If not, see . 19 | !------------------------------------------------------------------------------- 20 | !------------------------------------------------------------------------------- 21 | ! We kindly request that you cite Xcompact3d/Incompact3d in your 22 | ! publications and presentations. The following citations are suggested: 23 | ! 24 | ! 1-Bartholomew P., Deskos G., Frantz R.A.S., Schuch F.N., Lamballais E. & 25 | ! Laizet S., 2020, Xcompact3D: An open-source framework for solving 26 | ! turbulence problems on a Cartesian mesh, SoftwareX, vol 12, pp 100550 27 | ! 28 | ! 2-Laizet S. & Lamballais E., 2009, High-order compact schemes for 29 | ! incompressible flows: a simple and efficient method with the quasi-spectral 30 | ! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015 31 | ! 32 | ! 3-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence 33 | ! problems with up to 0(10^5) computational cores, Int. J. of Numerical 34 | ! Methods in Fluids, vol 67 (11), pp 1735-1757 35 | !################################################################################ 36 | 37 | module user_sim 38 | 39 | USE decomp_2d 40 | USE variables 41 | USE param 42 | 43 | IMPLICIT NONE 44 | 45 | real(mytype), save, allocatable, dimension(:,:,:) :: vol1,volSimps1 46 | integer :: FS 47 | character(len=100) :: fileformat 48 | character(len=1),parameter :: NL=char(10) !new line character 49 | 50 | PRIVATE ! All functions/subroutines private by default 51 | PUBLIC :: init_user, boundary_conditions_user, postprocess_user 52 | 53 | contains 54 | 55 | subroutine init_user (ux1,uy1,uz1,ep1,phi1) 56 | 57 | USE decomp_2d 58 | USE decomp_2d_io 59 | USE variables 60 | USE param 61 | USE MPI 62 | 63 | implicit none 64 | 65 | real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux1,uy1,uz1,ep1 66 | real(mytype),dimension(xsize(1),xsize(2),xsize(3),numscalar) :: phi1 67 | 68 | real(mytype) :: y,r,um,r3,x,z,h,ct 69 | real(mytype) :: cx0,cy0,cz0,hg,lg 70 | integer :: k,j,i,fh,ierror,is,code 71 | integer (kind=MPI_OFFSET_KIND) :: disp 72 | integer, dimension (:), allocatable :: seed 73 | integer :: isize 74 | 75 | if (iscalar==1) then 76 | 77 | phi1(:,:,:,:) = zero 78 | endif 79 | 80 | if (iin.eq.0) then !empty domain 81 | 82 | if (nrank==0) write(*,*) "Empty initial domain!" 83 | 84 | ux1=zero; uy1=zero; uz1=zero 85 | 86 | endif 87 | 88 | if (iin.eq.1) then !generation of a random noise 89 | 90 | !INIT FOR G AND U=MEAN FLOW + NOISE 91 | do k=1,xsize(3) 92 | do j=1,xsize(2) 93 | do i=1,xsize(1) 94 | ux1(i,j,k)=ux1(i,j,k)+bxx1(j,k) 95 | uy1(i,j,k)=uy1(i,j,k)+bxy1(j,k) 96 | uz1(i,j,k)=uz1(i,j,k)+bxz1(j,k) 97 | enddo 98 | enddo 99 | enddo 100 | 101 | endif 102 | 103 | #ifdef DEBG 104 | if (nrank .eq. 0) print *,'# init end ok' 105 | #endif 106 | 107 | return 108 | end subroutine init_user 109 | 110 | subroutine boundary_conditions_user (ux,uy,uz,phi,ep) 111 | 112 | USE param 113 | USE variables 114 | USE decomp_2d 115 | 116 | implicit none 117 | 118 | real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux,uy,uz,ep 119 | real(mytype),dimension(xsize(1),xsize(2),xsize(3),numscalar) :: phi 120 | 121 | IF (nclx1.EQ.2) THEN 122 | ENDIF 123 | IF (nclxn.EQ.2) THEN 124 | ENDIF 125 | 126 | IF (ncly1.EQ.2) THEN 127 | ENDIF 128 | IF (nclyn.EQ.2) THEN 129 | ENDIF 130 | 131 | IF (nclz1.EQ.2) THEN 132 | ENDIF 133 | IF (nclzn.EQ.2) THEN 134 | ENDIF 135 | 136 | end subroutine boundary_conditions_user 137 | 138 | subroutine postprocess_user(ux1,uy1,uz1,phi1,ep1) 139 | 140 | USE decomp_2d 141 | USE MPI 142 | 143 | real(mytype),intent(in),dimension(xsize(1),xsize(2),xsize(3)) :: ux1, uy1, uz1, ep1 144 | real(mytype),intent(in),dimension(xsize(1),xsize(2),xsize(3),numscalar) :: phi1 145 | 146 | end subroutine postprocess_user 147 | 148 | end module user_sim 149 | -------------------------------------------------------------------------------- /decomp2d/glassman.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This module contains a few 'generic' FFT routines, making the 13 | ! 2DECOMP&FFT library not dependent on any external libraries 14 | 15 | module glassman 16 | 17 | use decomp_2d, only : mytype 18 | 19 | implicit none 20 | 21 | contains 22 | 23 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 24 | ! Following is a FFT implementation based on algorithm proposed by 25 | ! Glassman, a general FFT algorithm supporting arbitrary input length. 26 | ! 27 | ! W. E. Ferguson, Jr., "A simple derivation of Glassman general-n fast 28 | ! Fourier transform," Comput. and Math. with Appls., vol. 8, no. 6, pp. 29 | ! 401-411, 1982. 30 | ! 31 | ! Original implemtation online at http://www.jjj.de/fft/fftpage.html 32 | ! 33 | ! Updated 34 | ! - to handle double-precision as well 35 | ! - unnecessary scaling code removed 36 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 37 | 38 | SUBROUTINE SPCFFT(U,N,ISIGN,WORK) 39 | 40 | IMPLICIT NONE 41 | 42 | LOGICAL :: INU 43 | INTEGER :: A,B,C,N,I,ISIGN 44 | COMPLEX(mytype) :: U(*),WORK(*) 45 | 46 | A = 1 47 | B = N 48 | C = 1 49 | INU = .TRUE. 50 | 51 | DO WHILE ( B .GT. 1 ) 52 | A = C * A 53 | C = 2 54 | DO WHILE ( MOD(B,C) .NE. 0 ) 55 | C = C + 1 56 | END DO 57 | B = B / C 58 | IF ( INU ) THEN 59 | CALL SPCPFT (A,B,C,U,WORK,ISIGN) 60 | ELSE 61 | CALL SPCPFT (A,B,C,WORK,U,ISIGN) 62 | END IF 63 | INU = ( .NOT. INU ) 64 | END DO 65 | 66 | IF ( .NOT. INU ) THEN 67 | DO I = 1, N 68 | U(I) = WORK(I) 69 | END DO 70 | END IF 71 | 72 | RETURN 73 | END SUBROUTINE SPCFFT 74 | 75 | 76 | SUBROUTINE SPCPFT( A, B, C, UIN, UOUT, ISIGN ) 77 | 78 | IMPLICIT NONE 79 | 80 | INTEGER :: ISIGN,A,B,C,IA,IB,IC,JCR,JC 81 | 82 | DOUBLE PRECISION :: ANGLE 83 | 84 | COMPLEX(mytype) :: UIN(B,C,A),UOUT(B,A,C),DELTA,OMEGA,SUM 85 | 86 | ANGLE = 6.28318530717958_mytype / REAL( A * C, kind=mytype ) 87 | OMEGA = CMPLX( 1.0, 0.0, kind=mytype ) 88 | 89 | IF( ISIGN .EQ. 1 ) THEN 90 | DELTA = CMPLX( DCOS(ANGLE), DSIN(ANGLE), kind=mytype ) 91 | ELSE 92 | DELTA = CMPLX( DCOS(ANGLE), -DSIN(ANGLE), kind=mytype ) 93 | END IF 94 | 95 | DO IC = 1, C 96 | DO IA = 1, A 97 | DO IB = 1, B 98 | SUM = UIN( IB, C, IA ) 99 | DO JCR = 2, C 100 | JC = C + 1 - JCR 101 | SUM = UIN( IB, JC, IA ) + OMEGA * SUM 102 | END DO 103 | UOUT( IB, IA, IC ) = SUM 104 | END DO 105 | OMEGA = DELTA * OMEGA 106 | END DO 107 | END DO 108 | 109 | RETURN 110 | END SUBROUTINE SPCPFT 111 | 112 | 113 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 114 | ! A 3D real-to-complex routine implemented using the 1D FFT above 115 | ! Input: nx*ny*nz real numbers 116 | ! Output: (nx/2+1)*ny*nz complex numbers 117 | ! Just like big FFT libraries (such as FFTW) do 118 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 119 | subroutine glassman_3d_r2c(in_r,nx,ny,nz,out_c) 120 | 121 | implicit none 122 | 123 | integer, intent(IN) :: nx,ny,nz 124 | real(mytype), dimension(nx,ny,nz) :: in_r 125 | complex(mytype), dimension(nx/2+1,ny,nz) :: out_c 126 | 127 | complex(mytype), allocatable, dimension(:) :: buf, scratch 128 | integer :: maxsize, i,j,k 129 | 130 | maxsize = max(nx, max(ny,nz)) 131 | allocate(buf(maxsize)) 132 | allocate(scratch(maxsize)) 133 | 134 | ! ===== 1D FFTs in X ===== 135 | do k=1,nz 136 | do j=1,ny 137 | ! Glassman's 1D FFT is c2c only, 138 | ! needing some pre- and post-processing for r2c 139 | ! pack real input in complex storage 140 | do i=1,nx 141 | buf(i) = cmplx(in_r(i,j,k),0._mytype, kind=mytype) 142 | end do 143 | call spcfft(buf,nx,-1,scratch) 144 | ! simply drop the redundant part of the complex output 145 | do i=1,nx/2+1 146 | out_c(i,j,k) = buf(i) 147 | end do 148 | end do 149 | end do 150 | 151 | ! ===== 1D FFTs in Y ===== 152 | do k=1,nz 153 | do i=1,nx/2+1 154 | do j=1,ny 155 | buf(j) = out_c(i,j,k) 156 | end do 157 | call spcfft(buf,ny,-1,scratch) 158 | do j=1,ny 159 | out_c(i,j,k) = buf(j) 160 | end do 161 | end do 162 | end do 163 | 164 | ! ===== 1D FFTs in Z ===== 165 | do j=1,ny 166 | do i=1,nx/2+1 167 | do k=1,nz 168 | buf(k) = out_c(i,j,k) 169 | end do 170 | call spcfft(buf,nz,-1,scratch) 171 | do k=1,nz 172 | out_c(i,j,k) = buf(k) 173 | end do 174 | end do 175 | end do 176 | 177 | deallocate(buf,scratch) 178 | 179 | return 180 | end subroutine glassman_3d_r2c 181 | 182 | 183 | end module glassman 184 | 185 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #======================================================================= 2 | # Makefile for Xcompact3D 3 | #======================================================================= 4 | # Choose pre-processing options 5 | # -DDOUBLE_PREC - use double-precision 6 | # -DSAVE_SINGLE - Save 3D data in single-precision 7 | # -DDEBG - debuggin xcompact3d.f90 8 | # generate a Git version string 9 | GIT_VERSION := $(shell git describe --tag --long --always) 10 | 11 | #######Select Flow Type####### 12 | # FLOW_TYPE = Lock-exchange 13 | FLOW_TYPE = TGV 14 | # FLOW_TYPE = Channel-flow 15 | # FLOW_TYPE = Periodic-hill 16 | # FLOW_TYPE = Cylinder 17 | # FLOW_TYPE = dbg-schemes 18 | 19 | DEFS = -DDOUBLE_PREC -DVERSION=\"$(GIT_VERSION)\" 20 | 21 | LCL = local# local,lad,sdu,archer 22 | IVER = 17# 15,16,17,18 23 | CMP = gcc# intel,gcc 24 | FFT = generic# generic,fftw3,mkl 25 | 26 | #######Minimum defs########### 27 | ifeq ($(FLOW_TYPE),Channel-flow) 28 | DEFS2 = -DSTRETCHING -DPOST 29 | else ifeq ($(FLOW_TYPE),Cylinder) 30 | DEFS2 = -DFORCES 31 | else ifeq ($(FLOW_TYPE),Lock-exchange) 32 | DEFS2 = -DPOST 33 | else ifeq ($(FLOW_TYPE),Periodic-hill) 34 | DEFS2 = -DSTRETCHING -DPOST 35 | else ifeq ($(FLOW_TYPE),TGV) 36 | DEFS2 = -DPOST 37 | endif 38 | DEFS2 += -DVISU 39 | 40 | #######CMP settings########### 41 | ifeq ($(CMP),intel) 42 | FC = mpiifort 43 | #FFLAGS = -fpp -O3 -xHost -heap-arrays -shared-intel -mcmodel=large -safe-cray-ptr -g -traceback 44 | FFLAGS = -fpp -O3 -xSSE4.2 -axAVX,CORE-AVX-I,CORE-AVX2 -ipo -fp-model fast=2 -mcmodel=large -safe-cray-ptr -I$(MPI_ROOT)/lib 45 | ##debuggin test: -check all -check bounds -chintel eck uninit -gen-interfaces -warn interfaces 46 | else ifeq ($(CMP),gcc) 47 | FC = mpif90 48 | #FFLAGS = -O3 -funroll-loops -floop-optimize -g -Warray-bounds -fcray-pointer -x f95-cpp-input 49 | FFLAGS = -cpp -funroll-loops -floop-optimize -g -Warray-bounds -fcray-pointer -fbacktrace -ffree-line-length-none 50 | #-ffpe-trap=invalid,zero 51 | else ifeq ($(CMP),nagfor) 52 | FC = mpinagfor 53 | FFLAGS = -fpp 54 | else ifeq ($(CMP),cray) 55 | FC = ftn 56 | FFLAGS = -cpp -xHost -O3 -ipo -heaparrays -safe-cray-ptr -g -traceback 57 | PLATFORM=intel 58 | endif 59 | 60 | 61 | MODDIR = ./mod 62 | DECOMPDIR = ./decomp2d 63 | SRCDIR = ./src 64 | 65 | ### List of files for the main code 66 | SRCDECOMP = $(DECOMPDIR)/decomp_2d.f90 $(DECOMPDIR)/glassman.f90 $(DECOMPDIR)/fft_$(FFT).f90 $(DECOMPDIR)/io.f90 67 | OBJDECOMP = $(SRCDECOMP:%.f90=%.o) 68 | SRC = $(SRCDIR)/module_param.f90 $(SRCDIR)/variables.f90 $(SRCDIR)/poisson.f90 $(SRCDIR)/derive.f90 $(SRCDIR)/schemes.f90 $(SRCDIR)/implicit.f90 $(SRCDIR)/parameters.f90 $(SRCDIR)/*.f90 69 | OBJ = $(SRC:%.f90=%.o) 70 | SRC = $(SRCDIR)/module_param.f90 $(SRCDIR)/variables.f90 $(SRCDIR)/poisson.f90 $(SRCDIR)/ibm.f90 $(SRCDIR)/derive.f90 $(SRCDIR)/schemes.f90 $(SRCDIR)/implicit.f90 $(SRCDIR)/forces.f90 $(SRCDIR)/BC-TBL.f90 $(SRCDIR)/navier.f90 $(SRCDIR)/tools.f90 $(SRCDIR)/les_models.f90 $(SRCDIR)/time_integrators.f90 $(SRCDIR)/filters.f90 $(SRCDIR)/visu.f90 $(SRCDIR)/BC-Sandbox.f90 $(SRCDIR)/BC-Lock-exchange.f90 $(SRCDIR)/parameters.f90 $(SRCDIR)/BC-User.f90 $(SRCDIR)/BC-TGV.f90 $(SRCDIR)/BC-Channel-flow.f90 $(SRCDIR)/BC-Periodic-hill.f90 $(SRCDIR)/BC-Cylinder.f90 $(SRCDIR)/BC-Mixing-layer.f90 $(SRCDIR)/BC-Jet.f90 $(SRCDIR)/BC-dbg-schemes.f90 $(SRCDIR)/statistics.f90 $(SRCDIR)/case.f90 $(SRCDIR)/transeq.f90 $(SRCDIR)/genepsi3d.f90 $(SRCDIR)/xcompact3d.f90 71 | 72 | ### List of files for the post-processing code 73 | PSRC = decomp_2d.f90 module_param.f90 io.f90 variables.f90 schemes.f90 derive.f90 parameters.f90 tools.f90 visu.f90 post.f90 74 | 75 | #######FFT settings########## 76 | ifeq ($(FFT),fftw3) 77 | #FFTW3_PATH=/usr 78 | #FFTW3_PATH=/usr/lib64 79 | FFTW3_PATH=/usr/local/Cellar/fftw/3.3.7_1 80 | INC=-I$(FFTW3_PATH)/include 81 | LIBFFT=-L$(FFTW3_PATH) -lfftw3 -lfftw3f 82 | else ifeq ($(FFT),fftw3_f03) 83 | FFTW3_PATH=/usr #ubuntu # apt install libfftw3-dev 84 | #FFTW3_PATH=/usr/lib64 #fedora # dnf install fftw fftw-devel 85 | #FFTW3_PATH=/usr/local/Cellar/fftw/3.3.7_1 #macOS # brew install fftw 86 | INC=-I$(FFTW3_PATH)/include 87 | LIBFFT=-L$(FFTW3_PATH)/lib -lfftw3 -lfftw3f 88 | else ifeq ($(FFT),generic) 89 | INC= 90 | LIBFFT= 91 | else ifeq ($(FFT),mkl) 92 | SRCDECOMP := $(DECOMPDIR)/mkl_dfti.f90 $(SRCDECOMP) 93 | LIBFFT=-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_sequential.a $(MKLROOT)/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread 94 | INC=-I$(MKLROOT)/include 95 | endif 96 | 97 | #######OPTIONS settings########### 98 | OPT = -I$(SRCDIR) -I$(DECOMPDIR) $(FFLAGS) 99 | LINKOPT = $(FFLAGS) 100 | #----------------------------------------------------------------------- 101 | # Normally no need to change anything below 102 | 103 | all: xcompact3d 104 | 105 | xcompact3d : $(OBJDECOMP) $(OBJ) 106 | $(FC) -o $@ $(LINKOPT) $(OBJDECOMP) $(OBJ) $(LIBFFT) 107 | 108 | $(OBJDECOMP):$(DECOMPDIR)%.o : $(DECOMPDIR)%.f90 109 | $(FC) $(FFLAGS) $(OPT) $(DEFS) $(DEFS2) $(INC) -c $< 110 | mv $(@F) ${DECOMPDIR} 111 | #mv *.mod ${DECOMPDIR} 112 | 113 | 114 | $(OBJ):$(SRCDIR)%.o : $(SRCDIR)%.f90 115 | $(FC) $(FFLAGS) $(OPT) $(DEFS) $(DEFS2) $(INC) -c $< 116 | mv $(@F) ${SRCDIR} 117 | #mv *.mod ${SRCDIR} 118 | 119 | ## This %.o : %.f90 doesn't appear to be called... 120 | %.o : %.f90 121 | $(FC) $(FFLAGS) $(DEFS) $(DEFS2) $(INC) -c $< 122 | 123 | .PHONY: post 124 | post: 125 | $(FC) $(FFLAGS) $(DEFS) $(DEFS2) post.f90 -c 126 | $(FC) $(FFLAGS) -o $@ $(PSRC:.f90=.o) 127 | 128 | .PHONY: clean 129 | 130 | 131 | clean: 132 | rm -f $(DECOMPDIR)/*.o $(DECOMPDIR)/*.mod 133 | rm -f $(SRCDIR)/*.o $(SRCDIR)/*.mod 134 | rm -f *.o *.mod xcompact3d post 135 | 136 | .PHONY: cleanall 137 | cleanall: clean 138 | rm -f *~ \#*\# out/* data/* stats/* planes/* *.xdmf *.log *.out nodefile core sauve* 139 | -------------------------------------------------------------------------------- /decomp2d/fft_common.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contains common code shared by all FFT engines 13 | 14 | integer, parameter, public :: DECOMP_2D_FFT_FORWARD = -1 15 | integer, parameter, public :: DECOMP_2D_FFT_BACKWARD = 1 16 | 17 | ! Physical space data can be stored in either X-pencil or Z-pencil 18 | integer, parameter, public :: PHYSICAL_IN_X = 1 19 | integer, parameter, public :: PHYSICAL_IN_Z = 3 20 | 21 | integer, save :: format ! input X-pencil or Z-pencil 22 | 23 | ! The libary can only be initialised once 24 | logical, save :: initialised = .false. 25 | 26 | ! Global size of the FFT 27 | integer, save :: nx_fft, ny_fft, nz_fft 28 | 29 | ! 2D processor grid 30 | integer, save, dimension(2) :: dims 31 | 32 | ! Decomposition objects 33 | TYPE(DECOMP_INFO), save :: ph ! physical space 34 | TYPE(DECOMP_INFO), save :: sp ! spectral space 35 | 36 | ! Workspace to store the intermediate Y-pencil data 37 | ! *** TODO: investigate how to use only one workspace array 38 | complex(mytype), allocatable, dimension(:,:,:) :: wk2_c2c, wk2_r2c 39 | complex(mytype), allocatable, dimension(:,:,:) :: wk13 40 | 41 | public :: decomp_2d_fft_init, decomp_2d_fft_3d, & 42 | decomp_2d_fft_finalize, decomp_2d_fft_get_size 43 | 44 | ! Declare generic interfaces to handle different inputs 45 | 46 | interface decomp_2d_fft_init 47 | module procedure fft_init_noarg 48 | module procedure fft_init_arg 49 | module procedure fft_init_general 50 | end interface 51 | 52 | interface decomp_2d_fft_3d 53 | module procedure fft_3d_c2c 54 | module procedure fft_3d_r2c 55 | module procedure fft_3d_c2r 56 | end interface 57 | 58 | 59 | contains 60 | 61 | 62 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 63 | ! Initialise the FFT module 64 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 65 | subroutine fft_init_noarg 66 | 67 | implicit none 68 | 69 | call fft_init_arg(PHYSICAL_IN_X) ! default input is X-pencil data 70 | 71 | return 72 | end subroutine fft_init_noarg 73 | 74 | subroutine fft_init_arg(pencil) ! allow to handle Z-pencil input 75 | 76 | implicit none 77 | 78 | integer, intent(IN) :: pencil 79 | 80 | call fft_init_general(pencil, nx_global, ny_global, nz_global) 81 | 82 | return 83 | end subroutine fft_init_arg 84 | 85 | ! Initialise the FFT library to perform arbitrary size transforms 86 | subroutine fft_init_general(pencil, nx, ny, nz) 87 | 88 | implicit none 89 | 90 | integer, intent(IN) :: pencil 91 | integer, intent(IN) :: nx, ny, nz 92 | 93 | logical, dimension(2) :: dummy_periods 94 | integer, dimension(2) :: dummy_coords 95 | integer :: status, errorcode, ierror 96 | 97 | if (initialised) then 98 | errorcode = 4 99 | call decomp_2d_abort(errorcode, & 100 | 'FFT library should only be initialised once') 101 | end if 102 | 103 | format = pencil 104 | nx_fft = nx 105 | ny_fft = ny 106 | nz_fft = nz 107 | 108 | ! determine the processor grid in use 109 | call MPI_CART_GET(DECOMP_2D_COMM_CART_X, 2, & 110 | dims, dummy_periods, dummy_coords, ierror) 111 | 112 | ! for c2r/r2c interface: 113 | ! if in physical space, a real array is of size: nx*ny*nz 114 | ! in spectral space, the complex array is of size: 115 | ! (nx/2+1)*ny*nz, if PHYSICAL_IN_X 116 | ! or nx*ny*(nz/2+1), if PHYSICAL_IN_Z 117 | 118 | call decomp_info_init(nx, ny, nz, ph) 119 | if (format==PHYSICAL_IN_X) then 120 | call decomp_info_init(nx/2+1, ny, nz, sp) 121 | else if (format==PHYSICAL_IN_Z) then 122 | call decomp_info_init(nx, ny, nz/2+1, sp) 123 | end if 124 | 125 | allocate(wk2_c2c(ph%ysz(1),ph%ysz(2),ph%ysz(3)), STAT=status) 126 | allocate(wk2_r2c(sp%ysz(1),sp%ysz(2),sp%ysz(3)), STAT=status) 127 | if (format==PHYSICAL_IN_X) then 128 | allocate(wk13(sp%xsz(1),sp%xsz(2),sp%xsz(3)), STAT=status) 129 | else if (format==PHYSICAL_IN_Z) then 130 | allocate(wk13(sp%zsz(1),sp%zsz(2),sp%zsz(3)), STAT=status) 131 | end if 132 | if (status /= 0) then 133 | errorcode = 3 134 | call decomp_2d_abort(errorcode, & 135 | 'Out of memory when initialising FFT') 136 | end if 137 | 138 | call init_fft_engine 139 | 140 | initialised = .true. 141 | 142 | return 143 | end subroutine fft_init_general 144 | 145 | 146 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 147 | ! Final clean up 148 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 149 | subroutine decomp_2d_fft_finalize 150 | 151 | implicit none 152 | 153 | call decomp_info_finalize(ph) 154 | call decomp_info_finalize(sp) 155 | 156 | deallocate(wk2_c2c, wk2_r2c, wk13) 157 | 158 | call finalize_fft_engine 159 | 160 | initialised = .false. 161 | 162 | return 163 | end subroutine decomp_2d_fft_finalize 164 | 165 | 166 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 167 | ! Return the size, starting/ending index of the distributed array 168 | ! whose global size is (nx/2+1)*ny*nz, for defining data structures 169 | ! in r2c and c2r interfaces 170 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 171 | subroutine decomp_2d_fft_get_size(istart, iend, isize) 172 | 173 | implicit none 174 | integer, dimension(3), intent(OUT) :: istart, iend, isize 175 | 176 | if (format==PHYSICAL_IN_X) then 177 | istart = sp%zst 178 | iend = sp%zen 179 | isize = sp%zsz 180 | else if (format==PHYSICAL_IN_Z) then 181 | istart = sp%xst 182 | iend = sp%xen 183 | isize = sp%xsz 184 | end if 185 | 186 | return 187 | end subroutine decomp_2d_fft_get_size 188 | -------------------------------------------------------------------------------- /src/BC-Mixing-layer.f90: -------------------------------------------------------------------------------- 1 | !################################################################################ 2 | !This file is part of Xcompact3d. 3 | ! 4 | !Xcompact3d 5 | !Copyright (c) 2012 Eric Lamballais and Sylvain Laizet 6 | !eric.lamballais@univ-poitiers.fr / sylvain.laizet@gmail.com 7 | ! 8 | ! Xcompact3d is free software: you can redistribute it and/or modify 9 | ! it under the terms of the GNU General Public License as published by 10 | ! the Free Software Foundation. 11 | ! 12 | ! Xcompact3d is distributed in the hope that it will be useful, 13 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ! GNU General Public License for more details. 16 | ! 17 | ! You should have received a copy of the GNU General Public License 18 | ! along with the code. If not, see . 19 | !------------------------------------------------------------------------------- 20 | !------------------------------------------------------------------------------- 21 | ! We kindly request that you cite Xcompact3d/Incompact3d in your 22 | ! publications and presentations. The following citations are suggested: 23 | ! 24 | ! 1-Bartholomew P., Deskos G., Frantz R.A.S., Schuch F.N., Lamballais E. & 25 | ! Laizet S., 2020, Xcompact3D: An open-source framework for solving 26 | ! turbulence problems on a Cartesian mesh, SoftwareX, vol 12, pp 100550 27 | ! 28 | ! 2-Laizet S. & Lamballais E., 2009, High-order compact schemes for 29 | ! incompressible flows: a simple and efficient method with the quasi-spectral 30 | ! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015 31 | ! 32 | ! 3-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence 33 | ! problems with up to 0(10^5) computational cores, Int. J. of Numerical 34 | ! Methods in Fluids, vol 67 (11), pp 1735-1757 35 | !################################################################################ 36 | 37 | module mixlayer 38 | 39 | USE decomp_2d 40 | USE variables 41 | USE param 42 | 43 | IMPLICIT NONE 44 | 45 | PRIVATE !! All functions/subroutines private by default 46 | PUBLIC :: init_mixlayer!, boundary_conditions_mixlayer, postprocessing_mixlayer 47 | 48 | contains 49 | 50 | subroutine init_mixlayer (rho1,ux1,uy1,uz1) 51 | 52 | USE decomp_2d, ONLY : mytype, xsize 53 | USE param, ONLY : u1, u2, dens1, dens2 54 | USE param, ONLY : half, one, two, four, eight, sixteen 55 | USE param, ONLY : ntime, nrhotime 56 | USE MPI 57 | 58 | implicit none 59 | 60 | real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux1,uy1,uz1,ep1 61 | real(mytype),dimension(xsize(1),xsize(2),xsize(3),nrhotime) :: rho1 62 | 63 | integer :: i, j, k, is 64 | real(mytype) :: x, y, z 65 | 66 | real(mytype) :: M, rspech, heatcap 67 | real(mytype) :: T1, T2, rhomin, rhomax 68 | real(mytype) :: disturb_decay, u_disturb, v_disturb 69 | 70 | if (iin.eq.0) then !empty domain 71 | if (nrank==0) then 72 | write(*,*) "Empty initial domain!" 73 | endif 74 | 75 | ux1=zero; uy1=zero; uz1=zero 76 | endif 77 | 78 | if (iin.eq.1) then !generation of a random noise 79 | if (nrank==0) then 80 | write(*,*) "Filled initial domain!" 81 | endif 82 | 83 | ux1=zero; uy1=zero; uz1=zero 84 | 85 | !! Compute flow for zero convective velocity 86 | rhomin = MIN(dens1, dens2) 87 | rhomax = MAX(dens1, dens2) 88 | T1 = pressure0 / dens1 89 | T2 = pressure0 / dens2 90 | u1 = SQRT(dens2 / dens1) / (SQRT(dens2 / dens1) + one) 91 | u2 = -SQRT(dens1 / dens2) / (one + SQRT(dens1 / dens2)) 92 | M = 0.2_mytype 93 | rspech = 1.4_mytype 94 | heatcap = (one / (T2 * (rspech - one))) * ((u1 - u2) / M)**2 95 | 96 | do k=1,xsize(3) 97 | do j=1,xsize(2) 98 | y=real((j+xstart(2)-2),mytype)*dy - half * yly 99 | do i=1,xsize(1) 100 | x=real(i+xstart(1)-2,mytype)*dx 101 | 102 | !! Set mean field 103 | ux1(i, j, k) = ux1(i, j, k) + half * (u1 + u2) & 104 | + half * (u1 - u2) * TANH(two * y) 105 | uy1(i, j, k) = zero 106 | uz1(i, j, k) = zero 107 | 108 | rho1(i, j, k, 1) = (one / (two * heatcap)) & 109 | * (ux1(i, j, k) * (u1 + u2) - ux1(i, j, k)**2 - u1 * u2) & 110 | + ux1(i, j, k) * (T1 - T2) / (u1 - u2) & 111 | + (T2 * u1 - T1 * u2) / (u1 - u2) 112 | rho1(i, j, k, 1) = one / rho1(i, j, k, 1) 113 | rho1(i, j, k, 1) = MAX(rho1(i, j, k, 1), rhomin) 114 | rho1(i, j, k, 1) = MIN(rho1(i, j, k, 1), rhomax) 115 | 116 | ! Calculate disturbance field (as given in Fortune2004) 117 | disturb_decay = 0.025_mytype * (u1 - u2) * EXP(-0.05_mytype * (y**2)) 118 | u_disturb = disturb_decay * (SIN(eight * PI * x / xlx) & 119 | + SIN(four * PI * x / xlx) / eight & 120 | + SIN(two * PI * x / xlx) / sixteen) 121 | u_disturb = (0.05_mytype * y * xlx / PI) * u_disturb 122 | v_disturb = disturb_decay * (COS(eight * PI * x / xlx) & 123 | + COS(four * PI * x / xlx) / eight & 124 | + COS(two * PI * x / xlx) / sixteen) 125 | 126 | ux1(i, j, k) = ux1(i, j, k) + u_disturb 127 | uy1(i, j, k) = uy1(i, j, k) + v_disturb 128 | enddo 129 | enddo 130 | enddo 131 | 132 | if (.not.ilmn) then 133 | rho1(:,:,:,:) = one 134 | endif 135 | 136 | endif 137 | 138 | #ifdef DEBG 139 | if (nrank .eq. 0) print *,'# init end ok' 140 | #endif 141 | 142 | return 143 | end subroutine init_mixlayer 144 | 145 | end module mixlayer 146 | -------------------------------------------------------------------------------- /examples/Periodic-hill/paraview_incompact3d.f90: -------------------------------------------------------------------------------- 1 | program visu_paraview 2 | 3 | implicit none 4 | 5 | integer(4) :: nx,ny,nz 6 | real(4) :: xlx,yly,zlz,dt,dx,dy,dz 7 | integer(4) :: nfiles, icrfile, file1, filen, ifile, dig1, dig2, dig3, dig4 8 | real(4), allocatable :: yp(:),y1(:),y3(:) 9 | integer(4) :: i, j, k, num, aig, ii, nfil,istret,nclx, ncly, nclz 10 | 11 | !IF THE DATA ARE STORED WITH 3 DIGITS, IE UX001,UX002,ETC. 12 | character(3) :: chits 13 | !IF THE DATA ARE STORED WITH 4 DIGITS, IE UX0001,UX0002,ETC. 14 | ! character(4) :: chits 15 | 16 | write (*,*) 'nx, ny, nz - Incompact3D' 17 | read (*,*) nx, ny, nz 18 | write (*,*) 'xlx, yly, zlz - Incompact3D' 19 | read (*,*) xlx, yly, zlz 20 | write (*,*) 'nclx, ncly, nclz - Incompact3D' 21 | read (*,*) nclx, ncly, nclz 22 | write (*,*) 'n files, first file, last file' 23 | read (*,*) nfiles,file1, filen 24 | write (*,*) 'Stretching in the y direction (Y=1/N=0)?' 25 | read (*,*) istret 26 | 27 | 28 | if (nclx==0) dx=xlx/nx 29 | if (nclx==1 .or. nclx==2) dx=xlx/(nx-1.) 30 | if (ncly==0) dy=yly/ny 31 | if (ncly==1.or.ncly==2) dy =yly/(ny-1.) 32 | if (nclz==0) dz=zlz/nz 33 | if (nclz==1.or.nclz==2) dz=zlz/(nz-1.) 34 | dt=1. 35 | 36 | allocate(y1(nx)) 37 | allocate(yp(ny)) 38 | allocate(y3(nz)) 39 | do i=1,nx 40 | y1(i)=(i-1)*dx 41 | enddo 42 | if (istret==1) then 43 | print *,'We need to read the yp.dat file' 44 | open(12,file='yp.dat',form='formatted',status='unknown') 45 | do j=1,ny 46 | read(12,*) yp(j) 47 | enddo 48 | close(12) 49 | else 50 | do j=1,ny 51 | yp(j)=(j-1)*dy 52 | enddo 53 | endif 54 | do k=1,nz 55 | y3(k)=(k-1)*dz 56 | enddo 57 | 58 | 59 | nfil=41 60 | open(nfil,file='visu.xdmf') 61 | 62 | write(nfil,'(A22)')'' 63 | write(nfil,*)'' 64 | write(nfil,*)'' 65 | write(nfil,*)'' 66 | write(nfil,*)' ' 68 | write(nfil,*)' ' 69 | write(nfil,*)' ' 70 | write(nfil,*)' ' 71 | write(nfil,*)' ',y1(:) 72 | write(nfil,*)' ' 73 | write(nfil,*)' ' 74 | write(nfil,*)' ',yp(:) 75 | write(nfil,*)' ' 76 | write(nfil,*)' ' 77 | write(nfil,*)' ',y3(:) 78 | write(nfil,*)' ' 79 | write(nfil,*)' ' 80 | write(nfil,'(/)') 81 | write(nfil,*)' ' 82 | write(nfil,*)' ' 88 | 89 | do ifile = file1, filen 90 | 91 | !IF THE DATA ARE STORED WITH 4 DIGITS, IE UX0001,UX0002,ETC. 92 | ! dig1 = ifile/1000 + 48 93 | ! dig2 = ( ifile - 1000*( ifile/1000 ) )/100 + 48 94 | ! dig3 = ( ifile - 100*( ifile/100 ) )/10 + 48 95 | ! dig4 = ( ifile - 10*( ifile/10 ) )/1 + 48 96 | ! chits(1:4) = char(dig1)//char(dig2)//char(dig3)//char(dig4) 97 | 98 | !IF THE DATA ARE STORED WITH 3 DIGITS, IE UX001,UX002,ETC. 99 | dig1 = ifile/100 + 48 100 | dig2 = ( ifile - 100*( ifile/100 ) )/10 + 48 101 | dig3 = ( ifile - 10*( ifile/10 ) )/1 + 48 102 | chits(1:3) = char(dig1)//char(dig2)//char(dig3) 103 | 104 | write(*,*) ifile, 'file'//chits 105 | 106 | write(nfil,'(/)') 107 | write(nfil,*)' ' 108 | write(nfil,*)' ' 109 | write(nfil,*)' ' 110 | !SINGLE PRECISION-->Precision=4 111 | !DOUBLE PRECISION-->Precision=8 112 | write(nfil,*)' ' 113 | write(nfil,*)' ' 116 | write(nfil,*)' ux'//chits 117 | write(nfil,*)' ' 118 | write(nfil,*)' ' 119 | 120 | !it is possible to add as much field as you want for example uy 121 | 122 | write(nfil,*)' ' 123 | write(nfil,*)' ' 126 | write(nfil,*)' uy'//chits 127 | write(nfil,*)' ' 128 | write(nfil,*)' ' 129 | 130 | write(nfil,*)' ' 131 | write(nfil,*)' ' 134 | write(nfil,*)' ep'//chits 135 | write(nfil,*)' ' 136 | write(nfil,*)' ' 137 | 138 | 139 | write(nfil,*)' ' 140 | 141 | enddo 142 | write(nfil,'(/)') 143 | write(nfil,*)' ' 144 | write(nfil,*)'' 145 | write(nfil,'(A7)')'' 146 | close(nfil) 147 | 148 | end program visu_paraview 149 | -------------------------------------------------------------------------------- /decomp2d/fft_common_3d.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contains 3D c2c/r2c/c2r transform subroutines which are 13 | ! identical for several FFT engines 14 | 15 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 16 | ! 3D FFT - complex to complex 17 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 18 | subroutine fft_3d_c2c(in, out, isign) 19 | 20 | implicit none 21 | 22 | complex(mytype), dimension(:,:,:), intent(INOUT) :: in 23 | complex(mytype), dimension(:,:,:), intent(OUT) :: out 24 | integer, intent(IN) :: isign 25 | 26 | #ifndef OVERWRITE 27 | complex(mytype), allocatable, dimension(:,:,:) :: wk1 28 | #endif 29 | 30 | if (format==PHYSICAL_IN_X .AND. isign==DECOMP_2D_FFT_FORWARD .OR. & 31 | format==PHYSICAL_IN_Z .AND. isign==DECOMP_2D_FFT_BACKWARD) then 32 | 33 | ! ===== 1D FFTs in X ===== 34 | #ifdef OVERWRITE 35 | call c2c_1m_x(in,isign,ph) 36 | #else 37 | allocate (wk1(ph%xsz(1),ph%xsz(2),ph%xsz(3))) 38 | wk1 = in 39 | call c2c_1m_x(wk1,isign,ph) 40 | #endif 41 | 42 | ! ===== Swap X --> Y; 1D FFTs in Y ===== 43 | 44 | if (dims(1)>1) then 45 | #ifdef OVERWRITE 46 | call transpose_x_to_y(in,wk2_c2c,ph) 47 | #else 48 | call transpose_x_to_y(wk1,wk2_c2c,ph) 49 | #endif 50 | call c2c_1m_y(wk2_c2c,isign,ph) 51 | else 52 | #ifdef OVERWRITE 53 | call c2c_1m_y(in,isign,ph) 54 | #else 55 | call c2c_1m_y(wk1,isign,ph) 56 | #endif 57 | end if 58 | 59 | ! ===== Swap Y --> Z; 1D FFTs in Z ===== 60 | if (dims(1)>1) then 61 | call transpose_y_to_z(wk2_c2c,out,ph) 62 | else 63 | #ifdef OVERWRITE 64 | call transpose_y_to_z(in,out,ph) 65 | #else 66 | call transpose_y_to_z(wk1,out,ph) 67 | #endif 68 | end if 69 | call c2c_1m_z(out,isign,ph) 70 | 71 | else if (format==PHYSICAL_IN_X .AND. isign==DECOMP_2D_FFT_BACKWARD & 72 | .OR. & 73 | format==PHYSICAL_IN_Z .AND. isign==DECOMP_2D_FFT_FORWARD) then 74 | 75 | ! ===== 1D FFTs in Z ===== 76 | #ifdef OVERWRITE 77 | call c2c_1m_z(in,isign,ph) 78 | #else 79 | allocate (wk1(ph%zsz(1),ph%zsz(2),ph%zsz(3))) 80 | wk1 = in 81 | call c2c_1m_z(wk1,isign,ph) 82 | #endif 83 | 84 | ! ===== Swap Z --> Y; 1D FFTs in Y ===== 85 | if (dims(1)>1) then 86 | #ifdef OVERWRITE 87 | call transpose_z_to_y(in,wk2_c2c,ph) 88 | #else 89 | call transpose_z_to_y(wk1,wk2_c2c,ph) 90 | #endif 91 | call c2c_1m_y(wk2_c2c,isign,ph) 92 | else ! out==wk2_c2c if 1D decomposition 93 | #ifdef OVERWRITE 94 | call transpose_z_to_y(in,out,ph) 95 | #else 96 | call transpose_z_to_y(wk1,out,ph) 97 | #endif 98 | call c2c_1m_y(out,isign,ph) 99 | end if 100 | 101 | ! ===== Swap Y --> X; 1D FFTs in X ===== 102 | if (dims(1)>1) then 103 | call transpose_y_to_x(wk2_c2c,out,ph) 104 | end if 105 | call c2c_1m_x(out,isign,ph) 106 | 107 | end if 108 | 109 | return 110 | end subroutine fft_3d_c2c 111 | 112 | 113 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 114 | ! 3D forward FFT - real to complex 115 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 116 | subroutine fft_3d_r2c(in_r, out_c) 117 | 118 | implicit none 119 | 120 | real(mytype), dimension(:,:,:), intent(IN) :: in_r 121 | complex(mytype), dimension(:,:,:), intent(OUT) :: out_c 122 | 123 | if (format==PHYSICAL_IN_X) then 124 | 125 | ! ===== 1D FFTs in X ===== 126 | call r2c_1m_x(in_r,wk13) 127 | 128 | ! ===== Swap X --> Y; 1D FFTs in Y ===== 129 | if (dims(1)>1) then 130 | call transpose_x_to_y(wk13,wk2_r2c,sp) 131 | call c2c_1m_y(wk2_r2c,-1,sp) 132 | else 133 | call c2c_1m_y(wk13,-1,sp) 134 | end if 135 | 136 | ! ===== Swap Y --> Z; 1D FFTs in Z ===== 137 | if (dims(1)>1) then 138 | call transpose_y_to_z(wk2_r2c,out_c,sp) 139 | else 140 | call transpose_y_to_z(wk13,out_c,sp) 141 | end if 142 | call c2c_1m_z(out_c,-1,sp) 143 | 144 | else if (format==PHYSICAL_IN_Z) then 145 | 146 | ! ===== 1D FFTs in Z ===== 147 | call r2c_1m_z(in_r,wk13) 148 | 149 | ! ===== Swap Z --> Y; 1D FFTs in Y ===== 150 | if (dims(1)>1) then 151 | call transpose_z_to_y(wk13,wk2_r2c,sp) 152 | call c2c_1m_y(wk2_r2c,-1,sp) 153 | else ! out_c==wk2_r2c if 1D decomposition 154 | call transpose_z_to_y(wk13,out_c,sp) 155 | call c2c_1m_y(out_c,-1,sp) 156 | end if 157 | 158 | ! ===== Swap Y --> X; 1D FFTs in X ===== 159 | if (dims(1)>1) then 160 | call transpose_y_to_x(wk2_r2c,out_c,sp) 161 | end if 162 | call c2c_1m_x(out_c,-1,sp) 163 | 164 | end if 165 | 166 | return 167 | end subroutine fft_3d_r2c 168 | 169 | 170 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 171 | ! 3D inverse FFT - complex to real 172 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 173 | subroutine fft_3d_c2r(in_c, out_r) 174 | 175 | implicit none 176 | 177 | complex(mytype), dimension(:,:,:), intent(INOUT) :: in_c 178 | real(mytype), dimension(:,:,:), intent(OUT) :: out_r 179 | 180 | #ifndef OVERWRITE 181 | complex(mytype), allocatable, dimension(:,:,:) :: wk1 182 | #endif 183 | 184 | if (format==PHYSICAL_IN_X) then 185 | 186 | ! ===== 1D FFTs in Z ===== 187 | #ifdef OVERWRITE 188 | call c2c_1m_z(in_c,1,sp) 189 | #else 190 | allocate(wk1(sp%zsz(1),sp%zsz(2),sp%zsz(3))) 191 | wk1 = in_c 192 | call c2c_1m_z(wk1,1,sp) 193 | #endif 194 | 195 | ! ===== Swap Z --> Y; 1D FFTs in Y ===== 196 | #ifdef OVERWRITE 197 | call transpose_z_to_y(in_c,wk2_r2c,sp) 198 | #else 199 | call transpose_z_to_y(wk1,wk2_r2c,sp) 200 | #endif 201 | call c2c_1m_y(wk2_r2c,1,sp) 202 | 203 | ! ===== Swap Y --> X; 1D FFTs in X ===== 204 | if (dims(1)>1) then 205 | call transpose_y_to_x(wk2_r2c,wk13,sp) 206 | call c2r_1m_x(wk13,out_r) 207 | else 208 | call c2r_1m_x(wk2_r2c,out_r) 209 | end if 210 | 211 | else if (format==PHYSICAL_IN_Z) then 212 | 213 | ! ===== 1D FFTs in X ===== 214 | #ifdef OVERWRITE 215 | call c2c_1m_x(in_c,1,sp) 216 | #else 217 | allocate(wk1(sp%xsz(1),sp%xsz(2),sp%xsz(3))) 218 | wk1 = in_c 219 | call c2c_1m_x(wk1,1,sp) 220 | #endif 221 | 222 | ! ===== Swap X --> Y; 1D FFTs in Y ===== 223 | if (dims(1)>1) then 224 | #ifdef OVERWRITE 225 | call transpose_x_to_y(in_c,wk2_r2c,sp) 226 | #else 227 | call transpose_x_to_y(wk1,wk2_r2c,sp) 228 | #endif 229 | call c2c_1m_y(wk2_r2c,1,sp) 230 | else ! in_c==wk2_r2c if 1D decomposition 231 | #ifdef OVERWRITE 232 | call c2c_1m_y(in_c,1,sp) 233 | #else 234 | call c2c_1m_y(wk1,1,sp) 235 | #endif 236 | end if 237 | 238 | ! ===== Swap Y --> Z; 1D FFTs in Z ===== 239 | if (dims(1)>1) then 240 | call transpose_y_to_z(wk2_r2c,wk13,sp) 241 | else 242 | #ifdef OVERWRITE 243 | call transpose_y_to_z(in_c,wk13,sp) 244 | #else 245 | call transpose_y_to_z(wk1,wk13,sp) 246 | #endif 247 | end if 248 | call c2r_1m_z(wk13,out_r) 249 | 250 | end if 251 | 252 | return 253 | end subroutine fft_3d_c2r 254 | -------------------------------------------------------------------------------- /decomp2d/io_write_every.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'write_every_...' in io.f90 14 | 15 | ! To write every few points of a 3D array to a file 16 | 17 | ! work out the distribution parameters, which may be different from 18 | ! the default distribution used by the decomposition library 19 | ! For exmample if nx=17 and p_row=4 20 | ! distribution is: 4 4 4 5 21 | 22 | ! If writing from the 1st element 23 | ! If saving every 3 points, then 5 points to be saved (17/3) 24 | ! default distribution would be 1 1 1 2 25 | ! However, 1st block (1-4) contains the 3rd point 26 | ! 2nd block (5-8) contains the 6th point 27 | ! 3rd block (9-12) contains the 9th and 12th point 28 | ! 4th block (13-17) contains then 15th point 29 | ! giving a 1 1 2 1 distribution 30 | ! So cannot use the base decomposition library for such IO 31 | 32 | ! If writing from the n-th element (n=?skip) 33 | ! If saving every 3 points, then 6 points to be saved 34 | ! However, 1st block (1-4) contains the 1st & 4th point 35 | ! 2nd block (5-8) contains the 7th point 36 | ! 3rd block (9-12) contains the 10th point 37 | ! 4th block (13-17) contains then 12th & 15th point 38 | ! giving a 1 2 2 1 distribution 39 | 40 | skip(1)=iskip 41 | skip(2)=jskip 42 | skip(3)=kskip 43 | 44 | do i=1,3 45 | if (from1) then 46 | xst(i) = (xstart(i)+skip(i)-1)/skip(i) 47 | if (mod(xstart(i)+skip(i)-1,skip(i))/=0) xst(i)=xst(i)+1 48 | xen(i) = (xend(i)+skip(i)-1)/skip(i) 49 | else 50 | xst(i) = xstart(i)/skip(i) 51 | if (mod(xstart(i),skip(i))/=0) xst(i)=xst(i)+1 52 | xen(i) = xend(i)/skip(i) 53 | end if 54 | xsz(i) = xen(i)-xst(i)+1 55 | end do 56 | 57 | do i=1,3 58 | if (from1) then 59 | yst(i) = (ystart(i)+skip(i)-1)/skip(i) 60 | if (mod(ystart(i)+skip(i)-1,skip(i))/=0) yst(i)=yst(i)+1 61 | yen(i) = (yend(i)+skip(i)-1)/skip(i) 62 | else 63 | yst(i) = ystart(i)/skip(i) 64 | if (mod(ystart(i),skip(i))/=0) yst(i)=yst(i)+1 65 | yen(i) = yend(i)/skip(i) 66 | end if 67 | ysz(i) = yen(i)-yst(i)+1 68 | end do 69 | 70 | do i=1,3 71 | if (from1) then 72 | zst(i) = (zstart(i)+skip(i)-1)/skip(i) 73 | if (mod(zstart(i)+skip(i)-1,skip(i))/=0) zst(i)=zst(i)+1 74 | zen(i) = (zend(i)+skip(i)-1)/skip(i) 75 | else 76 | zst(i) = zstart(i)/skip(i) 77 | if (mod(zstart(i),skip(i))/=0) zst(i)=zst(i)+1 78 | zen(i) = zend(i)/skip(i) 79 | end if 80 | zsz(i) = zen(i)-zst(i)+1 81 | end do 82 | 83 | ! if 'skip' value is large it is possible that some ranks do not 84 | ! contain any points to be written. Subarray constructor requires 85 | ! nonzero size so it is not possible to use MPI_COMM_WORLD for IO. 86 | ! Create a sub communicator for this... 87 | color = 1 88 | key = 0 ! rank order doesn't matter 89 | if (ipencil==1) then 90 | if (xsz(1)==0 .or. xsz(2)==0 .or. xsz(3)==0) then 91 | color = 2 92 | end if 93 | else if (ipencil==2) then 94 | if (ysz(1)==0 .or. ysz(2)==0 .or. ysz(3)==0) then 95 | color = 2 96 | end if 97 | else if (ipencil==3) then 98 | if (zsz(1)==0 .or. zsz(2)==0 .or. zsz(3)==0) then 99 | color = 2 100 | end if 101 | end if 102 | call MPI_COMM_SPLIT(MPI_COMM_WORLD,color,key,newcomm,ierror) 103 | 104 | if (color==1) then ! only ranks in this group do IO collectively 105 | 106 | ! generate subarray information 107 | sizes(1) = xsz(1) 108 | sizes(2) = ysz(2) 109 | sizes(3) = zsz(3) 110 | if (ipencil==1) then 111 | subsizes(1) = xsz(1) 112 | subsizes(2) = xsz(2) 113 | subsizes(3) = xsz(3) 114 | starts(1) = xst(1)-1 115 | starts(2) = xst(2)-1 116 | starts(3) = xst(3)-1 117 | else if (ipencil==2) then 118 | subsizes(1) = ysz(1) 119 | subsizes(2) = ysz(2) 120 | subsizes(3) = ysz(3) 121 | starts(1) = yst(1)-1 122 | starts(2) = yst(2)-1 123 | starts(3) = yst(3)-1 124 | else if (ipencil==3) then 125 | subsizes(1) = zsz(1) 126 | subsizes(2) = zsz(2) 127 | subsizes(3) = zsz(3) 128 | starts(1) = zst(1)-1 129 | starts(2) = zst(2)-1 130 | starts(3) = zst(3)-1 131 | end if 132 | 133 | ! copy data from original array 134 | ! needs a copy of original array in global coordinate 135 | if (ipencil==1) then 136 | allocate(wk(xst(1):xen(1),xst(2):xen(2),xst(3):xen(3))) 137 | allocate(wk2(xstart(1):xend(1),xstart(2):xend(2),xstart(3):xend(3))) 138 | wk2=var 139 | if (from1) then 140 | do k=xst(3),xen(3) 141 | do j=xst(2),xen(2) 142 | do i=xst(1),xen(1) 143 | wk(i,j,k) = wk2((i-1)*iskip+1,(j-1)*jskip+1,(k-1)*kskip+1) 144 | end do 145 | end do 146 | end do 147 | else 148 | do k=xst(3),xen(3) 149 | do j=xst(2),xen(2) 150 | do i=xst(1),xen(1) 151 | wk(i,j,k) = wk2(i*iskip,j*jskip,k*kskip) 152 | end do 153 | end do 154 | end do 155 | end if 156 | else if (ipencil==2) then 157 | allocate(wk(yst(1):yen(1),yst(2):yen(2),yst(3):yen(3))) 158 | allocate(wk2(ystart(1):yend(1),ystart(2):yend(2),ystart(3):yend(3))) 159 | wk2=var 160 | if (from1) then 161 | do k=yst(3),yen(3) 162 | do j=yst(2),yen(2) 163 | do i=yst(1),yen(1) 164 | wk(i,j,k) = wk2((i-1)*iskip+1,(j-1)*jskip+1,(k-1)*kskip+1) 165 | end do 166 | end do 167 | end do 168 | else 169 | do k=yst(3),yen(3) 170 | do j=yst(2),yen(2) 171 | do i=yst(1),yen(1) 172 | wk(i,j,k) = wk2(i*iskip,j*jskip,k*kskip) 173 | end do 174 | end do 175 | end do 176 | end if 177 | else if (ipencil==3) then 178 | allocate(wk(zst(1):zen(1),zst(2):zen(2),zst(3):zen(3))) 179 | allocate(wk2(zstart(1):zend(1),zstart(2):zend(2),zstart(3):zend(3))) 180 | wk2=var 181 | if (from1) then 182 | do k=zst(3),zen(3) 183 | do j=zst(2),zen(2) 184 | do i=zst(1),zen(1) 185 | wk(i,j,k) = wk2((i-1)*iskip+1,(j-1)*jskip+1,(k-1)*kskip+1) 186 | end do 187 | end do 188 | end do 189 | else 190 | do k=zst(3),zen(3) 191 | do j=zst(2),zen(2) 192 | do i=zst(1),zen(1) 193 | wk(i,j,k) = wk2(i*iskip,j*jskip,k*kskip) 194 | end do 195 | end do 196 | end do 197 | end if 198 | end if 199 | deallocate(wk2) 200 | 201 | ! MPI-IO 202 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 203 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 204 | call MPI_TYPE_COMMIT(newtype,ierror) 205 | call MPI_FILE_OPEN(newcomm, filename, & 206 | MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, & 207 | fh, ierror) 208 | filesize = 0_MPI_OFFSET_KIND 209 | call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting 210 | disp = 0_MPI_OFFSET_KIND 211 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 212 | newtype,'native',MPI_INFO_NULL,ierror) 213 | call MPI_FILE_WRITE_ALL(fh, wk, & 214 | subsizes(1)*subsizes(2)*subsizes(3), & 215 | data_type, MPI_STATUS_IGNORE, ierror) 216 | call MPI_FILE_CLOSE(fh,ierror) 217 | call MPI_TYPE_FREE(newtype,ierror) 218 | 219 | deallocate(wk) 220 | 221 | end if ! color==1 222 | 223 | call MPI_BARRIER(MPI_COMM_WORLD, ierror) 224 | -------------------------------------------------------------------------------- /decomp2d/alloc.inc: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 13 | ! Utility routine to help allocate 3D arrays 14 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 15 | 16 | ! X-pencil real arrays 17 | subroutine alloc_x_real(var, opt_decomp, opt_global) 18 | 19 | implicit none 20 | 21 | real(mytype), allocatable, dimension(:,:,:) :: var 22 | TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp 23 | logical, intent(IN), optional :: opt_global 24 | 25 | TYPE(DECOMP_INFO) :: decomp 26 | logical :: global 27 | integer :: alloc_stat, errorcode 28 | 29 | if (present(opt_decomp)) then 30 | decomp = opt_decomp 31 | else 32 | decomp = decomp_main 33 | end if 34 | 35 | if (present(opt_global)) then 36 | global = opt_global 37 | else 38 | global = .false. 39 | end if 40 | 41 | if (global) then 42 | allocate(var(decomp%xst(1):decomp%xen(1), & 43 | decomp%xst(2):decomp%xen(2), decomp%xst(3):decomp%xen(3)), & 44 | stat=alloc_stat) 45 | else 46 | allocate(var(decomp%xsz(1),decomp%xsz(2),decomp%xsz(3)), & 47 | stat=alloc_stat) 48 | end if 49 | 50 | if (alloc_stat /= 0) then 51 | errorcode = 8 52 | call decomp_2d_abort(errorcode, & 53 | 'Memory allocation failed when creating new arrays') 54 | end if 55 | 56 | return 57 | end subroutine alloc_x_real 58 | 59 | 60 | ! X-pencil complex arrays 61 | subroutine alloc_x_complex(var, opt_decomp, opt_global) 62 | 63 | implicit none 64 | 65 | complex(mytype), allocatable, dimension(:,:,:) :: var 66 | TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp 67 | logical, intent(IN), optional :: opt_global 68 | 69 | TYPE(DECOMP_INFO) :: decomp 70 | logical :: global 71 | integer :: alloc_stat, errorcode 72 | 73 | if (present(opt_decomp)) then 74 | decomp = opt_decomp 75 | else 76 | decomp = decomp_main 77 | end if 78 | 79 | if (present(opt_global)) then 80 | global = opt_global 81 | else 82 | global = .false. 83 | end if 84 | 85 | if (global) then 86 | allocate(var(decomp%xst(1):decomp%xen(1), & 87 | decomp%xst(2):decomp%xen(2), decomp%xst(3):decomp%xen(3)), & 88 | stat=alloc_stat) 89 | else 90 | allocate(var(decomp%xsz(1),decomp%xsz(2),decomp%xsz(3)), & 91 | stat=alloc_stat) 92 | end if 93 | 94 | if (alloc_stat /= 0) then 95 | errorcode = 8 96 | call decomp_2d_abort(errorcode, & 97 | 'Memory allocation failed when creating new arrays') 98 | end if 99 | 100 | return 101 | end subroutine alloc_x_complex 102 | 103 | 104 | ! Y-pencil real arrays 105 | subroutine alloc_y_real(var, opt_decomp, opt_global) 106 | 107 | implicit none 108 | 109 | real(mytype), allocatable, dimension(:,:,:) :: var 110 | TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp 111 | logical, intent(IN), optional :: opt_global 112 | 113 | TYPE(DECOMP_INFO) :: decomp 114 | logical :: global 115 | integer :: alloc_stat, errorcode 116 | 117 | if (present(opt_decomp)) then 118 | decomp = opt_decomp 119 | else 120 | decomp = decomp_main 121 | end if 122 | 123 | if (present(opt_global)) then 124 | global = opt_global 125 | else 126 | global = .false. 127 | end if 128 | 129 | if (global) then 130 | allocate(var(decomp%yst(1):decomp%yen(1), & 131 | decomp%yst(2):decomp%yen(2), decomp%yst(3):decomp%yen(3)), & 132 | stat=alloc_stat) 133 | else 134 | allocate(var(decomp%ysz(1),decomp%ysz(2),decomp%ysz(3)), & 135 | stat=alloc_stat) 136 | end if 137 | 138 | if (alloc_stat /= 0) then 139 | errorcode = 8 140 | call decomp_2d_abort(errorcode, & 141 | 'Memory allocation failed when creating new arrays') 142 | end if 143 | 144 | return 145 | end subroutine alloc_y_real 146 | 147 | 148 | ! Y-pencil complex arrays 149 | subroutine alloc_y_complex(var, opt_decomp, opt_global) 150 | 151 | implicit none 152 | 153 | complex(mytype), allocatable, dimension(:,:,:) :: var 154 | TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp 155 | logical, intent(IN), optional :: opt_global 156 | 157 | TYPE(DECOMP_INFO) :: decomp 158 | logical :: global 159 | integer :: alloc_stat, errorcode 160 | 161 | if (present(opt_decomp)) then 162 | decomp = opt_decomp 163 | else 164 | decomp = decomp_main 165 | end if 166 | 167 | if (present(opt_global)) then 168 | global = opt_global 169 | else 170 | global = .false. 171 | end if 172 | 173 | if (global) then 174 | allocate(var(decomp%yst(1):decomp%yen(1), & 175 | decomp%yst(2):decomp%yen(2), decomp%yst(3):decomp%yen(3)), & 176 | stat=alloc_stat) 177 | else 178 | allocate(var(decomp%ysz(1),decomp%ysz(2),decomp%ysz(3)), & 179 | stat=alloc_stat) 180 | end if 181 | 182 | if (alloc_stat /= 0) then 183 | errorcode = 8 184 | call decomp_2d_abort(errorcode, & 185 | 'Memory allocation failed when creating new arrays') 186 | end if 187 | 188 | return 189 | end subroutine alloc_y_complex 190 | 191 | 192 | ! Z-pencil real arrays 193 | subroutine alloc_z_real(var, opt_decomp, opt_global) 194 | 195 | implicit none 196 | 197 | real(mytype), allocatable, dimension(:,:,:) :: var 198 | TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp 199 | logical, intent(IN), optional :: opt_global 200 | 201 | TYPE(DECOMP_INFO) :: decomp 202 | logical :: global 203 | integer :: alloc_stat, errorcode 204 | 205 | if (present(opt_decomp)) then 206 | decomp = opt_decomp 207 | else 208 | decomp = decomp_main 209 | end if 210 | 211 | if (present(opt_global)) then 212 | global = opt_global 213 | else 214 | global = .false. 215 | end if 216 | 217 | if (global) then 218 | allocate(var(decomp%zst(1):decomp%zen(1), & 219 | decomp%zst(2):decomp%zen(2), decomp%zst(3):decomp%zen(3)), & 220 | stat=alloc_stat) 221 | else 222 | allocate(var(decomp%zsz(1),decomp%zsz(2),decomp%zsz(3)), & 223 | stat=alloc_stat) 224 | end if 225 | 226 | if (alloc_stat /= 0) then 227 | errorcode = 8 228 | call decomp_2d_abort(errorcode, & 229 | 'Memory allocation failed when creating new arrays') 230 | end if 231 | 232 | return 233 | end subroutine alloc_z_real 234 | 235 | 236 | ! Z-pencil complex arrays 237 | subroutine alloc_z_complex(var, opt_decomp, opt_global) 238 | 239 | implicit none 240 | 241 | complex(mytype), allocatable, dimension(:,:,:) :: var 242 | TYPE(DECOMP_INFO), intent(IN), optional :: opt_decomp 243 | logical, intent(IN), optional :: opt_global 244 | 245 | TYPE(DECOMP_INFO) :: decomp 246 | logical :: global 247 | integer :: alloc_stat, errorcode 248 | 249 | if (present(opt_decomp)) then 250 | decomp = opt_decomp 251 | else 252 | decomp = decomp_main 253 | end if 254 | 255 | if (present(opt_global)) then 256 | global = opt_global 257 | else 258 | global = .false. 259 | end if 260 | 261 | if (global) then 262 | allocate(var(decomp%zst(1):decomp%zen(1), & 263 | decomp%zst(2):decomp%zen(2), decomp%zst(3):decomp%zen(3)), & 264 | stat=alloc_stat) 265 | else 266 | allocate(var(decomp%zsz(1),decomp%zsz(2),decomp%zsz(3)), & 267 | stat=alloc_stat) 268 | end if 269 | 270 | if (alloc_stat /= 0) then 271 | errorcode = 8 272 | call decomp_2d_abort(errorcode, & 273 | 'Memory allocation failed when creating new arrays') 274 | end if 275 | 276 | return 277 | end subroutine alloc_z_complex 278 | -------------------------------------------------------------------------------- /src/post.f90: -------------------------------------------------------------------------------- 1 | !################################################################################ 2 | !This file is part of Xcompact3d. 3 | ! 4 | !Xcompact3d 5 | !Copyright (c) 2012 Eric Lamballais and Sylvain Laizet 6 | !eric.lamballais@univ-poitiers.fr / sylvain.laizet@gmail.com 7 | ! 8 | ! Xcompact3d is free software: you can redistribute it and/or modify 9 | ! it under the terms of the GNU General Public License as published by 10 | ! the Free Software Foundation. 11 | ! 12 | ! Xcompact3d is distributed in the hope that it will be useful, 13 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ! GNU General Public License for more details. 16 | ! 17 | ! You should have received a copy of the GNU General Public License 18 | ! along with the code. If not, see . 19 | !------------------------------------------------------------------------------- 20 | !------------------------------------------------------------------------------- 21 | ! We kindly request that you cite Xcompact3d/Incompact3d in your 22 | ! publications and presentations. The following citations are suggested: 23 | ! 24 | ! 1-Bartholomew P., Deskos G., Frantz R.A.S., Schuch F.N., Lamballais E. & 25 | ! Laizet S., 2020, Xcompact3D: An open-source framework for solving 26 | ! turbulence problems on a Cartesian mesh, SoftwareX, vol 12, pp 100550 27 | ! 28 | ! 2-Laizet S. & Lamballais E., 2009, High-order compact schemes for 29 | ! incompressible flows: a simple and efficient method with the quasi-spectral 30 | ! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015 31 | ! 32 | ! 3-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence 33 | ! problems with up to 0(10^5) computational cores, Int. J. of Numerical 34 | ! Methods in Fluids, vol 67 (11), pp 1735-1757 35 | !################################################################################ 36 | PROGRAM post 37 | 38 | USE decomp_2d 39 | USE decomp_2d_io 40 | USE variables 41 | USE param 42 | USE var 43 | USE MPI 44 | USE post_processing 45 | 46 | implicit none 47 | 48 | integer :: code,i,j,k,is,ii 49 | 50 | integer :: icrfile, file1, filen, ifile, ssfile, nt, iwrn, num, ttsize 51 | integer :: read_phi, read_u, read_ibm !! 3D fields 52 | integer :: comp_visu, comp_post 53 | real(8) :: tstart,t1,trank,tranksum,ttotal,tremaining,telapsed,trstart, trend 54 | character(30) :: filename 55 | character(1) :: a 56 | 57 | TYPE(DECOMP_INFO) :: phG,ph1,ph2,ph3,ph4 58 | 59 | call ft_parameter(.true.) 60 | 61 | CALL MPI_INIT(code) 62 | call decomp_2d_init(nx,ny,nz,p_row,p_col) 63 | call init_coarser_mesh_statS(nstat,nstat,nstat,.true.) !start from 1 == true 64 | call init_coarser_mesh_statV(nvisu,nvisu,nvisu,.true.) !start from 1 == true 65 | call init_coarser_mesh_statP(nprobe,nprobe,nprobe,.true.) !start from 1 == true 66 | call parameter() 67 | call init_variables 68 | call schemes() 69 | 70 | ux1=zero; uxm1=zero 71 | uy1=zero; uym1=zero 72 | uz1=zero; 73 | phi1=zero; phim1=zero 74 | diss1=zero; dissm1=zero 75 | pre1=zero; prem1=zero 76 | 77 | read_phi=0; read_u=0; read_ibm=0 78 | open(10,file='post.prm',status='unknown',form='formatted') 79 | read (10,'(A1)') a 80 | read (10,'(A1)') a 81 | read (10,'(A1)') a 82 | read (10,*) file1 83 | read (10,*) filen 84 | read (10,*) icrfile 85 | read (10,*) ssfile 86 | read (10,'(A1)') a 87 | read (10,'(A1)') a 88 | read (10,'(A1)') a 89 | read (10,*) comp_post 90 | read (10,*) comp_visu 91 | close(10) 92 | 93 | nt = (filen-file1)/icrfile+1 94 | 95 | if(comp_post .eq. 1) then 96 | read_phi=1; read_ibm=1; read_u=1 97 | endif 98 | 99 | if(comp_visu .eq. 1) then 100 | call init_coarser_mesh_statV(nvisu,nvisu,nvisu,.true.) !start from 1 == true 101 | read_phi=1; read_u=1; read_ibm=1 102 | endif 103 | if ( iscalar.eq.0) read_phi=0 104 | if ( ivirt .eq.0) read_ibm=0 105 | if ( read_ibm .eq. 1 ) then 106 | call decomp_2d_read_one(1,ep1,'./data/ibm0000') 107 | endif 108 | 109 | call init_post(ep1) 110 | 111 | ttsize=(read_phi*numscalar+read_u*3)*nx*ny*nz 112 | tstart=0.;t1=0.;trank=0.;tranksum=0.;ttotal=0. 113 | call cpu_time(tstart) 114 | 115 | do ii=1, nt 116 | call cpu_time(t1) 117 | ifile = (ii-1)*icrfile+file1 118 | write(filename,"(I4.4)") ifile 119 | t=dt*real(imodulo*ifile,mytype) 120 | itime=imodulo*ifile 121 | if (nrank==0) then 122 | print *,'--------------------------------------------' 123 | print *,'Snapshot',ifile, t 124 | endif 125 | 126 | !READ DATA 127 | call cpu_time(trstart) 128 | if ( read_phi .eq. 1 ) then 129 | do is=1, numscalar 130 | write(filename,"('./data/phi',I1.1,I4.4)") is, ifile 131 | call decomp_2d_read_one(1,phi1(:,:,:,is),filename) 132 | enddo 133 | call test_scalar_min_max(phi1) 134 | endif 135 | if ( read_u .eq. 1 ) then 136 | write(filename,"('./data/ux',I4.4)") ifile 137 | call decomp_2d_read_one(1,ux1,filename) 138 | write(filename,"('./data/uy',I4.4)") ifile 139 | call decomp_2d_read_one(1,uy1,filename) 140 | write(filename,"('./data/uz',I4.4)") ifile 141 | call decomp_2d_read_one(1,uz1,filename) 142 | call test_speed_min_max(ux1,uy1,uz1) 143 | endif 144 | call cpu_time(trend) 145 | 146 | if (ivisu.ne.0) then 147 | if (comp_visu .eq. 1) then 148 | call VISU_INSTA(ux1,uy1,uz1,phi1,ep1,.True.) 149 | endif 150 | endif 151 | if (ipost.ne.0) then 152 | if (comp_post .eq. 1) then 153 | call postprocessing(ux1,uy1,uz1,phi1,ep1) 154 | endif 155 | endif 156 | call cpu_time(trank) 157 | 158 | telapsed = (trank-tstart)/3600. 159 | tremaining = telapsed*(nt-ii)/(ii) 160 | 161 | if (nrank==0) then 162 | print *,'Time per this snapshot (s):',real(trank-t1) 163 | print *,'Reading speed (MB/s)',real((ttsize*1e-6)/(trend-trstart),4) 164 | write(*,"(' Remaining time:',I8,' h ',I2,' min')"), int(tremaining), int((tremaining-int(tremaining))*60.) 165 | write(*,"(' Elapsed time:',I8,' h ',I2,' min')"), int(telapsed), int((telapsed-int(telapsed))*60.) 166 | endif 167 | enddo 168 | 169 | call cpu_time(trank) 170 | ttotal=trank-tstart 171 | 172 | if (nrank==0) then 173 | print *,'===========================================================' 174 | print *,'' 175 | print *,'Post-processing finished successfully!' 176 | print *,'' 177 | print *,'2DECOMP with p_row*p_col=',p_row,p_col 178 | print *,'' 179 | print *,'nx*ny*nz=',nx*ny*nz 180 | print *,'nx,ny,nz=',nx,ny,nz 181 | print *,'dx,dy,dz=',dx,dy,dz 182 | print *,'' 183 | print *,'Averaged time per snapshot (s):',real(ttotal/nt,4) 184 | print *,'Total wallclock (s):',real(ttotal,4) 185 | print *,'Total wallclock (m):',real(ttotal/60.,4) 186 | print *,'Total wallclock (h):',real(ttotal/3600.,4) 187 | print *,'Total wallclock (d):',real(ttotal*1.1574e-5,4) 188 | print *,'' 189 | endif 190 | 191 | call decomp_2d_finalize 192 | CALL MPI_FINALIZE(code) 193 | end PROGRAM post 194 | -------------------------------------------------------------------------------- /scripts/testgithub_incompact3d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | ### Ask what should be run:- 4 | ### - 1 Get the bitbucket repository 5 | ### - 2 From an existing bitbucket repository, create all the tests 6 | ### - 3 Run on the test which existing folders 7 | # 8 | ### 9 | # 10 | echo "*****************************************************************" 11 | echo " Script to test the various cases of the distribution." 12 | echo " It starts from the latest 2.0 version of the" 13 | echo " github.com/xcompact3d/Incompact3d repository, which is" 14 | echo " downloaded." 15 | echo "*****************************************************************" 16 | # 17 | ### 18 | # 19 | rm -rf Incompact3d 20 | rm -rf BENCHMARK_SUITE 21 | rm -rf .output_incompact3d 22 | # 23 | echo 24 | # 25 | mkdir .output_incompact3d 26 | # 27 | read -p "Do you want to use github or local repository? (git/local): " Repo 28 | if [ $Repo == "local" ] 29 | then 30 | git clone ${I3D_HOME} Incompact3d 31 | else 32 | git clone https://github.com/xcompact3d/Incompact3d 33 | fi 34 | # 35 | cd Incompact3d 36 | # 37 | echo 38 | read -p "Which branch would you like to use? (default: master): " Branch 39 | if [ -z $Branch ] 40 | then 41 | echo "Checking out branch " $Branch 42 | git checkout ${Branch} 43 | fi 44 | # 45 | git status 46 | # 47 | echo 48 | # 49 | git log >& ../OUTPUT_git_log.log 50 | # 51 | git rev-list --all >& ../OUTPUT_git_rev-list.log 52 | # 53 | echo 54 | # 55 | export RevisionNumber=`git rev-list --count HEAD` 56 | # 57 | echo "The latest revision is the $RevisionNumber th one." 58 | # 59 | echo 60 | # 61 | read -p "Do you want to compare with another revision? (Yes/No): " RevisionYesNo 62 | # 63 | if [ $RevisionYesNo == "Yes" ] 64 | then 65 | read -p "Revision code for comparison : " OldRevisionCode 66 | # 67 | OldRevisionLineNumber="$(grep -n "$OldRevisionCode" ../OUTPUT_git_rev-list.log | head -n 1 | cut -d: -f1)" 68 | # 69 | OldRevisionLineNumber=$(($RevisionNumber - $OldRevisionLineNumber)) 70 | OldRevisionLineNumber=$(($OldRevisionLineNumber + 1)) 71 | # 72 | echo "The revision to compare to is the $OldRevisionLineNumber th." 73 | # 74 | elif [ $RevisionYesNo == "No" ] 75 | then 76 | echo "The script will be run for the latest revision number only." 77 | fi 78 | # 79 | echo 80 | # 81 | read -p "Compiler (gcc or intel): " compiler 82 | read -p "Number of processors for the tests: " nprocs 83 | read -p "Number of rows for the tests: " prow 84 | read -p "Number of cols for the tests: " pcol 85 | read -p "Number of time steps: " timesteps 86 | echo 87 | # 88 | ### Scan all the BC*.prm files 89 | # 90 | export listBCfiles=`ls examples/*/BC*prm` 91 | # 92 | echo 93 | # 94 | mkdir ../BENCHMARK_SUITE 95 | mkdir ../BENCHMARK_SUITE/$RevisionNumber 96 | # 97 | if [ $RevisionYesNo == "Yes" ] 98 | then 99 | mkdir ../BENCHMARK_SUITE/$OldRevisionLineNumber 100 | listrevision[0]="$OldRevisionLineNumber" 101 | listrevision[1]="$RevisionNumber" 102 | else 103 | listrevision[0]="$RevisionNumber" 104 | fi 105 | # 106 | for Revision in $listrevision 107 | do 108 | # 109 | for prmfile in $listBCfiles 110 | do 111 | # 112 | ####### Identify the tests and get their name 113 | # 114 | echo "*****************************************************************" 115 | # 116 | echo 117 | # 118 | BCfile=${prmfile/.prm/} 119 | NameTestCase=${BCfile##*/} # Strip path from case name 120 | NameTestCase=${NameTestCase:3} # Strip BC- from case name 121 | # 122 | echo " The $NameTestCase test case is prepared using the $compiler compiler" 123 | echo " with $nprocs processors and $timesteps time-steps." 124 | # 125 | echo 126 | # 127 | ####### Create a directory for each of the cases (identified from the BC*.prm files) 128 | # 129 | echo " A new directory is created, by copying the repository." 130 | echo " This directory is called $NameTestCase and located under BENCHMARK_SUITE/$Revision" 131 | echo " where $Revision is the revision to be dealt with." 132 | # 133 | export workdir=`pwd` 134 | # 135 | mkdir $workdir/../BENCHMARK_SUITE/$Revision/$NameTestCase 136 | mkdir $workdir/../BENCHMARK_SUITE/$Revision/$NameTestCase/src 137 | mkdir $workdir/../BENCHMARK_SUITE/$Revision/$NameTestCase/decomp2d 138 | # 139 | ####### Copy all the files (Makefile, *.f90, *.prm in each directory 140 | # 141 | echo 142 | echo " The required files (*.f90, *.inc, *.prm and Makefile) are copied under BENCHMARK_SUITE/$Revision/$NameTestCase" 143 | echo " and the folders required for the simulation to run are created." 144 | # 145 | cp decomp2d/*.f90 decomp2d/*.inc ../BENCHMARK_SUITE/$Revision/$NameTestCase/decomp2d/. 146 | cp src/*.f90 ../BENCHMARK_SUITE/$Revision/$NameTestCase/src/. 147 | cp $prmfile examples/probes.prm examples/post.prm examples/visu.prm Makefile ../BENCHMARK_SUITE/$Revision/$NameTestCase/. 148 | # 149 | mkdir ../BENCHMARK_SUITE/$Revision/$NameTestCase/out 150 | # 151 | cd ../BENCHMARK_SUITE/$Revision/$NameTestCase/ 152 | # 153 | ####### Change the compiler and flow types for what it needed (ask which one) 154 | ####### And add the right option for each case: 155 | # 156 | echo 157 | # 158 | sed -i -e "s/.*CMP =.*/CMP = $compiler/" Makefile 159 | export FLOW_TYPE=$NameTestCase 160 | # 161 | ####### Compile and link 162 | # 163 | echo " Beginning of compiling/Linking" 164 | # 165 | make >& compile.log 166 | # 167 | echo " End of compiling/linking" 168 | # 169 | if [ -f "incompact3d" ] 170 | then 171 | echo " The executable file incompact3d was created." 172 | else 173 | echo " The file incompact3d was not created. Check what error(s) occur(s) in the file compile.log." 174 | echo " The last 25 lines shows:" 175 | tail -25 compile.log 176 | fi 177 | # 178 | echo 179 | # 180 | ####### Change the number of time steps 181 | # 182 | if [ -f "incompact3d" ] 183 | then 184 | sed -i -e "s/.*ilast.*/$timesteps #ilast/" BC-$NameTestCase.prm 185 | sed -i -e "s/.*p_row.*/$prow #p_row/" BC-$NameTestCase.prm 186 | sed -i -e "s/.*p_col.*/$pcol #p_col/" BC-$NameTestCase.prm 187 | # 188 | ####### Run the simulation in parallel on npcrocs 189 | # 190 | echo " Start the simulation for $timesteps time-steps" 191 | # 192 | mpirun -np $nprocs ./incompact3d >& OUTPUT_${NameTestCase}_${nprocs}_${timesteps}.log 193 | # 194 | else 195 | echo " The simulation will not be run." 196 | fi 197 | # 198 | ####### Complete the run 199 | # 200 | if [ -f "incompact3d" ] 201 | then 202 | echo 203 | echo 204 | echo " The simulation of test case $NameTestCase using the $compiler compiler" 205 | echo " with $nprocs processors and $timesteps time-steps is completed." 206 | echo 207 | echo 208 | fi 209 | # 210 | cd $workdir 211 | # 212 | done 213 | # 214 | done 215 | # 216 | echo 217 | # 218 | echo "*****************************************************************" 219 | echo " All the simulations are completed." 220 | echo " Check the output of each of them" 221 | echo " in the OUTPUT*.log files" 222 | echo "*****************************************************************" 223 | -------------------------------------------------------------------------------- /src/xcompact3d.f90: -------------------------------------------------------------------------------- 1 | !################################################################################ 2 | !This file is part of Xcompact3d. 3 | ! 4 | !Xcompact3d 5 | !Copyright (c) 2012 Eric Lamballais and Sylvain Laizet 6 | !eric.lamballais@univ-poitiers.fr / sylvain.laizet@gmail.com 7 | ! 8 | ! Xcompact3d is free software: you can redistribute it and/or modify 9 | ! it under the terms of the GNU General Public License as published by 10 | ! the Free Software Foundation. 11 | ! 12 | ! Xcompact3d is distributed in the hope that it will be useful, 13 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ! GNU General Public License for more details. 16 | ! 17 | ! You should have received a copy of the GNU General Public License 18 | ! along with the code. If not, see . 19 | !------------------------------------------------------------------------------- 20 | !------------------------------------------------------------------------------- 21 | ! We kindly request that you cite Xcompact3d/Incompact3d in your 22 | ! publications and presentations. The following citations are suggested: 23 | ! 24 | ! 1-Bartholomew P., Deskos G., Frantz R.A.S., Schuch F.N., Lamballais E. & 25 | ! Laizet S., 2020, Xcompact3D: An open-source framework for solving 26 | ! turbulence problems on a Cartesian mesh, SoftwareX, vol 12, pp 100550 27 | ! 28 | ! 2-Laizet S. & Lamballais E., 2009, High-order compact schemes for 29 | ! incompressible flows: a simple and efficient method with the quasi-spectral 30 | ! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015 31 | ! 32 | ! 3-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence 33 | ! problems with up to 0(10^5) computational cores, Int. J. of Numerical 34 | ! Methods in Fluids, vol 67 (11), pp 1735-1757 35 | !################################################################################ 36 | 37 | program xcompact3d 38 | 39 | use var 40 | use case 41 | 42 | use transeq, only : calculate_transeq_rhs 43 | use time_integrators, only : int_time 44 | use navier, only : velocity_to_momentum, momentum_to_velocity, pre_correc, & 45 | calc_divu_constraint, solve_poisson, cor_vel 46 | use tools, only : restart, simu_stats 47 | 48 | implicit none 49 | 50 | call init_xcompact3d() 51 | 52 | do itime=ifirst,ilast 53 | !t=itime*dt 54 | t=t0 + (itime0 + itime + 1 - ifirst)*dt 55 | call simu_stats(2) 56 | 57 | do itr=1,iadvance_time 58 | 59 | call set_fluid_properties(rho1,mu1) 60 | call boundary_conditions(rho1,ux1,uy1,uz1,phi1,ep1) 61 | call calculate_transeq_rhs(drho1,dux1,duy1,duz1,dphi1,rho1,ux1,uy1,uz1,ep1,phi1,divu3) 62 | 63 | !! XXX N.B. from this point, X-pencil velocity arrays contain momentum. 64 | call velocity_to_momentum(rho1,ux1,uy1,uz1) 65 | 66 | call int_time(rho1,ux1,uy1,uz1,phi1,drho1,dux1,duy1,duz1,dphi1) 67 | call pre_correc(ux1,uy1,uz1,ep1) 68 | 69 | call calc_divu_constraint(divu3,rho1,phi1) 70 | call solve_poisson(pp3,px1,py1,pz1,rho1,ux1,uy1,uz1,ep1,drho1,divu3) 71 | call cor_vel(ux1,uy1,uz1,px1,py1,pz1) 72 | 73 | call momentum_to_velocity(rho1,ux1,uy1,uz1) 74 | !! XXX N.B. from this point, X-pencil velocity arrays contain velocity. 75 | 76 | call test_flow(rho1,ux1,uy1,uz1,phi1,ep1,drho1,divu3) 77 | 78 | enddo !! End sub timesteps 79 | 80 | call restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3(:,:,:,1),phi1,dphi1,px1,py1,pz1,1) 81 | 82 | call simu_stats(3) 83 | 84 | call postprocessing(rho1,ux1,uy1,uz1,pp3,phi1,ep1) 85 | 86 | enddo !! End time loop 87 | 88 | call finalise_xcompact3d() 89 | 90 | end program xcompact3d 91 | !######################################################################## 92 | !######################################################################## 93 | subroutine init_xcompact3d() 94 | 95 | use MPI 96 | use decomp_2d 97 | USE decomp_2d_poisson, ONLY : decomp_2d_poisson_init 98 | use case 99 | use forces 100 | 101 | use var 102 | 103 | use navier, only : calc_divu_constraint 104 | use tools, only : test_speed_min_max, test_scalar_min_max, & 105 | restart, & 106 | simu_stats, compute_cfldiff 107 | 108 | use param, only : ilesmod, jles 109 | use param, only : irestart 110 | 111 | use variables, only : nx, ny, nz, nxm, nym, nzm 112 | use variables, only : p_row, p_col 113 | use variables, only : nstat, nvisu, nprobe 114 | 115 | use les, only: init_explicit_les 116 | 117 | use visu, only : visu_init 118 | 119 | use genepsi, only : genepsi3d, epsi_init 120 | use ibm, only : body 121 | 122 | implicit none 123 | 124 | integer :: ierr 125 | 126 | integer :: nargin, FNLength, status, DecInd 127 | logical :: back 128 | character(len=80) :: InputFN, FNBase 129 | 130 | !! Initialise MPI 131 | call MPI_INIT(ierr) 132 | call MPI_COMM_RANK(MPI_COMM_WORLD,nrank,ierr) 133 | call MPI_COMM_SIZE(MPI_COMM_WORLD,nproc,ierr) 134 | 135 | ! Handle input file like a boss -- GD 136 | nargin=command_argument_count() 137 | if (nargin <1) then 138 | InputFN='input.i3d' 139 | if (nrank==0) print*, 'Xcompact3d is run with the default file -->', InputFN 140 | elseif (nargin.ge.1) then 141 | if (nrank==0) print*, 'Program is run with the provided file -->', InputFN 142 | 143 | call get_command_argument(1,InputFN,FNLength,status) 144 | back=.true. 145 | FNBase=inputFN((index(InputFN,'/',back)+1):len(InputFN)) 146 | DecInd=index(FNBase,'.',back) 147 | if (DecInd >1) then 148 | FNBase=FNBase(1:(DecInd-1)) 149 | end if 150 | endif 151 | 152 | call parameter(InputFN) 153 | 154 | call decomp_2d_init(nx,ny,nz,p_row,p_col) 155 | call init_coarser_mesh_statS(nstat,nstat,nstat,.true.) !start from 1 == true 156 | call init_coarser_mesh_statV(nvisu,nvisu,nvisu,.true.) !start from 1 == true 157 | call init_coarser_mesh_statP(nprobe,nprobe,nprobe,.true.) !start from 1 == true 158 | !div: nx ny nz --> nxm ny nz --> nxm nym nz --> nxm nym nzm 159 | call decomp_info_init(nxm, nym, nzm, ph1) 160 | call decomp_info_init(nxm, ny, nz, ph4) 161 | !gradp: nxm nym nzm -> nxm nym nz --> nxm ny nz --> nx ny nz 162 | call decomp_info_init(nxm, ny, nz, ph2) 163 | call decomp_info_init(nxm, nym, nz, ph3) 164 | 165 | call init_variables() 166 | 167 | if (itimescheme.eq.7) then 168 | call init_implicit 169 | endif 170 | 171 | call schemes() 172 | 173 | !if (nrank==0) call stabiltemp() 174 | 175 | call decomp_2d_poisson_init() 176 | call decomp_info_init(nxm,nym,nzm,phG) 177 | 178 | if (ilesmod.ne.0) then 179 | if (jles.gt.0) call init_explicit_les() 180 | endif 181 | 182 | if (iibm.eq.2) then 183 | call genepsi3d(ep1) 184 | else if (iibm.eq.1) then 185 | call epsi_init(ep1) 186 | call body(ux1,uy1,uz1,ep1) 187 | endif 188 | 189 | if (iforces.eq.1) then 190 | call init_forces() 191 | if (irestart==1) then 192 | call restart_forces(0) 193 | endif 194 | endif 195 | !#################################################################### 196 | ! initialise visu 197 | if (ivisu.ne.0) call visu_init() 198 | ! compute diffusion number of simulation 199 | call compute_cfldiff() 200 | !#################################################################### 201 | if (irestart==0) then 202 | call init(rho1,ux1,uy1,uz1,ep1,phi1,drho1,dux1,duy1,duz1,dphi1,pp3,px1,py1,pz1) 203 | itime = 0 204 | call preprocessing(rho1,ux1,uy1,uz1,pp3,phi1,ep1) 205 | else 206 | call restart(ux1,uy1,uz1,dux1,duy1,duz1,ep1,pp3(:,:,:,1),phi1,dphi1,px1,py1,pz1,0) 207 | endif 208 | 209 | call test_speed_min_max(ux1,uy1,uz1) 210 | if (iscalar==1) call test_scalar_min_max(phi1) 211 | 212 | call simu_stats(1) 213 | 214 | call calc_divu_constraint(divu3, rho1, phi1) 215 | 216 | 217 | if(nrank.eq.0)then 218 | open(42,file='time_evol.dat',form='formatted') 219 | endif 220 | 221 | endsubroutine init_xcompact3d 222 | !######################################################################## 223 | !######################################################################## 224 | subroutine finalise_xcompact3d() 225 | 226 | use MPI 227 | use decomp_2d 228 | 229 | use tools, only : simu_stats 230 | 231 | implicit none 232 | 233 | integer :: ierr 234 | 235 | if(nrank.eq.0)then 236 | close(42) 237 | endif 238 | call simu_stats(4) 239 | call decomp_2d_finalize 240 | CALL MPI_FINALIZE(ierr) 241 | 242 | endsubroutine finalise_xcompact3d 243 | -------------------------------------------------------------------------------- /decomp2d/fft_generic.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This is the 'generic' implementation of the FFT library 13 | 14 | module decomp_2d_fft 15 | 16 | use decomp_2d ! 2D decomposition module 17 | use glassman 18 | 19 | implicit none 20 | 21 | private ! Make everything private unless declared public 22 | 23 | ! engine-specific global variables 24 | complex(mytype), allocatable, dimension(:) :: buf, scratch 25 | 26 | ! common code used for all engines, including global variables, 27 | ! generic interface definitions and several subroutines 28 | #include "fft_common.inc" 29 | 30 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 31 | ! This routine performs one-time initialisations for the FFT engine 32 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 33 | subroutine init_fft_engine 34 | 35 | implicit none 36 | 37 | integer :: cbuf_size 38 | 39 | if (nrank==0) then 40 | write(*,*) ' ' 41 | write(*,*) '***** Using the generic FFT engine *****' 42 | write(*,*) ' ' 43 | end if 44 | 45 | cbuf_size = max(ph%xsz(1), ph%ysz(2)) 46 | cbuf_size = max(cbuf_size, ph%zsz(3)) 47 | allocate(buf(cbuf_size)) 48 | allocate(scratch(cbuf_size)) 49 | 50 | return 51 | end subroutine init_fft_engine 52 | 53 | 54 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 55 | ! This routine performs one-time finalisations for the FFT engine 56 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 57 | subroutine finalize_fft_engine 58 | 59 | implicit none 60 | 61 | deallocate(buf,scratch) 62 | 63 | return 64 | end subroutine finalize_fft_engine 65 | 66 | 67 | ! Following routines calculate multiple one-dimensional FFTs to form 68 | ! the basis of three-dimensional FFTs. 69 | 70 | ! c2c transform, multiple 1D FFTs in x direction 71 | subroutine c2c_1m_x(inout, isign, decomp) 72 | 73 | implicit none 74 | 75 | complex(mytype), dimension(:,:,:), intent(INOUT) :: inout 76 | integer, intent(IN) :: isign 77 | TYPE(DECOMP_INFO), intent(IN) :: decomp 78 | 79 | integer :: i,j,k 80 | 81 | do k=1,decomp%xsz(3) 82 | do j=1,decomp%xsz(2) 83 | do i=1,decomp%xsz(1) 84 | buf(i) = inout(i,j,k) 85 | end do 86 | call spcfft(buf,decomp%xsz(1),isign,scratch) 87 | do i=1,decomp%xsz(1) 88 | inout(i,j,k) = buf(i) 89 | end do 90 | end do 91 | end do 92 | 93 | return 94 | 95 | end subroutine c2c_1m_x 96 | 97 | ! c2c transform, multiple 1D FFTs in y direction 98 | subroutine c2c_1m_y(inout, isign, decomp) 99 | 100 | implicit none 101 | 102 | complex(mytype), dimension(:,:,:), intent(INOUT) :: inout 103 | integer, intent(IN) :: isign 104 | TYPE(DECOMP_INFO), intent(IN) :: decomp 105 | 106 | integer :: i,j,k 107 | 108 | do k=1,decomp%ysz(3) 109 | do i=1,decomp%ysz(1) 110 | do j=1,decomp%ysz(2) 111 | buf(j) = inout(i,j,k) 112 | end do 113 | call spcfft(buf,decomp%ysz(2),isign,scratch) 114 | do j=1,decomp%ysz(2) 115 | inout(i,j,k) = buf(j) 116 | end do 117 | end do 118 | end do 119 | 120 | return 121 | 122 | end subroutine c2c_1m_y 123 | 124 | ! c2c transform, multiple 1D FFTs in z direction 125 | subroutine c2c_1m_z(inout, isign, decomp) 126 | 127 | implicit none 128 | 129 | complex(mytype), dimension(:,:,:), intent(INOUT) :: inout 130 | integer, intent(IN) :: isign 131 | TYPE(DECOMP_INFO), intent(IN) :: decomp 132 | 133 | integer :: i,j,k 134 | 135 | do j=1,decomp%zsz(2) 136 | do i=1,decomp%zsz(1) 137 | do k=1,decomp%zsz(3) 138 | buf(k) = inout(i,j,k) 139 | end do 140 | call spcfft(buf,decomp%zsz(3),isign,scratch) 141 | do k=1,decomp%zsz(3) 142 | inout(i,j,k) = buf(k) 143 | end do 144 | end do 145 | end do 146 | 147 | return 148 | 149 | end subroutine c2c_1m_z 150 | 151 | ! r2c transform, multiple 1D FFTs in x direction 152 | subroutine r2c_1m_x(input, output) 153 | 154 | implicit none 155 | 156 | real(mytype), dimension(:,:,:), intent(IN) :: input 157 | complex(mytype), dimension(:,:,:), intent(OUT) :: output 158 | 159 | integer :: i,j,k, s1,s2,s3, d1 160 | 161 | s1 = size(input,1) 162 | s2 = size(input,2) 163 | s3 = size(input,3) 164 | d1 = size(output,1) 165 | 166 | do k=1,s3 167 | do j=1,s2 168 | ! Glassman's FFT is c2c only, 169 | ! needing some pre- and post-processing for r2c 170 | ! pack real input in complex storage 171 | do i=1,s1 172 | buf(i) = cmplx(input(i,j,k),0._mytype, kind=mytype) 173 | end do 174 | call spcfft(buf,s1,-1,scratch) 175 | ! note d1 ~ s1/2+1 176 | ! simply drop the redundant part of the complex output 177 | do i=1,d1 178 | output(i,j,k) = buf(i) 179 | end do 180 | end do 181 | end do 182 | 183 | return 184 | 185 | end subroutine r2c_1m_x 186 | 187 | ! r2c transform, multiple 1D FFTs in z direction 188 | subroutine r2c_1m_z(input, output) 189 | 190 | implicit none 191 | 192 | real(mytype), dimension(:,:,:), intent(IN) :: input 193 | complex(mytype), dimension(:,:,:), intent(OUT) :: output 194 | 195 | integer :: i,j,k, s1,s2,s3, d3 196 | 197 | s1 = size(input,1) 198 | s2 = size(input,2) 199 | s3 = size(input,3) 200 | d3 = size(output,3) 201 | 202 | do j=1,s2 203 | do i=1,s1 204 | ! Glassman's FFT is c2c only, 205 | ! needing some pre- and post-processing for r2c 206 | ! pack real input in complex storage 207 | do k=1,s3 208 | buf(k) = cmplx(input(i,j,k),0._mytype, kind=mytype) 209 | end do 210 | call spcfft(buf,s3,-1,scratch) 211 | ! note d3 ~ s3/2+1 212 | ! simply drop the redundant part of the complex output 213 | do k=1,d3 214 | output(i,j,k) = buf(k) 215 | end do 216 | end do 217 | end do 218 | 219 | return 220 | 221 | end subroutine r2c_1m_z 222 | 223 | ! c2r transform, multiple 1D FFTs in x direction 224 | subroutine c2r_1m_x(input, output) 225 | 226 | implicit none 227 | 228 | complex(mytype), dimension(:,:,:), intent(IN) :: input 229 | real(mytype), dimension(:,:,:), intent(OUT) :: output 230 | 231 | integer :: i,j,k, d1,d2,d3 232 | 233 | d1 = size(output,1) 234 | d2 = size(output,2) 235 | d3 = size(output,3) 236 | 237 | do k=1,d3 238 | do j=1,d2 239 | ! Glassman's FFT is c2c only, 240 | ! needing some pre- and post-processing for c2r 241 | do i=1,d1/2+1 242 | buf(i) = input(i,j,k) 243 | end do 244 | ! expanding to a full-size complex array 245 | ! For odd N, the storage is: 246 | ! 1, 2, ...... N/2+1 integer division rounded down 247 | ! N, ...... N/2+2 => a(i) is conjugate of a(N+2-i) 248 | ! For even N, the storage is: 249 | ! 1, 2, ...... N/2 , N/2+1 250 | ! N, ...... N/2+2 again a(i) conjugate of a(N+2-i) 251 | do i=d1/2+2,d1 252 | buf(i) = conjg(buf(d1+2-i)) 253 | end do 254 | call spcfft(buf,d1,1,scratch) 255 | do i=1,d1 256 | ! simply drop imaginary part 257 | output(i,j,k) = real(buf(i), kind=mytype) 258 | end do 259 | end do 260 | end do 261 | 262 | return 263 | 264 | end subroutine c2r_1m_x 265 | 266 | ! c2r transform, multiple 1D FFTs in z direction 267 | subroutine c2r_1m_z(input, output) 268 | 269 | implicit none 270 | 271 | complex(mytype), dimension(:,:,:), intent(IN) :: input 272 | real(mytype), dimension(:,:,:), intent(OUT) :: output 273 | 274 | integer :: i,j,k, d1,d2,d3 275 | 276 | d1 = size(output,1) 277 | d2 = size(output,2) 278 | d3 = size(output,3) 279 | 280 | do j=1,d2 281 | do i=1,d1 282 | do k=1,d3/2+1 283 | buf(k) = input(i,j,k) 284 | end do 285 | do k=d3/2+2,d3 286 | buf(k) = conjg(buf(d3+2-k)) 287 | end do 288 | call spcfft(buf,d3,1,scratch) 289 | do k=1,d3 290 | output(i,j,k) = real(buf(k), kind=mytype) 291 | end do 292 | end do 293 | end do 294 | 295 | return 296 | 297 | end subroutine c2r_1m_z 298 | 299 | 300 | #include "fft_common_3d.inc" 301 | 302 | 303 | end module decomp_2d_fft 304 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | ## The Xcompact3d code 9 | 10 | ![Build Status](https://github.com/fschuch/Xcompact3d/workflows/Build/badge.svg) 11 | [![DOI](https://img.shields.io/badge/doi-10.1016%2Fj.softx.2020.100550-blue)](https://doi.org/10.1016/j.softx.2020.100550) 12 | 13 | Xcompact3d is a Fortran-MPI based, finite difference high-performance code for solving the 14 | incompressible or low Mach number Navier-Stokes equations with an arbitrary number of scalar transport 15 | equations. 16 | 17 | This repository contains a major upgrade in the Xcompact3d code. The new version is faster, more flexible and user friendly. 18 | 19 | The main homepage for the original Incompact3d can be found at [incompact3d.com](https://www.incompact3d.com/). You can find a list of the work related to the code. 20 | 21 | **This is a Fork from Xcompact3d´s official repository, for more information see the [Changelog](CHANGELOG.md)**. 22 | 23 | ## Resources 24 | 25 | - **Homepage:** 26 | - **Old Binaries (please try to use the latest Github version instead):** 27 | - **Discussion section (FORUM):** 28 | - **Xcompact3d-toolbox**, a set of tools for pre and postprocessing prepared for the high-order Navier-Stokes solver Xcompact3d: 29 | 30 | New users and developers are welcome to join. 31 | 32 | ### External Resources 33 | 34 | - [**Twitter**](https://twitter.com/incompact3d) 35 | 36 | ### Benchmark test cases for code comparison ### 37 | 38 | We established a solid and easy way to run a range of benchmark test cases to verify the 39 | code. 40 | Xcompact3d now supports multiple cases, selectable at runtime in the parameter file input.i3d, 41 | including a user-defined case (note this will require editing the setup in src/BC-User.f90 and 42 | recompiling, check the other setup files src/BC-*.f90 for guidance). 43 | The following cases are set to match the parameters for cases of 44 | reference articles obtained with different codes. 45 | 46 | |Code| Flow configuration | BC File | Reference | Dataset | 47 | |:----------------:|:----------------:|:----------------:|:----------------:|:----------------:| 48 | |1| Gravity Current | Lock-exchange |[Necker et al. (2002)](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.483.5774&rep=rep1&type=pdf) 49 | |2| Taylor-Green Vortices | TGV |[Beck et al. (2014)](https://link.springer.com/article/10.1007/s00162-011-0253-7) 50 | |3| Periodic Channel | Channel-flow |[Moser, Kim & Mansour (1999)](https://www.researchgate.net/publication/243777258_Direct_Numerical_Simulation_of_Turbulent_Channel_Flow_up_to_Re590)|[Dataset](http://turbulence.ices.utexas.edu/data/MKM/chan180/profiles/) 51 | |5| Flow over a Cylinder | Cylinder |[Mittal and Balachandar (1995)](https://www.researchgate.net/publication/252073966_Effect_of_three-dimensionality_on_the_lift_and_drag_of_nominal_two-dimensional_cylinders) 52 | 53 | N.B. Other cases are in preparation. 54 | 55 | ## New compiling FLAGS 56 | 57 | -DDOUBLE_PREC - use double-precision 58 | -DSAVE_SINGLE - save 3D data in single-precision 59 | -DDEBG - debuggin incompact3d.f90 60 | 61 | **Note:** In order to compile the code with the appropriate flags you must enter the -D$FLAG, i.e., -DDOUBLE_PREC 62 | 63 | # Compiled code performance 64 | 65 | Xcompact3d is designed to run on laptops/workstations up to large clusters. We support the gfortran, ifort and ftn compilers 66 | which can be selected at compile time by 67 | 68 | make CMP=gcc 69 | make CMP=intel 70 | make CMP=cray 71 | 72 | respectively (it will default to gfortran otherwise). Note that we use gfortran for development, therefore not all optimizations are enabled by default - if you want to perform production runs using gfortran, adding -O3 to the FFLAGS for CMP=gcc should provide a significant speed up. 73 | 74 | ## Source Download and Compilation 75 | 76 | First, make sure you have all the [required dependencies](#required-build-tools-and-external-libraries) installed. 77 | Then, acquire the source code by cloning the git repository: 78 | 79 | git clone git@github.com:xcompact3d/Incompact3d.git 80 | 81 | (If you are behind a firewall, you may need to use the `https` protocol instead of the `git` protocol: 82 | 83 | git config --global url."https://".insteadOf git@ 84 | 85 | Be sure to also configure your system to use the appropriate proxy settings, e.g. by setting the `https_proxy` and `http_proxy` variables.) 86 | 87 | By default you will be building the latest master version of Xcompact3d, to use the release preview you must checkout the release branch 88 | 89 | git checkout release 90 | 91 | Now run `make` to build the `Xcompact3d` executable. To perform a parallel build, use `make -j N` and supply the maximum number of concurrent processes. (See [Platform Specific Build Notes] for details.) 92 | This takes a while, but only has to be done once. If the defaults in the build do not work for you, and you need to set specific make parameters, you can save them in `Make.user`. The build will automatically check for the existence of `Makefile` and use it if it exists. 93 | Building Xcompact3d requires very little of disk space and virtual memory. 94 | 95 | **Note:** The compiling process 96 | 97 | Once it is built, you can run the `Xcompact3d` executable using its full path in the directory created above (the `Xcompact3d` directory). 98 | 99 | Now you should be able to run Xcompact3d like this: 100 | 101 | mpirun -n 4 ./xcompact3d ./examples//input.i3d 102 | 103 | If a input.i3d file is not provide, xcompact3d will look for it locally (i.e. try to load ./input.i3d). 104 | 105 | If everything works correctly, you will see a Xcompact3d banner and an interactive prompt into which you can enter expressions for evaluation. (Errors related to libraries might be caused by old, incompatible libraries sitting around in your PATH. In this case, try moving the `Xcompact3d` directory earlier in the PATH). 106 | 107 | ### Updating an existing source tree 108 | 109 | If you have previously downloaded `incompact3d` using `git clone`, you can update the 110 | existing source tree using `git pull` rather than starting anew: 111 | 112 | cd incompact3d 113 | git pull && make 114 | 115 | Assuming that you had made no changes to the source tree that will conflict 116 | with upstream updates, these commands will trigger a build to update to the 117 | latest version. 118 | 119 | #### General troubleshooting 120 | 121 | 1. Over time, the base library may accumulate enough changes such that the 122 | bootstrapping process in building the system image will fail. If this 123 | happens, the build may fail with an error like 124 | 125 | ```sh 126 | *** This error is usually fixed by running 'make clean'. If the error persists, try 'make cleanall' *** 127 | ``` 128 | As described, running `make clean && make` is usually sufficient. Occasionally, the stronger cleanup done by `make cleanall` is needed. 129 | 130 | 131 | ## Platform-Specific Notes 132 | 133 | ### Linux 134 | 135 | #### General 136 | 137 | * GCC version 4.7 or later is required to compile the code. 138 | 139 | We recommended that you remove the limits of the environment (e.g. in `.bash_profile`) 140 | 141 | ulimit -c unlimited 142 | ulimit -s unlimited 143 | 144 | You must exit and re-login from your terminal for the change to take effect 145 | 146 | ulimit -a 147 | 148 | #### Architecture Customization 149 | 150 | Xcompact3d can be compiled for a non-generic architecture by configuring the `ARCH` Makefile variable. See the appropriate section of `Makefile` for additional customization options, such as `MARCH` and `CPU_TARGET`. You can also set `march=native` for a maximum-performance build customized for the current machine CPU. 151 | 152 | #### Ubuntu 153 | 154 | In order to compile and execute Xcompact3d in the latest Ubuntu version please install the following packages: 155 | 156 | sudo apt install gfortran libopenmpi-dev 157 | 158 | #### Fedora/RHEL/CentOS 159 | 160 | On RHEL/CentOS 6 systems: 161 | 162 | sudo dnf install gcc-gfortran 163 | 164 | ### OS X 165 | 166 | You need to have the current Xcode command line utilities installed: run `xcode-select --install` in the terminal. 167 | You will need to rerun this terminal command after each OS X update, otherwise you may run into errors involving missing libraries or headers. You will also need a 64-bit gfortran to compile the code. The gfortran-4.7 (and newer) compilers in Brew, Fink, and MacPorts work for building Xcompact3d. On current systems, we recommend that you install the command line tools as described above. Older systems do not have a separate command line tools package from Apple, and will require a full Xcode install. On these, you will need at least Xcode 4.3.3. In Xcode prior to v5.0, you can alternatively go to Preferences -> Downloads and select the Command Line Utilities. 168 | 169 | ## GitHub Configuration 170 | 171 | To add you SSH key to your GitHub account please follow the steps https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/ or just copy the content of the id_rsa.pub file to your clipboard, go to Personal settings and add a new SSH key: 172 | 173 | cat ~/.ssh/id_rsa.pub 174 | -------------------------------------------------------------------------------- /examples/Sandbox/README.md: -------------------------------------------------------------------------------- 1 | # Sandbox Flow Configuration 2 | 3 | > "A Jupyter sandbox environment coupled into the high-order Navier-Stokes solver Xcompact3d", at JupyterCon 2020 ([@JupyterCon](https://twitter.com/JupyterCon)), by [@fschuch](https://github.com/fschuch), [@momba98](https://github.com/momba98), [@filipi](https://github.com/filipi) & J.H. Silvestrini. More details are available [in this link](https://www.fschuch.com/en/publication/2020-jupytercon/). 4 | 5 | The `module sandbox` ([BC-Sandbox.f90](../../src/BC-Sandbox.f90)) is a new addition to the code. 6 | With this module, the entire initial set-up for any given flow configuration can be imported from external files, including physical and numerical parameters, initial and boundary conditions, and a solid geometry that can be inserted with Immersed Boundary Method (IBM). There is no need to worry about parallel computation in a distributed-memory system, Message Passing Interface, besides coding, compiling, testing, and debugging in Fortran. 7 | 8 | The outcome of the presented framework benefits users from different levels: 9 | 10 | - For students in computational fluid dynamics, it provides direct hands-on experience and a safe place for practising and learning; 11 | - For advanced users and code developers, it works as a rapid prototyping tool to test concepts and then compare results to validate any future implementations at the numerical solver; 12 | - Furthermore, it is a useful advance in terms of research reproducibility. 13 | 14 | The sandbox flow configuration is activated when `itype=10` at the configuration file. Xcompact3d will then read all the necessary arrays for the initial set-up from the disc, in the raw binary format compatible with [2DECOMP&FFT](http://www.2decomp.org/). 15 | These arrays can be provided from any computational tool, the choice is up to the user: Fortran, Matlab, Python, or any other. In this way, it adds no extra dependencies to your workflow. 16 | 17 | ## Initial set-up 18 | 19 | Try it with the Python package [Xcompact3d-toolbox](https://github.com/fschuch/xcompact3d_toolbox) ([see examples online](https://xcompact3d-toolbox.readthedocs.io/en/latest/tutorial.html#sandbox-examples)). 20 | Everything needed is obtained in a [xarray.Dataset](http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html), including all variables that should be provided to Xcompact3d and the sandbox flow configuration, according to the computational and physical parameters at the configuration file `input.i3d`. See the example: 21 | 22 | ```python 23 | >>> import xcompact3d_toolbox as x3d 24 | >>> import xcompact3d_toolbox.sandbox 25 | >>> prm = x3d.Parameters(loadfile='input.i3d') 26 | >>> dataset = x3d.sandbox.init_dataset(prm) 27 | >>> dataset 28 | 29 | Dimensions: (n: 1, x: 17, y: 17, z: 17) 30 | Coordinates: 31 | * x (x) float64 0.0 0.0625 0.125 0.1875 ... 0.875 0.9375 1.0 32 | * y (y) float64 0.0 0.0625 0.125 0.1875 ... 0.875 0.9375 1.0 33 | * z (z) float64 0.0 0.0625 0.125 0.1875 ... 0.875 0.9375 1.0 34 | * n (n) int32 0 35 | Data variables: 36 | bxx1 (y, z) float64 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 37 | bxy1 (y, z) float64 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 38 | bxz1 (y, z) float64 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 39 | noise_mod_x1 (y, z) float64 0.0 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 40 | bxphi1 (n, y, z) float64 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 41 | byphi1 (n, x, z) float64 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 42 | byphin (n, x, z) float64 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 43 | ux (x, y, z) float64 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 44 | uy (x, y, z) float64 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 45 | uz (x, y, z) float64 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 0.0 46 | phi (n, x, y, z) float64 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0 47 | >>> # Sequence of operations to set the value for the variables above 48 | >>> dataset.x3d.write(prm) 49 | ``` 50 | 51 | More details are provided bellow, if you want to code your own solution. The examples are in Python, but it should be compatible with any language, as long as the files are written as raw binaries in the same fashion that [2DECOMP&FFT](http://www.2decomp.org/) would do, and the filenames are correct. 52 | 53 | ### Initial Condition 54 | 55 | The subroutine `init_sandbox` ([BC-Sandbox.f90](../../src/BC-Sandbox.f90)) reads the initial values for velocity from three files: 56 | 57 | * `./data/ux.bin`, with dimensions (nx, ny, nz); 58 | * `./data/uy.bin`, with dimensions (nx, ny, nz); 59 | * `./data/uz.bin`, with dimensions (nx, ny, nz). 60 | 61 | Each scalar field is loaded (if `numscalar > 0`) from the file: 62 | 63 | * `./data/phi.bin`, with dimensions (nx, ny, nz), where 1 <= n <= numscalar. 64 | 65 | In Python, any of the arrays can be handled with Numpy, just make sure to use `dtype=np.float64` if Xcompact3d was compiled with the flag `-DDOUBLE_PREC`, use `dtype=np.float32` otherwise. See the example: 66 | 67 | ```python 68 | import numpy 69 | 70 | ux = numpy.zeros( 71 | shape = (nx, ny, nz), 72 | dtype = numpy.float64 73 | ) 74 | uy = numpy.zeros_like(ux) 75 | uz = numpy.zeros_like(ux) 76 | 77 | phi = numpy.zeros( 78 | shape = (nx, ny, nz, numscalar), 79 | dtype = numpy.float64 80 | ) 81 | 82 | ''' 83 | Sequence of operations to set 84 | the initial velocity and scalar concentration 85 | ''' 86 | 87 | ux.T.tofile('./data/ux.bin') 88 | uy.T.tofile('./data/uy.bin') 89 | uz.T.tofile('./data/uz.bin') 90 | 91 | for n in range(numscalar): 92 | phi[:,:,:,n].T.tofile('./data/phi{}.bin'.format(n+1)) 93 | ``` 94 | 95 | ### Geometry 96 | 97 | The subroutine `geomcomplex_sandbox` ([BC-Sandbox.f90](../../src/BC-Sandbox.f90)) reads the epsilon field describing the solid geometry that is going to be inserted in the computational domain by IBM: 98 | 99 | * `./data/geometry/epsilon.bin`, with dimensions (nx, ny, nz). 100 | 101 | It is just necessary if `iibm = 1`. See the example: 102 | 103 | ```python 104 | epsi = numpy.zeros( 105 | shape = (nx, ny, nz), 106 | dtype = numpy.float64 107 | ) 108 | 109 | ''' 110 | Sequence of operations to set 111 | the geometry as 1 inside the object(s) 112 | and 0 in the fluid region 113 | ''' 114 | 115 | epsi.T.tofile('./data/ux.bin') 116 | ``` 117 | 118 | More information about the solid object(s) is necessary for the alternating direction forcing strategy (if `iibm = 2`), Xcompact3d expects to read it from three files (`obj-x.csv`, `obj-y.csv`, `obj-z.csv`), consider using [`xcompact3d_toolbox.genepsi.gene_epsi_3D`](xcompact3d_toolbox.genepsi.gene_epsi_3D) in this case ([see example](https://xcompact3d-toolbox.readthedocs.io/en/latest/examples/Cylinder.html)). 119 | 120 | ### Flow Rate Control 121 | 122 | A forcing term is included at `module sandbox` in order to keep a constant flow rate when the flow is periodic in the stream-wise direction (`nclx1=nclxn=0`). To do so, the subroutine `flow_rate_control` ([BC-Sandbox.f90](../../src/BC-Sandbox.f90)) applies a customized operator for the volumetric integration, it can be set in the file: 123 | 124 | * `'./data/vol_frc.bin`, with dimensions (nx, ny, nz). 125 | 126 | Then, the code will compute de stream-wise flow rate as `int = sum(vol_frc * ux)`, and correct the stream-wise velocity as `ux = ux / int`. 127 | 128 | ### Boundary Condition 129 | 130 | The value of the functions must be provided for Dirichlet boundary condition. 131 | At the moment, `module sandbox` only supports reading the velocity BC where `x=0`, of course, if `nclx1=2`. It can be done using three files: 132 | 133 | * `./data/bxx1.bin`, with dimensions (ny,nz), for `ux` where `x=0`; 134 | * `./data/bxy1.bin`, with dimensions (ny,nz), for `uy` where `x=0`; 135 | * `./data/bxz1.bin`, with dimensions (ny,nz), for `uz` where `x=0`. 136 | 137 | Additionally, a function can be provided for random noise modulation at the inlet, in order to prevent noise in specific regions of the inflow plane. See `inflow` ([BC-Sandbox.f90](../../src/BC-Sandbox.f90)) for more details. It is done with the file: 138 | 139 | * `./data/noise_mod_x1.bin`, with dimensions (ny,nz). 140 | 141 | In the case of `nclxn=2`, `module sandbox` will apply convective outflow. Any other boundary set as 2 will be considered no-slip. 142 | 143 | For the scalar field(s), `n` inflow profiles (where `x=0`) are loaded when `nclxS1=2`: 144 | 145 | * `./data/bxphi1.bin`, with dimensions (ny,nz), for `phi` where `x=0`. 146 | 147 | A convective outflow is applied for scalar if `nclxSn=2`. Besides, if the settling velocity is zero (`uset[n]=0`), the value of scalar field(s) at the bottom (`y=0`, when `nclyS1=2`) and top (`y=Ly`, when `nclySx=2`) can be set using the files: 148 | 149 | * `./data/byphi1`, with dimensions (nx,nz), for `phi` where `y=0`; 150 | * `./data/byphin`, with dimensions (nx,nz), for `phi` where `y=Ly`. 151 | 152 | On the other hand, deposit condition is applied when the settling velocity is greater than zero. 153 | 154 | See the example: 155 | 156 | ```python 157 | bxx1 = numpy.zeros( 158 | shape = (nx, ny), 159 | dtype = numpy.float64 160 | ) 161 | bxy1 = numpy.zeros_like(bxx1) 162 | bxy1 = numpy.zeros_like(bxx1) 163 | noise_mod = numpy.ones_like(bxx1) 164 | 165 | bxphi1 = numpy.zeros( 166 | shape = (nx, ny, numscalar), 167 | dtype = numpy.float64 168 | ) 169 | byphi1 = numpy.zeros( 170 | shape = (nx, nz, numscalar), 171 | dtype = numpy.float64 172 | ) 173 | byphin = numpy.ones_like(byphi1) 174 | 175 | ''' 176 | Sequence of operations to set 177 | the BC for velocity and scalar concentration 178 | ''' 179 | 180 | bxx1.T.tofile('./data/bxx1.bin') 181 | bxy1.T.tofile('./data/bxy1.bin') 182 | bxz1.T.tofile('./data/bxz1.bin') 183 | noise_mod.T.tofile('./data/noise_mod_x1.bin') 184 | 185 | for n in range(numscalar): 186 | bxphi1[:,:,n].T.tofile('./data/bxphi1{}.bin'.format(n+1)) 187 | byphi1[:,:,n].T.tofile('./data/byphi1{}.bin'.format(n+1)) 188 | byphin[:,:,n].T.tofile('./data/byphiz{}.bin'.format(n+1)) 189 | ``` 190 | -------------------------------------------------------------------------------- /src/BC-Channel-flow.f90: -------------------------------------------------------------------------------- 1 | !################################################################################ 2 | !This file is part of Xcompact3d. 3 | ! 4 | !Xcompact3d 5 | !Copyright (c) 2012 Eric Lamballais and Sylvain Laizet 6 | !eric.lamballais@univ-poitiers.fr / sylvain.laizet@gmail.com 7 | ! 8 | ! Xcompact3d is free software: you can redistribute it and/or modify 9 | ! it under the terms of the GNU General Public License as published by 10 | ! the Free Software Foundation. 11 | ! 12 | ! Xcompact3d is distributed in the hope that it will be useful, 13 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ! GNU General Public License for more details. 16 | ! 17 | ! You should have received a copy of the GNU General Public License 18 | ! along with the code. If not, see . 19 | !------------------------------------------------------------------------------- 20 | !------------------------------------------------------------------------------- 21 | ! We kindly request that you cite Xcompact3d/Incompact3d in your 22 | ! publications and presentations. The following citations are suggested: 23 | ! 24 | ! 1-Bartholomew P., Deskos G., Frantz R.A.S., Schuch F.N., Lamballais E. & 25 | ! Laizet S., 2020, Xcompact3D: An open-source framework for solving 26 | ! turbulence problems on a Cartesian mesh, SoftwareX, vol 12, pp 100550 27 | ! 28 | ! 2-Laizet S. & Lamballais E., 2009, High-order compact schemes for 29 | ! incompressible flows: a simple and efficient method with the quasi-spectral 30 | ! accuracy, J. Comp. Phys., vol 228 (15), pp 5989-6015 31 | ! 32 | ! 3-Laizet S. & Li N., 2011, Incompact3d: a powerful tool to tackle turbulence 33 | ! problems with up to 0(10^5) computational cores, Int. J. of Numerical 34 | ! Methods in Fluids, vol 67 (11), pp 1735-1757 35 | !################################################################################ 36 | module channel 37 | 38 | use decomp_2d 39 | use variables 40 | use param 41 | 42 | implicit none 43 | 44 | integer :: FS 45 | character(len=100) :: fileformat 46 | character(len=1),parameter :: NL=char(10) !new line character 47 | 48 | real(mytype),save,allocatable,dimension(:) :: usum,vsum,wsum,uusum,uvsum,uwsum,vvsum,vwsum,wwsum 49 | 50 | PRIVATE ! All functions/subroutines private by default 51 | PUBLIC :: init_channel, boundary_conditions_channel, postprocess_channel, & 52 | momentum_forcing_channel, & 53 | geomcomplex_channel 54 | 55 | contains 56 | !############################################################################ 57 | subroutine init_channel (ux1,uy1,uz1,ep1,phi1) 58 | 59 | use decomp_2d 60 | use decomp_2d_io 61 | use variables 62 | use param 63 | use MPI 64 | 65 | implicit none 66 | 67 | real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux1,uy1,uz1,ep1 68 | real(mytype),dimension(xsize(1),xsize(2),xsize(3),numscalar) :: phi1 69 | 70 | real(mytype) :: y,r,um,r3,x,z,h,ct 71 | real(mytype) :: cx0,cy0,cz0,hg,lg 72 | integer :: k,j,i,fh,ierror,ii,is,it,code 73 | integer (kind=MPI_OFFSET_KIND) :: disp 74 | 75 | integer, dimension (:), allocatable :: seed 76 | 77 | if (iscalar==1) then 78 | if (nrank.eq.0) print *,'Imposing linear temperature profile' 79 | do k=1,xsize(3) 80 | do j=1,xsize(2) 81 | if (istret.eq.0) y=real(j+xstart(2)-2,mytype)*dy 82 | if (istret.ne.0) y=yp(j+xstart(2)-1) 83 | do i=1,xsize(1) 84 | phi1(i,j,k,:) = 1. - y/yly 85 | enddo 86 | enddo 87 | enddo 88 | 89 | phi1(:,:,:,:) = zero !change as much as you want 90 | if ((nclyS1.eq.2).and.(xstart(2).eq.1)) then 91 | !! Generate a hot patch on bottom boundary 92 | phi1(:,1,:,:) = one 93 | endif 94 | if ((nclySn.eq.2).and.(xend(2).eq.ny)) then 95 | phi1(:,xsize(2),:,:) = zero 96 | endif 97 | endif 98 | 99 | ux1=zero;uy1=zero;uz1=zero 100 | if (iin.ne.0) then 101 | call system_clock(count=code) 102 | if (iin.eq.2) code=0 103 | call random_seed(size = ii) 104 | call random_seed(put = code+63946*nrank*(/ (i - 1, i = 1, ii) /)) 105 | 106 | call random_number(ux1) 107 | call random_number(uy1) 108 | call random_number(uz1) 109 | endif 110 | 111 | !modulation of the random noise + initial velocity profile 112 | do k=1,xsize(3) 113 | do j=1,xsize(2) 114 | if (istret.eq.0) y=real(j+xstart(2)-1-1,mytype)*dy-yly/two 115 | if (istret.ne.0) y=yp(j+xstart(2)-1)-yly/two 116 | um=exp(-zptwo*y*y) 117 | do i=1,xsize(1) 118 | ux1(i,j,k)=init_noise*um*(two*ux1(i,j,k)-one)+one-y*y 119 | uy1(i,j,k)=init_noise*um*(two*uy1(i,j,k)-one) 120 | uz1(i,j,k)=init_noise*um*(two*uz1(i,j,k)-one) 121 | enddo 122 | enddo 123 | enddo 124 | 125 | !INIT FOR G AND U=MEAN FLOW + NOISE 126 | do k=1,xsize(3) 127 | do j=1,xsize(2) 128 | do i=1,xsize(1) 129 | ux1(i,j,k)=ux1(i,j,k)+bxx1(j,k) 130 | uy1(i,j,k)=uy1(i,j,k)+bxy1(j,k) 131 | uz1(i,j,k)=uz1(i,j,k)+bxz1(j,k) 132 | enddo 133 | enddo 134 | enddo 135 | 136 | #ifdef DEBG 137 | if (nrank .eq. 0) print *,'# init end ok' 138 | #endif 139 | 140 | return 141 | end subroutine init_channel 142 | !############################################################################ 143 | !############################################################################ 144 | subroutine boundary_conditions_channel (ux,uy,uz,phi) 145 | 146 | use param 147 | use variables 148 | use decomp_2d 149 | use tools, only : channel_cfr 150 | 151 | implicit none 152 | 153 | real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ux,uy,uz 154 | real(mytype),dimension(xsize(1),xsize(2),xsize(3),numscalar) :: phi 155 | !!$ real(mytype),dimension(xsize(1),xsize(2),xsize(3)) :: ut 156 | 157 | real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: gx 158 | real(mytype) :: x, y, z 159 | integer :: i, j, k, is 160 | 161 | if (icpg.ne.one) then ! if not constant pressure gradient 162 | if (icfr.eq.one) then ! constant flow rate without transposition 163 | call channel_cfr(ux,two/three) 164 | else if (icfr.eq.two) then 165 | call transpose_x_to_y(ux,gx) 166 | call channel_flrt(gx,two/three) 167 | call transpose_y_to_x(gx,ux) 168 | end if 169 | end if 170 | 171 | if (iscalar.ne.0) then 172 | if (itimescheme.ne.7) then 173 | if ((nclyS1.eq.2).and.(xstart(2).eq.1)) then 174 | !! Generate a hot patch on bottom boundary 175 | phi(:,1,:,:) = one 176 | endif 177 | if ((nclySn.eq.2).and.(xend(2).eq.ny)) THEN 178 | phi(:,xsize(2),:,:) = zero 179 | endif 180 | endif 181 | endif 182 | 183 | return 184 | end subroutine boundary_conditions_channel 185 | !############################################################################ 186 | !############################################################################ 187 | subroutine channel_flrt (ux,constant) 188 | 189 | use decomp_2d 190 | use decomp_2d_poisson 191 | use variables 192 | use param 193 | use var 194 | use MPI 195 | 196 | implicit none 197 | 198 | real(mytype),dimension(ysize(1),ysize(2),ysize(3)) :: ux 199 | real(mytype) :: constant 200 | 201 | integer :: j,i,k,code 202 | real(mytype) :: can,ut3,ut,ut4 203 | 204 | ut3=zero 205 | do k=1,ysize(3) 206 | do i=1,ysize(1) 207 | ut=zero 208 | do j=1,ny-1 209 | if (istret.eq.0) then 210 | ut=ut+dy*(ux(i,j+1,k)-half*(ux(i,j+1,k)-ux(i,j,k))) 211 | else 212 | ut=ut+(yp(j+1)-yp(j))*(ux(i,j+1,k)-half*(ux(i,j+1,k)-ux(i,j,k))) 213 | endif 214 | enddo 215 | ut=ut/yly 216 | ut3=ut3+ut 217 | enddo 218 | enddo 219 | ut3=ut3/(real(nx*nz,mytype)) 220 | 221 | call MPI_ALLREDUCE(ut3,ut4,1,real_type,MPI_SUM,MPI_COMM_WORLD,code) 222 | 223 | can=-(constant-ut4) 224 | 225 | if (nrank==0) print *,nrank,'UT',ut4,can 226 | 227 | do k=1,ysize(3) 228 | do i=1,ysize(1) 229 | do j=2,ny-1 230 | ux(i,j,k)=ux(i,j,k)-can 231 | enddo 232 | enddo 233 | enddo 234 | 235 | return 236 | end subroutine channel_flrt 237 | !############################################################################ 238 | !############################################################################ 239 | subroutine postprocess_channel(ux1,uy1,uz1,pp3,phi1,ep1) !By Felipe Schuch 240 | 241 | use MPI 242 | use decomp_2d 243 | use decomp_2d_io 244 | use var, only : umean,vmean,wmean,pmean,uumean,vvmean,wwmean,uvmean,uwmean,vwmean,tmean 245 | use var, only : phimean, phiphimean 246 | use var, only : ta1, pp1, di1 247 | use var, only : ppi3, dip3 248 | use var, only : pp2, ppi2, dip2 249 | 250 | use var, ONLY : nxmsize, nymsize, nzmsize 251 | use param, ONLY : npress 252 | 253 | real(mytype),intent(in),dimension(xsize(1),xsize(2),xsize(3)) :: ux1, uy1, uz1, ep1 254 | real(mytype),intent(in),dimension(xsize(1),xsize(2),xsize(3),numscalar) :: phi1 255 | real(mytype), dimension(ph1%zst(1):ph1%zen(1), ph1%zst(2):ph1%zen(2), nzmsize, npress), intent(in) :: pp3 256 | character(len=30) :: filename 257 | 258 | integer :: is 259 | 260 | return 261 | end subroutine postprocess_channel 262 | !############################################################################ 263 | !############################################################################ 264 | !! 265 | !! SUBROUTINE: momentum_forcing 266 | !! AUTHOR: Paul Bartholomew 267 | !! DESCRIPTION: Applies rotation for t < spinup_time. 268 | !! 269 | !############################################################################ 270 | subroutine momentum_forcing_channel(dux1, duy1, ux1, uy1) 271 | 272 | implicit none 273 | 274 | real(mytype), intent(in), dimension(xsize(1), xsize(2), xsize(3)) :: ux1, uy1 275 | real(mytype), dimension(xsize(1), xsize(2), xsize(3), ntime) :: dux1, duy1 276 | 277 | if (icpg.eq.one) then 278 | !! fcpg: add constant pressure gradient in streamwise direction 279 | dux1(:,:,:,1) = dux1(:,:,:,1) + fcpg !* (re/re_cent)**2 280 | endif 281 | 282 | if (itime.lt.spinup_time) then 283 | if (nrank==0) print *,'Rotating turbulent channel at speed ',wrotation 284 | dux1(:,:,:,1) = dux1(:,:,:,1) - wrotation*uy1(:,:,:) 285 | duy1(:,:,:,1) = duy1(:,:,:,1) + wrotation*ux1(:,:,:) 286 | endif 287 | 288 | end subroutine momentum_forcing_channel 289 | !############################################################################ 290 | !############################################################################ 291 | subroutine geomcomplex_channel(epsi,nxi,nxf,ny,nyi,nyf,nzi,nzf,yp,remp) 292 | 293 | use decomp_2d, only : mytype 294 | use param, only : zero, one, two 295 | use ibm 296 | 297 | implicit none 298 | 299 | integer :: nxi,nxf,ny,nyi,nyf,nzi,nzf 300 | real(mytype),dimension(nxi:nxf,nyi:nyf,nzi:nzf) :: epsi 301 | real(mytype),dimension(ny) :: yp 302 | real(mytype) :: remp 303 | integer :: j 304 | real(mytype) :: ym 305 | real(mytype) :: zeromach 306 | real(mytype) :: h 307 | 308 | epsi(:,:,:) = zero 309 | h = (yly - two) / two 310 | 311 | zeromach=one 312 | do while ((one + zeromach / two) .gt. one) 313 | zeromach = zeromach/two 314 | end do 315 | zeromach = 1.0e1*zeromach 316 | 317 | do j=nyi,nyf 318 | ym=yp(j) 319 | if ((ym.le.h).or.(ym.ge.(h+two))) then 320 | epsi(:,j,:)=remp 321 | endif 322 | enddo 323 | 324 | return 325 | end subroutine geomcomplex_channel 326 | !############################################################################ 327 | end module channel 328 | --------------------------------------------------------------------------------