Simple UDF question

Numerical methods and mathematical models of Elmer
Post Reply
Estiivan
Posts: 25
Joined: 14 Nov 2016, 14:06
Antispam: Yes

Simple UDF question

Post by Estiivan » 21 Dec 2016, 18:53

I have a file called MyLibrary_ver2.f90 (edited from some tutorial):

Code: Select all

FUNCTION MyFunctionVer2() 
USE DefUtils
TYPE(Model_t) :: Model
  print *, 'Hei Solverilta'
END FUNCTION MyFunctionVer2
Then I gave a command

Code: Select all

elmerf90 -o MyLibrary_ver2.so MyLibrary_ver2.f90 
and a file called MyLibrary_ver2.so was created to same folder as was .f90 file.

How can I call this function from Elmer? As I understand something like

Code: Select all

Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
should be written in .sif file. But where should it put there? Also, should .so file be in some specific folder?

annier
Posts: 1117
Joined: 27 Aug 2013, 13:51
Antispam: Yes

Re: Simple UDF question

Post by annier » 22 Dec 2016, 09:54

Hi Estiivan,
1.
Estiivan wrote: But where should it put there?
The Real Procedure should be put in the section of the sif where it is to be called.
If it is a Material property related procedure (function), then call it from:

Code: Select all

Material n
...
Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
...
End
If it is a function for BCs (Boundary Condition), call it as:

Code: Select all

Boundary condition n
...
Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
...
End
n = 1, 2, 3, 4, ...

and so on and so on...

2.
Estiivan wrote:Also, should .so file be in some specific folder?
The shared object file is put in the same folder with your solver input file (sif) file.


Yours Sincerely,
Anil Kunwar
Anil Kunwar
Department of Materials Engineering, KU Leuven, Belgium

Estiivan
Posts: 25
Joined: 14 Nov 2016, 14:06
Antispam: Yes

Re: Simple UDF question

Post by Estiivan » 29 Dec 2016, 17:02

Hi annier!

Any suggestions to which block I should place my

Code: Select all

Real Procedure "MyLibrary_ver2" "MyFunctionVer2"
call to my function? As this is not exactly material or BC function, I think.

With regards,
Estiivan

raback
Site Admin
Posts: 3464
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Simple UDF question

Post by raback » 30 Dec 2016, 11:46

Hi

You cannot change the API. A function should return a value. Maybe the solver API would better suit your needs here. Then you would create a new solver block and place the procedure name there.

-Peter

Post Reply