Giter Club home page Giter Club logo

ntustcfdlab's Introduction

NTUSTCFD



!    y=1 ______________                                                                                 
!       /             /|       |  Author  : Zi-Hsuan Wei                                                 
!      /             / |       |  Version : 1.8                                                          
!     /____________ /  |       |  Web     : http://smetana.me.ntust.edu.tw/                              
!     |  |         |   |                                                        
!     |  |         |   |                                          
!     |  | x=y=z=0 |   |                                           
!     |  |_________|___|x=1                                        
!     |  /         |  /                                         
!     | /          | /                                        
!     |/___________|/                                         
!    z=1                                                  
!     

This code is a Fortran 3D flow using projection method with FVM. Navier Stokes equations are solved for velocity and pressure fields. The output data can be visualized with tecplot or paraview.

How to use?

The code being implemented in Fortran90, and Fortran being a compiled language, it requires a compiler such as mpiifort or mpif90.

1.main.f90

Simulation parameters to be defined in the main program 'main.f90'. Selecting the number of threads of OpenMP.


!------------------- OPENMP ------------------------!
nthreads = 4    
call omp_set_num_threads(nthreads)
!------------------- OPENMP ------------------------!

!-----------------Parameters for the simulation------------------!
   
omega                          = 1.5               ! Set value for SOR method

zeta                           = 1.e-4             ! zeta for solving pressure matrix

itmax                          = 3000              ! maximum for zeta in Gauss Seidel subroutines

zeta_vel                       = 1.e-10            ! convergence condition for velocity field

time                           = 0.0               ! initialize time of simulation
   
AOA1                           = 5.D0              ! initialize AOA of simulation
   
nstep                          = 100000            ! number of timesteps for the simulation
   
isto                           = 100               ! data stored every 'isto' steps
   
LES                            = 0                 ! the LES mode. 1 : on ; 0 : off
   
steadiness                     = 2                 ! steady : 1 ; unsteady : 2 
   
totalcosttime                  = 0                 ! initialize wall time
   
inputfile                      = '0000.Q'          !input first q file
   
StartDynamic                   = 1000000

NACA_filename                  = 'NACA0012.DAT'
   
!-----------------Parameters for the simulation------------------!

2.variables_module.f90

Numerical values for the non-uniform mesh size, Re number and what kind of B.Cs to be defined in the program 'variables_module.f90'.


real*8, parameter            :: Re           = 10.0
          
real*8, parameter            :: dt           = 1.0e-3
          
integer, parameter           :: nx           = 40
          
integer, parameter           :: ny           = 40
          
integer, parameter           :: nz           = 40 
          
real*8, parameter            :: lx           = 1.0
          
real*8, parameter            :: ly           = 1.0
          
real*8, parameter            :: lz           = 1.0

character(len=20)            :: Gridder      = 'uniform'  !non-uniform, uniform


!--------------------- Unequal grid ---------------------!

real*8, parameter            :: GridderXc        = 12.5
    
real*8, parameter            :: GridderYc        = 3.948
    
real*8, parameter            :: GridderZc        = 3.95
    
integer, parameter           :: nxSml            = 16
        
integer, parameter           :: nySml            = 100
    
integer, parameter           :: nyMid            = 150
    
integer, parameter           :: nzSml            = 200

integer, parameter           :: nzMid            = 300
    
real*8, parameter            :: lxSml            = 1.0
        
real*8, parameter            :: lySml            = 0.3
    
real*8, parameter            :: lyMid            = 0.6
    
real*8, parameter            :: lzSml            = 1.1

real*8, parameter            :: lzMid            = 2.0

real*8                       :: dySml, dyMid, dy

real*8                       :: dxSml, dx
    
real*8                       :: dzSml, dzMid, dz

!--------------------- Unequal grid ---------------------!


!----------------------------B.Cs---------------------------!

!    y=1 ______________                                                                                 
!       /             /|                                                     
!      /       N     / |                                                          
!     /____________ /  |                                
!     |  |         |   |                                                        
!     |  | B       |   |                                          
!   W |  | x=y=z=0 | E |                                           
!     |  |_________|___|x=1                                        
!     |  /         |  /                                         
!     | /     S    | /                                        
!     |/___________|/                                         
!    z=1 F     
!   Neumann     du/dn = 0
!   Dirichlet   u = 1
!   no-slip     u = 0

character(len=20)            :: WestWall_u         = 'no-slip'
character(len=20)            :: WestWall_v         = 'no-slip'
character(len=20)            :: WestWall_w         = 'no-slip'
    
character(len=20)            :: EastWall_u         = 'no-slip'
character(len=20)            :: EastWall_v         = 'no-slip'
character(len=20)            :: EastWall_w         = 'no-slip'
    
character(len=20)            :: SouthWall_u        = 'no-slip'
character(len=20)            :: SouthWall_v        = 'no-slip'
character(len=20)            :: SouthWall_w        = 'no-slip'
    
character(len=20)            :: NorthWall_u        = 'no-slip'
character(len=20)            :: NorthWall_v        = 'no-slip'
character(len=20)            :: NorthWall_w        = 'Dirichlet'
    
character(len=20)            :: BackWall_u         = 'no-slip'
character(len=20)            :: BackWall_v         = 'no-slip'
character(len=20)            :: BackWall_w         = 'no-slip'
    
character(len=20)            :: FrontWall_u        = 'no-slip'
character(len=20)            :: FrontWall_v        = 'no-slip'
character(len=20)            :: FrontWall_w        = 'no-slip'



!----------------------------B.Cs---------------------------!

3.Running the code

Use the Makefile to compile all the files and create the Executive file (sol0). Launch the Executive file (sol0) by command :


mpirun -np A ./sol0

where A is the number of processor

4.Output file

You will get different fields (.q) and mesh file (.x). After that, you need input q files and x file to tecplot or paraview.

5.clean data

Remove the q files and x file by command as :


make cleanall
or
make clean

6.Other informations

More details can be found in folder of introduction.

Mesh

Alt text

flapping airfoil

Alt text

The one-degree-of-freedom vortex-induced vibration (VIV) response of circular cylinder

Alt text

Cavity at Re = 1000

Alt text

Validation with cavity at Re = 1000

Alt text Alt text

ntustcfdlab's People

Contributors

hsuan221 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ntustcfdlab's Issues

Data race in solver parallelised reduction

In the file solver.f90 at lines 81 and 125 appears this block:

!$OMP PARALLEL DO 
do i=1,n; norm=norm+r(i)*r(i); end do
!$OMP END PARALLEL DO

There is a data race here as threads handling different iterations of the reduction loop are trying to update the same variable concurrently. In order to restore correctness, the OpenMP reduction clause can be used, it will ensure that each thread sum its r(i)*r(i) increments into a thread-local temporary variable. At the end of the loop, OpenMP will make those threads sum the final value of their thread-local temporary variable back into the original norm variable, taking care of potential data races in the process. The corrected block would look as follows:

!$OMP PARALLEL DO REDUCTION(+:norm)
do i=1,n; norm=norm+r(i)*r(i); end do
!$OMP END PARALLEL DO

There might be other blocks in a similar situation, for which the same fix applies, such as the one at line 113 in the same file solver.f90:

!$OMP PARALLEL DO 
do i=1,n; x(i)=x(i)+alpha*p(i)+omega*ss(i); end do
!$OMP END PARALLEL DO

You can refer to https://rookiehpc.github.io/openmp/docs/reduction/index.html for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.