Solver: CDIFS
Description: A sphere settling in a quiscent flow
References: Dave, H., Herrmann, M. & Kasbaoui, M. H. The volume-filtering immersed boundary method. Journal of Computational Physics 487, 112136 (2023).
| Type | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|
| type(block_obj) | :: | block |
Block object manages the Cartesian grid |
|||
| type(parallel_obj) | :: | parallel |
Utility that handles parallel (MPI) functions |
|||
| type(parser_obj) | :: | parser |
Utility that parses input files |
Defines boundary conditions.
Builds and writes block file.
Builds and writes initial flow fields.
Builds and writes resolved particles.
program main !>-------------------------------------------------------------------------- ! Program: Settling sphere ! Author: Mohamed Houssem Kasbaoui ! ! Solver: CDIFS ! ! Description: A sphere settling in a quiscent flow ! ! References: ! Dave, H., Herrmann, M. & Kasbaoui, M. H. The volume-filtering immersed ! boundary method. Journal of Computational Physics 487, 112136 (2023). ! -------------------------------------------------------------------------- use leapKinds use leapParser use leapParallel use leapBlock use leapEulerian implicit none type(parallel_obj) :: parallel !! Utility that handles parallel (MPI) functions type(parser_obj) :: parser !! Utility that parses input files type(block_obj) :: block !! Block object manages the Cartesian grid ! Initialize parser call parser%Initialize() ! Parse input file call parser%ParseFile() ! Initialize parallel environment call parallel%Initialize() ! Set the block info call SetUpCaseBlock() ! Set the initial fields call SetUpCaseFields() ! Set resolved particles call SetUpCaseResPart() ! Set boundary conditions call SetUpCaseBCS() ! Free up data call block%Finalize() call parser%Finalize() call parallel%Finalize() contains subroutine SetUpCaseBlock() !> Builds and writes block file. implicit none ! Work variables character(str64) :: filename real(wp) :: L(3) integer :: N(3) integer :: ngc integer :: Nb(3) real(wp) :: xlo(3) real(wp) :: xhi(3) integer :: ilo(3) integer :: ihi(3) ! Get info from parser call parser%Get("Block file", filename) call parser%Get("Domain size", L ) call parser%Get("Grid points", N ) call parser%Get("Ghost cells", ngc ) call parser%Get("Partition", Nb ) ! Domain extents xlo=-0.5_wp*L ; xhi= 0.5_wp*L ilo=[1,1,1] ; ihi=N ! Initialize the main block call block%Initialize(ngc,parallel) ! Setup the domain periodicity call block%SetPeriodicity([.false.,.true.,.false.]) ! Create a uniform block call block%SetupUniformGrid(xlo,xhi,ilo,ihi) ! Partition block for parallel initializations call block%Partition(Nb) ! Write block to disk call block%Write(filename) return end subroutine SetUpCaseBlock subroutine SetUpCaseFields() !> Builds and writes initial flow fields. implicit none ! Work variables type(Eulerian_set) :: fields type(eulerian_obj_r) :: V(3) type(eulerian_obj_r) :: P character(str64) :: filename ! Get info from parser call parser%Get("Fields IC file", filename) ! Initialize fields container call fields%Initialize(block,parallel) ! Add fields to container (this will allocate data) call fields%Add('V1', 1, V(1)) call fields%Add('V2', 2, V(2)) call fields%Add('V3', 3, V(3)) call fields%Add('P', 0, P ) V(1) = 0.0_wp V(2) = 0.0_wp V(3) = 0.0_wp P = 0.0_wp ! Write data to disk call fields%SetWriteFileName(filename) call fields%Write(0,0.0_wp) ! Clear data call fields%Finalize() return end subroutine SetUpCaseFields subroutine SetUpCaseResPart() !> Builds and writes resolved particles. use particles_resolved implicit none ! Work variables type(ResPart_set) :: RP character(str64) :: filename real(wp) :: diam real(wp) :: rhop real(wp) :: dl integer :: n call parser%Get('RP IC file', filename ) call parser%Get("Particle diameter", diam ) call parser%Get("Particle density", rhop ) ! Initialze resolved particles call RP%Initialize('ResPart',block,parallel) if (parallel%RankIsRoot()) then ! Activate only 1 particle on this Rank call RP%Resize(1) ! IB resolution dl=0.5_wp*minval(block%dx) select type(particle => RP%p) type is (ResPart_obj) do n=1,1 ! Particle globabl ID particle(n)%id = int(n,kind=8) ! Diameter particle(n)%d = diam ! Position particle(n)%p(1) = 0.0_wp particle(n)%p(2) = block%pmax(2) - 2.0_wp*diam particle(n)%p(3) = 0.0_wp ! Velocity particle(n)%v = 0.0_wp ! Angular velocity particle(n)%w = 0.0_wp ! Density particle(n)%rho = rhop ! Zero force and torque particle(n)%Fh = 0.0_wp particle(n)%Th = 0.0_wp particle(n)%Fc = 0.0_wp particle(n)%Tc = 0.0_wp ! Add surface markers call RP%ib%AddSphere(particle(n)%p,particle(n)%d/2.0_wp,particle(n)%v,dl,particle(n)%id) end do end select end if ! Treatment for periodicity call RP%ApplyPeriodicity call RP%ib%ApplyPeriodicity ! Send to the right rank call RP%Communicate call RP%ib%Communicate ! Localize centers and markers on grid call RP%Localize call RP%ib%Localize ! Write data to disk call RP%SetWriteFileName(filename) call RP%Write(0,0.0_WP) ! Finalize call RP%Finalize end subroutine SetUpCaseResPart subroutine SetUpCaseBCS() !> Defines boundary conditions. use leapBC implicit none ! Work variables type(bc_set) :: bcs real(wp) :: xhi(3),xlo(3) real(wp), pointer :: BCVal(:,:,:) ! Initialize utility that handles boundary conditions call bcs%Initialize(block,parallel) ! Setup regions where boundary conditions apply associate (pmin => block%pmin, pmax => block%pmax) xlo = [pmin(1),pmin(2),pmin(3)] xhi = [pmin(1),pmax(2),pmax(3)] call bcs%Add('xL', xlo, xhi, normal = '+x1') xlo = [pmax(1),pmin(2),pmin(3)] xhi = [pmax(1),pmax(2),pmax(3)] call bcs%Add('xR', xlo, xhi, normal = '-x1') xlo = [pmin(1),pmin(2),pmax(3)] xhi = [pmax(1),pmax(2),pmax(3)] call bcs%Add('zR', xlo, xhi, normal = '-x3') xlo = [pmin(1),pmin(2),pmin(3)] xhi = [pmax(1),pmax(2),pmin(3)] call bcs%Add('zL', xlo, xhi, normal = '+x3') end associate call bcs%SetBC('xL', BC_OUTFLOW) call bcs%SetBC('xR', BC_OUTFLOW) call bcs%SetBC('zL', BC_OUTFLOW) call bcs%SetBC('zR', BC_OUTFLOW) call bcs%SetBC('xL', BC_DIRICHLET,'ibVF') call bcs%SetBC('xR', BC_DIRICHLET,'ibVF') call bcs%SetBC('zL', BC_DIRICHLET,'ibVF') call bcs%SetBC('zR', BC_DIRICHLET,'ibVF') call bcs%GetBCPointer('xL','ibVF',BCVal); BCVal=0.0_wp call bcs%GetBCPointer('xR','ibVF',BCVal); BCVal=0.0_wp call bcs%GetBCPointer('zL','ibVF',BCVal); BCVal=0.0_wp call bcs%GetBCPointer('zR','ibVF',BCVal); BCVal=0.0_wp ! Write boundary conditions call bcs%Write(0,0.0_wp) ! Clear data call bcs%Finalize() return end subroutine SetUpCaseBCS end program main