User Defined Currents

<< Click to Display Table of Contents >>

Navigation:  Flexcom > Theory > Applied Loading > Current Loading >

User Defined Currents

Previous pageNext page

Introduction

The user-subroutine option facilitates the definition of time varying currents. This option is available for complete generality, particularly for situations where the standard modelling options do not completely cover user requirements. For example, soliton currents which occur in the South China sea are solitary internal waves which induce a time-varying current distribution.

Operation

Any generic compiler may be used to compile a DLL (dynamic link library) which may be linked into Flexcom. When you invoke a user subroutine option, you must have written the relevant source code, and compiled it into a DLL, before you perform the actual Flexcom analysis. Note also that there are standard templates provided in the Flexcom installation folder which illustrate how to create DLLs.

When you specify the name of the DLL file, Flexcom loads the DLL and searches for the load subroutine that was embedded into the DLL when it was compiled. Once Flexcom locates the subroutine, the subroutine is dynamically loaded into the Flexcom analysis module executable. The analysis then proceeds. When running, at each time step the user-subroutine is called once for every integration point on every submerged element. You must program your module to govern the current velocity and accelerations, typically as a function of depth and time. The subroutine arguments provide information regarding the instantaneous location of the integration point under consideration.

Finally, when the analysis is completed the temporary Flexcom executable is deleted. Note that if you use the facility, then the operation is completely automatic and transparent to you, and requires no intervention by you at runtime in compiling or linking the program.

Subroutine Format

A blank or template FORTRAN listing of subroutine currnt, the Flexcom current user-subroutine, is shown below. Experienced FORTRAN users will be aware that the comment lines are optional, and serve no function other than to make the code more comprehensible. Other than the comments, there are some lines that this user-subroutine must contain. These are:

the subroutine statement

the implicit none statement

the integer and real(8) statements

the !dec$ attributes statements to make the variables and subroutine available to Flexcom

the end subroutine statement

The subroutine statement has ten arguments, to be described shortly. The implicit none statement requires that all variables used in the routine be declared explicitly. The integer and real(8) statements are used to declare integer and double precision variables. It is important to note that all calculations in Flexcom use double precision arithmetic, so you should always use the double precision form of any FORTRAN intrinsic functions you invoke (for example, use dcos rather than cos for the cosine of an angle). The !dec$ attributes statements are used to make the variables and subroutine available to Flexcom. Finally, the use of the end subroutine statement signals the end of the subroutine coding.

User-Subroutine Template

  ! Subroutine to define arbitrary current loading

  subroutine currnt(time, x, y, z, vcx, vcy, vcz, acx, acy, acz)

  !dec$ attributes dllimport, stdcall, reference :: currnt

    implicit none

     

    real(8), intent(in) :: time

    !dec$ attributes reference :: time

    real(8), intent(in) :: x

    !dec$ attributes reference :: x

    real(8), intent(in) :: y

    !dec$ attributes reference :: y

    real(8), intent(in) :: z

    !dec$ attributes reference :: z

    real(8), intent(inout) :: vcx

    !dec$ attributes reference :: vcx

    real(8), intent(inout) :: vcy

    !dec$ attributes reference :: vcy

    real(8), intent(inout) :: vcz

    !dec$ attributes reference :: vcz

    real(8), intent(inout) :: acx

    !dec$ attributes reference :: acx

    real(8), intent(inout) :: acy

    !dec$ attributes reference :: acy

    real(8), intent(inout) :: acz

    !dec$ attributes reference :: acz

 

    !

    ! Variable Names

    !

    !     time    : The instantaneous solution time

    !     x       : The global X position of the integration point under consideration

    !     y       : The global Y position of the integration point under consideration

    !     z       : The global Z position of the integration point under consideration

    !     vcx     : The current velocity in the global X direction

    !     vcy     : The current velocity in the global Y direction

    !     vcz     : The current velocity in the global Z direction

    !     acx     : The current acceleration in the global X direction

    !     acy     : The current acceleration in the global Y direction

    !     acz     : The current acceleration in the global Z direction

    !

    ! Declare local variables.

 

    ! Insert coding to define user-specified loading below this line.      

     

  end subroutine currnt

 

The ten arguments of subroutine currnt are listed in the comments statements above. The first four, comprising solution time and instantaneous location of point of interest, are passed to currnt for information only, to be used in calculating the user-defined current velocity and acceleration terms at that point in space and time. The values of these variables should not be altered. The remaining six variables are the ones which you control as the user. The source code to compute and define the current velocity and acceleration in each degree of freedom should be inserted after the 'Insert coding' comment, but before the end subroutine statement.

All applied loads and displacements in Flexcom are optionally ramped or gradually increased up to the full values over a time period (the ramp time) you define. Further information is provided in Load Ramping.