Compile the UDF

Junta_20361
Junta_20361 New Altair Community Member
edited October 2020 in Community Q&A

Hello guys,

I have got a trouble while using AcuSolve cmd prompt to compile the UDF file.

 

To be more precise, i am doing an AcuSolve tutorial ACU-4002: sloshing of water in a tank.

There was a step:

<?xml version="1.0" encoding="UTF-8"?>image.thumb.png.70feb086e95f01235ef5c1539bb0f290.png

 

I have follow the intructions but the cmd prompt have an error like below:

image.png.b692c9d4f9c3a94a6adb9c3eee109640.png

while:

'C:\Users\ducho\Desktop\multiphase' is my working directory for this case and it has already contained 'gravity.c' file (copied from AcuSolve tutorials-model files)

 

I also searched for more help on AcuSolve user-define function manunal but didnt found.

 

So can you guys help me out?

appreciate any help. Thank you!

 

Tagged:

Answers

  • ydigit
    ydigit
    Altair Employee
    edited February 2019

    AcuSolve installation does not have a C/C++ Compiler. So you would need to install a compiler  seprately and then link the compiler to AcuSolve.

     

    Windows system would probably work well with Microsoft Visual Studio.

    Linux systems generally have GCC preinstalled.

  • acupro
    acupro
    Altair Employee
    edited February 2019

    Try just typing

     

    acuMakeDll

     

    and return, without adding '-src gravity.c' - and see which errors are returned.  As mentioned, you do need to have a compiler installed.  It seems Visual Studio Community is the latest free version from Microsoft.

  • Junta_20361
    Junta_20361 New Altair Community Member
    edited February 2019

    Try just typing

     

    acuMakeDll

     

    and return, without adding '-src gravity.c' - and see which errors are returned.  As mentioned, you do need to have a compiler installed.  It seems Visual Studio Community is the latest free version from Microsoft.

     

    AcuSolve installation does not have a C/C++ Compiler. So you would need to install a compiler  seprately and then link the compiler to AcuSolve.

     

    Windows system would probably work well with Microsoft Visual Studio.

    Linux systems generally have GCC preinstalled.

    Thank you guys,

    I have found the issue.

    My computer didn't have any C/C++ compiler.

     

    Altair university also has a post about this problem.

     

    Share to others who have faced problem like me : https://altairuniversity.com/11523-acusolve-search-for-installed-compiler-tips-tricks/

  • whj
    whj Altair Community Member
    edited May 2019

    Hello:

    I have encountered some problems in learning acusolve acu-4002, and I have been unable to run gravity.c file. My compiler software has been installed (VS2013), and the environment configuration has been completed according to the relevant information (Figure 1). However, the following problem was encountered in operation (Figure 2). The gravity. obj file cannot be found, nor can the. Dll file be generated.

     

     

    I also tried to run gravity. C program separately in VS2013, but I also found many errors. (Fig. 3)

    1. error LNK2019: Unparsable external symbol _udfCheckNumUsrVals, which is referenced in function _usrGravity

    2. error LNK1120: Three unresolved external commands

    3. IntelliSense: Undefined identifier 'Integer'

    4. IntelliSense: Undefined identifier 'String'

    5. IntelliSense: Undefined identifier 'Void'

    6. IntelliSense: Undefined identifier 'Real'

    I hope you can help me. Thank you very much.

    <?xml version="1.0" encoding="UTF-8"?>1.jpg

    <?xml version="1.0" encoding="UTF-8"?>2.jpg

    <?xml version="1.0" encoding="UTF-8"?>3.png

    <?xml version="1.0" encoding="UTF-8"?>5.png

    <?xml version="1.0" encoding="UTF-8"?>00F165EB%409E4D7633.44C2D15C.jpg_recompress.jpg

  • acupro
    acupro
    Altair Employee
    edited May 2019

    You don't post the image of the compile attempt where it actually shows errors.  Please use the AcuSolve Command Prompt and go into the directory where the gravity.c user function resides.  Then issue the command, maybe first without any options - just:

     

    acuMakeDll

     

    and see what happens.

  • whj
    whj Altair Community Member
    edited May 2019

    Hello guys,

    I have got a trouble while using AcuSolve cmd prompt to compile the UDF file.

     

    To be more precise, i am doing an AcuSolve tutorial ACU-4002: sloshing of water in a tank.

    There was a step:

    <?xml version="1.0" encoding="UTF-8"?>image.thumb.png.70feb086e95f01235ef5c1539bb0f290.png

     

    I have follow the intructions but the cmd prompt have an error like below:

    <?xml version="1.0" encoding="UTF-8"?>image.png.b692c9d4f9c3a94a6adb9c3eee109640.png

    while:

    'C:\Users\ducho\Desktop\multiphase' is my working directory for this case and it has already contained 'gravity.c' file (copied from AcuSolve tutorials-model files)

     

    I also searched for more help on AcuSolve user-define function manunal but didnt found.

     

    So can you guys help me out?

    appreciate any help. Thank you!

     

    Hello,
    'C: Users ducho Desktop multiphase' Is this your working file?
    How is this set up? When I open my acusolve CMD prompt, default d: Document, do you know how to set it to the current working folder?

     

  • whj
    whj Altair Community Member
    edited May 2019

    You don't post the image of the compile attempt where it actually shows errors.  Please use the AcuSolve Command Prompt and go into the directory where the gravity.c user function resides.  Then issue the command, maybe first without any options - just:

     

    acuMakeDll

     

    and see what happens.

    Thank you very much

    I have a few questions to ask you.

    Question 1:

    Interface for starting acusolve Cmd prompt

    Default d:\ Documents>

    Is that right?

    If not, how do I modify the path?

    Do I need to set the path of the model folder?

    <?xml version="1.0" encoding="UTF-8"?>图片1.png

  • whj
    whj Altair Community Member
    edited May 2019

    You don't post the image of the compile attempt where it actually shows errors.  Please use the AcuSolve Command Prompt and go into the directory where the gravity.c user function resides.  Then issue the command, maybe first without any options - just:

     

    acuMakeDll

     

    and see what happens.

    Question 2

    Enter only acuMakeDll to display the following information

    <?xml version="1.0" encoding="UTF-8"?>图片2.png

  • whj
    whj Altair Community Member
    edited May 2019

    You don't post the image of the compile attempt where it actually shows errors.  Please use the AcuSolve Command Prompt and go into the directory where the gravity.c user function resides.  Then issue the command, maybe first without any options - just:

     

    acuMakeDll

     

    and see what happens.

    Question 3

    Header files: acusim.h and udf.h

    Source file: gravity.c

    Running in VS2013, the following errors occurred:

    Error LNK2019: Unparsable external symbol udfGetUsrVals, which is quoted in the function usrGravity as D: Documents ACU4002_Sloshing Tank Console Application 3 Console Application 3 Console Application 3 y. obj

    Error 4 LNK1120: Three unresolved external commands D: Documents ACU4002_Sloshing Tank Console Application 3 x64 Debug Console Application 3.dll

    After searching for information on the Internet, I found that some people said that the reason for this problem was the lack of library files (.lib/.dll).

    I hope you can help me. Thank you very much.:D/emoticons/default_biggrin.png' srcset='/emoticons/biggrin@2x.png 2x' title=':D' width='20' />

    <?xml version="1.0" encoding="UTF-8"?>图片3.png

  • acupro
    acupro
    Altair Employee
    edited May 2019

    You need to go into the directory where the C code user-function is on your machine.

     

    The compiler itself as you've shown in the Window above will not be aware of the libraries in the AcuSolve installation.  But when you are in the AcuSolve Command Prompt, the appropriate paths are set (PATH, LD_LIBRARY_PATH, etc), and the necessary libraries are available to acuMakeDll.

  • whj
    whj Altair Community Member
    edited May 2019

    You need to go into the directory where the C code user-function is on your machine.

     

    The compiler itself as you've shown in the Window above will not be aware of the libraries in the AcuSolve installation.  But when you are in the AcuSolve Command Prompt, the appropriate paths are set (PATH, LD_LIBRARY_PATH, etc), and the necessary libraries are available to acuMakeDll.

    Thank you very much, but I still don't know what to do.
    What commands do I need to enter before I can enter the directory where the user functions in C code are located?

    What libraries are necessary for ACUMAKEDLL to use? I found libabd. lib, libcci. lib, libeco. lib, libfrm. lib only in the installation directory of acusolve. But he doesn't seem to be what acuMakeDll needs.

    I attach the relevant library files, header files and C programs that may be needed in the running of the program.

    In udf.h file, only some functions are declared, but the program how these functions work is not given. But I can't find the relevant documents.

    I hope you can help me see where this problem appears.

     

    Unable to find an attachment - read this blog

  • whj
    whj Altair Community Member
    edited May 2019

    You need to go into the directory where the C code user-function is on your machine.

     

    The compiler itself as you've shown in the Window above will not be aware of the libraries in the AcuSolve installation.  But when you are in the AcuSolve Command Prompt, the appropriate paths are set (PATH, LD_LIBRARY_PATH, etc), and the necessary libraries are available to acuMakeDll.

    1846743993_TIM20190511112145.jpg.d895368ceda9f531b3b69178b3828333.jpg

     

    You need to go into the directory where the C code user-function is on your machine.

     

    The compiler itself as you've shown in the Window above will not be aware of the libraries in the AcuSolve installation.  But when you are in the AcuSolve Command Prompt, the appropriate paths are set (PATH, LD_LIBRARY_PATH, etc), and the necessary libraries are available to acuMakeDll.

    I've just solved the problem of how to set up a working directory, but I'm still prompted that the gravity. obj file can't be found in the working directory.
    But the display shows that libusr.dll has been created

  • acupro
    acupro
    Altair Employee
    edited May 2019

    Looks like you should be good to go, since the dll was created.

  • whj
    whj Altair Community Member
    edited May 2019

    Looks like you should be good to go, since the dll was created.

    Thanks for your help

    I recently used UDF to define motion, and I found a program for rotating translational motion in the official help document, but when I ran it, it made some errors, showing grid divergence, but I've increased the number of grids near objects, and it's still not getting better.
    Please help me again. Thank you very much.

    Unable to find an attachment - read this blog

  • whj
    whj Altair Community Member
    edited May 2019

    Looks like you should be good to go, since the dll was created.

    This is the error that is prompted during the exercise.

    image.png.83c1899934ff7e689d418958839da930.png

  • whj
    whj Altair Community Member
    edited May 2019


    I have attached some screenshots which may help for reference.

    Set mesh-motion

     

    image.png.d191b7707ea534d6bca35d4549bdafe3.png

     

    Setting grid motion on the surface of moving object

    image.png.849f2b0163b69cde49eab626b9428b91.png

     

     

  • whj
    whj Altair Community Member
    edited May 2019

    image.png.6b94f8db1f267ee162db4cf317717e23.png

    image.png.497628b22e278352e00ceed824b1884d.png

  • whj
    whj Altair Community Member
    edited May 2019

                          Severe mesh distortion; must reduce time increment
    acuSolve:     Max error ref.  coord. = 4.804283e-004 -6.017617e-005 -1.802330e-005
    acuSolve:     Max error curr. coord. = 4.804267e-004 -6.000000e-005 -1.802330e-005
    acuSolve:      Worst elem. has nodes = 398 7450 7451 11222
    acuSolve:     Severe mesh distortion; mesh not fully updated

    image.png.804a9e82d3016b1fbb7efa36207afe48.png

  • acupro
    acupro
    Altair Employee
    edited May 2019

    You'll probably need to contact your local Altair support office to see if they can help you.

  • Felipe Espinosa
    Felipe Espinosa Altair Community Member
    edited August 2019

    Hello Duc,

     

    I'm unable to access tutorial ACU-4002: Sloshing water in a tank. I'm very interested in the topic, I think my problem is that I'm using version 2017 and I'm missing documentation updates. Is there any possibility that you could share this with me?

     

    Kind regards.

  • acupro
    acupro
    Altair Employee
    edited August 2019

    You can download the latest release versions from connect.altair.com - which will then include the documentation, tutorials, etc.  You can request a login there if you don't already have one.

  • Anetlam
    Anetlam Altair Community Member
    edited August 2019

    I try to compile the sample of SampleVisual. I do it as follow:
    1 Create a empty dll in VC6.0
    2 Add files SampleVisual.cpp and rc and all need headfiles

    When I compile the project, it report that file SampleVisual.rh not find. I can not find the file in sdk.

    Would you like to tell me how to compile that? Thanks.

  • acupro
    acupro
    Altair Employee
    edited August 2019

    What is SampleVisual?  To compile a UDF for AcuSolve on Windows, you would use the AcuSolve Command Prompt and the acuMakeDll command, as shown in the examples above.  It then will find the proper compiler installation and proceed with compiling.  You will not use the compiler itself directly.