Commit 57cec8a1 authored by Paul Stryck's avatar Paul Stryck
Browse files

exercise 4

parent b82b6615
<?xml version="1.0"?>
<controls>
<general>
<name>Periodic Channel Flow</name>
<caseid>CFD2 Tutorial</caseid>
</general>
<grids>
<grid name="grid">
<fromFile>
<gridFilePath>../grids</gridFilePath>
<gridFileName>high_rey</gridFileName>
<!-- <gridFileName>low_rey</gridFileName>-->
</fromFile>
</grid>
</grids>
<restart>
<restart>false</restart>
</restart>
<timeLoop>
<unsteady>false</unsteady>
<maxTimesteps>1</maxTimesteps>
<timeDelta>1</timeDelta>
</timeLoop>
<outerLoop>
<maxIteration>30000</maxIteration>
<divergenceTolerance>1.5e+26</divergenceTolerance>
<convergenceTolerance>0.5e-16</convergenceTolerance>
</outerLoop>
<equations>
<equation name="mome">
<EQMomentum>
<solve_x>true</solve_x>
<solve_y>true</solve_y>
<solve_z>false</solve_z>
<convectiveFluxDiscretisation>
<UD1_CD_BLEND>
<blendingFactor>0.7</blendingFactor>
</UD1_CD_BLEND>
</convectiveFluxDiscretisation>
<gradientCalculation>
<LEASTSQUARE/>
</gradientCalculation>
<relaxationFactor>0.5</relaxationFactor>
</EQMomentum>
</equation>
<equation name="pres">
<EQPressure>
<pressureReferencePosition>0.05 0.05 0.05</pressureReferencePosition>
<pressureReference>1.e5</pressureReference>
<maxIteration>2000</maxIteration>
<gradientCalculation>
<GAUSS>
<gradientLoops>2</gradientLoops>
</GAUSS>
</gradientCalculation>
</EQPressure>
</equation>
<equation name="turb">
<EQTurbulence>
<turbulenceModel>KOMEGA_STANDARD</turbulenceModel>
<!-- <turbulenceModel>KEPSILON_STANDARD</turbulenceModel>-->
<!--turbulenceModel>KOMEGA_MSST</turbulenceModel-->
</EQTurbulence>
</equation>
<equation>
<EQWallDistance>
<calculationMethod>GEOMETRIC</calculationMethod>
</EQWallDistance>
</equation>
</equations>
<bodyForces/>
<monitors/>
<developer>
</developer>
<output>
<event name="default">
<forceGridWrite>true</forceGridWrite>
</event>
</output>
<materials>
<backgroundMaterial>Air</backgroundMaterial>
<material>
<materialEntry name="Air">
<fluid>
<viscosityMolecular>1.8e-5</viscosityMolecular>
<density>1.2</density>
</fluid>
</materialEntry>
</material>
</materials>
<initial>
<velocity userCode="false">44.2 0. 0.</velocity>
<pressure userCode="false">1.0e5</pressure>
<temperature userCode="false">293.0</temperature>
</initial>
<boundaries>
<family name="INLET">
<BCVelocity>
<velocity userCode="false">44.2 0.0 0.0</velocity>
<!-- <komega userCode="true">0.0</velocity>-->
</BCVelocity>
</family>
<family name="OUTLET">
<BCOutflow/>
</family>
<family name="YMIN">
<BCWall>
<useWallFunction>HIGH_RN</useWallFunction>
<!-- <useWallFunction>LOW_RN</useWallFunction>-->
</BCWall>
</family>
<family name="YMAX">
<BCWall>
<useWallFunction>HIGH_RN</useWallFunction>
<!-- <useWallFunction>LOW_RN</useWallFunction>-->
</BCWall>
</family>
<family name="ZMIN">
<BCSymmetryPlane/>
</family>
<family name="ZMAX">
<BCSymmetryPlane/>
</family>
</boundaries>
</controls>
!***********************************************************************
!
! Hamburg Ship Model Basin (HSVA)
! TU Hamburg-Harburg (TUHH)
! Maritime Research Institute of Netherlands (MARIN)
!
! FreSCo
!
! $Id: post.F90 21 2005-06-08 12:50:20Z dieke $
!
! (c) 2004-2001 HSVA,TUHH
! Proprietary data. Unauthorized use, distribution,
! or duplication is prohibited. All rights reserved.
!
!***********************************************************************
!
!! module post
! this module can be used to set up special post-processing routines. Use
! -post_outit to modyfy values in each outer iteration
! -post_timestep to modyfy values in each timesteo
! -post_final to set values after the solution
! algorithm is finished or stopped
!
!***********************************************************************
MODULE post
USE common_user_code
USE controls
USE equations
USE fielddata
USE fielddata_tools
USE fielddata_pointers
USE forces
USE geometry
USE logging
USE math
USE movegrid
USE parameters
USE topology
USE tracing
USE grids
USE parallel
USE counters
USE files
IMPLICIT NONE
PRIVATE
PUBLIC post_init_set_initial_fields_6,&
post_init_setup_lists_3,&
post_init_register_fields_4,&
post_init_after_grid_resize_5,&
post_timestep,&
post_outit,&
post_adoutit,&
post_final,&
post_exit_default_1
CONTAINS
!======================================================================
SUBROUTINE post_init_set_initial_fields_6
!=====================================================================
! use this to set initital values. To resolve dependencies between
! several *_inital modules this is called several times. Thus
! do not put ALLOCATE statements here.
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_post_init_set_initial_fields_6)
!! register the files for the output for example:
!! OPEN(1193, file='inlet.dat')
CALL tracing_trace_end(trace_post_init_set_initial_fields_6)
END SUBROUTINE post_init_set_initial_fields_6
!======================================================================
SUBROUTINE post_init_setup_lists_3
!======================================================================
! use this routine to set up linked lists, to get sizes or to allocate fields
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_post_init_setup_lists_3)
CALL tracing_trace_end(trace_post_init_setup_lists_3)
END SUBROUTINE post_init_setup_lists_3
!======================================================================
SUBROUTINE post_init_register_fields_4
!=====================================================================
! use *_init_register_fields_4 module for fielddata_init_register_fields_4,
! equation_system_register_equation_system ... statements
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_post_init_register_fields_4)
CALL tracing_trace_end(trace_post_init_register_fields_4)
END SUBROUTINE post_init_register_fields_4
!======================================================================
SUBROUTINE post_init_after_grid_resize_5
!=====================================================================
! use *_init_after_grid_resize_5 module for all *_get_pointer statements
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_post_init_after_grid_resize_5)
CALL tracing_trace_end(trace_post_init_after_grid_resize_5)
END SUBROUTINE post_init_after_grid_resize_5
!======================================================================
SUBROUTINE post_timestep(timestep,simultime)
!======================================================================
! this routine is executed after each timestep
!----------------------------------------------------------------------
IMPLICIT NONE
INTEGER :: timestep
REAL(dp) :: simultime
CALL tracing_trace_begin(trace_post_timestep)
CALL tracing_trace_end(trace_post_timestep)
END SUBROUTINE post_timestep
!======================================================================
SUBROUTINE post_outit(out_iter)
!======================================================================
! this routine is executed after each outer iteration
!----------------------------------------------------------------------
IMPLICIT NONE
INTEGER :: out_iter,i
CALL tracing_trace_begin(trace_post_outit)
CALL tracing_trace_end(trace_post_outit)
END SUBROUTINE post_outit
!======================================================================
SUBROUTINE post_adoutit(adout_iter)
!======================================================================
! this routine is executed after each adjoint outer iteration
!----------------------------------------------------------------------
IMPLICIT NONE
INTEGER :: adout_iter
CALL tracing_trace_begin(trace_post_adoutit)
CALL tracing_trace_end(trace_post_adoutit)
END SUBROUTINE post_adoutit
!======================================================================
SUBROUTINE post_final
!======================================================================
! this routine is executed only once after the computation has stopped
! due to max no of iteration, truncation error or stopfile. It is not
! executed when killfile is used
!----------------------------------------------------------------------
INTEGER :: iCell,iface
REAL(dp) :: eps, u_p, u_t, y_p
CALL tracing_trace_begin(trace_post_final)
eps = 10e-5
OPEN (unit = 0001, file = "VOutletNoDim.dat")
OPEN (unit = 0002, file = "VOutlet.dat")
WRITE(0001,*) '# y, U_p, Y_p'
WRITE(0002,*) '# y, U_x, U_t'
DO iface = nIntFaces+1, nIntFaces+nBndFaces
IF (family_f(iface) == topology_get_ifamily(trim('YMIN'))) THEN
icell = cell2_f(iface)
if (abs( cent_c_3(icell,1)-4.5) < eps) THEN
u_t=sqrt(shearstress_c_3(cell2_f(iface),1)/rho_c(icell))
END IF
END IF
END DO
!! calculation and Saving of the u+- and y+ values @channel center
DO icell = 1, nIntcells
if (abs( cent_c_3(icell,1)-4.5) < eps) THEN
u_p= v_c_3(icell,1)/u_t
y_p= cent_c_3(icell,2)*u_t/ 1.8e-5 * rho_c(icell)
WRITE(0001,*) cent_c_3(icell,2), u_p , y_p
WRITE(0002,*) cent_c_3(icell,2), v_c_3(icell,1), u_t
END IF
ENDDO
CALL tracing_trace_end(trace_post_final)
END SUBROUTINE post_final
!======================================================================
SUBROUTINE post_exit_default_1
!=====================================================================
! use *_exit_default_1 module for DEALLOCATE statements etc.
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_post_exit_default_1)
!! if you are using files, close them here
CALL tracing_trace_end(trace_post_exit_default_1)
END SUBROUTINE post_exit_default_1
END MODULE post
!***********************************************************************
!
! Hamburg Ship Model Basin (HSVA)
! TU Hamburg-Harburg (TUHH)
! Maritime Research Institute of Netherlands (MARIN)
!
! FreSCo
!
! $Id: set_phi.F90 21 2005-06-08 12:50:20Z dieke $
!
! (c) 2004-2016 HSVA,TUHH
! Proprietary data. Unauthorized use, distribution,
! or duplication is prohibited. All rights reserved.
!
!***********************************************************************
!
!! module set_phi
! this module can be used to set user defined values. Use
! -set_phi_initial to set values before the solution
! algorithm starts
! -set_phi_outit to modify values in each outer iteration
! -set_phi_timestep to modify values in each timestep
!
!***********************************************************************
MODULE set_phi
USE controls
USE equations
USE fielddata
USE fielddata_pointers
USE fielddata_tools
USE forces
USE geometry
USE logging
USE math
USE movegrid
USE parameters
USE topology
USE tracing
USE common_user_code
USE grids
USE parallel
IMPLICIT NONE
PRIVATE
PUBLIC set_phi_init_set_initial_fields_6_900,&
set_phi_init_setup_lists_3,&
set_phi_init_register_fields_4,&
set_phi_init_after_grid_resize_5,&
set_phi_timestep,&
set_phi_outit,&
set_phi_adoutit,&
set_phi_final,&
set_phi_exit_default_1
CONTAINS
!======================================================================
SUBROUTINE set_phi_init_set_initial_fields_6_900
!=====================================================================
! use this to set initital values. To resolve dependencies between
! several *_inital modules this is called several times. Thus
! do not put ALLOCATE statements here.
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_set_phi_init_set_initial_fields_6_900)
CALL tracing_trace_end(trace_set_phi_init_set_initial_fields_6_900)
END SUBROUTINE set_phi_init_set_initial_fields_6_900
!======================================================================
SUBROUTINE set_phi_init_setup_lists_3
!======================================================================
! use this routine to set up linked lists, to get sizes or to allocate fields
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_set_phi_init_setup_lists_3)
CALL tracing_trace_end(trace_set_phi_init_setup_lists_3)
END SUBROUTINE set_phi_init_setup_lists_3
!======================================================================
SUBROUTINE set_phi_init_register_fields_4
!=====================================================================
! use *_init_register_fields_4 module for fielddata_init_register_fields_4,
! equation_system_register_equation_system ... statements
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_set_phi_init_register_fields_4)
CALL tracing_trace_end(trace_set_phi_init_register_fields_4)
END SUBROUTINE set_phi_init_register_fields_4
!======================================================================
SUBROUTINE set_phi_init_after_grid_resize_5
!=====================================================================
! use *_init_after_grid_resize_5 module for all *_get_pointer statements
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_set_phi_init_after_grid_resize_5)
CALL tracing_trace_end(trace_set_phi_init_after_grid_resize_5)
END SUBROUTINE set_phi_init_after_grid_resize_5
!======================================================================
SUBROUTINE set_phi_timestep(timestep,simultime)
!======================================================================
! this routine is executed after each timestep
!----------------------------------------------------------------------
IMPLICIT NONE
INTEGER :: timestep
REAL(dp) :: simultime
CALL tracing_trace_begin(trace_set_phi_timestep)
CALL tracing_trace_end(trace_set_phi_timestep)
END SUBROUTINE set_phi_timestep
!======================================================================
SUBROUTINE set_phi_outit(out_iter)
!======================================================================
! this routine is executed after each outer iteration
!----------------------------------------------------------------------
IMPLICIT NONE
INTEGER :: out_iter
INTEGER :: icell, iface
INTEGER :: i
REAL(dp) :: v_ref, correction
REAL(dp) :: area, vol_out, vol_in
REAL(dp), DIMENSION(78,2) :: v_out
REAL(dp), DIMENSION(78) :: nk_c, nomega_c, neps_c
! REAL(dp), DIMENSION(39,2) :: v_out
! REAL(dp) :: H, v_in1, v_ref
! REAL(dp), DIMENSION(:), ALLOCATABLE, SAVE :: v_out, v_in
CALL tracing_trace_begin(trace_set_phi_outit)
v_ref = 44.2
vol_out = 0.0d0
vol_in = 0.0d0
v_out(:,:) = 0.0d0
area = 0.0d0
i = 1
! H = 1.d0
! v_in1 = v_ref * H
DO iface = nIntFaces + 1, nIntFaces + nBndFaces
IF (family_f(iface) == topology_get_ifamily(trim('OUTLET'))) THEN
! Iterate all OUTLET Boundary faces
icell = cell2_f(iface)
! get velocity in x direction
v_out(i,1) = v_c_3(icell, 1)
! get velocity in y direction
v_out(i,2) = v_c_3(icell, 2)
! Turbulence model values
nk_c(i) = k_c(icell)
nomega_c(i) = omega_c(icell)
neps_c(i) = eps_c(icell)
i = i + 1
! Calculate Volume Flux
vol_out = vol_out + v_c_3(icell, 1) * surf_f(iface)
area = area + surf_f(iface)
END IF
END DO
vol_in = v_ref * area
correction = vol_in / vol_out
i = 1
DO iface = nIntFaces + 1, nIntFaces + nBndFaces
IF (family_f(iface) == topology_get_ifamily(trim('INLET'))) THEN
! Iterate all INLET Boundary faces
icell = cell2_f(iface)
v_c_3(icell, 1) = v_out(i,1) * correction
k_c(icell) = nk_c(i)
omega_c(icell) = nomega_c(i)
eps_c(icell) = neps_c(i)
v_c_3(icell, 2) = v_out(i,2) !* correction
i = i + 1
END IF
END DO
!
!!
!! 1- calculation of the mass flux at the beginning of the calculation
!!
!! 2- calculation of the mass flux at the outlet at each timestep
!!
!! 3- Save the velocities at the outlet in a temporary field
!!
!! 4- insert the old velocities from the outlet at the inlet corrected with the ratio of the mass fluxes
!!
!!
CALL tracing_trace_end(trace_set_phi_outit)
END SUBROUTINE set_phi_outit
!======================================================================
SUBROUTINE set_phi_adoutit(adout_iter)
!======================================================================
! this routine is executed after each adjoint outer iteration
!----------------------------------------------------------------------
IMPLICIT NONE
INTEGER :: adout_iter
CALL tracing_trace_begin(trace_set_phi_adoutit)
CALL tracing_trace_end(trace_set_phi_adoutit)
END SUBROUTINE set_phi_adoutit
!======================================================================
SUBROUTINE set_phi_final
!======================================================================
! this routine is executed only once after the computation has stopped
! due to max no of iteration, truncation error or stopfile. It is not
! executed when killfile is used
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_set_phi_final)
CALL tracing_trace_end(trace_set_phi_final)
END SUBROUTINE set_phi_final
!======================================================================
SUBROUTINE set_phi_exit_default_1
!=====================================================================
! use *_exit_default_1 module for DEALLOCATE statements etc.
!----------------------------------------------------------------------
CALL tracing_trace_begin(trace_set_phi_exit_default_1)
CALL tracing_trace_end(trace_set_phi_exit_default_1)
END SUBROUTINE set_phi_exit_default_1
END MODULE set_phi
<?xml version="1.0"?>
<controls>
<general>
<name>Periodic Channel Flow</name>
<caseid>CFD2 Tutorial</caseid>
</general>
<grids>
<grid name="grid">
<fromFile>
<gridFilePath>../grids</gridFilePath>
<gridFileName>high_rey</gridFileName>
<!-- <gridFileName>low_rey</gridFileName>-->
</fromFile>
</grid>
</grids>
<restart>
<restart>false</restart>