24. ComFLOW as static library

The ComFLOW subroutines have also been linked into a library so they can be linked to and used by other external programs. Different versions of the ComFLOW library are available on both Linux and Windows. In this section it is assumed that one of the available library versions in the subdirectory lib has been selected for coupling and that it has been renamed to comflow.lib.

An example of an application is the effect of sloshing in cargo tanks on ship motions. The ComFLOW library has been coupled to the MARIN ship motion program aNySIM. ComFLOW determines the internal sloshing loads and aNySIM determines the ship motions due to these sloshing loads and other external forces (incoming waves), see :cite:`bunnik2010modelling`.

24.1. Getting started

The library comflow.lib has been compiled with the Intel Fortran compiler, in double precision and with OpenMP support. The library can be coupled to the user’s program by any available Fortran compiler, preferably the Intel Fortran compiler (ifort).

  • For the coupling under Linux: when myprog.f contains the external program of the user, type at the command prompt:

    As a result, the coupled executable myprog.out is created.

  • For the coupling under Windows, type at the command prompt in a DOS window

    ifort /double-size:64 /real-size:64 /Qopenmp myprog.f
                                      comflow.lib /exe:myprog.exe
    

    As a result the coupled executable myprog.exe is created.

The subroutines that are available to external programs are given below. All underlying subroutines, called by these subroutines, are also available in the library. The subroutines only have to be called, they cannot be modified. The required subroutines are:

24.2. Available subroutines

Note

Still to come.

24.3. An example

The example given below shows how to move a sloshing tank in ComFLOW with a user-written program and how to obtain the sloshing loads. In the example, the motion of the sloshing tank is prescribed in the external program. The geometry of the sloshing tank has to described in the input file ${INPUT}/geometry.in (see Section 5) and the simulation is further controlled with ${INPUT}/comflow.in (see Chapter 27). Note that the option motionframe should be set to 2 (see fixed_form_input/moving_frame).

The example shown below is also included in the ComFLOW distribution and can be found in the folder examples/.

!
      program move_sloshing_tank
!
      implicit none
!
      integer*4 i,boxnr,tcycle
      real*8  force(3),moment(3),inertia(3)
      real*8  t,tmax,dt,t_next
      real*8  pos(6),velocity(6),acceleration(6)
      real*8  moment_location(3)

!     run GEODEF
      call initialize(1)  !<-- 1=GEODEF
      call setup          !<-- process input files
      call geoliq         !<--
      call closure        !<-- clean up

!     now run ComFLOW
      call initialize(0)  !<-- 0=COMFLOW
      call setup          !<-- process input files
!
      pos = 0.0
      velocity = 0.0
      acceleration = 0.0
      ! pre-compute the tank motions, velocities and accelerations
      do i=0,1002
        t_next = i*0.01
        pos(2) = 0.1*sin(4.0*t_next)
        velocity(2) = 0.1*4.*cos(4.0*t_next)
        acceleration(2) = -0.1*16.0*sin(4.0*t_next)
        call set_moving_frame(t_next, pos, velocity, acceleration)
      enddo
!
      boxnr = 1
      moment_location = 0.0
!
      call get_time(tcycle,t,tmax,dt)
      ! start time loop
      do while (t < tmax)
!
         ! carry out a timestep
         call loop
         call get_time(tcycle,t,tmax,dt)
!
         ! obtain the forces on the tank
         call get_force_frcbx(boxnr,force,moment,inertia, moment_location)
      enddo
!
      call closure        !<-- clean up again
!
      end program
!