├── .github └── workflows │ └── compile.yml ├── .gitignore ├── ACKNOWLEDGEMENTS ├── LICENSE ├── README.md ├── examples ├── _manuscript_lid_driven_cavity │ └── dns.in ├── _manuscript_taylor_green_vortex │ └── dns.in ├── _manuscript_turbulent_channel │ └── dns.in ├── _manuscript_turbulent_duct │ └── dns.in ├── _old_input_files │ ├── _manuscript_lid_driven_cavity │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── _manuscript_taylor_green_vortex │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── _manuscript_turbulent_channel │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── _manuscript_turbulent_duct │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── closed_box │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── couette │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── developing_channel │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── developing_duct │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── half_channel │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── lid_driven_cavity │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── periodic_channel │ │ ├── bc.h90 │ │ └── setup.h90 │ ├── periodic_duct │ │ ├── bc.h90 │ │ └── setup.h90 │ └── triperiodic │ │ ├── bc.h90 │ │ └── setup.h90 ├── closed_box │ └── dns.in ├── couette │ └── dns.in ├── developing_channel │ └── dns.in ├── developing_duct │ └── dns.in ├── half_channel │ └── dns.in ├── lid_driven_cavity │ └── dns.in ├── periodic_channel │ └── dns.in ├── periodic_duct │ └── dns.in ├── triperiodic │ └── dns.in └── turbulent_channel_constant_pressure_gradient │ └── dns.in ├── src ├── 2decomp │ ├── LICENSE │ ├── alloc.f90 │ ├── decomp_2d.f90 │ ├── factor.f90 │ ├── halo.f90 │ ├── halo_common.f90 │ ├── io.f90 │ ├── io_read_one.f90 │ ├── io_read_var.f90 │ ├── io_write_every.f90 │ ├── io_write_one.f90 │ ├── io_write_plane.f90 │ ├── io_write_var.f90 │ ├── transpose_x_to_y.f90 │ ├── transpose_x_to_z.f90 │ ├── transpose_y_to_x.f90 │ ├── transpose_y_to_z.f90 │ ├── transpose_z_to_x.f90 │ └── transpose_z_to_y.f90 ├── INFO_INPUT.md ├── INFO_VISU.md ├── Makefile ├── Makefile_cpu ├── Makefile_summit ├── bound.f90 ├── chkdiv.f90 ├── chkdt.f90 ├── common_mpi.f90 ├── correc.f90 ├── data │ └── readme.txt ├── debug.f90 ├── dns.in ├── fft.f90 ├── fftw.f90 ├── fillps.f90 ├── initflow.f90 ├── initgrid.f90 ├── initmpi.f90 ├── initsolver.f90 ├── load.f90 ├── main.f90 ├── mom.f90 ├── momd.f90 ├── moms.f90 ├── nvtx.f90 ├── out1d.h90 ├── out2d.h90 ├── out3d.h90 ├── output.f90 ├── param.f90 ├── rk.f90 ├── sanity.f90 ├── solver.f90 └── types.f90 ├── tests └── lid_driven_cavity │ ├── Makefile │ ├── data_ldc_re1000.txt │ ├── dns.in │ ├── test.py │ └── testit.sh └── utils ├── plot2d ├── param.py ├── plot_2d_flow_slice.py ├── pltparams.py └── readme.txt ├── read_binary_data ├── matlab │ ├── read_restart_file.m │ └── read_single_field_binary.m └── python │ ├── read_restart_file.py │ └── read_single_field_binary.py └── visualize_fields ├── gen_xdmf_easy ├── write_xdmf.py ├── write_xdmf_box.py └── write_xdmf_restart.py ├── gen_xdmf_non_uniform_grid ├── gen_grid.f90 ├── gen_xdmf.f90 ├── genview.sh ├── param.h90 └── readme.txt └── gen_xdmf_uniform_grid ├── gen_xdmf.f90 ├── genview.sh ├── param.h90 └── readme.txt /.github/workflows/compile.yml: -------------------------------------------------------------------------------- 1 | name: compilation test 2 | 3 | on: [push,pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: install software 13 | run: | 14 | sudo apt-get update; sudo apt-get install gfortran libopenmpi-dev libfftw3-dev 15 | # 16 | NVVERSION_A=20.11 17 | NVVERSION_B=2011 18 | CUDA_VERSION=11.1 19 | export NVHPC_SILENT=true 20 | export NVHPC_INSTALL_TYPE=single 21 | export NVHPC_INSTALL_DIR=$HOME/software/nvidia/hpc_sdk 22 | wget https://developer.download.nvidia.com/hpc-sdk/$NVVERSION_A/nvhpc_2020_${NVVERSION_B}_Linux_x86_64_cuda_$CUDA_VERSION.tar.gz 23 | tar xpzf nvhpc_2020_${NVVERSION_B}_Linux_x86_64_cuda_$CUDA_VERSION.tar.gz 24 | ./nvhpc_2020_${NVVERSION_B}_Linux_x86_64_cuda_$CUDA_VERSION/install 25 | rm -rf nvhpc_2020_${NVVERSION_B}_Linux_x86_64_cuda_$CUDA_VERSION* 26 | - name: test compilation 27 | run: | 28 | NVVERSION=20.11 29 | NVHPC_INSTALL_DIR=$HOME/software/nvidia/hpc_sdk 30 | NVARCH=`uname -s`_`uname -m`; export NVARCH 31 | NVCOMPILERS=$NVHPC_INSTALL_DIR; export NVCOMPILERS 32 | MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/$NVVERSION/compilers/man; export MANPATH 33 | PATH=$NVCOMPILERS/$NVARCH/$NVVERSION/compilers/bin:$PATH; export PATH 34 | export PATH=$NVCOMPILERS/$NVARCH/$NVVERSION/comm_libs/mpi/bin:$PATH 35 | export MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/$NVVERSION/comm_libs/mpi/man 36 | export LD_LIBRARY_PATH=$NVHPC_INSTALL_DIR/Linux_x86_64/$NVVERSION/compilers/lib:$LD_LIBRARY_PATH 37 | # 38 | cd src/ 39 | make -j && make run && make clean 40 | make -j OPT=-O3 OTH= && make run && make clean 41 | make -j OPT=-O3 OTH= OMP+=-fopenmp && make run && make clean 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.mod 3 | *.out 4 | *.bin 5 | *.MOD 6 | *.log 7 | *dSYM 8 | *.xdmf 9 | *.xmf 10 | cans 11 | run/ 12 | src/data/*.* 13 | run/data/*.* 14 | -------------------------------------------------------------------------------- /ACKNOWLEDGEMENTS: -------------------------------------------------------------------------------- 1 | I would like to acknowledge Wim-Paul Breugem and Bendiks Jan Boersma from the TU 2 | Delft for fruitful discussions that motivated the development of this code. 3 | Although written from scratch, this code was deeply influenced by an in-house 4 | FORTRAN code for turbulent channel flow developed by WPB. 5 | 6 | The routines for performing global transpositions are based on the 2decomp&fft 7 | library (http://www.2decomp.org/decomp.html). Some modifications to these 8 | routines have been performed in the CFD code AFiD 9 | (https://github.com/PhysicsofFluids/AFiD), and ported to this code. 10 | 11 | Moreover, the initialization of Multi-Threaded FFTs with the FFTW guru interface 12 | was inspired by AFiD's implementation. 13 | 14 | Pedro Costa 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2018 Pedro Costa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/_manuscript_lid_driven_cavity/dns.in: -------------------------------------------------------------------------------- 1 | 128 128 128 ! itot, jtot, ktot 2 | 1. 1. 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | zer ! inivel 7 | F ! is_wallturb 8 | 10000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 100 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | D D D D D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | D D D D D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | D D D D D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | N N N N N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 1. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/_manuscript_taylor_green_vortex/dns.in: -------------------------------------------------------------------------------- 1 | 512 512 512 ! itot, jtot, ktot 2 | 6.2831853071795 1.e586 6.283185307179586 6.283185307179586 ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1600. ! uref, lref, rey 6 | tgv ! inivel 7 | F ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P P P ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P P P ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P P P ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P P P ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/_manuscript_turbulent_channel/dns.in: -------------------------------------------------------------------------------- 1 | 512 256 144 ! itot, jtot, ktot 2 | 6. 3. 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 5640. ! uref, lref, rey 6 | poi ! inivel 7 | T ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 100 500 10000 5000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | T F F ! is_forced(1:3) 22 | 1. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/_manuscript_turbulent_duct/dns.in: -------------------------------------------------------------------------------- 1 | 512 128 128 ! itot, jtot, ktot 2 | 10. 1. 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 4410. ! uref, lref, rey 6 | poi ! inivel 7 | T ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 100 500 10000 5000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P D D D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P D D D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P D D D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P N N N N ! cbcpre(0:1,1:3,1) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3 ) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | T F F ! is_forced(1:3) 22 | 1. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_lid_driven_cavity/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'D','D', & ! u in x lower,upper bound 9 | 'D','D', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'D','D', & ! v in x lower,upper bound 12 | 'D','D', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'D','D', & ! w in x lower,upper bound 15 | 'D','D', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,1.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'N','N', & ! p in x lower,upper bound 35 | 'N','N', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_lid_driven_cavity/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 128, jtot = 128, ktot = 128 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx = 1.d0, ly = 1.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'zer' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 10000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 100, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_taylor_green_vortex/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'P','P', & ! u in y lower,upper bound 10 | 'P','P', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'P','P', & ! v in y lower,upper bound 13 | 'P','P', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'P','P', & ! w in y lower,upper bound 16 | 'P','P'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,1.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'P','P', & ! p in y lower,upper bound 36 | 'P','P'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_taylor_green_vortex/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 512, jtot = 512, ktot = 512 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx = 2.d0*pi, ly = 2.d0*pi, lz = 2.d0*pi 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1600.d0, uref = 1.d0, lref = 1.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'tgv' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_turbulent_channel/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'P','P', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'P','P', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'P','P', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'P','P', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.true. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/1.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_turbulent_channel/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 512, jtot = 256, ktot = 144 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx =6.d0, ly = 3.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 5640.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'poi' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .true. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 100, & 49 | iout2d = 500, iout3d = 10000, isave = 5000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_turbulent_duct/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'D','D', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'D','D', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'D','D', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'N','N', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.true. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/1.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/_manuscript_turbulent_duct/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 512, jtot = 128, ktot = 128 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx =10.d0, ly = 1.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 4410.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'poi' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .true. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 100, & 49 | iout2d = 500, iout3d = 10000, isave = 5000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/closed_box/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'D','D', & ! u in x lower,upper bound 9 | 'D','D', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'D','D', & ! v in x lower,upper bound 12 | 'D','D', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'D','D', & ! w in x lower,upper bound 15 | 'D','D', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'N','N', & ! p in x lower,upper bound 35 | 'N','N', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/closed_box/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx = 1.d0, ly = 1.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'zer' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/couette/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'P','P', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'P','P', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'P','P', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | .5d0,-.5d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'P','P', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/couette/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx =3.d0, ly = 1.5d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'cou' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 20000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/developing_channel/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'D','N', & ! u in x lower,upper bound 9 | 'P','P', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'N','N', & ! v in x lower,upper bound 12 | 'P','P', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'N','N', & ! w in x lower,upper bound 15 | 'P','P', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/1.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'N','D', & ! p in x lower,upper bound 35 | 'P','P', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.true. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/developing_channel/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx =3.d0, ly = 1.5d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'zer' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/developing_duct/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'D','N', & ! u in x lower,upper bound 9 | 'D','D', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'N','N', & ! v in x lower,upper bound 12 | 'D','D', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'N','N', & ! w in x lower,upper bound 15 | 'D','D', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/1.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'N','D', & ! p in x lower,upper bound 35 | 'N','N', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.true. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/developing_duct/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx =3.d0, ly = 1.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'zer' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/half_channel/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'P','P', & ! u in y lower,upper bound 10 | 'D','N', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'P','P', & ! v in y lower,upper bound 13 | 'D','N', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'P','P', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'P','P', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.true. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/1.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/half_channel/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx = 3.d0, ly = 1.5d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'hcl' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/lid_driven_cavity/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'D','D', & ! u in x lower,upper bound 9 | 'D','D', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'D','D', & ! v in x lower,upper bound 12 | 'D','D', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'D','D', & ! w in x lower,upper bound 15 | 'D','D', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,1.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'N','N', & ! p in x lower,upper bound 35 | 'N','N', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/lid_driven_cavity/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx = 1.d0, ly = 1.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'zer' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/periodic_channel/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'P','P', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'P','P', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'P','P', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'P','P', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.true. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/1.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/periodic_channel/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx =3.d0, ly = 1.5d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'log' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/periodic_duct/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'D','D', & ! u in y lower,upper bound 10 | 'D','D', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'D','D', & ! v in y lower,upper bound 13 | 'D','D', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'D','D', & ! w in y lower,upper bound 16 | 'D','D'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'N','N', & ! p in y lower,upper bound 36 | 'N','N'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.true. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/1.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/periodic_duct/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx =3.d0, ly = 1.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'poi' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/_old_input_files/triperiodic/bc.h90: -------------------------------------------------------------------------------- 1 | !-------------------------------------------------------------- 2 | ! boundary conditions 3 | ! P -> periodic, D -> Dirichlet, N -> Neumann 4 | !-------------------------------------------------------------- 5 | ! velocity 6 | ! 7 | character(len=1), parameter, dimension(0:1,3,3) :: cbcvel = & 8 | reshape((/'P','P', & ! u in x lower,upper bound 9 | 'P','P', & ! u in y lower,upper bound 10 | 'P','P', & ! u in z lower,upper bound 11 | 'P','P', & ! v in x lower,upper bound 12 | 'P','P', & ! v in y lower,upper bound 13 | 'P','P', & ! v in z lower,upper bound 14 | 'P','P', & ! w in x lower,upper bound 15 | 'P','P', & ! w in y lower,upper bound 16 | 'P','P'/), & ! w in z lower,upper bound 17 | shape(cbcvel)) 18 | ! values pertaining to the velocity BCs (arbitrary for 'P') 19 | real(8) , parameter, dimension(0:1,3,3) :: bcvel = & 20 | reshape((/0.d0,0.d0, & 21 | 0.d0,0.d0, & 22 | 0.d0,0.d0, & 23 | 0.d0,0.d0, & 24 | 0.d0,0.d0, & 25 | 0.d0,0.d0, & 26 | 0.d0,0.d0, & 27 | 0.d0,0.d0, & 28 | 0.d0,0.d0/), & 29 | shape(bcvel)) 30 | !------------------------------------------------------------------- 31 | ! pressure (homogeneous) 32 | ! 33 | character(len=1), parameter, dimension(0:1,3) :: cbcpre = & 34 | reshape((/'P','P', & ! p in x lower,upper bound 35 | 'P','P', & ! p in y lower,upper bound 36 | 'P','P'/), & ! p in z lower,upper bound 37 | shape(cbcpre)) 38 | real(8) , parameter, dimension(0:1,3) :: bcpre = & 39 | reshape((/0.d0,0.d0, & ! p in x lower,upper bound 40 | 0.d0,0.d0, & ! p in y lower,upper bound 41 | 0.d0,0.d0/), & ! p in z lower,upper bound 42 | shape(bcpre)) 43 | !------------------------------------------------------------------- 44 | ! forcing the flow with a pressure gradient 45 | ! that balances the total wall shear 46 | ! (e.g. for a pressure-driven channel) 47 | ! 48 | logical, parameter, dimension(3) :: is_forced = & 49 | reshape((/.false. , & ! in x 50 | .false. , & ! in y 51 | .false. /), & ! in z 52 | shape(is_forced)) 53 | ! 54 | ! desired values of bulk velocities 55 | ! (only relevant if the corresponding boolean 56 | ! above is .true.) 57 | ! 58 | real(8), parameter, dimension(3) :: velf = & 59 | reshape((/0.d0, & ! in x 60 | 0.d0, & ! in y 61 | 0.d0/), & ! in z 62 | shape(velf)) 63 | ! 64 | ! outflow boundary condition 65 | ! if is_outflow(i,j) is true, an outflow condition is prescribed for the 66 | ! face-centered velocity at that boundary 67 | ! the outflow BC is determined from the condition of zero divergence 68 | ! 69 | logical, parameter, dimension(0:1,3) :: is_outflow = & 70 | reshape((/.false. ,.false. , & ! outflow in x lower,upper bound 71 | .false. ,.false. , & ! outflow in y lower,upper bound 72 | .false. ,.false. /), & ! outflow in z lower,upper bound 73 | shape(is_outflow)) 74 | -------------------------------------------------------------------------------- /examples/_old_input_files/triperiodic/setup.h90: -------------------------------------------------------------------------------- 1 | ! total number of points in x, y and z 2 | integer, parameter :: itot = 64, jtot = 64, ktot = 64 3 | ! domain length in x, y and z 4 | real(8), parameter :: lx = 1.d0, ly = 1.0d0, lz = 1.d0 5 | real(8), parameter :: dx = lx/(1.d0*itot), & ! grid parameters 6 | dy = ly/(1.d0*jtot), & 7 | dz = lz/(1.d0*ktot), & 8 | dxi = dx**(-1), & 9 | dyi = dy**(-1), & 10 | dzi = dz**(-1), & 11 | dzmin = dz , & 12 | gr = 0.0d0 ! grid stretching parameter (0. -> no stretching; 13 | ! see initgrid.f90) 14 | real(8), parameter :: cfl = .95d0 15 | real(8), parameter :: rey = 1000.d0, uref = 1.d0, lref = lz/2.d0, visc = uref*(2.d0*lref)/rey 16 | ! 17 | include 'bc.h90' ! boundary conditions file 18 | ! 19 | ! type of initial velocity field (see init.f90) 20 | ! iniu = 'cou' --> plane Couette flow (u->streamwise velocity in x dir) 21 | ! = 'poi' --> plane Poiseuille flow (u->streamwise velocity in x dir) 22 | ! = 'zer' --> zero velocity everywhere 23 | ! = 'log' --> logarithmic profile + noise (u->streamwise velocity in x dir) 24 | ! = 'hcl' --> half channel with log profile + noise (u->streamwise velocity in x dir) 25 | ! = 'hcp' --> half channel with poiseuille profile (u->streamwise velocity in x dir) 26 | ! = 'tgv' --> Taylor-Green vortex 27 | character(len=3), parameter :: inivel = 'zer' 28 | ! 29 | ! is_wallturb: if .true., generates an initial condition that triggers transition to turbulence in wall-bounded flows (assumes streamwise direction x) 30 | logical, parameter :: is_wallturb = .false. 31 | ! 32 | integer, parameter :: nstep = 100000 ! number of time steps 33 | logical, parameter :: restart = .false. ! restart or not from a checkpoint 34 | ! 35 | ! -> every *icheck* time steps compute the new time step size dt 36 | ! according to the new stability criterion and cfl (above) 37 | ! -> every *iout0d* time steps update the history files with global scalar variables; 38 | ! currently the forcing pressure gradient and time step history are reported 39 | ! -> every *iout1d* time steps write 1d profiles (velocity and its moments) 40 | ! to a file 41 | ! -> every *iout2d* time steps write a 2d slice of a 3d scalar field to a file 42 | ! -> every *iout3d* time steps write a 3d scalar field into a file 43 | ! -> every *isave* time steps write a checkpoint file 44 | ! note: in order to edit the outputs based on the specific flow case, edit 45 | ! main.f90 or even output.f90 accordingly. Currently these assume the z to be 46 | ! an inhomogeneous direction. 47 | ! 48 | integer, parameter :: icheck = 10, iout0d = 10, iout1d = 20, & 49 | iout2d = 500, iout3d = 1000, isave = 2000 50 | ! 51 | ! grid of computational subdomains 52 | integer, parameter, dimension(2) :: dims = (/2,2/) 53 | ! x and y sizes of local arrays in the basic 2D z-pencil decomposition 54 | integer, parameter :: imax = itot/dims(1), jmax = jtot/dims(2) 55 | ! 56 | ! number of OpenMP threads 57 | integer, parameter :: nthreadsmax = 4 58 | -------------------------------------------------------------------------------- /examples/closed_box/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 1. 1. 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | zer ! inivel 7 | F ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | D D D D D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | D D D D D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | D D D D D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | N N N N N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/couette/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 1. 1.5 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | cou ! inivel 7 | F ! is_wallturb 8 | 20000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. .5 -.5 ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/developing_channel/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 1. 1.5 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | zer ! inivel 7 | F ! is_wallturb 8 | 20000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | D N P P D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | N N P P D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | N N P P D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | N D P P N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 1. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/developing_duct/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 1. 1.5 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | zer ! inivel 7 | F ! is_wallturb 8 | 20000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | D N D D D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | N N D D D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | N N D D D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | N D N N N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 1. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/half_channel/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 1. 1.5 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | hcl ! inivel 7 | F ! is_wallturb 8 | 20000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P D N ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P D N ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | T F F ! is_forced(1:3) 22 | 1. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/lid_driven_cavity/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 1. 1. 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | zer ! inivel 7 | F ! is_wallturb 8 | 20000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | D D D D D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | D D D D D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | D D D D D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | N N N N N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 1. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/periodic_channel/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 3. 1.5 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | log ! inivel 7 | F ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | T F F ! is_forced(1:3) 22 | 1. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/periodic_duct/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 3. 1.5 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | log ! inivel 7 | F ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P D D D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P D D D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P D D D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P N N N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | T F F ! is_forced(1:3) 22 | 1. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/triperiodic/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 1. 1. 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | zer ! inivel 7 | F ! is_wallturb 8 | 10000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 1000 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P P P ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P P P ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P P P ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P P P ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /examples/turbulent_channel_constant_pressure_gradient/dns.in: -------------------------------------------------------------------------------- 1 | 512 256 144 ! itot, jtot, ktot 2 | 12. 6. 2. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 180. ! uref, lref, rey 6 | pdc ! inivel 7 | T ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 100 500 10000 5000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 1. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! nthreadsmax 25 | -------------------------------------------------------------------------------- /src/2decomp/LICENSE: -------------------------------------------------------------------------------- 1 | The source files inside this folder are part of the 2DECOMP&FFT library 2 | and follow follow a separate copyright (stated in the header of each file). 3 | -------------------------------------------------------------------------------- /src/2decomp/factor.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-2012 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 | -------------------------------------------------------------------------------- /src/2decomp/halo.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-2012 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.f90" 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.f90" 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 | -------------------------------------------------------------------------------- /src/2decomp/io_read_one.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-2012 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 | -------------------------------------------------------------------------------- /src/2decomp/io_read_var.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-2012 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 | -------------------------------------------------------------------------------- /src/2decomp/io_write_one.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-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 | -------------------------------------------------------------------------------- /src/2decomp/io_write_plane.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-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_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 | -------------------------------------------------------------------------------- /src/2decomp/io_write_var.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-2012 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 | -------------------------------------------------------------------------------- /src/INFO_VISU.md: -------------------------------------------------------------------------------- 1 | # how to visualize the output binary files form *CaNS* 2 | 3 | ## \[*NEW*\] the easy way 4 | 5 | in addition to the binary files for visualization, *CaNS* now generates a log file that contains information about the saved data (see `out2d.h90` and `out3d.h90` for more details); this new approach uses that log file to generate the `Xdmf` visualization file. 6 | 7 | the steps are as follows: 8 | 9 | 1. after the simulation has run, copy the contents of `utils/visualize_fields/gen_xdmf_easy/write_xdmf.py` to the simulation `data` folder; 10 | 2. run the file with `python write_xdmf.py`. 11 | 3. load the generated Xdmf (`*.xmf`) file using paraview/visit or other visualization software. 12 | 13 | ## example: how to visualize the default binary output 14 | 15 | ### 3D fields 16 | 17 | when running the script `write_xdmf.py` we get the following prompts: 18 | 19 | ~~~ 20 | $ python write_xdmf.py 21 | Name of the log file written by CaNS [log_visu_3d.out]: 22 | Name to be appended to the grid files to prevent overwriting []: 23 | Name of the output file [viewfld_DNS.xmf]: 24 | ~~~ 25 | 26 | * the first value is the name of the file that logged the saved data; 27 | * the second is a name to append to the grid files that are generated, which should change for different log files to prevent conflicts; 28 | * the third is the name of the visualization file. 29 | 30 | by pressing enter three times, the default values in the square brackets are assumed by the script; these correspond to the default steps required for visualizing 3D field data. 31 | 32 | ### 2D fields 33 | 34 | the procedure for visualizing 2D field data that is saved by *CaNS* in `out2d.h90` is exactly the same; it is just that the correct log file should be selected. *CaNS* saves by default field data in a plane of constant `y=ly/2`, and logs the saves to a file named `log_visu_2d_slice_1.out`. If more planes are saved, the user should make sure that one log file per plane is saved by *CaNS* (e.g. if another plane is saved, the log file written in `out2d.h90` could be named `log_visu_2d_slice_2.out`); see `out2d.h90` for more details. The corresponding steps to generate the Xdmf file would be, for instance: 35 | 36 | ~~~ 37 | $ python write_xdmf.py 38 | Name of the log file written by CaNS [log_visu_3d.out]: log_visu_2d_slice_1.out 39 | Name to be appended to the grid files to prevent overwriting []: 2d 40 | Name of the output file [viewfld_DNS.xmf]: viewfld_DNS_2d.xmf 41 | ~~~ 42 | 43 | ### checkpoint files 44 | 45 | A similar script also located in `utils/visualize_fields/gen_xdmf_easy/`, named `write_xdmf_restart.py`, can be used to generate metadata that allows to visualize the field data contained in all saved checkpoint files: 46 | 47 | ~~~ 48 | $ python write_xdmf_restart.py 49 | Name of the pattern of the restart files to be visualized [fld?*.bin]: 50 | Names of stored variables [VEX VEY VEZ PRE]: 51 | Name to be appended to the grid files to prevent overwriting [_fld]: 52 | Name of the output file [viewfld_DNS_fld.xmf]: 53 | ~~~ 54 | 55 | ## the older way 56 | 57 | 1. after the simulation has run, copy the contents of `utils/visualize_fields/gen_xdmf_non_uniform_grid/` to the simulation `data` folder; 58 | 2. edit the `param.h90` file according to the flow physical and computational parameters, and output frequency; 59 | 3. run the `./genview.sh`, which generates a file `viewfld_DNS.xmf`. The script uses `gfortran` to compile `gen_xdmf.f90`; 60 | 4. the file `viewfld_DNS.xmf` can be used to visualize the contents of the raw binary files with e.g. paraview. 61 | 62 | For more details see the first lines of `gen_xdmf.f90`. 63 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # fortran compiler 2 | FC = mpif90 3 | # flags 4 | BIG := # -mcmodel=medium 5 | DBG := # -g -fbacktrace -Wall -O0 -Wextra -pedantic -fcheck=all 6 | OMP := #-mp # -fopenmp 7 | OPT := -O3 -Mcuda=ccall,cuda11.0#,cuda10.0 8 | #OPT := -O3 -Mcuda=cc70,nofma 9 | OTH := -DTIMING -DGPU_MPI -DEPA2A -DTIMING -DUSE_CUDA -DUSE_NVTX -DEPHC #-DDEBUG #-DIMPDIFF 10 | PROF := #-pg 11 | FFLAGS := $(OPT) $(BIG) $(DBG) $(PROF) $(OMP) $(OTH) 12 | TARGET = cans 13 | # 14 | OBJ = bound.o chkdiv.o chkdt.o common_mpi.o correc.o debug.o fft.o fftw.o fillps.o initflow.o initgrid.o initmpi.o initsolver.o load.o main.o mom.o momd.o moms.o output.o param.o rk.o sanity.o solver.o decomp_2d.o io.o types.o nvtx.o 15 | # 16 | LIBS = -lfftw3 -lfftw3_threads -Mcudalib=cufft -L/usr/local/cuda/lib64 -lnvToolsExt 17 | # 18 | all: $(TARGET) 19 | # 20 | $(TARGET): $(OBJ) 21 | $(FC) $(FFLAGS) $(OBJ) $(LIBS) -o $(TARGET) 22 | # src, run and data directories 23 | SRCDIR := $(pwd) 24 | RUNDIR := $(SRCDIR)../run 25 | DATDIR := $(RUNDIR)/data 26 | # 27 | run: $(TARGET) 28 | @mkdir -p $(RUNDIR) $(DATDIR) 29 | @cp $(TARGET) $(RUNDIR) 30 | @cp dns.in $(RUNDIR) 31 | @printf "\nExecutable file $(TARGET) and input file dns.in copied to run folder $(RUNDIR)\n" 32 | # 33 | .PHONY: clean 34 | clean: 35 | rm -rf *.o *.mod *dSYM $(TARGET) 36 | # dependencies 37 | bound.o: bound.f90 common_mpi.o nvtx.o types.o 38 | $(FC) $(FFLAGS) -cpp -c bound.f90 39 | chkdiv.o: chkdiv.f90 common_mpi.o types.o 40 | $(FC) $(FFLAGS) -cpp -c chkdiv.f90 41 | chkdt.o: chkdt.f90 common_mpi.o types.o 42 | $(FC) $(FFLAGS) -cpp -c chkdt.f90 43 | common_mpi.o: common_mpi.f90 param.o types.o 44 | $(FC) $(FFLAGS) -cpp -c common_mpi.f90 45 | correc.o: correc.f90 types.o 46 | $(FC) $(FFLAGS) -cpp -c correc.f90 47 | debug.o: debug.f90 common_mpi.o types.o 48 | $(FC) $(FFLAGS) -cpp -c debug.f90 49 | fillps.o: fillps.f90 types.o 50 | $(FC) $(FFLAGS) -cpp -c fillps.f90 51 | fft.o: fft.f90 common_mpi.o fftw.o types.o 52 | $(FC) $(FFLAGS) -cpp -c fft.f90 53 | fftw.o: fftw.f90 param.o 54 | $(FC) $(FFLAGS) -cpp -c fftw.f90 55 | initflow.o: initflow.f90 common_mpi.o decomp_2d.o types.o 56 | $(FC) $(FFLAGS) -Mnovect -cpp -c initflow.f90 57 | initgrid.o: initgrid.f90 param.o types.o 58 | $(FC) $(FFLAGS) -cpp -c initgrid.f90 59 | initmpi.o: initmpi.f90 decomp_2d.o common_mpi.o types.o 60 | $(FC) $(FFLAGS) -cpp -c initmpi.f90 61 | initsolver.o: initsolver.f90 common_mpi.o fft.o param.o types.o 62 | $(FC) $(FFLAGS) -cpp -c initsolver.f90 63 | load.o: load.f90 common_mpi.o decomp_2d.o io.o types.o 64 | $(FC) $(FFLAGS) -cpp -c load.f90 65 | main.o: main.f90 bound.o chkdiv.o chkdt.o debug.o fft.o fillps.o initflow.o initflow.o initgrid.o initmpi.o initsolver.o load.o output.o param.o rk.o sanity.o solver.o types.o out1d.h90 out2d.h90 out3d.h90 nvtx.o 66 | $(FC) $(FFLAGS) -cpp -c main.f90 67 | mom.o: mom.f90 common_mpi.o types.o 68 | $(FC) $(FFLAGS) -cpp -c mom.f90 69 | momd.o: momd.f90 common_mpi.o types.o 70 | $(FC) $(FFLAGS) -cpp -c momd.f90 71 | moms.o: moms.f90 types.o 72 | $(FC) $(FFLAGS) -cpp -c moms.f90 73 | output.o: output.f90 io.o types.o 74 | $(FC) $(FFLAGS) -cpp -c output.f90 75 | param.o: param.f90 types.o 76 | $(FC) $(FFLAGS) -cpp -c param.f90 77 | rk.o: rk.f90 debug.o mom.o momd.o moms.o param.o types.o nvtx.o 78 | $(FC) $(FFLAGS) -cpp -c rk.f90 79 | sanity.o: sanity.f90 bound.o chkdiv.o common_mpi.o correc.o debug.o decomp_2d.o fft.o fillps.o initflow.o initmpi.o initsolver.o param.o solver.o types.o 80 | $(FC) $(FFLAGS) -cpp -c sanity.f90 81 | solver.o: solver.f90 fft.o param.o types.o 82 | $(FC) $(FFLAGS) -cpp -c solver.f90 83 | types.o: types.f90 84 | $(FC) $(FFLAGS) -cpp -c $< 85 | # 2decomp&fft library 86 | FFLAGS_2DECOMP :=# -DOVERWRITE -DEVEN 87 | 2decompdir=2decomp/ 88 | decomp_2d.o: $(2decompdir)decomp_2d.f90 nvtx.o 89 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)decomp_2d.f90 90 | io.o: $(2decompdir)io.f90 decomp_2d.o 91 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)io.f90 92 | nvtx.o: nvtx.f90 93 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c nvtx.f90 94 | -------------------------------------------------------------------------------- /src/Makefile_cpu: -------------------------------------------------------------------------------- 1 | # fortran compiler 2 | FC = mpif90 3 | # flags 4 | BIG := # -mcmodel=medium 5 | DBG := # -g -fbacktrace -Wall -O0 -Wextra -pedantic -fcheck=all 6 | OMP := -mp # -fopenmp 7 | OPT := -O3 8 | OTH := -DDEBUG -DTIMING #-DIMPDIFF 9 | PROF := #-pg 10 | FFLAGS := $(OPT) $(BIG) $(DBG) $(PROF) $(OMP) $(OTH) 11 | # 12 | TARGET = cans_cpu 13 | # 14 | OBJ = bound.o chkdiv.o chkdt.o common_mpi.o correc.o debug.o fft.o fftw.o fillps.o initflow.o initgrid.o initmpi.o initsolver.o load.o main.o mom.o momd.o moms.o output.o param.o rk.o sanity.o solver.o decomp_2d.o io.o 15 | # 16 | LIBS = -lfftw3 -lfftw3_threads 17 | # 18 | all: $(TARGET) 19 | # 20 | $(TARGET): $(OBJ) 21 | $(FC) $(FFLAGS) $(OBJ) $(LIBS) -o $(TARGET) 22 | # 23 | .PHONY: clean 24 | clean: 25 | rm -rf *.o *.mod *dSYM $(TARGET) 26 | # dependencies 27 | bound.o: bound.f90 common_mpi.o 28 | $(FC) $(FFLAGS) -cpp -c bound.f90 29 | chkdiv.o: chkdiv.f90 common_mpi.o 30 | $(FC) $(FFLAGS) -cpp -c chkdiv.f90 31 | chkdt.o: chkdt.f90 common_mpi.o 32 | $(FC) $(FFLAGS) -cpp -c chkdt.f90 33 | common_mpi.o: common_mpi.f90 param.o 34 | $(FC) $(FFLAGS) -cpp -c common_mpi.f90 35 | correc.o: correc.f90 36 | $(FC) $(FFLAGS) -cpp -c correc.f90 37 | debug.o: debug.f90 common_mpi.o 38 | $(FC) $(FFLAGS) -cpp -c debug.f90 39 | fillps.o: fillps.f90 40 | $(FC) $(FFLAGS) -cpp -c fillps.f90 41 | fft.o: fft.f90 common_mpi.o fftw.o 42 | $(FC) $(FFLAGS) -cpp -c fft.f90 43 | fftw.o: fftw.f90 param.o 44 | $(FC) $(FFLAGS) -cpp -c fftw.f90 45 | initflow.o: initflow.f90 common_mpi.o decomp_2d.o 46 | $(FC) $(FFLAGS) -Mnovect -cpp -c initflow.f90 47 | initgrid.o: initgrid.f90 param.o 48 | $(FC) $(FFLAGS) -cpp -c initgrid.f90 49 | initmpi.o: initmpi.f90 decomp_2d.o common_mpi.o 50 | $(FC) $(FFLAGS) -cpp -c initmpi.f90 51 | initsolver.o: initsolver.f90 common_mpi.o fft.o param.o 52 | $(FC) $(FFLAGS) -cpp -c initsolver.f90 53 | load.o: load.f90 common_mpi.o decomp_2d.o io.o 54 | $(FC) $(FFLAGS) -cpp -c load.f90 55 | main.o: main.f90 bound.o chkdiv.o chkdt.o debug.o fft.o fillps.o initflow.o initflow.o initgrid.o initmpi.o initsolver.o load.o output.o param.o rk.o sanity.o solver.o out1d.h90 out2d.h90 out3d.h90 56 | $(FC) $(FFLAGS) -cpp -c main.f90 57 | mom.o: mom.f90 common_mpi.o 58 | $(FC) $(FFLAGS) -cpp -c mom.f90 59 | momd.o: momd.f90 common_mpi.o 60 | $(FC) $(FFLAGS) -cpp -c momd.f90 61 | moms.o: moms.f90 62 | $(FC) $(FFLAGS) -cpp -c moms.f90 63 | output.o: output.f90 io.o 64 | $(FC) $(FFLAGS) -cpp -c output.f90 65 | param.o: param.f90 setup.h90 bc.h90 66 | $(FC) $(FFLAGS) -cpp -c param.f90 67 | rk.o: rk.f90 debug.o mom.o momd.o moms.o param.o 68 | $(FC) $(FFLAGS) -cpp -c rk.f90 69 | sanity.o: sanity.f90 bound.o chkdiv.o common_mpi.o correc.o debug.o decomp_2d.o fft.o fillps.o initflow.o initmpi.o initsolver.o param.o solver.o 70 | $(FC) $(FFLAGS) -cpp -c sanity.f90 71 | solver.o: solver.f90 fft.o param.o 72 | $(FC) $(FFLAGS) -cpp -c solver.f90 73 | # 2decomp&fft library 74 | FFLAGS_2DECOMP := -DDOUBLE_PREC# -DOVERWRITE -DEVEN 75 | 2decompdir=2decomp/ 76 | decomp_2d.o: $(2decompdir)decomp_2d.f90 77 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)decomp_2d.f90 78 | io.o: $(2decompdir)io.f90 decomp_2d.o 79 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)io.f90 80 | -------------------------------------------------------------------------------- /src/Makefile_summit: -------------------------------------------------------------------------------- 1 | # module load pgi/18.10 cuda fftw 2 | # 3 | # fortran compiler 4 | FC = mpif90 5 | # flags 6 | BIG := # -mcmodel=medium 7 | DBG := # -g -fbacktrace -Wall -O0 -Wextra -pedantic -fcheck=all 8 | OMP := #-mp # -fopenmp 9 | OPT := -O3 -Mcuda=cc70,cuda9.2 10 | #OPT := -O3 -Mcuda=cc70,nofma 11 | OTH := -DEPHC -DGPU_MPI -DEPA2A -DTIMING -DUSE_CUDA -DUSE_NVTX #-DDEBUG #-DIMPDIFF 12 | PROF := #-pg 13 | FFLAGS := $(OPT) $(BIG) $(DBG) $(PROF) $(OMP) $(OTH) 14 | # 15 | TARGET = cans 16 | # 17 | OBJ = bound.o chkdiv.o chkdt.o common_mpi.o correc.o debug.o fft.o fftw.o fillps.o initflow.o initgrid.o initmpi.o initsolver.o load.o main.o mom.o momd.o moms.o output.o param.o rk.o sanity.o solver.o decomp_2d.o io.o nvtx.o 18 | # 19 | LIBS = -L$(OLCF_FFTW_ROOT)/lib -lfftw3 -lfftw3_threads -L/usr/local/cuda/lib64 -lnvToolsExt -Mcudalib=cufft 20 | # 21 | all: $(TARGET) 22 | # 23 | $(TARGET): $(OBJ) 24 | $(FC) $(FFLAGS) $(OBJ) $(LIBS) -o $(TARGET) 25 | # 26 | .PHONY: clean 27 | clean: 28 | rm -rf *.o *.mod *dSYM $(TARGET) 29 | # dependencies 30 | bound.o: bound.f90 common_mpi.o nvtx.o 31 | $(FC) $(FFLAGS) -cpp -c bound.f90 32 | chkdiv.o: chkdiv.f90 common_mpi.o 33 | $(FC) $(FFLAGS) -cpp -c chkdiv.f90 34 | chkdt.o: chkdt.f90 common_mpi.o 35 | $(FC) $(FFLAGS) -cpp -c chkdt.f90 36 | common_mpi.o: common_mpi.f90 param.o 37 | $(FC) $(FFLAGS) -cpp -c common_mpi.f90 38 | correc.o: correc.f90 39 | $(FC) $(FFLAGS) -cpp -c correc.f90 40 | debug.o: debug.f90 common_mpi.o 41 | $(FC) $(FFLAGS) -cpp -c debug.f90 42 | fillps.o: fillps.f90 43 | $(FC) $(FFLAGS) -cpp -c fillps.f90 44 | fft.o: fft.f90 common_mpi.o fftw.o 45 | $(FC) $(FFLAGS) -cpp -c fft.f90 46 | fftw.o: fftw.f90 param.o 47 | $(FC) $(FFLAGS) -cpp -c fftw.f90 48 | initflow.o: initflow.f90 common_mpi.o decomp_2d.o 49 | $(FC) $(FFLAGS) -Mnovect -cpp -c initflow.f90 50 | initgrid.o: initgrid.f90 param.o 51 | $(FC) $(FFLAGS) -cpp -c initgrid.f90 52 | initmpi.o: initmpi.f90 decomp_2d.o common_mpi.o 53 | $(FC) $(FFLAGS) -cpp -c initmpi.f90 54 | initsolver.o: initsolver.f90 common_mpi.o fft.o param.o 55 | $(FC) $(FFLAGS) -cpp -c initsolver.f90 56 | load.o: load.f90 common_mpi.o decomp_2d.o io.o 57 | $(FC) $(FFLAGS) -cpp -c load.f90 58 | main.o: main.f90 bound.o chkdiv.o chkdt.o debug.o fft.o fillps.o initflow.o initflow.o initgrid.o initmpi.o initsolver.o load.o output.o param.o rk.o sanity.o solver.o out1d.h90 out2d.h90 out3d.h90 nvtx.o 59 | $(FC) $(FFLAGS) -cpp -c main.f90 60 | mom.o: mom.f90 common_mpi.o 61 | $(FC) $(FFLAGS) -cpp -c mom.f90 62 | momd.o: momd.f90 common_mpi.o 63 | $(FC) $(FFLAGS) -cpp -c momd.f90 64 | moms.o: moms.f90 65 | $(FC) $(FFLAGS) -cpp -c moms.f90 66 | output.o: output.f90 io.o 67 | $(FC) $(FFLAGS) -cpp -c output.f90 68 | param.o: param.f90 setup.h90 bc.h90 69 | $(FC) $(FFLAGS) -cpp -c param.f90 70 | rk.o: rk.f90 debug.o mom.o momd.o moms.o param.o nvtx.o 71 | $(FC) $(FFLAGS) -cpp -c rk.f90 72 | sanity.o: sanity.f90 bound.o chkdiv.o common_mpi.o correc.o debug.o decomp_2d.o fft.o fillps.o initflow.o initmpi.o initsolver.o param.o solver.o 73 | $(FC) $(FFLAGS) -cpp -c sanity.f90 74 | solver.o: solver.f90 fft.o param.o 75 | $(FC) $(FFLAGS) -cpp -c solver.f90 76 | # 2decomp&fft library 77 | FFLAGS_2DECOMP := -DDOUBLE_PREC# -DOVERWRITE -DEVEN 78 | 2decompdir=2decomp/ 79 | decomp_2d.o: $(2decompdir)decomp_2d.f90 nvtx.o 80 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)decomp_2d.f90 81 | io.o: $(2decompdir)io.f90 decomp_2d.o 82 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)io.f90 83 | nvtx.o: nvtx.f90 84 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c nvtx.f90 85 | -------------------------------------------------------------------------------- /src/chkdiv.f90: -------------------------------------------------------------------------------- 1 | module mod_chkdiv 2 | use mpi 3 | use mod_common_mpi, only: myid,coord,ierr 4 | use mod_types 5 | implicit none 6 | private 7 | public chkdiv 8 | contains 9 | subroutine chkdiv(n,dli,dzfi,u,v,w,divtot,divmax) 10 | !@cuf use cudafor 11 | ! 12 | ! checks the divergence of the velocity field 13 | ! 14 | implicit none 15 | integer , intent(in), dimension(3) :: n 16 | real(rp), intent(in), dimension(3) :: dli 17 | real(rp), intent(in), dimension(0:) :: dzfi 18 | real(rp), intent(in), dimension(0:,0:,0:) :: u,v,w 19 | real(rp), intent(out) :: divtot,divmax 20 | real(rp) :: dxi,dyi,div!,dzi,div 21 | #ifdef USE_CUDA 22 | attributes(managed) :: u,v,w,dzfi 23 | integer :: istat 24 | #endif 25 | integer :: i,j,k,im,jm,km 26 | !integer :: ii,jj 27 | ! 28 | dxi = dli(1) 29 | dyi = dli(2) 30 | !dzi = dli(3) 31 | divtot = 0. 32 | divmax = 0. 33 | #ifdef USE_CUDA 34 | !$cuf kernel do(3) <<<*,*>>> 35 | #else 36 | !$OMP PARALLEL DO DEFAULT(none) & 37 | !$OMP SHARED(n,u,v,w,dxi,dyi,dzfi) & 38 | !$OMP PRIVATE(i,j,k,im,jm,km,div) & 39 | !$OMP REDUCTION(+:divtot) & 40 | !$OMP REDUCTION(max:divmax) 41 | #endif 42 | do k=1,n(3) 43 | km = k-1 44 | do j=1,n(2) 45 | jm = j-1 46 | do i=1,n(1) 47 | im = i-1 48 | div = (w(i,j,k)-w(i,j,km))*dzfi(k) + & 49 | (v(i,j,k)-v(i,jm,k))*dyi + & 50 | (u(i,j,k)-u(im,j,k))*dxi 51 | divmax = max(divmax,abs(div)) 52 | divtot = divtot + div 53 | !ii = coord(1)*n(1)+i 54 | !jj = coord(2)*n(2)+j 55 | !if(abs(div).ge.1.e-12) print*,div,'Large divergence at grid cell: ',ii,jj,k,div 56 | enddo 57 | enddo 58 | enddo 59 | #ifndef USE_CUDA 60 | !$OMP END PARALLEL DO 61 | #endif 62 | !@cuf istat=cudaDeviceSynchronize() 63 | call mpi_allreduce(MPI_IN_PLACE,divtot,1,MPI_REAL_RP,MPI_SUM,MPI_COMM_WORLD,ierr) 64 | call mpi_allreduce(MPI_IN_PLACE,divmax,1,MPI_REAL_RP,MPI_MAX,MPI_COMM_WORLD,ierr) 65 | if(myid.eq.0) print*, 'Total divergence = ', divtot, '| Maximum divergence = ', divmax 66 | return 67 | end subroutine chkdiv 68 | end module mod_chkdiv 69 | -------------------------------------------------------------------------------- /src/chkdt.f90: -------------------------------------------------------------------------------- 1 | module mod_chkdt 2 | use mpi 3 | use mod_common_mpi, only:ierr 4 | use mod_types 5 | implicit none 6 | private 7 | public chkdt 8 | contains 9 | subroutine chkdt(n,dl,dzci,dzfi,visc,u,v,w,dtmax) 10 | !@cuf use cudafor 11 | ! 12 | ! computes maximum allowed timestep 13 | ! 14 | implicit none 15 | integer , intent(in), dimension(3) :: n 16 | real(rp), intent(in), dimension(3) :: dl 17 | real(rp), intent(in), dimension(0:) :: dzci,dzfi 18 | real(rp), intent(in) :: visc 19 | real(rp), intent(in), dimension(0:,0:,0:) :: u,v,w 20 | real(rp), intent(out) :: dtmax 21 | real(rp) :: dxi,dyi,dzi 22 | real(rp) :: ux,uy,uz,vx,vy,vz,wx,wy,wz 23 | real(rp) :: dtix,dtiy,dtiz,dti,dlmin 24 | #ifdef USE_CUDA 25 | attributes(managed) :: u,v,w,dzci,dzfi 26 | integer :: istat 27 | #endif 28 | integer :: i,j,k 29 | ! 30 | dti = 0. 31 | dxi = 1./dl(1) 32 | dyi = 1./dl(2) 33 | dzi = 1./dl(3) 34 | #ifdef USE_CUDA 35 | !$cuf kernel do(3) <<<*,*>>> 36 | #else 37 | !$OMP PARALLEL DO DEFAULT(none) & 38 | !$OMP SHARED(n,u,v,w,dxi,dyi,dzi,dzci,dzfi) & 39 | !$OMP PRIVATE(i,j,k,ux,uy,uz,vx,vy,vz,wx,wy,wz,dtix,dtiy,dtiz) & 40 | !$OMP REDUCTION(max:dti) 41 | #endif 42 | do k=1,n(3) 43 | do j=1,n(2) 44 | do i=1,n(1) 45 | ux = abs(u(i,j,k)) 46 | vx = 0.25*abs( v(i,j,k)+v(i,j-1,k)+v(i+1,j,k)+v(i+1,j-1,k) ) 47 | wx = 0.25*abs( w(i,j,k)+w(i,j,k-1)+w(i+1,j,k)+w(i+1,j,k-1) ) 48 | dtix = ux*dxi+vx*dyi+wx*dzfi(k) 49 | uy = 0.25*abs( u(i,j,k)+u(i,j+1,k)+u(i-1,j+1,k)+u(i-1,j,k) ) 50 | vy = abs(v(i,j,k)) 51 | wy = 0.25*abs( w(i,j,k)+w(i,j+1,k)+w(i,j+1,k-1)+w(i,j,k-1) ) 52 | dtiy = uy*dxi+vy*dyi+wy*dzfi(k) 53 | uz = 0.25*abs( u(i,j,k)+u(i-1,j,k)+u(i-1,j,k+1)+u(i,j,k+1) ) 54 | vz = 0.25*abs( v(i,j,k)+v(i,j-1,k)+v(i,j-1,k+1)+v(i,j,k+1) ) 55 | wz = abs(w(i,j,k)) 56 | dtiz = uz*dxi+vz*dyi+wz*dzci(k) 57 | dti = max(dti,dtix,dtiy,dtiz) 58 | enddo 59 | enddo 60 | enddo 61 | #ifndef USE_CUDA 62 | !$OMP END PARALLEL DO 63 | #endif 64 | !@cuf istat=cudaDeviceSynchronize() 65 | call mpi_allreduce(MPI_IN_PLACE,dti,1,MPI_REAL_RP,MPI_MAX,MPI_COMM_WORLD,ierr) 66 | if(dti.eq.0.) dti = 1. 67 | dlmin = minval(dl) 68 | dlmin = min(dlmin,minval(1./dzfi)) ! minimum of dzf is an estimate on the safe side 69 | #ifdef IMPDIFF 70 | dtmax = sqrt(3.)/dti 71 | #else 72 | dtmax = min(1.65/12./visc*dlmin**2,sqrt(3.)/dti) 73 | #endif 74 | return 75 | end subroutine chkdt 76 | end module mod_chkdt 77 | -------------------------------------------------------------------------------- /src/common_mpi.f90: -------------------------------------------------------------------------------- 1 | module mod_common_mpi 2 | use mpi 3 | use mod_param, only: dims 4 | use mod_types 5 | implicit none 6 | integer :: myid 7 | integer :: left,right,front,back 8 | integer, dimension(2) :: coord 9 | integer :: comm_cart,ierr 10 | integer :: xhalo,yhalo 11 | integer :: status(MPI_STATUS_SIZE) 12 | real(rp), allocatable, dimension(:,:) :: xsl_buf, xrl_buf, ysl_buf, yrl_buf, xsr_buf, xrr_buf, ysr_buf, yrr_buf 13 | #ifdef USE_CUDA 14 | integer :: mydev 15 | #ifdef GPU_MPI 16 | attributes(device) :: xsl_buf, xrl_buf, ysl_buf, yrl_buf, xsr_buf, xrr_buf, ysr_buf, yrr_buf 17 | #else 18 | attributes(managed) :: xsl_buf, xrl_buf, ysl_buf, yrl_buf, xsr_buf, xrr_buf, ysr_buf, yrr_buf 19 | #endif 20 | #endif 21 | end module mod_common_mpi 22 | -------------------------------------------------------------------------------- /src/correc.f90: -------------------------------------------------------------------------------- 1 | module mod_correc 2 | use mod_types 3 | implicit none 4 | private 5 | public correc 6 | contains 7 | subroutine correc(n,dli,dzci,dt,p,up,vp,wp,u,v,w) 8 | !@cuf use cudafor 9 | ! 10 | ! corrects the velocity so that it is divergence free 11 | ! 12 | implicit none 13 | integer , intent(in), dimension(3) :: n 14 | real(rp), intent(in), dimension(3) :: dli 15 | real(rp), intent(in), dimension(0:) :: dzci 16 | real(rp), intent(in) :: dt 17 | real(rp), intent(in) , dimension(0:,0:,0:) :: p,up,vp,wp 18 | real(rp), intent(out), dimension(0:,0:,0:) :: u,v,w 19 | real(rp) :: factori,factorj 20 | !real(rp), dimension(0:n(3)+1) :: factork 21 | #ifdef USE_CUDA 22 | attributes(managed) :: p,up,vp,wp,u,v,w,dzci 23 | integer:: istat 24 | #endif 25 | integer :: i,j,k,ip,jp,kp 26 | ! 27 | !factor = rkcoeffab(rkiter)*dt 28 | ! 29 | factori = dt*dli(1) 30 | factorj = dt*dli(2) 31 | #ifdef USE_CUDA 32 | !$cuf kernel do(3) <<<*,*>>> 33 | #else 34 | !$OMP PARALLEL DO DEFAULT(none) & 35 | !$OMP SHARED(n,factori,u,up,p) & 36 | !$OMP PRIVATE(i,j,k,ip) 37 | #endif 38 | do k=0,n(3)+1 39 | do j=0,n(2)+1 40 | do i=0,n(1) 41 | ip = i+1 42 | u(i,j,k) = up(i,j,k) - factori*( p(ip,j,k)-p(i,j,k)) 43 | enddo 44 | enddo 45 | enddo 46 | #ifndef USE_CUDA 47 | !$OMP END PARALLEL DO 48 | #endif 49 | #ifdef USE_CUDA 50 | !$cuf kernel do(3) <<<*,*>>> 51 | #else 52 | !$OMP PARALLEL DO DEFAULT(none) & 53 | !$OMP SHARED(n,factorj,v,vp,p) & 54 | !$OMP PRIVATE(i,j,k,jp) 55 | #endif 56 | do k=0,n(3)+1 57 | do j=0,n(2) 58 | jp = j+1 59 | do i=0,n(1)+1 60 | v(i,j,k) = vp(i,j,k) - factorj*( p(i,jp,k)-p(i,j,k)) 61 | enddo 62 | enddo 63 | enddo 64 | #ifndef USE_CUDA 65 | !$OMP END PARALLEL DO 66 | #endif 67 | #ifdef USE_CUDA 68 | !$cuf kernel do(3) <<<*,*>>> 69 | #else 70 | !$OMP PARALLEL DO DEFAULT(none) & 71 | !$OMP SHARED(n,dt,dzci,w,wp,p) & 72 | !$OMP PRIVATE(i,j,k,kp) 73 | #endif 74 | do k=0,n(3) 75 | kp = k+1 76 | do j=0,n(2)+1 77 | do i=0,n(1)+1 78 | w(i,j,k) = wp(i,j,k) - dt*dzci(k)*(p(i,j,kp)-p(i,j,k)) 79 | enddo 80 | enddo 81 | enddo 82 | #ifndef USE_CUDA 83 | !$OMP END PARALLEL DO 84 | #endif 85 | !@cuf istat=cudaDeviceSynchronize() 86 | return 87 | end subroutine correc 88 | end module mod_correc 89 | -------------------------------------------------------------------------------- /src/data/readme.txt: -------------------------------------------------------------------------------- 1 | the DNS code writes all the output files to this folder by default 2 | -------------------------------------------------------------------------------- /src/debug.f90: -------------------------------------------------------------------------------- 1 | module mod_debug 2 | use mpi 3 | use mod_common_mpi, only: myid,ierr,coord 4 | use mod_param , only: dims 5 | use mod_types 6 | implicit none 7 | private 8 | public chkmean,chk_helmholtz 9 | contains 10 | subroutine chkmean(n,dzlzi,p,mean) 11 | !@cuf use cudafor 12 | ! 13 | ! compute the mean value of an observable over the entire domain 14 | ! 15 | implicit none 16 | integer , intent(in), dimension(3) :: n 17 | real(rp), intent(in), dimension(0:) :: dzlzi 18 | real(rp), intent(in), dimension(0:,0:,0:) :: p 19 | real(rp), intent(out) :: mean 20 | #ifdef USE_CUDA 21 | attributes(managed) :: p,dzlzi 22 | integer :: istat 23 | #endif 24 | integer :: i,j,k 25 | mean = 0. 26 | #ifdef USE_CUDA 27 | !$cuf kernel do(3) <<<*,*>>> 28 | #else 29 | !$OMP PARALLEL DO DEFAULT(none) & 30 | !$OMP SHARED(n,p,dzlzi) & 31 | !$OMP PRIVATE(i,j,k) & 32 | !$OMP REDUCTION(+:mean) 33 | #endif 34 | do k=1,n(3) 35 | do j=1,n(2) 36 | do i=1,n(1) 37 | mean = mean + p(i,j,k)*dzlzi(k) 38 | enddo 39 | enddo 40 | enddo 41 | #ifndef USE_CUDA 42 | !$OMP END PARALLEL DO 43 | #endif 44 | !@cuf istat=cudaDeviceSynchronize() 45 | call mpi_allreduce(MPI_IN_PLACE,mean,1,MPI_REAL_RP,MPI_SUM,MPI_COMM_WORLD,ierr) 46 | mean = mean/(1.*n(1)*dims(1)*n(2)*dims(2)) 47 | return 48 | end subroutine chkmean 49 | ! 50 | subroutine chk_helmholtz(n,dli,dzci,dzfi,alpha,fp,fpp,bc,c_or_f,diffmax) 51 | ! 52 | ! this subroutine checks if the implementation of implicit diffusion is 53 | ! correct 54 | ! 55 | implicit none 56 | integer , intent(in), dimension(3) :: n 57 | real(rp), intent(in), dimension(2) :: dli 58 | real(rp), intent(in) :: alpha 59 | real(rp), intent(in), dimension(0:) :: dzfi,dzci 60 | real(rp), intent(in), dimension(0:,0:,0:) :: fp,fpp 61 | character(len=1), intent(in), dimension(0:1,3) :: bc 62 | character(len=1), intent(in), dimension(3) :: c_or_f 63 | real(rp), intent(out) :: diffmax 64 | real(rp) :: val 65 | integer :: i,j,k,im,ip,jm,jp,km,kp 66 | integer :: idir 67 | integer, dimension(3) :: q 68 | !integer :: ii,jj 69 | q(:) = 0 70 | do idir = 1,3 71 | if(bc(1,idir).ne.'P'.and.c_or_f(idir).eq.'f') q(idir) = 1 72 | enddo 73 | select case(c_or_f(3)) 74 | ! 75 | ! need to compute the maximum difference! 76 | ! 77 | case('c') 78 | diffmax = 0. 79 | do k=1,n(3)-q(3) 80 | kp = k + 1 81 | km = k - 1 82 | do j=1,n(2)-q(2) 83 | jp = j + 1 84 | jm = j - 1 85 | do i=1,n(1)-q(1) 86 | ip = i + 1 87 | im = i - 1 88 | val = fpp(i,j,k)+(1./alpha)*( & 89 | (fpp(ip,j,k)-2.*fpp(i,j,k)+fpp(im,j,k))*(dli(1)**2) + & 90 | (fpp(i,jp,k)-2.*fpp(i,j,k)+fpp(i,jm,k))*(dli(2)**2) + & 91 | ((fpp(i,j,kp)-fpp(i,j,k ))*dzci(k ) - & 92 | (fpp(i,j,k )-fpp(i,j,km))*dzci(km))*dzfi(k) ) 93 | val = val*alpha 94 | diffmax = max(diffmax,abs(val-fp(i,j,k))) 95 | !ii = coord(1)*n(1)+i 96 | !jj = coord(2)*n(2)+j 97 | !if(abs(val-fp(i,j,k)).gt.1.e-8) print*, 'Large difference : ', val-fp(i,j,k),ii,jj,k 98 | enddo 99 | enddo 100 | enddo 101 | case('f') 102 | diffmax = 0. 103 | do k=1,n(3)-q(3) 104 | kp = k + 1 105 | km = k - 1 106 | do j=1,n(2)-q(2) 107 | jp = j + 1 108 | jm = j - 1 109 | do i=1,n(1)-q(1) 110 | ip = i + 1 111 | im = i - 1 112 | val = fpp(i,j,k)+(1./alpha)*( & 113 | (fpp(ip,j,k)-2.*fpp(i,j,k)+fpp(im,j,k))*(dli(1)**2) + & 114 | (fpp(i,jp,k)-2.*fpp(i,j,k)+fpp(i,jm,k))*(dli(2)**2) + & 115 | ((fpp(i,j,kp)-fpp(i,j,k ))*dzfi(kp) - & 116 | (fpp(i,j,k )-fpp(i,j,km))*dzfi(k ))*dzci(k) ) 117 | val = val*alpha 118 | diffmax = max(diffmax,abs(val-fp(i,j,k))) 119 | !ii = coord(1)*n(1)+i 120 | !jj = coord(2)*n(2)+j 121 | !if(abs(val-fp(i,j,k)).gt.1.e-8) print*, 'Large difference : ', val,fp(i,j,k),ii,jj,k 122 | enddo 123 | enddo 124 | enddo 125 | end select 126 | call mpi_allreduce(MPI_IN_PLACE,diffmax,1,MPI_REAL_RP,MPI_MAX,MPI_COMM_WORLD,ierr) 127 | return 128 | end subroutine chk_helmholtz 129 | end module mod_debug 130 | -------------------------------------------------------------------------------- /src/dns.in: -------------------------------------------------------------------------------- 1 | 64 64 64 ! itot, jtot, ktot 2 | 3. 1.5 1. ! lx, ly, lz 3 | 1. ! gr 4 | .95 1.0e5 ! cfl, dtmin 5 | 1. 1. 1000. ! uref, lref, rey 6 | poi ! inivel 7 | T ! is_wallturb 8 | 100000 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 100 500 10000 5000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P P P D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P P P D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P P P D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P P P N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | T F F ! is_forced(1:3) 22 | 1. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! numthreadsmax 25 | -------------------------------------------------------------------------------- /src/fftw.f90: -------------------------------------------------------------------------------- 1 | module mod_fftw_param 2 | use mod_types 3 | use iso_c_binding 4 | #ifdef USE_CUDA 5 | use cufft 6 | #endif 7 | ! 8 | type, bind(C) :: fftw_iodim 9 | integer(C_INT) n, is, os 10 | end type fftw_iodim 11 | ! 12 | interface 13 | type(C_PTR) function fftw_plan_guru_r2r(rank,dims, & 14 | howmany_rank,howmany_dims,in,out,kind,flags) & 15 | #ifdef SINGLE_PRECISION 16 | bind(C, name='fftwf_plan_guru_r2r') 17 | #else 18 | bind(C, name='fftw_plan_guru_r2r') 19 | #endif 20 | import 21 | integer(C_INT), value :: rank 22 | type(fftw_iodim), dimension(*), intent(in) :: dims 23 | integer(C_INT), value :: howmany_rank 24 | type(fftw_iodim), dimension(*), intent(in) :: howmany_dims 25 | #ifdef SINGLE_PRECISION 26 | real(C_FLOAT ), dimension(*), intent(out) :: in,out 27 | #else 28 | real(C_DOUBLE), dimension(*), intent(out) :: in,out 29 | #endif 30 | integer(C_INT) :: kind 31 | integer(C_INT), value :: flags 32 | end function fftw_plan_guru_r2r 33 | end interface 34 | ! 35 | integer :: FFTW_PATIENT,FFTW_ESTIMATE 36 | parameter (FFTW_PATIENT=32) 37 | parameter (FFTW_ESTIMATE=64) 38 | integer FFTW_R2HC 39 | parameter (FFTW_R2HC=0) 40 | integer FFTW_HC2R 41 | parameter (FFTW_HC2R=1) 42 | ! 43 | integer REDFT00 44 | parameter (FFTW_REDFT00=3) 45 | integer FFTW_REDFT01 46 | parameter (FFTW_REDFT01=4) 47 | integer FFTW_REDFT10 48 | parameter (FFTW_REDFT10=5) 49 | integer FFTW_REDFT11 50 | parameter (FFTW_REDFT11=6) 51 | integer FFTW_RODFT00 52 | parameter (FFTW_RODFT00=7) 53 | integer FFTW_RODFT01 54 | parameter (FFTW_RODFT01=8) 55 | integer FFTW_RODFT10 56 | parameter (FFTW_RODFT10=9) 57 | integer FFTW_RODFT11 58 | parameter (FFTW_RODFT11=10) 59 | ! 60 | type(C_PTR) :: fwd_guruplan_y,bwd_guruplan_y 61 | type(C_PTR) :: fwd_guruplan_z,bwd_guruplan_z 62 | logical :: planned=.false. 63 | 64 | #ifdef USE_CUDA 65 | integer :: batch 66 | integer :: cufft_plan_fwd_x, cufft_plan_bwd_x 67 | integer :: cufft_plan_fwd_y, cufft_plan_bwd_y 68 | complex(rp),device,allocatable,dimension(:) :: cufft_workspace 69 | integer :: CUFFT_FWD_TYPE,CUFFT_BWD_TYPE 70 | #ifdef SINGLE_PRECISION 71 | parameter(CUFFT_FWD_TYPE = CUFFT_R2C) 72 | parameter(CUFFT_BWD_TYPE = CUFFT_C2R) 73 | #else 74 | parameter(CUFFT_FWD_TYPE = CUFFT_D2Z) 75 | parameter(CUFFT_BWD_TYPE = CUFFT_Z2D) 76 | #endif 77 | #endif 78 | 79 | end module mod_fftw_param 80 | -------------------------------------------------------------------------------- /src/fillps.f90: -------------------------------------------------------------------------------- 1 | module mod_fillps 2 | use mod_types 3 | implicit none 4 | private 5 | public fillps 6 | contains 7 | subroutine fillps(n,dli,dzfi,dti,up,vp,wp,p) 8 | !@cuf use cudafor 9 | ! 10 | ! fill the right-hand side of the Poisson equation for the correction pressure. 11 | ! 12 | ! the discrete divergence is: 13 | ! 14 | ! w(i,j,k)-w(i,j,k-1) v(i,j,k)-v(i,j-1,k) u(i,j,k)-u(i-1,j,k) 15 | ! ------------------- + ------------------- + ------------------- = div 16 | ! dz dy dx 17 | ! 18 | implicit none 19 | integer , intent(in), dimension(3) :: n 20 | real(rp), intent(in), dimension(3) :: dli 21 | real(rp), intent(in), dimension(0:) :: dzfi 22 | real(rp), intent(in) :: dti 23 | real(rp), intent(in ), dimension(0:,0:,0:) :: up,vp,wp 24 | real(rp), intent(out), dimension(0:,0:,0:) :: p 25 | real(rp) :: dtidxi,dtidyi!,dtidzi 26 | !real(rp), dimension(0:n(3)+1) :: dtidzfi 27 | #ifdef USE_CUDA 28 | attributes(managed) :: up,vp,wp,p,dzfi!,dtidzfi 29 | integer :: istat 30 | #endif 31 | integer :: i,j,k,im,jm,km 32 | ! 33 | dtidxi = dti*dli(1) 34 | dtidyi = dti*dli(2) 35 | #ifdef USE_CUDA 36 | !$cuf kernel do(3) <<<*,*>>> 37 | #else 38 | !$OMP PARALLEL DO DEFAULT(none) & 39 | !$OMP SHARED(n,p,up,vp,wp,dti,dzfi,dtidyi,dtidxi) & 40 | !$OMP PRIVATE(i,j,k,im,jm,km) 41 | #endif 42 | do k=1,n(3) 43 | km = k-1 44 | do j=1,n(2) 45 | jm = j-1 46 | do i=1,n(1) 47 | im = i-1 48 | p(i,j,k) = ( & 49 | (wp(i,j,k)-wp(i,j,km))*dti*dzfi(k)+ & 50 | (vp(i,j,k)-vp(i,jm,k))*dtidyi + & 51 | (up(i,j,k)-up(im,j,k))*dtidxi ) 52 | enddo 53 | enddo 54 | enddo 55 | #ifndef USE_CUDA 56 | !$OMP END PARALLEL DO 57 | #endif 58 | !@cuf istat=cudaDeviceSynchronize() 59 | ! 60 | return 61 | end subroutine fillps 62 | end module mod_fillps 63 | -------------------------------------------------------------------------------- /src/initgrid.f90: -------------------------------------------------------------------------------- 1 | module mod_initgrid 2 | use mod_param, only:pi 3 | use mod_types 4 | implicit none 5 | private 6 | public initgrid 7 | contains 8 | subroutine initgrid(inivel,n,gr,lz,dzc,dzf,zc,zf) 9 | ! 10 | ! initializes the non-uniform grid in z 11 | ! 12 | implicit none 13 | character(len=3), intent(in) :: inivel 14 | integer , intent(in) :: n 15 | real(rp), intent(in) :: gr,lz 16 | real(rp), intent(out), dimension(0:n+1) :: dzc,dzf,zc,zf 17 | real(rp) :: z0 18 | integer :: k 19 | procedure (), pointer :: gridpoint => null() 20 | select case(inivel) 21 | case('zer','log','poi','cou') 22 | gridpoint => gridpoint_cluster_two_end 23 | case('hcl','hcp') 24 | gridpoint => gridpoint_cluster_one_end 25 | case default 26 | gridpoint => gridpoint_cluster_two_end 27 | end select 28 | ! 29 | ! step 1) determine coordinates of cell faces zf 30 | ! 31 | do k=1,n 32 | z0 = (k-0.)/(1.*n) 33 | call gridpoint(gr,z0,zf(k)) 34 | zf(k) = zf(k)*lz 35 | enddo 36 | zf(0) = 0. 37 | ! 38 | ! step 2) determine grid spacing between faces dzf 39 | ! 40 | do k=1,n 41 | dzf(k) = zf(k)-zf(k-1) 42 | enddo 43 | dzf(0 ) = dzf(1) 44 | dzf(n+1) = dzf(n) 45 | ! 46 | ! step 3) determine grid spacing between centers dzc 47 | ! 48 | do k=0,n 49 | dzc(k) = .5*(dzf(k)+dzf(k+1)) 50 | enddo 51 | dzc(n+1) = dzc(n) 52 | ! 53 | ! step 4) compute coordinates of cell centers zc and faces zf 54 | ! 55 | zc(0) = -dzc(0)/2. 56 | zf(0) = 0. 57 | do k=1,n+1 58 | zc(k) = zc(k-1) + dzc(k-1) 59 | zf(k) = zf(k-1) + dzf(k) 60 | enddo 61 | return 62 | end subroutine initgrid 63 | ! 64 | ! grid stretching functions 65 | ! see e.g., Fluid Flow Phenomena -- A Numerical Toolkit, by P. Orlandi 66 | ! Pirozzoli et al. JFM 788, 614–639 (commented) 67 | ! 68 | subroutine gridpoint_cluster_two_end(alpha,z0,z) 69 | ! 70 | ! clustered at the two sides 71 | ! 72 | implicit none 73 | real(rp), intent(in) :: alpha,z0 74 | real(rp), intent(out) :: z 75 | if(alpha.ne.0.) then 76 | z = 0.5*(1.+tanh((z0-0.5)*alpha)/tanh(alpha/2.)) 77 | !z = 0.5*(1.+erf( (z0-0.5)*alpha)/erf( alpha/2.)) 78 | else 79 | z = z0 80 | endif 81 | return 82 | end subroutine gridpoint_cluster_two_end 83 | subroutine gridpoint_cluster_one_end(alpha,z0,z) 84 | ! 85 | ! clustered at the lower side 86 | ! 87 | implicit none 88 | real(rp), intent(in) :: alpha,z0 89 | real(rp), intent(out) :: z 90 | if(alpha.ne.0.) then 91 | z = 1.0*(1.+tanh((z0-1.0)*alpha)/tanh(alpha/1.)) 92 | !z = 1.0*(1.+erf( (z0-1.0)*alpha)/erf( alpha/1.)) 93 | else 94 | z = z0 95 | endif 96 | return 97 | end subroutine gridpoint_cluster_one_end 98 | subroutine gridpoint_cluster_middle(alpha,z0,z) 99 | ! 100 | ! clustered in the middle 101 | ! 102 | implicit none 103 | real(rp), intent(in) :: alpha,z0 104 | real(rp), intent(out) :: z 105 | if(alpha.ne.0.) then 106 | if( z0.le.0.5) then 107 | z = 0.5*(1.-1.+tanh(2.*alpha*(z0-0.))/tanh(alpha)) 108 | !z = 0.5*(1.-1.+erf( 2.*alpha*(z0-0.))/erf( alpha)) 109 | elseif(z0.gt.0.5) then 110 | z = 0.5*(1.+1.+tanh(2.*alpha*(z0-1.))/tanh(alpha)) 111 | !z = 0.5*(1.+1.+erf( 2.*alpha*(z0-1.))/erf( alpha)) 112 | endif 113 | else 114 | z = z0 115 | endif 116 | return 117 | end subroutine gridpoint_cluster_middle 118 | end module mod_initgrid 119 | -------------------------------------------------------------------------------- /src/load.f90: -------------------------------------------------------------------------------- 1 | module mod_load 2 | use mpi 3 | use mod_common_mpi, only: ierr,dims,myid 4 | use decomp_2d 5 | use decomp_2d_io 6 | use mod_types 7 | implicit none 8 | private 9 | public load 10 | contains 11 | subroutine load(io,filename,n,u,v,w,p,time,istep) 12 | ! 13 | ! reads/writes a restart file 14 | ! 15 | implicit none 16 | character(len=1) , intent(in) :: io 17 | character(len=*), intent(in) :: filename 18 | integer , intent(in), dimension(3) :: n 19 | real(rp), intent(inout), dimension(n(1),n(2),n(3)) :: u,v,w,p 20 | real(rp), intent(inout) :: time,istep 21 | real(rp), dimension(2) :: fldinfo 22 | integer :: fh 23 | integer(kind=MPI_OFFSET_KIND) :: filesize,disp,good 24 | integer(8), dimension(3) :: ng 25 | integer :: lenr 26 | ! 27 | select case(io) 28 | case('r') 29 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename , & 30 | MPI_MODE_RDONLY, MPI_INFO_NULL,fh, ierr) 31 | ! 32 | ! check file size first 33 | ! 34 | call MPI_FILE_GET_SIZE(fh,filesize,ierr) 35 | ng(:) = n(:) 36 | ng(1:2) = ng(1:2)*dims(:) 37 | lenr = storage_size(time)/8 38 | good = int(product(ng)*4+2,MPI_OFFSET_KIND)*lenr 39 | if(filesize.ne.good) then 40 | if(myid.eq.0) print*, '' 41 | if(myid.eq.0) print*, '*** Simulation aborted due a checkpoint file with incorrect size ***' 42 | if(myid.eq.0) print*, ' file: ', filename, ' | expected size: ', good, '| actual size: ', filesize 43 | call decomp_2d_finalize 44 | call MPI_FINALIZE(ierr) 45 | error stop 46 | endif 47 | ! 48 | ! read 49 | ! 50 | disp = 0_MPI_OFFSET_KIND 51 | call decomp_2d_read_var(fh,disp,3,u) 52 | call decomp_2d_read_var(fh,disp,3,v) 53 | call decomp_2d_read_var(fh,disp,3,w) 54 | call decomp_2d_read_var(fh,disp,3,p) 55 | call decomp_2d_read_scalar(fh,disp,2,fldinfo) 56 | time = fldinfo(1) 57 | istep = fldinfo(2) 58 | call MPI_FILE_CLOSE(fh,ierr) 59 | case('w') 60 | ! 61 | ! write 62 | ! 63 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename , & 64 | MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL,fh, ierr) 65 | filesize = 0_MPI_OFFSET_KIND 66 | call MPI_FILE_SET_SIZE(fh,filesize,ierr) ! guarantee overwriting 67 | disp = 0_MPI_OFFSET_KIND 68 | call decomp_2d_write_var(fh,disp,3,u) 69 | call decomp_2d_write_var(fh,disp,3,v) 70 | call decomp_2d_write_var(fh,disp,3,w) 71 | call decomp_2d_write_var(fh,disp,3,p) 72 | fldinfo = (/time,istep/) 73 | call decomp_2d_write_scalar(fh,disp,2,fldinfo) 74 | call MPI_FILE_CLOSE(fh,ierr) 75 | end select 76 | return 77 | end subroutine load 78 | end module mod_load 79 | -------------------------------------------------------------------------------- /src/moms.f90: -------------------------------------------------------------------------------- 1 | module mod_moms 2 | use mod_types 3 | implicit none 4 | private 5 | public momsad 6 | contains 7 | subroutine momsad(nx,ny,nz,dxi,dyi,dzi,dzci,dzfi,dzflzi,visc,u,v,w,s,dsdt) 8 | implicit none 9 | integer , intent(in) :: nx,ny,nz 10 | real(rp), intent(in) :: dxi,dyi,dzi,visc 11 | real(rp), intent(in), dimension(0:) :: dzci,dzfi,dzflzi 12 | real(rp), dimension(0:,0:,0:), intent(in) :: u,v,w,s 13 | real(rp), dimension(:,:,:), intent(out) :: dsdt 14 | integer :: im,ip,jm,jp,km,kp,i,j,k 15 | real(rp) :: usip,usim,vsjp,vsjm,wskp,wskm 16 | real(rp) :: dsdxp,dsdxm,dsdyp,dsdym,dsdzp,dsdzm 17 | ! 18 | !$OMP PARALLEL DO DEFAULT(none) & 19 | !$OMP PRIVATE(i,j,k,im,jm,km,ip,jp,kp) & 20 | !$OMP PRIVATE(usip,usim,vsjp,vsjm,wskp,wskm) & 21 | !$OMP PRIVATE(dsdxp,dsdxm,dsdyp,dsdym,dsdzp,dsdzm) & 22 | !$OMP SHARED(nx,ny,nz,dxi,dyi,dzi,visc,u,v,w,s,dsdt,dzci,dzfi) 23 | do k=1,nz 24 | kp = k + 1 25 | km = k - 1 26 | do j=1,ny 27 | jp = j + 1 28 | jm = j - 1 29 | do i=1,nx 30 | ip = i + 1 31 | im = i - 1 32 | usim = 0.5*( s(im,j,k)+s(i,j,k) )*u(im,j,k) 33 | usip = 0.5*( s(ip,j,k)+s(i,j,k) )*u(i ,j,k) 34 | vsjm = 0.5*( s(i,jm,k)+s(i,j,k) )*v(i,jm,k) 35 | vsjp = 0.5*( s(i,jp,k)+s(i,j,k) )*v(i,j ,k) 36 | wskm = 0.5*( s(i,j,km)+s(i,j,k) )*w(i,j,km) 37 | wskp = 0.5*( s(i,j,kp)+s(i,j,k) )*w(i,j,k ) 38 | dsdxp = (s(ip,j,k)-s(i ,j,k))*dxi 39 | dsdxm = (s(i ,j,k)-s(im,j,k))*dxi 40 | dsdyp = (s(i,jp,k)-s(i,j ,k))*dyi 41 | dsdym = (s(i,j ,k)-s(i,jm,k))*dyi 42 | dsdzp = (s(i,j,kp)-s(i,j,k ))*dzci(k) 43 | dsdzm = (s(i,j,k )-s(i,j,km))*dzci(km) 44 | ! 45 | dsdt(i,j,k) = dxi*( -usip + usim ) + (dsdxp-dsdxm)*visc*dxi + & 46 | dyi*( -vsjp + vsjm ) + (dsdyp-dsdym)*visc*dyi + & 47 | dzfi(k)*( -wskp + wskm ) + (dsdzp-dsdzm)*visc*dzfi(k) 48 | enddo 49 | enddo 50 | enddo 51 | !$OMP END PARALLEL DO 52 | return 53 | end subroutine momsad 54 | end module mod_moms 55 | -------------------------------------------------------------------------------- /src/nvtx.f90: -------------------------------------------------------------------------------- 1 | ! 2 | ! Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 3 | ! 4 | ! 5 | ! Permission is hereby granted, free of charge, to any person obtaining a 6 | ! copy of this software and associated documentation files (the "Software"), 7 | ! to deal in the Software without restriction, including without limitation 8 | ! the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | ! and/or sell copies of the Software, and to permit persons to whom the 10 | ! Software is furnished to do so, subject to the following conditions: 11 | ! 12 | ! The above copyright notice and this permission notice shall be included in 13 | ! all copies or substantial portions of the Software. 14 | ! 15 | ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | ! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | ! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | ! THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | ! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | ! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | ! DEALINGS IN THE SOFTWARE. 22 | ! 23 | 24 | ! Interface for NVTX markers 25 | module nvtx 26 | use iso_c_binding 27 | #ifdef USE_CUDA 28 | use cudafor 29 | implicit none 30 | 31 | integer,private :: col(7) = [ Z'0000ff00', Z'000000ff', Z'00ffff00',Z'00ff00ff',Z'0000ffff', & 32 | Z'00ff0000', Z'00ffffff'] 33 | character(len=256),private :: tempName 34 | 35 | logical, save :: isopen = .false. 36 | 37 | type, bind(C):: nvtxEventAttributes 38 | integer(C_INT16_T):: version=1 39 | integer(C_INT16_T):: size=48 ! 40 | integer(C_INT):: category=0 41 | integer(C_INT):: colorType=1 ! NVTX_COLOR_ARGB = 1 42 | integer(C_INT):: color 43 | integer(C_INT):: payloadType=0 ! NVTX_PAYLOAD_UNKNOWN = 0 44 | integer(C_INT):: reserved0 45 | integer(C_INT64_T):: payload ! union uint,int,double 46 | integer(C_INT):: messageType=1 ! NVTX_MESSAGE_TYPE_ASCII = 1 47 | type(C_PTR):: message ! ascii char 48 | end type nvtxEventAttributes 49 | 50 | #ifdef USE_NVTX 51 | interface nvtxRangePush 52 | ! push range with custom label and standard color 53 | subroutine nvtxRangePushA(name) bind(C, name='nvtxRangePushA') 54 | use iso_c_binding 55 | character(kind=C_CHAR,len=*) :: name 56 | end subroutine nvtxRangePushA 57 | 58 | ! push range with custom label and custom color 59 | subroutine nvtxRangePushEx(event) bind(C, name='nvtxRangePushEx') 60 | use iso_c_binding 61 | import:: nvtxEventAttributes 62 | type(nvtxEventAttributes):: event 63 | end subroutine nvtxRangePushEx 64 | end interface nvtxRangePush 65 | 66 | interface nvtxRangePop 67 | subroutine nvtxRangePop() bind(C, name='nvtxRangePop') 68 | end subroutine nvtxRangePop 69 | end interface nvtxRangePop 70 | #endif 71 | #endif 72 | 73 | contains 74 | 75 | subroutine nvtxStartRange(name,id) 76 | character(kind=c_char,len=*) :: name 77 | integer, optional:: id 78 | #ifdef USE_CUDA 79 | #ifdef USE_NVTX 80 | type(nvtxEventAttributes):: event 81 | integer :: istat 82 | istat = cudaDeviceSynchronize() 83 | 84 | tempName=trim(name)//c_null_char 85 | 86 | if ( .not. present(id)) then 87 | call nvtxRangePush(tempName) 88 | else 89 | event%color=col(mod(id,7)+1) 90 | event%message=c_loc(tempName) 91 | call nvtxRangePushEx(event) 92 | end if 93 | #endif 94 | #endif 95 | end subroutine nvtxStartRange 96 | 97 | subroutine nvtxEndRange 98 | #ifdef USE_CUDA 99 | #ifdef USE_NVTX 100 | integer :: istat 101 | istat = cudaDeviceSynchronize() 102 | call nvtxRangePop 103 | #endif 104 | #endif 105 | end subroutine nvtxEndRange 106 | 107 | subroutine nvtxStartRangeAsync(name,id) 108 | character(kind=c_char,len=*) :: name 109 | integer, optional:: id 110 | #ifdef USE_CUDA 111 | #ifdef USE_NVTX 112 | type(nvtxEventAttributes):: event 113 | tempName=trim(name)//c_null_char 114 | if ( .not. present(id)) then 115 | call nvtxRangePush(tempName) 116 | else 117 | event%color=col(mod(id,7)+1) 118 | event%message=c_loc(tempName) 119 | call nvtxRangePushEx(event) 120 | end if 121 | #endif 122 | #endif 123 | end subroutine nvtxStartRangeAsync 124 | 125 | subroutine nvtxEndRangeAsync 126 | #ifdef USE_CUDA 127 | #ifdef USE_NVTX 128 | call nvtxRangePop 129 | #endif 130 | #endif 131 | end subroutine nvtxEndRangeAsync 132 | 133 | end module nvtx 134 | -------------------------------------------------------------------------------- /src/out1d.h90: -------------------------------------------------------------------------------- 1 | ! out1d(fname,n,idir,z,dzlzi,p) 2 | ! 3 | ! writes the profile of a variable averaged 4 | ! over two domain directions (see output.f90) 5 | ! 6 | ! fname -> name of the file 7 | ! n -> size of the input array 8 | ! idir -> direction of the profile 9 | ! z -> z coordinate (grid is non-uniform in z) 10 | ! dzlzi -> dz/lz weight of a grid cell for averaging over z 11 | ! p -> 3D input scalar field 12 | ! 13 | ! modify the calls below as desired 14 | ! 15 | call out1d(trim(datadir)//'umean_z_fld_' //fldnum//'.out',n,3,zc,dzf/lz,u) 16 | call out1d(trim(datadir)//'vmean_z_fld_' //fldnum//'.out',n,3,zc,dzf/lz,v) 17 | call out1d(trim(datadir)//'wmean_z_fld_' //fldnum//'.out',n,3,zf,dzc/lz,w) 18 | !call out1d(trim(datadir)//'umean_y_fld_' //fldnum//'.out',n,2,zc,dzf/lz,u) 19 | !call out1d(trim(datadir)//'vmean_y_fld_' //fldnum//'.out',n,2,zc,dzf/lz,v) 20 | !call out1d(trim(datadir)//'wmean_y_fld_' //fldnum//'.out',n,2,zc,dzf/lz,w) 21 | !call out1d(trim(datadir)//'umean_x_fld_' //fldnum//'.out',n,1,zc,dzf/lz,u) 22 | !call out1d(trim(datadir)//'vmean_x_fld_' //fldnum//'.out',n,1,zc,dzf/lz,v) 23 | !call out1d(trim(datadir)//'wmean_x_fld_' //fldnum//'.out',n,1,zc,dzf/lz,w) 24 | !call out1d_2(trim(datadir)//'velstats_fld_'//fldnum//'.out',n,3,zc,u,v,w) 25 | -------------------------------------------------------------------------------- /src/out2d.h90: -------------------------------------------------------------------------------- 1 | ! 2 | ! write_visu_2d(datadir,fname_bin,fname_log,varname,inorm,nslice,ng,time,istep,p) 3 | ! 4 | ! saves field data into a binary file and appends information about the data to a file 5 | ! the log file can be used to generate a xdmf file for visualization of field data 6 | ! 7 | ! datadir -> name of the directory where the data is saved 8 | ! fname_bin -> name of the output binary file 9 | ! fname_log -> name of the log file (each different plane that is saved should 10 | ! correspond to a different log file) 11 | ! varname -> name of the variable that is saved 12 | ! to create a vector, append _X _Y and _Z to the variable name, denoting the 13 | ! three components of the vector field 14 | ! inorm -> plane is perpendicular to direction inorm (1, 2, or 3) 15 | ! islice -> plane is of constant index islice in direction inorm 16 | ! ng -> array with the global number of points in each direction 17 | ! time -> physical time 18 | ! istep -> time step number 19 | ! p -> 3D input scalar field 20 | ! 21 | ! modify the calls below as desired 22 | ! 23 | call write_visu_2d(datadir,'u_slice_fld_'//fldnum//'.bin','log_visu_2d_slice_1.out','Velocity_X', & 24 | 2,ng(2)/2,ng,time,istep, & 25 | u(1:n(1),1:n(2),1:n(3))) 26 | call write_visu_2d(datadir,'v_slice_fld_'//fldnum//'.bin','log_visu_2d_slice_1.out','Velocity_Y', & 27 | 2,ng(2)/2,ng,time,istep, & 28 | v(1:n(1),1:n(2),1:n(3))) 29 | call write_visu_2d(datadir,'w_slice_fld_'//fldnum//'.bin','log_visu_2d_slice_1.out','Velocity_Z', & 30 | 2,ng(2)/2,ng,time,istep, & 31 | w(1:n(1),1:n(2),1:n(3))) 32 | call write_visu_2d(datadir,'p_slice_fld_'//fldnum//'.bin','log_visu_2d_slice_1.out','Pressure_P', & 33 | 2,ng(2)/2,ng,time,istep, & 34 | p(1:n(1),1:n(2),1:n(3))) 35 | -------------------------------------------------------------------------------- /src/out3d.h90: -------------------------------------------------------------------------------- 1 | ! 2 | ! write_visu_3d(datadir,fname_bin,fname_log,varname,nmin,nmax,nskip,time,istep,p) 3 | ! 4 | ! saves field data into a binary file and appends information about the data to a file 5 | ! the log file can be used to generate a xdmf file for visualization of field data 6 | ! 7 | ! datadir -> name of the directory where the data is saved 8 | ! fname_bin -> name of the output binary file 9 | ! fname_log -> name of the log file (can be the same for a time series of data with the same grid) 10 | ! varname -> name of the variable that is saved 11 | ! to create a vector, append _X _Y and _Z to the variable name, denoting the 12 | ! three components of the vector field 13 | ! nmin -> first element of the field that is saved in each direction, e.g. (/1,1,1/) 14 | ! nmax -> last element of the field that is saved in each direction, e.g. (/ng(1),ng(2),ng(3)/) 15 | ! nskip -> step size with which the grid points are saved, e.g. (/1,1,1/) if the whole array is saved 16 | ! time -> physical time 17 | ! istep -> time step number 18 | ! p -> 3D input scalar field 19 | ! 20 | ! modify the calls below as desired 21 | ! 22 | call write_visu_3d(datadir,'vex_fld_'//fldnum//'.bin','log_visu_3d.out','Velocity_X', & 23 | (/1,1,1/),(/ng(1),ng(2),ng(3)/),(/1,1,1/),time,istep, & 24 | u(1:n(1),1:n(2),1:n(3))) 25 | call write_visu_3d(datadir,'vey_fld_'//fldnum//'.bin','log_visu_3d.out','Velocity_Y', & 26 | (/1,1,1/),(/ng(1),ng(2),ng(3)/),(/1,1,1/),time,istep, & 27 | v(1:n(1),1:n(2),1:n(3))) 28 | call write_visu_3d(datadir,'vez_fld_'//fldnum//'.bin','log_visu_3d.out','Velocity_Z', & 29 | (/1,1,1/),(/ng(1),ng(2),ng(3)/),(/1,1,1/),time,istep, & 30 | w(1:n(1),1:n(2),1:n(3))) 31 | call write_visu_3d(datadir,'pre_fld_'//fldnum//'.bin','log_visu_3d.out','Pressure_P', & 32 | (/1,1,1/),(/ng(1),ng(2),ng(3)/),(/1,1,1/),time,istep, & 33 | p(1:n(1),1:n(2),1:n(3))) 34 | -------------------------------------------------------------------------------- /src/param.f90: -------------------------------------------------------------------------------- 1 | module mod_param 2 | use mod_types 3 | implicit none 4 | public 5 | ! 6 | ! parameters 7 | ! 8 | real(rp), parameter :: pi = acos(-1._rp) 9 | real(rp), parameter :: small = epsilon(pi)*10**(precision(pi)/2) 10 | character(len=100), parameter :: datadir = 'data/' 11 | real(rp), parameter, dimension(2,3) :: rkcoeff = reshape((/ 32._rp/60._rp, 0._rp , & 12 | 25._rp/60._rp, -17._rp/60._rp, & 13 | 45._rp/60._rp, -25._rp/60._rp/), shape(rkcoeff)) 14 | real(rp), parameter, dimension(3) :: rkcoeff12 = rkcoeff(1,:)+rkcoeff(2,:) 15 | ! 16 | ! variables to be determined from the input file 'dns.in' 17 | ! 18 | integer :: itot,jtot,ktot,imax,jmax 19 | real(rp) :: lx,ly,lz,dx,dy,dz,dxi,dyi,dzi,gr 20 | real(rp) :: cfl,dtmin 21 | real(rp) :: uref,lref,rey,visc 22 | ! 23 | character(len=100) :: inivel 24 | logical :: is_wallturb 25 | ! 26 | integer :: nstep 27 | real(rp) :: time_max,tw_max 28 | logical, dimension(3) :: stop_type 29 | logical :: restart,is_overwrite_save 30 | integer :: icheck,iout0d,iout1d,iout2d,iout3d,isave 31 | ! 32 | integer, dimension(2) :: dims 33 | integer :: nthreadsmax 34 | ! 35 | character(len=1), dimension(0:1,3,3) :: cbcvel 36 | real(rp) , dimension(0:1,3,3) :: bcvel 37 | character(len=1), dimension(0:1,3) :: cbcpre 38 | real(rp) , dimension(0:1,3) :: bcpre 39 | ! 40 | real(rp), dimension(3) :: bforce 41 | logical , dimension(3) :: is_forced 42 | real(rp), dimension(3) :: velf 43 | ! 44 | integer , dimension(3) :: ng 45 | integer , dimension(3) :: n 46 | real(rp), dimension(3) :: l 47 | real(rp), dimension(3) :: dl 48 | real(rp), dimension(3) :: dli 49 | ! 50 | contains 51 | subroutine read_input(myid) 52 | use mpi 53 | implicit none 54 | integer, intent(in) :: myid 55 | integer :: iunit,ierr 56 | open(newunit=iunit,file='dns.in',status='old',action='read',iostat=ierr) 57 | if( ierr.eq.0 ) then 58 | read(iunit,*) itot,jtot,ktot 59 | read(iunit,*) lx,ly,lz 60 | read(iunit,*) gr 61 | read(iunit,*) cfl,dtmin 62 | read(iunit,*) uref,lref,rey 63 | read(iunit,*) inivel 64 | read(iunit,*) is_wallturb 65 | read(iunit,*) nstep, time_max,tw_max 66 | read(iunit,*) stop_type(1),stop_type(2),stop_type(3) 67 | read(iunit,*) restart,is_overwrite_save 68 | read(iunit,*) icheck,iout0d,iout1d,iout2d,iout3d,isave 69 | read(iunit,*) cbcvel(0,1,1),cbcvel(1,1,1),cbcvel(0,2,1),cbcvel(1,2,1),cbcvel(0,3,1),cbcvel(1,3,1) 70 | read(iunit,*) cbcvel(0,1,2),cbcvel(1,1,2),cbcvel(0,2,2),cbcvel(1,2,2),cbcvel(0,3,2),cbcvel(1,3,2) 71 | read(iunit,*) cbcvel(0,1,3),cbcvel(1,1,3),cbcvel(0,2,3),cbcvel(1,2,3),cbcvel(0,3,3),cbcvel(1,3,3) 72 | read(iunit,*) cbcpre(0,1 ),cbcpre(1,1 ),cbcpre(0,2 ),cbcpre(1,2 ),cbcpre(0,3 ),cbcpre(1,3 ) 73 | read(iunit,*) bcvel(0,1,1), bcvel(1,1,1), bcvel(0,2,1), bcvel(1,2,1), bcvel(0,3,1), bcvel(1,3,1) 74 | read(iunit,*) bcvel(0,1,2), bcvel(1,1,2), bcvel(0,2,2), bcvel(1,2,2), bcvel(0,3,2), bcvel(1,3,2) 75 | read(iunit,*) bcvel(0,1,3), bcvel(1,1,3), bcvel(0,2,3), bcvel(1,2,3), bcvel(0,3,3), bcvel(1,3,3) 76 | read(iunit,*) bcpre(0,1 ), bcpre(1,1 ), bcpre(0,2 ), bcpre(1,2 ), bcpre(0,3 ), bcpre(1,3 ) 77 | read(iunit,*) bforce(1),bforce(2),bforce(3) 78 | read(iunit,*) is_forced(1),is_forced(2),is_forced(3) 79 | read(iunit,*) velf(1),velf(2),velf(3) 80 | read(iunit,*) dims(1),dims(2) 81 | read(iunit,*) nthreadsmax 82 | else 83 | if(myid.eq.0) print*, 'Error reading the input file' 84 | if(myid.eq.0) print*, 'Aborting...' 85 | call MPI_FINALIZE(ierr) 86 | error stop 87 | endif 88 | close(iunit) 89 | dx = lx/(1.*itot) 90 | dy = ly/(1.*jtot) 91 | dz = lz/(1.*ktot) 92 | dxi = dx**(-1) 93 | dyi = dy**(-1) 94 | dzi = dz**(-1) 95 | imax = itot/dims(1) 96 | jmax = jtot/dims(2) 97 | ! 98 | visc = uref*lref/rey 99 | ng = (/itot,jtot,ktot/) 100 | n = (/imax,jmax,ktot/) 101 | l = (/lx,ly,lz/) 102 | dl = (/dx,dy,dz/) 103 | dli = (/dxi,dyi,dzi/) 104 | return 105 | end subroutine read_input 106 | end module mod_param 107 | -------------------------------------------------------------------------------- /src/types.f90: -------------------------------------------------------------------------------- 1 | module mod_types 2 | use mpi, only: MPI_REAL,MPI_DOUBLE_PRECISION 3 | #ifdef SINGLE_PRECISION 4 | integer, parameter, public :: rp = KIND(1.0) 5 | integer, parameter, public :: MPI_REAL_RP = MPI_REAL 6 | #else 7 | integer, parameter, public :: rp = KIND(0.0D0) 8 | integer, parameter, public :: MPI_REAL_RP = MPI_DOUBLE_PRECISION 9 | #endif 10 | end module mod_types 11 | -------------------------------------------------------------------------------- /tests/lid_driven_cavity/Makefile: -------------------------------------------------------------------------------- 1 | # fortran compiler 2 | FC = mpif90 3 | # flags 4 | BIG := # -mcmodel=medium 5 | DBG := # -g -fbacktrace -Wall -O0 -Wextra -pedantic -fcheck=all 6 | OMP := #-mp # -fopenmp 7 | OPT := -O3 -Mcuda=ccall,cuda11.0#,cuda10.0 8 | #OPT := -O3 -Mcuda=cc70,nofma 9 | OTH := -DTIMING -DGPU_MPI -DEPA2A -DTIMING -DUSE_CUDA -DUSE_NVTX -DEPHC #-DDEBUG #-DIMPDIFF 10 | PROF := #-pg 11 | FFLAGS := $(OPT) $(BIG) $(DBG) $(PROF) $(OMP) $(OTH) 12 | TARGET = cans 13 | # 14 | OBJ = bound.o chkdiv.o chkdt.o common_mpi.o correc.o debug.o fft.o fftw.o fillps.o initflow.o initgrid.o initmpi.o initsolver.o load.o main.o mom.o momd.o moms.o output.o param.o rk.o sanity.o solver.o decomp_2d.o io.o types.o nvtx.o 15 | # 16 | LIBS = -lfftw3 -lfftw3_threads -Mcudalib=cufft -L/usr/local/cuda/lib64 -lnvToolsExt 17 | # 18 | all: $(TARGET) 19 | # 20 | $(TARGET): $(OBJ) 21 | $(FC) $(FFLAGS) $(OBJ) $(LIBS) -o $(TARGET) 22 | # src, run and data directories 23 | SRCDIR := $(pwd) 24 | RUNDIR := $(SRCDIR)../run 25 | DATDIR := $(RUNDIR)/data 26 | # 27 | run: $(TARGET) 28 | @mkdir -p $(RUNDIR) $(DATDIR) 29 | @cp $(TARGET) $(RUNDIR) 30 | @cp dns.in $(RUNDIR) 31 | @printf "\nExecutable file $(TARGET) and input file dns.in copied to run folder $(RUNDIR)\n" 32 | # 33 | .PHONY: clean 34 | clean: 35 | rm -rf *.o *.mod *dSYM $(TARGET) 36 | # dependencies 37 | bound.o: bound.f90 common_mpi.o nvtx.o types.o 38 | $(FC) $(FFLAGS) -cpp -c bound.f90 39 | chkdiv.o: chkdiv.f90 common_mpi.o types.o 40 | $(FC) $(FFLAGS) -cpp -c chkdiv.f90 41 | chkdt.o: chkdt.f90 common_mpi.o types.o 42 | $(FC) $(FFLAGS) -cpp -c chkdt.f90 43 | common_mpi.o: common_mpi.f90 param.o types.o 44 | $(FC) $(FFLAGS) -cpp -c common_mpi.f90 45 | correc.o: correc.f90 types.o 46 | $(FC) $(FFLAGS) -cpp -c correc.f90 47 | debug.o: debug.f90 common_mpi.o types.o 48 | $(FC) $(FFLAGS) -cpp -c debug.f90 49 | fillps.o: fillps.f90 types.o 50 | $(FC) $(FFLAGS) -cpp -c fillps.f90 51 | fft.o: fft.f90 common_mpi.o fftw.o types.o 52 | $(FC) $(FFLAGS) -cpp -c fft.f90 53 | fftw.o: fftw.f90 param.o 54 | $(FC) $(FFLAGS) -cpp -c fftw.f90 55 | initflow.o: initflow.f90 common_mpi.o decomp_2d.o types.o 56 | $(FC) $(FFLAGS) -Mnovect -cpp -c initflow.f90 57 | initgrid.o: initgrid.f90 param.o types.o 58 | $(FC) $(FFLAGS) -cpp -c initgrid.f90 59 | initmpi.o: initmpi.f90 decomp_2d.o common_mpi.o types.o 60 | $(FC) $(FFLAGS) -cpp -c initmpi.f90 61 | initsolver.o: initsolver.f90 common_mpi.o fft.o param.o types.o 62 | $(FC) $(FFLAGS) -cpp -c initsolver.f90 63 | load.o: load.f90 common_mpi.o decomp_2d.o io.o types.o 64 | $(FC) $(FFLAGS) -cpp -c load.f90 65 | main.o: main.f90 bound.o chkdiv.o chkdt.o debug.o fft.o fillps.o initflow.o initflow.o initgrid.o initmpi.o initsolver.o load.o output.o param.o rk.o sanity.o solver.o types.o out1d.h90 out2d.h90 out3d.h90 nvtx.o 66 | $(FC) $(FFLAGS) -cpp -c main.f90 67 | mom.o: mom.f90 common_mpi.o types.o 68 | $(FC) $(FFLAGS) -cpp -c mom.f90 69 | momd.o: momd.f90 common_mpi.o types.o 70 | $(FC) $(FFLAGS) -cpp -c momd.f90 71 | moms.o: moms.f90 types.o 72 | $(FC) $(FFLAGS) -cpp -c moms.f90 73 | output.o: output.f90 io.o types.o 74 | $(FC) $(FFLAGS) -cpp -c output.f90 75 | param.o: param.f90 types.o 76 | $(FC) $(FFLAGS) -cpp -c param.f90 77 | rk.o: rk.f90 debug.o mom.o momd.o moms.o param.o types.o nvtx.o 78 | $(FC) $(FFLAGS) -cpp -c rk.f90 79 | sanity.o: sanity.f90 bound.o chkdiv.o common_mpi.o correc.o debug.o decomp_2d.o fft.o fillps.o initflow.o initmpi.o initsolver.o param.o solver.o types.o 80 | $(FC) $(FFLAGS) -cpp -c sanity.f90 81 | solver.o: solver.f90 fft.o param.o types.o 82 | $(FC) $(FFLAGS) -cpp -c solver.f90 83 | types.o: types.f90 84 | $(FC) $(FFLAGS) -cpp -c $< 85 | # 2decomp&fft library 86 | FFLAGS_2DECOMP :=# -DOVERWRITE -DEVEN 87 | 2decompdir=2decomp/ 88 | decomp_2d.o: $(2decompdir)decomp_2d.f90 nvtx.o 89 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)decomp_2d.f90 90 | io.o: $(2decompdir)io.f90 decomp_2d.o 91 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c $(2decompdir)io.f90 92 | nvtx.o: nvtx.f90 93 | $(FC) $(FFLAGS) -cpp $(FFLAGS_2DECOMP) -c nvtx.f90 94 | -------------------------------------------------------------------------------- /tests/lid_driven_cavity/data_ldc_re1000.txt: -------------------------------------------------------------------------------- 1 | 7.8125000e-03 -3.1095216e-02 2 | 2.3437500e-02 -8.3540127e-02 3 | 3.9062500e-02 -1.2849577e-01 4 | 5.4687500e-02 -1.6870639e-01 5 | 7.0312500e-02 -2.0652188e-01 6 | 8.5937500e-02 -2.4295277e-01 7 | 1.0156250e-01 -2.7747221e-01 8 | 1.1718750e-01 -3.0851031e-01 9 | 1.3281250e-01 -3.3416215e-01 10 | 1.4843750e-01 -3.5277174e-01 11 | 1.6406250e-01 -3.6332860e-01 12 | 1.7968750e-01 -3.6569098e-01 13 | 1.9531250e-01 -3.6060902e-01 14 | 2.1093750e-01 -3.4953180e-01 15 | 2.2656250e-01 -3.3426054e-01 16 | 2.4218750e-01 -3.1657378e-01 17 | 2.5781250e-01 -2.9794420e-01 18 | 2.7343750e-01 -2.7940278e-01 19 | 2.8906250e-01 -2.6153750e-01 20 | 3.0468750e-01 -2.4457665e-01 21 | 3.2031250e-01 -2.2850401e-01 22 | 3.3593750e-01 -2.1316866e-01 23 | 3.5156250e-01 -1.9837011e-01 24 | 3.6718750e-01 -1.8391366e-01 25 | 3.8281250e-01 -1.6963929e-01 26 | 3.9843750e-01 -1.5543093e-01 27 | 4.1406250e-01 -1.4121361e-01 28 | 4.2968750e-01 -1.2694478e-01 29 | 4.4531250e-01 -1.1260400e-01 30 | 4.6093750e-01 -9.8183871e-02 31 | 4.7656250e-01 -8.3682971e-02 32 | 4.9218750e-01 -6.9101153e-02 33 | 5.0781250e-01 -5.4436797e-02 34 | 5.2343750e-01 -3.9685460e-02 35 | 5.3906250e-01 -2.4839421e-02 36 | 5.5468750e-01 -9.8876651e-03 37 | 5.7031250e-01 5.1839946e-03 38 | 5.8593750e-01 2.0392858e-02 39 | 6.0156250e-01 3.5759451e-02 40 | 6.1718750e-01 5.1307811e-02 41 | 6.3281250e-01 6.7065881e-02 42 | 6.4843750e-01 8.3065834e-02 43 | 6.6406250e-01 9.9344067e-02 44 | 6.7968750e-01 1.1594047e-01 45 | 6.9531250e-01 1.3289650e-01 46 | 7.1093750e-01 1.5025151e-01 47 | 7.2656250e-01 1.6803678e-01 48 | 7.4218750e-01 1.8626699e-01 49 | 7.5781250e-01 2.0492898e-01 50 | 7.7343750e-01 2.2396841e-01 51 | 7.8906250e-01 2.4327555e-01 52 | 8.0468750e-01 2.6267212e-01 53 | 8.2031250e-01 2.8190180e-01 54 | 8.3593750e-01 3.0062699e-01 55 | 8.5156250e-01 3.1843497e-01 56 | 8.6718750e-01 3.3486128e-01 57 | 8.8281250e-01 3.4946957e-01 58 | 8.9843750e-01 3.6215024e-01 59 | 9.1406250e-01 3.7412981e-01 60 | 9.2968750e-01 3.9059183e-01 61 | 9.4531250e-01 4.2512345e-01 62 | 9.6093750e-01 5.0245396e-01 63 | 9.7656250e-01 6.5085666e-01 64 | 9.9218750e-01 8.7633306e-01 65 | -------------------------------------------------------------------------------- /tests/lid_driven_cavity/dns.in: -------------------------------------------------------------------------------- 1 | 2 64 64 ! itot, jtot, ktot 2 | 0.03125 1. 1. ! lx, ly, lz 3 | 0. ! gr 4 | .95 1.e5 ! cfl 5 | 1. 1. 1000. ! uref, lref, rey 6 | zer ! inivel 7 | F ! is_wallturb 8 | 1500 100. 0.1 ! nstep,time_max,tw_max 9 | T F F ! stop_type(1:3) 10 | F T ! restart,is_overwrite_save 11 | 10 10 20 500 500 2000 ! icheck, iout0d, iout1d, iout2d, iout3d, isave 12 | P P D D D D ! cbcvel(0:1,1:3,1) [u BC type] 13 | P P D D D D ! cbcvel(0:1,1:3,2) [v BC type] 14 | P P D D D D ! cbcvel(0:1,1:3,3) [w BC type] 15 | P P N N N N ! cbcpre(0:1,1:3 ) [p BC type] 16 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,1) [u BC value] 17 | 0. 0. 0. 0. 0. 1. ! bcvel(0:1,1:3,2) [v BC value] 18 | 0. 0. 0. 0. 0. 0. ! bcvel(0:1,1:3,3) [w BC value] 19 | 0. 0. 0. 0. 0. 0. ! bcpre(0:1,1:3 ) [p BC value] 20 | 0. 0. 0. ! bforce(1:3) 21 | F F F ! is_forced(1:3) 22 | 0. 0. 0. ! velf(1:3) 23 | 2 2 ! dims(1:2) 24 | 4 ! nthreadsmax 25 | -------------------------------------------------------------------------------- /tests/lid_driven_cavity/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def test_ldc(): 3 | import numpy as np 4 | from read_single_field_binary import read_single_field_binary 5 | data,xp,yp,zp,xu,yv,zw = read_single_field_binary("vey_fld_0001500.bin",np.array([1,1,1])) 6 | data_ref = np.loadtxt("data_ldc_re1000.txt") 7 | islice = int(np.size(data[0,0,:])/2) 8 | np.testing.assert_allclose(data[0,islice,:], data_ref[:,1], rtol=1e-7, atol=0) 9 | if __name__ == "__main__": 10 | test_ldc() 11 | print("Passed!") 12 | -------------------------------------------------------------------------------- /tests/lid_driven_cavity/testit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TESTDIR=$(pwd) 3 | CANSDIR=$(pwd)/../.. 4 | SRCDIR=$CANSDIR/src 5 | RUNDIR=$CANSDIR/run 6 | UTILSDIR=$CANSDIR/utils 7 | rm -rf $RUNDIR 8 | echo "Compiling ..." 9 | sleep 2 10 | cp $TESTDIR/Makefile $SRCDIR && cd $SRCDIR && make clean && make -j run 11 | cp $TESTDIR/dns.in $RUNDIR && cd $RUNDIR 12 | echo "Running CaNS..." 13 | sleep 2 14 | mpirun -n 1 ./cans 15 | cp $TESTDIR/*.* data/ && cp $UTILSDIR/read_binary_data/python/read_single_field_binary.py $RUNDIR/data/ && cd $RUNDIR/data/ 16 | echo "Running test..." 17 | sleep 2 18 | pytest test.py 19 | rm -rf $RUNDIR 20 | -------------------------------------------------------------------------------- /utils/plot2d/param.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | datadir = 'data/' 4 | figsdir = 'figs/' 5 | exto = '.pdf' 6 | filenamei = datadir + 'fld_u_slice_fld_0629500.bin' 7 | filenameo = figsdir + 'visu' + exto 8 | # 9 | n2 = 128 10 | n1 = 128 11 | l2 = 1.0 12 | l1 = 1.0 13 | dx1 = l1/float(n1) 14 | dx2 = l2/float(n2) 15 | # 16 | fgtitle = r'Slice at $y/h = 0.5$' 17 | cbtitle = r'$u/U_b$' 18 | x1title = r'$x/h$' 19 | x2title = r'$z/h$' 20 | -------------------------------------------------------------------------------- /utils/plot2d/plot_2d_flow_slice.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from pltparams import * 3 | from param import * 4 | import pylab 5 | # 6 | # read data 7 | # 8 | f = open(filenamei,'rb') 9 | fld = np.fromfile(f,dtype='float64') 10 | fld = np.reshape(fld,(n2,n1),order='C') 11 | f.close() 12 | # 13 | # initialize figure 14 | # 15 | initfig(ar = l2/l1) 16 | fig, ax, formatter = newfig() 17 | #ax.set_axis_off() 18 | #ax.get_xaxis().set_visible(False) 19 | #ax.get_yaxis().set_visible(False) 20 | # 21 | # plot data 22 | # 23 | x1 = np.linspace(0.+dx1/2.,l1-dx1/2.,n1) 24 | x2 = np.linspace(0.+dx2/2.,l2-dx2/2.,n2) 25 | cs1 = ax.contourf(x1, x2, fld, 26 | cmap=plt.cm.jet) 27 | cbar = fig.colorbar(cs1, orientation='vertical') 28 | # 29 | # format figrue 30 | # 31 | ax.set_title(fgtitle) 32 | cbar.ax.set_title(cbtitle) 33 | ax.set_xlabel(x1title) 34 | ax.set_ylabel(x2title) 35 | # 36 | # save figure 37 | # 38 | fig.tight_layout(pad=0.15) 39 | plt.show() 40 | fig.savefig(filenameo) 41 | -------------------------------------------------------------------------------- /utils/plot2d/pltparams.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | import numpy as np 4 | import matplotlib 5 | import matplotlib.pyplot as plt 6 | # 7 | def initfig(width = 600.0, ar = (np.sqrt(5)-1.0)/2.0, scl = 0.95): 8 | fig_width_pt = width # \showthe\columnwidth 9 | inches_per_pt = 1.0/72.27 # pt to in 10 | aspect_ratio = ar # aspect ratio 11 | fig_scale = scl # scale factor 12 | fig_width = fig_width_pt*inches_per_pt*fig_scale # width in in 13 | fig_height = fig_width*aspect_ratio # height in in 14 | fig_size = [fig_width,fig_height] # final dimensions 15 | params = {'backend' : 'ps', 16 | 'font.family' : 'serif', 17 | 'font.size' : 10, 18 | 'axes.labelsize' : 10, 19 | 'legend.fontsize': 8, 20 | 'xtick.labelsize': 8, 21 | 'ytick.labelsize': 8, 22 | 'text.usetex' : True, 23 | 'figure.figsize' : fig_size} 24 | plt.rcParams.update(params) 25 | # 26 | def format(x, pos): 27 | 'The two args are the value and tick position' 28 | return '%1.2g' % (x) 29 | # 30 | def newfig(): 31 | plt.cla() 32 | plt.clf() 33 | plt.close() 34 | fig = plt.figure() 35 | ax = fig.add_subplot(111) 36 | formatter = matplotlib.ticker.FuncFormatter(format) 37 | return fig, ax, formatter 38 | -------------------------------------------------------------------------------- /utils/plot2d/readme.txt: -------------------------------------------------------------------------------- 1 | plot_2d_flow_slice.py is a python script that reads an output file from CaNS containing a planar section of a 3D scalar field (unformatted FORTRAN binary file). It is meant to give a simple example of how to read and plot planar data. The corresponding parameters should be changed in param.py. 2 | -------------------------------------------------------------------------------- /utils/read_binary_data/matlab/read_restart_file.m: -------------------------------------------------------------------------------- 1 | % 2 | % setting up some parameters 3 | % 4 | precision = 'double'; % precision of the real-valued data 5 | r0 = [0.,0.,0.]; % domain origin 6 | non_uniform_grid = true; 7 | % 8 | % read geometry file 9 | % 10 | geofile = "geometry.out"; 11 | data = dlmread(geofile); 12 | ng = data(1,:); 13 | l = data(2,:); 14 | dl = l./ng; 15 | % 16 | % read and generate grid 17 | % 18 | xp = linspace(r0(1)+dl(1)/2.,r0(1)+l(1),ng(1)); % centered x grid 19 | yp = linspace(r0(2)+dl(2)/2.,r0(2)+l(2),ng(2)); % centered y grid 20 | zp = linspace(r0(3)+dl(3)/2.,r0(3)+l(3),ng(3)); % centered z grid 21 | xu = xp + dl(1)/2.; % staggered x grid 22 | yv = yp + dl(2)/2.; % staggered y grid 23 | zw = zp + dl(3)/2.; % staggered z grid 24 | if(non_uniform_grid) 25 | f = fopen('grid.bin'); 26 | grid_z = fread(f,[ng(3),4],precision); 27 | fclose(f); 28 | zp = r0(3) + grid_z(:,3)'; % centered z grid 29 | zw = r0(3) + grid_z(:,4)'; % staggered z grid 30 | end 31 | % 32 | % read checkpoint binary file 33 | % 34 | filenamei = input("Name of the binary restart file written by CaNS [fld.bin]: "); 35 | if isempty(filenamei) 36 | filenamei = "fld.bin"; 37 | end 38 | data = zeros([ng(1),ng(2),ng(3),4]); % u(:,:,:),v(:,:,:),w(:,:,:),p(:,:,:) 39 | fldinfo = zeros([2,1]); 40 | f = fopen(filenamei); 41 | for p = 1:4 42 | data(:,:,:,p) = reshape(fread(f,ng(1)*ng(2)*ng(3),precision),[ng(1),ng(2),ng(3)]); 43 | end 44 | fldinfo(:) = fread(f,2,precision); 45 | fclose(f); 46 | % 47 | % store data in arrays 48 | % 49 | u = data(:,:,:,1); 50 | v = data(:,:,:,2); 51 | w = data(:,:,:,3); 52 | p = data(:,:,:,4); 53 | time = fldinfo(1); 54 | istep = round(fldinfo(2)); 55 | -------------------------------------------------------------------------------- /utils/read_binary_data/matlab/read_single_field_binary.m: -------------------------------------------------------------------------------- 1 | % 2 | % setting up some parameters 3 | % 4 | precision = 'double'; % precision of the real-valued data 5 | r0 = [0.,0.,0.]; % domain origin 6 | non_uniform_grid = true; 7 | % 8 | % read geometry file 9 | % 10 | geofile = "geometry.out"; 11 | data = dlmread(geofile); 12 | ng = data(1,:); 13 | l = data(2,:); 14 | dl = l./ng; 15 | % 16 | % read and generate grid 17 | % 18 | xp = linspace(r0(1)+dl(1)/2.,r0(1)+l(1),ng(1)); % centered x grid 19 | yp = linspace(r0(2)+dl(2)/2.,r0(2)+l(2),ng(2)); % centered y grid 20 | zp = linspace(r0(3)+dl(3)/2.,r0(3)+l(3),ng(3)); % centered z grid 21 | xu = xp + dl(1)/2.; % staggered x grid 22 | yv = yp + dl(2)/2.; % staggered y grid 23 | zw = zp + dl(3)/2.; % staggered z grid 24 | if(non_uniform_grid) 25 | f = fopen('grid.bin'); 26 | grid_z = fread(f,[ng(3),4],precision); 27 | fclose(f); 28 | zp = r0(3) + grid_z(:,3)'; % centered z grid 29 | zw = r0(3) + grid_z(:,4)'; % staggered z grid 30 | end 31 | % 32 | % read checkpoint binary file 33 | % 34 | filenamei = input("Name of the binary file written by CaNS (e.g. vex_fld_0000000.bin)]: ") 35 | if isempty(filenamei) 36 | end 37 | iskipx = input("Data saved every (ix, iy, iz) points. Value of ix? [1]: ") 38 | if isempty(iskipx) 39 | iskipx = 1 40 | end 41 | iskipy = input("Data saved every (ix, iy, iz) points. Value of iy? [1]: ") or "1" 42 | if isempty(iskipy) 43 | iskipy = 1 44 | end 45 | iskipz = input("Data saved every (ix, iy, iz) points. Value of iz? [1]: ") or "1" 46 | if isempty(iskipz) 47 | iskipz = 1 48 | end 49 | iskip = [iskipx,iskipy,iskipz] 50 | n = round(ng./iskip) 51 | data = zeros([n[0],n[1],n[2]]) 52 | f = fopen(filenamei); 53 | data(:,:,:) = reshape(fread(f,ng(1)*ng(2)*ng(3),precision),[ng(1),ng(2),ng(3)]); 54 | fclose(f); 55 | -------------------------------------------------------------------------------- /utils/read_binary_data/python/read_restart_file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def read_restart_file(filenamei): 3 | import numpy as np 4 | # 5 | # setting up some parameters 6 | # 7 | iprecision = 8 # precision of the real-valued data 8 | r0 = np.array([0.,0.,0.]) # domain origin 9 | non_uniform_grid = True 10 | precision = 'float64' 11 | if(iprecision == 4): precision = 'float32' 12 | # 13 | # read geometry file 14 | # 15 | geofile = "geometry.out" 16 | data = np.loadtxt(geofile, comments = "!", max_rows = 2) 17 | ng = data[0,:].astype('int') 18 | l = data[1,:] 19 | dl = l/(1.*ng) 20 | # 21 | # read and generate grid 22 | # 23 | xp = np.arange(r0[0]+dl[0]/2.,r0[0]+l[0],dl[0]) # centered x grid 24 | yp = np.arange(r0[1]+dl[1]/2.,r0[1]+l[1],dl[1]) # centered y grid 25 | zp = np.arange(r0[2]+dl[2]/2.,r0[2]+l[2],dl[2]) # centered z grid 26 | xu = xp + dl[0]/2. # staggered x grid 27 | yv = yp + dl[1]/2. # staggered y grid 28 | zw = zp + dl[2]/2. # staggered z grid 29 | if(non_uniform_grid): 30 | f = open('grid.bin','rb') 31 | grid_z = np.fromfile(f,dtype=precision) 32 | f.close() 33 | grid_z = np.reshape(grid_z,(ng[2],4),order='F') 34 | zp = r0[2] + grid_z[:,2] # centered z grid 35 | zw = r0[2] + grid_z[:,3] # staggered z grid 36 | # 37 | # read checkpoint binary file 38 | # 39 | offset = 0 40 | disp = np.prod(ng) 41 | data = np.zeros([ng[0],ng[1],ng[2],4]) # u[:,:,:],v[:,:,:],w[:,:,:],p[:,:,:] 42 | fldinfo = np.zeros([2]) 43 | with open(filenamei,'rb') as f: 44 | for p in range(4): 45 | f.seek(offset) 46 | fld = np.fromfile(f,dtype=precision,count=disp) 47 | data[:,:,:,p] = np.reshape(fld,(ng[0],ng[1],ng[2]),order='F') 48 | offset += iprecision*disp 49 | f.seek(offset) 50 | fldinfo[:] = np.fromfile(f,dtype=precision,count=2) 51 | f.close 52 | # 53 | # store data in arrays 54 | # 55 | u = data[:,:,:,0] 56 | v = data[:,:,:,1] 57 | w = data[:,:,:,2] 58 | p = data[:,:,:,3] 59 | time = fldinfo[0] 60 | istep = int(fldinfo[1]) 61 | return u,v,w,p,time,istep 62 | if __name__ == "__main__": 63 | filenamei = input("Name of the binary restart file written by CaNS [fld.bin]: ") or "fld.bin" 64 | read_restart_file(filenamei) 65 | -------------------------------------------------------------------------------- /utils/read_binary_data/python/read_single_field_binary.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | def read_single_field_binary(filenamei,iskip): 3 | import numpy as np 4 | # 5 | # setting up some parameters 6 | # 7 | iprecision = 8 # precision of the real-valued data 8 | r0 = np.array([0.,0.,0.]) # domain origin 9 | non_uniform_grid = True 10 | precision = 'float64' 11 | if(iprecision == 4): precision = 'float32' 12 | # 13 | # read geometry file 14 | # 15 | geofile = "geometry.out" 16 | geo = np.loadtxt(geofile, comments = "!", max_rows = 2) 17 | ng = geo[0,:].astype('int') 18 | l = geo[1,:] 19 | dl = l/(1.*ng) 20 | # 21 | # read and generate grid 22 | # 23 | xp = np.arange(r0[0]+dl[0]/2.,r0[0]+l[0],dl[0]) # centered x grid 24 | yp = np.arange(r0[1]+dl[1]/2.,r0[1]+l[1],dl[1]) # centered y grid 25 | zp = np.arange(r0[2]+dl[2]/2.,r0[2]+l[2],dl[2]) # centered z grid 26 | xu = xp + dl[0]/2. # staggered x grid 27 | yv = yp + dl[1]/2. # staggered y grid 28 | zw = zp + dl[2]/2. # staggered z grid 29 | if(non_uniform_grid): 30 | f = open('grid.bin','rb') 31 | grid_z = np.fromfile(f,dtype=precision) 32 | f.close() 33 | grid_z = np.reshape(grid_z,(ng[2],4),order='F') 34 | zp = r0[2] + np.transpose(grid_z[:,2]) # centered z grid 35 | zw = r0[2] + np.transpose(grid_z[:,3]) # staggered z grid 36 | # 37 | # read binary file 38 | # 39 | n = (ng[:]/iskip[:]).astype(int) 40 | data = np.zeros([n[0],n[1],n[2]]) 41 | fld = np.fromfile(filenamei,dtype=precision) 42 | data[:,:,:] = np.reshape(fld,(n[0],n[1],n[2]),order='F') 43 | # 44 | # reshape grid 45 | # 46 | xp = xp[0:ng[0]:iskip[0]] 47 | yp = yp[0:ng[1]:iskip[1]] 48 | zp = zp[0:ng[2]:iskip[2]] 49 | xu = xu[0:ng[0]:iskip[0]] 50 | yv = yv[0:ng[1]:iskip[1]] 51 | zw = zw[0:ng[2]:iskip[2]] 52 | return data,xp,yp,zp,xu,yv,zw 53 | if __name__ == "__main__": 54 | import numpy as np 55 | filenamei = input("Name of the binary file written by CaNS (e.g. vex_fld_0000000.bin)]: ") 56 | iskipx = input("Data saved every (ix, iy, iz) points. Value of ix? [1]: ") or "1" 57 | iskipy = input("Data saved every (ix, iy, iz) points. Value of iy? [1]: ") or "1" 58 | iskipz = input("Data saved every (ix, iy, iz) points. Value of iz? [1]: ") or "1" 59 | iskip = np.array([iskipx,iskipy,iskipz]).astype(int) 60 | read_single_field_binary(filenamei,iskip) 61 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_easy/write_xdmf_box.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import os 3 | # 4 | # define some custom parameters, not defined in the DNS code 5 | # 6 | iseek = 0 # number of bytes to skip relative to the origin of the binary file (0 for CaNS) 7 | iprecision = 8 # precision of real-valued data 8 | r0 = np.array([0.,0.,0.]) # domain origin 9 | non_uniform_grid = True 10 | # 11 | # define data type and 12 | # read saved data log 13 | # 14 | dtype_saves = np.dtype([ \ 15 | ('file' , 'U100'), ('variable', 'U100'), \ 16 | ('imin' , int) , ('jmin' , int), ('kmin' , int), \ 17 | ('imax' , int) , ('jmax' , int), ('kmax' , int), \ 18 | ('istep', int) , ('jstep', int), ('kstep', int), \ 19 | ('time' , float), ('isave', int) \ 20 | ]) 21 | geofile = "geometry.out" 22 | logfile = input("Name of the log file written by CaNS [log_visu_3d.out]: ") or "log_visu_3d.out" 23 | saves = np.loadtxt(logfile, dtype=dtype_saves) 24 | # 25 | # remove duplicates 26 | # 27 | saves = np.unique(saves) 28 | # 29 | # sort elements by increasing isave 30 | # 31 | saves = np.sort(saves, order='isave') 32 | # 33 | # harvest some information from the log file 34 | # 35 | nelements = saves.size 36 | nflds = 0 37 | isave = saves['isave'][0] 38 | while(isave == saves['isave'][nflds] and nflds < nelements-1): nflds += 1 39 | if(nflds == nelements-1): nflds += 1 40 | nsaves = int(nelements/nflds) 41 | # 42 | # retrieve some computational parameters 43 | # 44 | data = np.loadtxt(geofile, comments = "!", max_rows = 2) 45 | ng = data[0,:].astype('int') 46 | l = data[1,:] 47 | dl = l/(1.*ng) 48 | # 49 | # write xml file 50 | # 51 | from xml.etree import ElementTree 52 | from xml.dom import minidom 53 | from xml.etree.ElementTree import Element, SubElement, Comment 54 | Xdmf = Element("Xdmf", attrib = {"xmlns:xi": "http://www.w3.org/2001/XInclude", "Version": "2.0"}) 55 | domain = SubElement(Xdmf, "Domain") 56 | topology = SubElement(domain,"Topology", attrib = {"name": "TOPO", "TopologyType": "3DRectMesh", "Dimensions" : "{} {} {}".format(2, 2, 2)}) 57 | geometry = SubElement(domain,"Geometry", attrib = {"name": "GEO", "GeometryType": "ORIGIN_DXDYDZ"}) 58 | dataitem = SubElement(geometry, "DataItem", attrib = {"Format": "XML", "NumberType": "Float", "Dimensions": "{}".format(3)}) 59 | dataitem.text = "{:15.6E} {:15.6E} {:15.6E}".format(r0[0],r0[1],r0[2]) 60 | dataitem = SubElement(geometry, "DataItem", attrib = {"Format": "XML", "NumberType": "Float", "Dimensions": "{}".format(3)}) 61 | dataitem.text = "{:15.6E} {:15.6E} {:15.6E}".format(l[0],l[1],l[2]) 62 | grid = SubElement(domain, "Grid", attrib = {"Name": "TimeSeries", "GridType": "Collection", "CollectionType": "Temporal"}) 63 | time = SubElement(grid, "Time", attrib = {"TimeType":"List"}) 64 | dataitem = SubElement(time, "DataItem", attrib = {"Format": "XML", "NumberType": "Float", "Dimensions": "{}".format(nsaves)}) 65 | dataitem.text = "" 66 | for ii in range(nsaves): 67 | dataitem.text += "{:15.6E}".format(saves["time"][ii*nflds]) + " " 68 | for ii in range(nsaves): 69 | grid_fld = SubElement(grid,"Grid", attrib = {"Name": "T{:7}".format(str(saves['isave'][ii*nflds]).zfill(7)), "GridType": "Uniform"}) 70 | topology = SubElement(grid_fld, "Topology", attrib = {"Reference": "/Xdmf/Domain/Topology[1]"}) 71 | geometry = SubElement(grid_fld, "Geometry", attrib = {"Reference": "/Xdmf/Domain/Geometry[1]"}) 72 | output = ElementTree.tostring(Xdmf, 'utf-8') 73 | output = minidom.parseString(output) 74 | output = output.toprettyxml(indent=" ",newl='\n') 75 | # 76 | # write visualization file 77 | # 78 | outfile = input("Name of the output file [viewbox_DNS.xmf]: ") or "viewbox_DNS.xmf" 79 | xdmf_file = open(outfile, 'w') 80 | xdmf_file.write(output) 81 | xdmf_file.close 82 | # 83 | # workaround to add the DOCTYPE line 84 | # 85 | xdmf_file = open(outfile, "r") 86 | contents = xdmf_file.readlines() 87 | xdmf_file.close() 88 | contents.insert(1, '\n') 89 | xdmf_file = open(outfile, "w") 90 | contents = "".join(contents) 91 | xdmf_file.write(contents) 92 | xdmf_file.close() 93 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_non_uniform_grid/gen_grid.f90: -------------------------------------------------------------------------------- 1 | program gen_grid 2 | ! 3 | ! this program generates a the grid files to be read by the xdmf file 4 | ! the output file from CaNS 'grid.bin' must be on this folder 5 | ! 6 | ! Pedro Costa (p.simoes.costa@gmail.com) 7 | ! 8 | implicit none 9 | include 'param.h90' 10 | ! 11 | integer :: iunit,i,j,k,lenr 12 | real(8), dimension(nz) :: dummy,zc 13 | ! 14 | iunit = 99 15 | inquire (iolength=lenr) dummy(1) 16 | ! 17 | ! generate cell-centered grid in x (uniform) 18 | ! 19 | open(iunit,file='x.bin',access='direct',recl=nx*lenr) 20 | write(iunit,rec=1) ((i-0.5)*dx,i=1,nx) 21 | close(iunit) 22 | ! 23 | ! generate cell-centered grid in y (uniform) 24 | ! 25 | open(iunit,file='y.bin',access='direct',recl=ny*lenr) 26 | write(iunit,rec=1) ((j-0.5)*dy,j=1,ny) 27 | close(iunit) 28 | ! 29 | ! generate cell-centered grid in z (non-uniform) from file 'grid.bin' 30 | ! 31 | open(iunit,file='grid.bin',access='direct',recl=4*nz*lenr) 32 | read(iunit,rec=1) dummy(1:nz),dummy(1:nz),zc(1:nz),dummy(1:nz) 33 | close(iunit) 34 | open(iunit,file='z.bin',access='direct',recl=nz*lenr) 35 | write(iunit,rec=1) zc(1:nz) 36 | close(iunit) 37 | end program gen_grid 38 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_non_uniform_grid/genview.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # 1) generate grid files 4 | # 5 | gfortran gen_grid.f90 -o a.out && ./a.out && rm -rf a.out 6 | # 7 | # 2) generate xdmf file 8 | # 9 | gfortran gen_xdmf.f90 -o a.out && ./a.out && rm -rf a.out 10 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_non_uniform_grid/param.h90: -------------------------------------------------------------------------------- 1 | ! 2 | ! parameter file for gen_xdmf.f90 3 | ! Pedro Costa (p.simoes.costa@gmail.com) 4 | ! 5 | character (len=10), parameter :: casename = 'DNS' 6 | ! 7 | ! number and names of scalar fields; 8 | ! the number of entries in array scalname *must* 9 | ! be equal to nscal 10 | ! 11 | integer, parameter :: nscal = 4 12 | character (len=3), parameter, dimension(nscal) :: scalname = (/'vex','vey','vez','pre'/) 13 | ! 14 | ! number of grid points and domain dimensions 15 | ! 16 | integer, parameter :: nx = 64, & 17 | ny = 64, & 18 | nz = 64 19 | real(8), parameter :: lx = 3.0d0, & 20 | ly = 1.5d0, & 21 | lz = 1.0d0 22 | ! 23 | ! grid size and domain origin 24 | ! 25 | real(8), parameter :: dx = lx/(1.*nx), & 26 | dy = ly/(1.*ny), & 27 | dz = lz/(1.*nz) 28 | real(8), parameter :: x0 = dx/2.d0, & 29 | y0 = dy/2.d0, & 30 | z0 = dz/2.d0 31 | ! 32 | ! initial time and time step 33 | ! 34 | real(8), parameter :: t0 = 0.d0 35 | real(8), parameter :: dt = 0.01d0 36 | ! 37 | ! first field, last field and step size 38 | ! 39 | integer, parameter :: fldstart = 1000 , & 40 | fldend = 3000, & 41 | nskip = 1000 42 | ! 43 | ! to compare time evolution of a scalar to a certain 44 | ! fixed time instant: 45 | ! is_fldcmp = .true. 46 | ! fldcmp = #desired instant 47 | ! (e.g. the deformation of an interface compared to its 48 | ! the inital condition) 49 | ! 50 | logical, parameter :: is_fldcmp = .false. 51 | integer, parameter :: fldcmp = 0 52 | ! 53 | ! precision of input file (8 -- double; 4 -- single) 54 | ! 55 | integer, parameter :: iprec = 8 56 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_non_uniform_grid/readme.txt: -------------------------------------------------------------------------------- 1 | gen_xdmf.f90 generates a XDMF file for visualizing a time series 3D fields in a non-uniform regular Cartesian grid. Instructions on its usage can be found in the first lines of the .f90 file. 2 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_uniform_grid/genview.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # generate xdmf file 4 | # 5 | gfortran gen_xdmf.f90 -o a.out && ./a.out && rm -rf a.out 6 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_uniform_grid/param.h90: -------------------------------------------------------------------------------- 1 | ! 2 | ! parameter file for gen_xdmf.f90 3 | ! Pedro Costa (p.simoes.costa@gmail.com) 4 | ! 5 | character (len=10), parameter :: casename = 'DNS' 6 | ! 7 | ! number and names of scalar fields; 8 | ! the number of entries in array scalname *must* 9 | ! be equal to nscal 10 | ! 11 | integer, parameter :: nscal = 4 12 | character (len=3), parameter, dimension(nscal) :: scalname = (/'vex','vey','vez','pre'/) 13 | ! 14 | ! number of grid points and domain dimensions 15 | ! 16 | integer, parameter :: nx = 64, & 17 | ny = 64, & 18 | nz = 64 19 | real(8), parameter :: lx = 3.0d0, & 20 | ly = 1.5d0, & 21 | lz = 1.0d0 22 | ! 23 | ! grid size and domain origin 24 | ! 25 | real(8), parameter :: dx = lx/(1.*nx), & 26 | dy = ly/(1.*ny), & 27 | dz = lz/(1.*nz) 28 | real(8), parameter :: x0 = dx/2.d0, & 29 | y0 = dy/2.d0, & 30 | z0 = dz/2.d0 31 | ! 32 | ! initial time and time step 33 | ! 34 | real(8), parameter :: t0 = 0.d0 35 | real(8), parameter :: dt = 0.01d0 36 | ! 37 | ! first field, last field and step size 38 | ! 39 | integer, parameter :: fldstart = 1000 , & 40 | fldend = 3000, & 41 | nskip = 1000 42 | ! 43 | ! to compare time evolution of a scalar to a certain 44 | ! fixed time instant: 45 | ! is_fldcmp = .true. 46 | ! fldcmp = #desired instant 47 | ! (e.g. the deformation of an interface compared to its 48 | ! the inital condition) 49 | ! 50 | logical, parameter :: is_fldcmp = .false. 51 | integer, parameter :: fldcmp = 0 52 | ! 53 | ! precision of input file (8 -- double; 4 -- single) 54 | ! 55 | integer, parameter :: iprec = 8 56 | -------------------------------------------------------------------------------- /utils/visualize_fields/gen_xdmf_uniform_grid/readme.txt: -------------------------------------------------------------------------------- 1 | gen_xdmf.f90 generates a XDMF file for visualizing a time series 3D fields in a uniform Caresian grid. Instructions on its usage can be found in the first lines of the .f90 file. 2 | --------------------------------------------------------------------------------