module common_data character*50 config character*50 participantName character*50 meshName c parameters for implicit coupling character*50 writeInitialData character*50 readItCheckp character*50 writeItCheckp character*50 readDataName character*50 writeDataName integer rank integer commSize integer ongoing integer dimensions integer meshID integer readDataID integer writeDataID integer,save :: bool = 0 double precision dt integer, dimension(:), allocatable :: vertexIDs double precision, dimension(:), allocatable :: vertices double precision, dimension(:), allocatable :: readData double precision, dimension(:), allocatable :: writeData end module common_data subroutine loadsetud(time,lft,llt,crv,iduls,parm,nod,nnm1) use common_data ! first timestep, here the setup is done before first execution of ls-dyna if (time.eq.0) then print *,'Now in loadsetud' endif if (time.eq.0) then config='../precice-config.xml' participantName='SolverOne' meshName='MeshOne' writeDataName = 'dataOne' readDataName = 'dataTwo' rank=0 commSize=1 c number of nodes in current set should be given in parameter 1 c which is equal to the first variable in keyword `*USER_LOADING` numberOfVertices=parm(1) ! is 3 in this case print *,'numberOfVertices',numberOfVertices print *,'Vertices',vertices writeInitialData= &' ' reatItCheckp= &' ' writeItCheckp= &' ' c _____________________________________________________________________ c| | c| Create preCICE | c|_____________________________________________________________________| call precicef_action_write_initial_data(writeInitialData) call precicef_action_read_iter_checkp(readItCheckp) call precicef_action_write_iter_checkp(writeItCheckp) call precicef_create(participantName,config,rank,commSize) print *, 'created' call precicef_get_dims(dimensions) print *, 'precice dimensions:',dimensions allocate(vertices(numberOfVertices*dimensions)) allocate(vertexIDs(numberOfVertices)) allocate(readData(numberOfVertices*dimensions)) allocate(writeData(numberOfVertices*dimensions)) print *,'allocated' print *,'getmeshid' call precicef_get_mesh_id(meshName,meshID) do i = 1,numberOfVertices,1 do j = 1,dimensions,1 vertices((i - 1)*dimensions + j ) = i-1 readData((i - 1)*dimensions + j ) = 5 ! hardcoded values to differentiate writeData((i - 1)*dimensions + j ) = 10 enddo ! vertexIDs(i) = i-1 enddo print *,'vertices',vertices print *,'readdata',readData print *,'writeData',writeData print *,'setvertices' call precicef_set_vertices(meshID,numberOfVertices,vertices,vertexIDs) deallocate(vertices) print *,'vertexIDs',vertexIDs print *,'get data id read' call precicef_get_data_id(readDataName,meshID,readDataID) print *,'get data id write' call precicef_get_data_id(writeDataName,meshID,writeDataID) print *,'initial readDataID',readDataID print *,'initial writeDataID',writeDataID c _____________________________________________________________________ c| | c| Initialise preCICE | c|_____________________________________________________________________| print *, 'initialize' call precicef_initialize(dt) ! write initial data call precicef_is_action_required(writeInitialData, bool) if (bool.eq.1) then write (*,*) 'DUMMY: Writing initial data' endif call precicef_initialize_data() print *, 'End of first loadsetud in Timestep' endif c _____________________________________________________________________ c| | c| Time steps after initialisation | c|_____________________________________________________________________| ! in all timesteps after the initialisation the normal steps are executed if (time.ge.0.AND.time.le.endtim) then print *,'steps after initialization' ! write checkpoint call precicef_is_action_required(writeItCheckp, bool) if (bool.EQ.1) then write (*,*) 'DUMMY: Writing iteration checkpoint' call precicef_mark_action_fulfilled(writeItCheckp) endif ! read data call precicef_is_read_data_available(bool) if (bool.EQ.1) then print *, 'readData before reading',readData call precicef_read_bvdata(readDataID,numberOfVertices,vertexIDs,readData) print *,'read bv data: ',readData endif endif c ___________________________________________________________ c| | c| HERE THE LS-DYNA STEP IS CALCULATED | c|___________________________________________________________| call precicef_is_write_data_required(dt, bool) if (bool.EQ.1) then print *, "writing data: ", writeData ! This code is executed *after* each ls-dyna time step call precicef_write_bvdata(writeDataID, numberOfVertices,vertexIDs, writeData) print *, "wrote data: ", writeData endif ! advance call precicef_advance(dt) ! read Checkpoint call precicef_is_action_required(readItCheckp, bool) if (bool.EQ.1) then write (*,*) 'DUMMY: Reading iteration checkpoint' call precicef_mark_action_fulfilled(readItCheckp) else write (*,*) 'DUMMY: Advancing in time' endif c _____________________________________________________________________ c| | c| Check if ongoing | c|_____________________________________________________________________| print *,'checkongoing' call precicef_is_coupling_ongoing(ongoing) print *,ongoing if (ongoing.eq.0) then c _____________________________________________________________________ c| | c| Finalise preCICE | c|_____________________________________________________________________| print *,'finalize' call precicef_finalize() c _____________________________________________________________________ c| | c| Deallocate memory of arrays | c|_____________________________________________________________________| print *,'deallocate' if (allocated (vertexIDs)) deallocate(vertexIDs) ! if (allocated (vertices)) deallocate(vertices) if (allocated (readData)) deallocate(readData) if (allocated (writeData)) deallocate(writeData) c _____________________________________________________________________ c| | c| Terminate LS-DYNA | c|_____________________________________________________________________| print *,'end lsdyna' call adios(1) endif end