Calling user subroutines in shared libraries

Hi,

There is a good option to call UMAT in shared libraries. It does not require any modification to CalculiX, is generally easier to set up and is very flexible. I wonder if this functionality can be used for the other subroutines like “dload.f”.

Let’s assume that it is going to define hydrostatic pressure loading on a structure. In this case, it is needed to build Calculix from the source!

I believe this is only available for the umats, not for any other user subroutine. You might be able to hack a similar mechanism for the dload as the umats, but you will need to look into the source code.

i guessed only in material is possible,

Yes, you are right.
It will be helpful if there is a similar mechanism for other subroutines.
Is there any place to request that feature?

You can email Guido directly to see if this is something he might be interested in doing. I doubt it would take priority over bug fixes and other features.

You can create an issue in the GitHub repository: Issues · Dhondtguido/CalculiX · GitHub

Thank you, @Calc_em.
I created an issue there:

Hi again,
I managed to call dload subroutine from a DLL file on Windows. I share my experience here.

First, I changed the dload.f in the src directory as shown in the following figure:

The “dload.f” calls a new subroutine “ext_dload” that is a DLL warper defined in a new source code called “ext_dload.c” as:

For building the ccx, it is needed to add “ext_dload.c” at the end of the build chain in “Makefile.inc”:
image

Here is an example of a user-defined load defined in a fortran code, MY_DLOAD.F:

Using MinGW to compile it into a DLL file: gfortran -shared -o MY_DLOAD.DLL MY_DLOAD.F and move the MY_DLOAD.DLL into the directory that contains “ccx.exe”.

Finally, it can be called in the input file as:
*dload
Internal-1_Surface-1_S6,P4NU@MY_DLOAD,1.0

5 Likes

The built can be found through the following link:

2 Likes

Well done @m_farrokh !!

1 Like

So good! Thanks for this clear and comprehensive step-through!!!

2 Likes

That looks amazing. Quick question tough - with NLGEOM, is it using the deformed coordinates or the original mesh coordinates?

2 Likes

Hi @m_farrokh , thanks for this post, I need to do something similar but adding an interface to dflux - the thing is, I am having issues to compile calculix on windows, the information available is not enough to do it. Would you mind to make a tutorial on how to compile Calculix from scratch? you did here a clear explanation, so I believe you can make the difference by helping a lot of people with the same problem

Follow the steps in:
http://dhondt.de/ccx_2.22.README.INSTALL.
It is straightforward. Then do the same as this post.

sorry, but those instructions are not straightforward for windows. There should be some considerations for Windows. anyone can help me with that?

These should get you there:

@PGA Here’s one that I maintain based on the GE version. Included instructions reproduced below to show how simple it is. You only have to download one other thing (Msys2) which is then basically just spam the OK button to install.

https://mecway.com/download/ccx_win64_mkl_pardiso_source_2.21_2.zip

  1. Your Windows username must not contain spaces.
  2. Install MSYS2 from https://www.msys2.org/
  3. Extract this archive’s ccx folder to msys64/home/<username>/ so that the paths are msys64/home/<username>/ccx/…
  4. Open “MSYS2 MSYS” shell and enter these commands
    cd ~/ccx
    ./build.sh
  5. Find the compiled ccx.exe, ccx_MKL.exe, and their dlls in msys64/home/<username>/ccx/x64/install
3 Likes