My Project
programmer's documentation
Examples of boundary conditions ale

Local variables

! Local variables
integer ifac, iel, ii
integer inod
integer ilelt, nlelt
double precision delta, deltaa
integer, allocatable, dimension(:) :: lstelt

Initialization and finalization

The following initialization block needs to be added for the following examples:

! Allocate a temporary array for boundary faces selection
allocate(lstelt(nfabor))

At the end of the subroutine, it is recommended to deallocate the work array:

! Deallocate the temporary array
deallocate(lstelt)

In theory Fortran 95 deallocates locally-allocated arrays automatically, but deallocating arrays in a symetric manner to their allocation is good pratice, and avoids using a different logic C and Fortran.

Assign boundary conditions to boundary faces

One may use selection criteria to filter boundary case subsets.
Loop on faces from a subset.
Set the boundary condition for each face.

Calculation of displacement at current time step

deltaa = sin(3.141596d0*(ntcabs-1)/50.d0)
delta = sin(3.141596d0*ntcabs/50.d0)

Example 1

Example : For boundary faces of color 4 assign a fixed velocity

call getfbr('4', nlelt, lstelt)
!==========
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
! Element adjacent a la face de bord
iel = ifabor(ifac)
ialtyb(ifac) = ivimpo
rcodcl(ifac,iuma,1) = 0.d0
rcodcl(ifac,ivma,1) = 0.d0
rcodcl(ifac,iwma,1) = (delta-deltaa)/dt(iel)
enddo

Example 2

Example: For boundary face of color 5 assign a fixed displacement on nodes

call getfbr('5', nlelt, lstelt)
!==========
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
do ii = ipnfbr(ifac), ipnfbr(ifac+1)-1
inod = nodfbr(ii)
if (impale(inod).eq.0) then
disale(1,inod) = 0.d0
disale(2,inod) = 0.d0
disale(3,inod) = delta
impale(inod) = 1
endif
enddo
enddo

Example 3

Example : For boundary faces of color 6 assign a sliding boundary

call getfbr('6', nlelt, lstelt)
!==========
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
ialtyb(ifac) = igliss
enddo

Example 4

Example : Prescribe elsewhere a fixed boundary

call getfbr('not (4 or 5 or 6)', nlelt, lstelt)
!==========
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
ialtyb(ifac) = ibfixe
enddo
getfbr
subroutine getfbr(fstr, facnb, faces)
Build the list of boundary faces matching a criteria string.
Definition: cs_selector_f2c.f90:111
dt
Definition: cs_field_pointer.h:65