{"id":26005382,"url":"https://github.com/precice/lsdyna-adapter","last_synced_at":"2026-03-06T18:36:58.822Z","repository":{"id":47349811,"uuid":"198997630","full_name":"precice/lsdyna-adapter","owner":"precice","description":"preCICE-adapter manual for the FEM code LS-DYNA ","archived":false,"fork":false,"pushed_at":"2021-10-28T17:08:00.000Z","size":61,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-05T20:58:16.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/precice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-26T10:27:32.000Z","updated_at":"2024-06-23T16:17:50.000Z","dependencies_parsed_at":"2022-09-14T05:00:51.597Z","dependency_job_id":null,"html_url":"https://github.com/precice/lsdyna-adapter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/precice/lsdyna-adapter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Flsdyna-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Flsdyna-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Flsdyna-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Flsdyna-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/precice","download_url":"https://codeload.github.com/precice/lsdyna-adapter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/precice%2Flsdyna-adapter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30191232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T18:30:16.692Z","status":"ssl_error","status_checked_at":"2026-03-06T18:30:13.818Z","response_time":250,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-05T20:53:45.834Z","updated_at":"2026-03-06T18:36:58.785Z","avatar_url":"https://github.com/precice.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# preCICE Adapter for LS-DYNA\nAuthor: Stefan Scheiblhofer, Stephan Jäger ([LKR Leichtmetallkompetenzzentrum Ranshofen GmbH](https://www.ait.ac.at/lkr))   \nContact: \u003cmatthias.hartmann@ait.ac.at\u003e\n\nThis is the readme to develop a preCICE adapter for LS-DYNA.\nThe readme is based on preCICE V1.3.0 and LS-DYNA R9.3.0 in the\ndouble SMP Version.\n\n## Getting started\n\n### LS-DYNA\n\nThe typical field of application for LS-DYNA is crash simulation and\nrather oriented towards the explicit, mechanical solver. However, \nthe finite element method based solver is often exhausted to its limits\nin the case of the thermal solver. This is especially true with casting \nprocess simulations.  Thereby, the fluid\nflow in the melt of the casting component has a significant impact\non the thermal field. This also depends on the components dimensions and process\nparameters. However, this fluid flow cannot be considered with the FEM based LS-DYNA solver.\nConsequently, the main idea behind the adapter for LS-DYNA is to import and use the\ntemperature field of an external solver. This should help to improve the\naccuracy of the temperature field in the melt section, while still being able\nto calculate the resulting strain and stress fields.  \n\n### Prerequisites\n\npreCICE is written in C++. However, preCICE also provides\nAPIs or bindings for non C++ codes. A list and current overview can be seen\n[here](https://github.com/precice/precice/wiki/Non%E2%80%93standard-APIs).\nIn order to use preCICE within LS-DYNA there are some prerequisites,\nwhich have to be met before implementing preCICE in LS-DYNA. \nAfter successful [installation](https://github.com/precice/precice/wiki/Building:-Using-CMake)\nof preCICE it is necessary to link the preCICE library to LS-DYNA.\nThere are basically two ways to link preCICE to LS-DYNA: the first is linking\nthe static library; the second is linking the shared object library of preCICE to LS-DYNA.\n\n#### Linking the static library\n\nOne of the simplest ways is to use the static library. The first step is to copy the static\nlibrary of preCICE *libprecice.a* to the LS-DYNA usermat package\ndirectory. Second step is the implementation in LS-DYNA \nto change the Makefile for the LS-DYNA executable. This\nstarts by adding the dependencies of preCICE to the compiler flag *LF*:\n```bash\nLF= -i-static  -openmp -lrt -lstdc++ -lpthread -lboost_system -lboost_log -lboost_log_setup -lboost_thread -lboost_filesystem -lboost_program_options -lpython2.7 -lxml2\n```\nThe next necessary adaption of the Makefile is adding *libprecice.a* at\nthe end of the the compiler flag `LIBS`.\n\n#### Linking the shared object library\n\nThe recommended approach is to build preCICE as a shared object library.\nFollowing the installation instructions on how to build preCICE, the default\ninstall location for the shared object library is `/usr/local`. \nIn contrast to [linking the static library](#linking-the-static-library), the\nnecessary changes to the Makefile are reduced to the compiler flag `LF`.\nFor linking the shared object library of preCICE change `LF` to the following:\n```bash\nLF= -i-static  -openmp -lrt -lstdc++ -lpthread -lboost_system -lboost_log -lboost_log_setup -lboost_thread -lboost_filesystem -lboost_program_options -lpython2.7 -lxml2 -I/usr/local/include -L/usr/local/lib -lprecice\n```\nThe detailed description on how to edit the Make-file can be in the [precice wiki](https://github.com/precice/precice/wiki/Linking-to-preCICE#linking-from-make-or-other-scripts).\n\n## Adapter design\n\nLS-DYNA enables the user to define *user defined loads* via the keywords\n`*USER_LOADING` and `*USER_LOADING_SET`. These keywords automatically\ninvoke the call of the subroutines *loadud* and *loadsetud* respectively.\nThe keyword `*USER_LOADING` defines parameters, which can then\nbe used by the keyword `*USER_LOADING_SET` and its subroutine *loadsetud*.\nThe loadings defined with the keyword `*USER_LOADING_SET` \ncan be nodal forces, body forces, temperature distribution and pressure\non segments or beams. For the complete description of the keyword\nplease refer to the [LS-DYNA keyword manual Volume 1](http://ftp.lstc.com/anonymous/outgoing/jday/manuals/DRAFT_Vol_I.pdf).\nWithin the called subroutine *loadsetud*, which can be found\nin the *dyn21.f*-file of the usermat-version of LS-DYNA,\nit is possible to define the user-defined loads. The original\n*dyn21.f*-file returns some examples on how to do that.\n\nThe subroutine *loadsetud* also enables the implementation of analytical\nequations and/or import of externally solved data. With that in mind\nand the capabilities of preCICE, it should then be possible to\ncouple an external solver to LS-DYNA.\n\nThe key issue, while designing an adapter for a proprietary code\nas LS-DYNA, is finding the correct placement of the preCICE functions\nwithin the available user interfaces. The placement of the preCICE \nfunctions has to be tested, to call the functions appropriatly relative \nto the placement of the subroutines within the source code of LS-DYNA.\n\nThe current development status of the preCICE adapter within LS-DYNA\nuses two subroutines of LS-DYNA, which are *uctrl1* and *loadsetud*.\nThe subroutine *loadsetud* is called before calculating the\ntime step while *uctrl1* is called after each (mechanical) time step.\nAs the function calls are separated between two subroutines the\nvariable definitions for all (preCICE) relevant variables are located\nin a general module. In this way, both subroutines can access the variables with\nthe same content.\n\nFor the goal of coupling temperature fields into LS-DYNA through the\nkeyword `*USER_LOADING_SET` and preCICE, *loadsetud* is called before\n*uctrl1*. Consequently, the initialisation of preCICE\nis realised within *loadsetud*. This is done once at the first call of the subroutine. \n\nThe subroutine\n*loadsetud* is also called before actually calculating the current\ntimestep. It is mandatory to read the vector\nor scalar in here. In order to read the data\nfor the current timestep it is necessary to call\nthe precice function *advance*. This function call transfers the data between the solvers.   \n\nWhile *loadsetud* intialises preCICE and reads data, *uctrl1* writes\nvector or scalar data after the present timestep has been calculated.\nFinally, preCICE is finalised in *uctrl1* which also includes the\ntermination of LS-DYNA.\n\nThe work flow of the preCICE adapter within LS-DYNA can be summmarised\nwith the following two flow chart diagrams. The blue boxes show the\nfunctions and routines called in the subroutine *loadsetud*, while the\ngreen boxes represent the subroutine *uctrl1*. White boxes are functions and\nprocesses which are called by LS-DYNA. These cannot be interfered by the user.\n\n![Work flow preCICE Adapter: Main](images/FlowChart_preCICE_LSDYNA_Adapter_Main.pdf)\n![Work flow precice Adapter: Start preCICE](images/FlowChart_preCICE_LSDYNA_Adapter_start_precice.pdf)\n\nThe following code lines show the schematic overview of the \nthe subroutines and the general module for the definition of the preCICE\nrelevant variables considering the blocks introduced by the flow\nchart diagrams.\n\n```fortran\n      module common_data\n\n      character*50 config\n      character*50 participantName\n      character*50 meshName\n\nc     parameters for implicit coupling\n      character*50 writeInitialData\n      character*50 readItCheckp\n      character*50 writeItCheckp\n\n      integer rank\n      integer commSize\n      integer ongoing\n      integer dimensions\n      integer meshID\n      integer tempID\n      integer dummyID\n      integer,save :: bool = 0\n\n      real dtLimit\n\n      integer, dimension(:), allocatable :: vertexIDs\n      integer, dimension(:), allocatable :: nodeIDs\n\n      double precision, dimension(:), allocatable :: coords\n      double precision, dimension(:), allocatable :: temps\n      double precision, dimension(:), allocatable :: dummyItCheckp\n      double precision, dimension(:), allocatable :: dummy\n\n      end module common_data \n\n\n\n      subroutine loadsetud(time,lft,llt,crv,iduls,parm,nod,nnm1)\n\t  \n\t  use common_data\n\n      if (time.eq.0) then\nc _____________________________________________________________________\nc|                                                                     |\nc|      Initialise variables                                           |\nc|_____________________________________________________________________|\n        config='precice-config.xml'\n        participantName='solverMech'\n        meshName='meshMech'\n        rank=0\n        commSize=1\nc       number of nodes in current set should be given in parameter 1\nc       which is equal to the first variable in keyword `*USER_LOADING`\n        numNodesInSet=parm(1)\n        writeInitialData=                                               \u0026\n     \u0026'                                                  '\n        reatItCheckp=                                                   \u0026\n     \u0026'                                                  '\n        writeItCheckp=                                                  \u0026\n     \u0026'                                                  '\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Create preCICE                                                 |\nc|_____________________________________________________________________|\n\n        call precicef_create(participantName,config,rank,commSize)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Initialise constants for implicit coupling                     |\nc|_____________________________________________________________________|\n\n        call precicef_action_write_initial_data(writeInitialData)\n        call precicef_action_read_iter_checkp(readItCheckp)\n        call precicef_action_write_iter_checkp(writeItCheckp)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Get dimensions of preCICE config file                          |\nc|_____________________________________________________________________|\n\n        call precicef_get_dims(dimensions)\nc\nc       After the variable dimensions was set, all arrays can be allocated\nc\n        allocate(vertexIDs(numNodesInSet))\n        allocate(nodeIDs(numNodesInSet))\n        allocate(temps(numNodesInSet))\n        allocate(dummy(numNodesInSet))\n        allocate(dummyItCheckp(numNodesInSet))\n        allocate(coords(numNodesInSet*dimensions))\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Get mesh ID from preCICE                                       |\nc|_____________________________________________________________________|\n\n        call precicef_get_mesh_id(meshName, meshID)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Get data ID(s) from preCICE                                    |\nc|_____________________________________________________________________|\n\n        call precicef_get_data_id('Temperature', meshID, tempID)\n        call precicef_get_data_id('Dummy', meshID, dummyID)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Set vertices for preCICE                                       |\nc|_____________________________________________________________________|\n\n        call precicef_set_vertices(meshID, numNodesInSet, coords,vertexIDs)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Initialise preCICE                                             |\nc|_____________________________________________________________________|\n\n        call precicef_initialize(dtLimit)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Write initial data                                             |\nc|_____________________________________________________________________|\n\n        call precicef_is_action_required(writeInitialData, bool)\n        if (bool.eq.1) then\n          call precicef_write_bsdata(dummyID, numNodesInSet,vertexIDs, dummy)\n          call precicef_fulfilled_action(writeInitialData)\n        endif\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Get initial data from preCICE                                  |\nc|_____________________________________________________________________|\n\n        call precicef_initialize_data()\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Read initial data                                              |\nc|_____________________________________________________________________|\n\n        call precicef_read_bsdata(tempID, numNodesInSet, vertexIDs,temps)\n\nc       save data for current timestep\n        call precicef_is_action_required(writeItCheckp, bool)\n        if (bool.eq.1) then\n          dummyItCheckp=dummy\n          call precicef_fulfilled_action(writeItCheckp)\n        endif\n      endif\n\n      if (time.gt.0.AND.time.le.endtim) then\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Advance to the next time step                                  |\nc|_____________________________________________________________________|\n\n        call precicef_advance(dtLimit)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Read data                                                      |\nc|_____________________________________________________________________|\n\n        call precicef_read_bsdata(tempID,numNodesInSet,vertexIDs,temps)\n  \n      endif\n\nc     set temperatures for current block\n      do i=lft,llt\n        udl(i)=temps(i)\n      enddo\n\n      return\n      end\n\n\n\n      subroutine uctrl1 (numnp,ndof,time,dt1,dt2,prtc,pltc,frci,prto,\n     . plto,frco,vt,vr,at,ar,ut,ur,xmst,xmsr,irbody,rbdyn,usrhv,\n     . messag,totalm,cycle,idrint,mtype,mxrb,nrba,rbcor,x,rbv,nrbn,\n     . nrb,xrb,yrb,zrb,axrb,ayrb,azrb,dtx,nmmat,rba,fvalnew,fvalold,\n     . fvalmid,fvalnxt)\n\n\t  use common_data\nc _____________________________________________________________________\nc|                                                                     |\nc|    Write data                                                       |\nc|_____________________________________________________________________|\n\n      call precicef_write_bsdata(dummyID, numNodesInSet,vertexIDs, dummy)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|    Check if ongoing                                                 |\nc|_____________________________________________________________________|\n\n      call precicef_is_coupling_ongoing(ongoing)\n\n      if (ongoing.eq.0) then\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Finalise preCICE                                               |\nc|_____________________________________________________________________|\n\n        call precicef_finalize()\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Deallocate memory of arrays                                    |\nc|_____________________________________________________________________|\n\n        if (allocated (vertexIDs)) deallocate(vertexIDs)\n        if (allocated (nodeIDs)) deallocate(nodeIDs)\n        if (allocated (coords)) deallocate(coords)\n        if (allocated (temps)) deallocate(temps)\n        if (allocated (dummy)) deallocate(dummy)\n        if (allocated (dummyItCheckp)) deallocate(dummyItCheckp)\n\nc _____________________________________________________________________\nc|                                                                     |\nc|      Terminate LS-DYNA                                              |\nc|_____________________________________________________________________|\n\n        call adios(1)\n\n      endif\n\n      return\n      end\n```\n\n## Limits and remarks\n\nThe developments of the adapter inside LS-DYNA have been tested and\npromoted against the available OpenFOAM adapater. The results of the\ndeveloped test case have been published in the ECCOMAS Coupled\nProblems 2019 [Proceedings](https://congress.cimne.com/coupled2019/frontal/doc/EbookCoupled2019.pdf).   \nThe presented preCICE adapter for LS-DYNA is based on an\nimplicit, two-way-coupling. The\ntwo-way-coupling was the more beneficial way to receive correct values for the\ndata initialisation at *time = 0* and at the end of the simulation at\n*time = endtime*. As a result, the present adapter writes dummy values as a second variable.  \nThe participant's name, configuration file name, mesh name, as well as \ndata names are hard-coded within the subroutines. A more general approach\nwould be nice, but have not been the goal of these developments\nfor the LS-DYNA adapter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprecice%2Flsdyna-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprecice%2Flsdyna-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprecice%2Flsdyna-adapter/lists"}