47 use,
intrinsic:: iso_fortran_env, only: stdout => output_unit, stderr => error_unit
58 real(R8P):: rtol = 0.0001_r8p
59 integer(I4P):: nout = 1000_i4p
60 character(3):: oform =
"tec"
80 integer,
intent(OUT),
optional:: free_unit
90 if ((n1/=stdout).AND.(n1/=stderr))
then
91 inquire (unit=n1,opened=lopen,iostat=ios)
116 write(stdout,
'(A)')
' DCS'
117 write(stdout,
'(A)')
' Driven-Cavity Simulator code'
118 write(stdout,
'(A)')
' Usage:'
119 write(stdout,
'(A)')
' ./DCS -N number_of_cells [optionals parameters]'
121 write(stdout,
'(A)')
' Optional parameters:'
122 write(stdout,
'(A)')
' -Re Reynolds_number => default 500'
123 write(stdout,
'(A)')
' -beta over_relaxation_parameter => default 0.6'
124 write(stdout,
'(A)')
' -rtol residual_tolerance => default 10^-4'
125 write(stdout,
'(A)')
' -nout standard_output_update_frequency => default 1000 iterations'
126 write(stdout,
'(A)')
' -oform output_file_format => "tec" for Tecplot output or "gnu" for gnuplot one, default "tec"'
128 write(stdout,
'(A)')
' Example: '
129 write(stdout,
'(A)')
' ./DCS -Re 9.d2 -beta 0.5d0 -N 256 -nout 10000 -rtol 1.d-6'
142 integer(I4P):: nca = 0
144 character(6):: ca_switch
145 character(100):: sbuf
153 nca = command_argument_count()
155 write(stderr,
'(A)')
' Error: no argument has been passed to command line'
163 call get_command_argument(c, ca_switch)
164 select case(adjustl(trim(ca_switch)))
166 call get_command_argument(c+1,sbuf) ; c = c + 1
169 call get_command_argument(c+1,sbuf) ; c = c + 1
172 call get_command_argument(c+1,sbuf) ; c = c + 1
175 call get_command_argument(c+1,sbuf) ; c = c + 1
178 call get_command_argument(c+1,sbuf) ; c = c + 1
181 call get_command_argument(c+1,oform) ; c = c + 1
183 write(stderr,
'(A)')
' Error: switch "'//adjustl(trim(ca_switch))//
'" is unknown'
190 write(stderr,
'(A)')
' Error: the number of cells N must be passed as command line argument'
194 write(stdout,
'(A)')
' Some information about the precision of runnig machine'
197 write(stdout,
'(A)')
' Simulation parameters'
198 write(stdout,
'(A)')
' Re='//trim(
str(n=re))
199 write(stdout,
'(A)')
' beta='//trim(
str(n=beta))
200 write(stdout,
'(A)')
' N='//trim(
str(n=n))
201 write(stdout,
'(A)')
' rtol='//trim(
str(n=rtol))
202 write(stdout,
'(A)')
' nout='//trim(
str(n=nout))
203 write(stdout,
'(A)')
' oform='//trim(oform)
206 call cavity%initialize(re=re,beta=beta,n=n)
216 integer(I4P):: n = 0_i4p
222 sor:
do while(((residual%s>rtol).AND.(residual%v>rtol)))
226 call
computestream(cons=cavity%cons,beta=cavity%beta,dh=cavity%mesh%dh)
228 call
computevorticity(cons=cavity%cons,re=cavity%Re,beta=cavity%beta,dh=cavity%mesh%dh)
230 residual =
computeresidual(cons=cavity%cons,re=cavity%Re,dh=cavity%mesh%dh)
231 if (mod(n,nout)==0)
then
232 write(stdout,
'(A)')
' iteration n='//trim(
str(n=n))//&
233 ' residuals: s='//trim(
str(n=residual%s))//
' v='//trim(
str(n=residual%v))
236 write(stdout,
'(A)')
' Convergence achieved n='//trim(
str(n=n))
251 select case(trim(oform))
254 open(unit=
get_unit(u),file=
'DCS_out.tec')
255 write(u,
'(A)')
'VARIABLES="x" "y" "s" "v"'
256 write(u,
'(A)')
'ZONE T="Driven Cavity" I='//trim(
str(n=cavity%mesh%N+1))//
' J='//trim(
str(n=cavity%mesh%N+1))
259 write(u,
'(A)')trim(
str(n=cavity%mesh%x(i)))//
' '//trim(
str(n=cavity%mesh%y(j)))//
' '//&
260 trim(
str(n=cavity%cons(i,j)%s))//
' '//trim(
str(n=cavity%cons(i,j)%v))
266 open(unit=
get_unit(u),file=
'DCS_out.gnu')
269 write(u,
'(A)')trim(
str(n=cavity%mesh%x(i)))//
' '//trim(
str(n=cavity%mesh%y(j)))//
' '//&
270 trim(
str(n=cavity%cons(i,j)%s))//
' '//trim(
str(n=cavity%cons(i,j)%v))
subroutine dcs_simulate()
Subroutine for simulating drive cavity problems.
pure type(type_conservative) function, public computeresidual(cons, Re, dh)
Function for computing residuals.
subroutine print_usage()
Subroutine for printing to stdout the correct usage of the code.
This module contains the definition of Type_Cavity and its procedures.
Derived type containing conservative variables.
pure subroutine, public computevorticity(cons, Re, beta, dh)
Subroutine for computing new (n+1) vorticity.
pure subroutine, public computestream(cons, beta, dh)
Subroutine for computing new (n+1) stream function.
Procedure for converting number, real and integer, to string (number to string type casting); logical...
integer function get_unit(Free_Unit)
The Get_Unit function returns a free logic unit for opening a file.
program dcs
DCS is an Open source program for simulating driven cavity problems.
subroutine dcs_initialize()
Subroutine for initializing the simulation according to the input options.
subroutine dcs_finalize()
Subroutine for finalizing the simulation.
subroutine, public ir_print(myrank, Nproc)
Subroutine for printing to the standard output the kind definition of reals and integers and the util...
real(r8p), parameter, public maxr8p
Min and max values of kind=R8P variable.
This module contains the definition of Type_Conservative and its procedures.
Derived type containing conservative variables.
Module IR_Precision makes available some portable kind-parameters and some useful procedures to deal ...