I am reading the ElmerSolver Manual under the sif structure, keyword syntax, defining parameters depending on field variables, and I have a feeling that Elmer cannot do
Velocity = Variable ........
but only
Velocity i = Variable ........
(where i is of course a fixed number 1 or 2 or 3)
and for the sake of argument, whereas
Potential = Variable elfield Ne Grad
Real MATC "..."
would be illegal,
Potential = Variable elfield 1, elfield 2, elfield 3, Ne Grad 1, Ne Grad 2, Ne Grad 3
Real MATC "..."
would be acceptable syntax
Next, with Fortran functions:
Density = Variable Temperature
Procedure "filename" "proc"
FUNCTION proc( Model, n, T ) RESULT(dens)
USE DefUtils
IMPLICIT None
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: T, dens
dens = 1000*(1-1.0d-4(T-273.0d0))
END FUNCTION proc
it is stated that n is the node index and T is the value of the independent variable at that node. I guess there is something like
do i=1,Nnodes
density = proc(Model, i, Temperature(i))
end do
implied in Procedure "filename" "proc" I also guess writing
FUNCTION proc( Model, T ) RESULT(dens)
would be illegal even though INTEGER :: n is not used anywhere in the above definition of proc because Procedure "filename" "proc"
expects that there should be 3 parameters to proc.
And with
Density = Variable Coordinate
Procedure "filename" "proc"
FUNCTION proc( Model, n, T ) RESULT(dens)
.....
would the definition of proc access Coordinate at node n using
T(1) for x,T(2) for y,T(3) for z ??
Is anything as stated incorrect up to now ?
Thanks in advance
Vectors in sif assigments and Fortran functions
-
- Site Admin
- Posts: 4812
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Vectors in sif assigments and Fortran functions
Hi
You can have for example
and call it with
or within code get the variables
and call it with
The library takes case of creating the arguments from the list of variables in the sif file. So for nodal finite elements the "n" is the nodal index.
It should be noted the the same UDFs may be called on integration points and then "n" will no longer be a nodal value, but you could still use the 1st syntax as the library evaluates the arguments automatically at the integration points.
Hope this helps in understanding.
-Peter
You can have for example
Code: Select all
FUNCTION proc( Model, n, T ) RESULT(dens)
USE DefUtils
IMPLICIT None
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: T(6), dens
dens = function_of(T(1),T(2),...)
END FUNCTION proc
Code: Select all
Potential = Variable elfield 1, elfield 2, elfield 3, Ne Grad 1, Ne Grad 2, Ne Grad 3
Real Procedure "mymodule" "proc"
Code: Select all
FUNCTION proc( Model, n, dummy ) RESULT(dens)
USE DefUtils
IMPLICIT None
TYPE(Model_t) :: Model
INTEGER :: n
REAL(KIND=dp) :: dummy, T(6), dens
TYPE(Variable_t), POINTER :: Var
Var => VariableGet(Model % Variables,'elfield1')
T(1) = Var % Values(Var % Perm(n))
Var => VariableGet(Model % Variables,'elfield2')
T(2) = Var % Values(Var % Perm(n))
...
dens = function_of(T(1),T(2),...)
END FUNCTION proc
Code: Select all
Potential = Variable "time"
Real Procedure "mymodule" "proc"
It should be noted the the same UDFs may be called on integration points and then "n" will no longer be a nodal value, but you could still use the 1st syntax as the library evaluates the arguments automatically at the integration points.
Hope this helps in understanding.
-Peter
Re: Vectors in sif assigments and Fortran functions
Just my opinion, but for everyone's benefit, perhaps this example of the proc code with the dummy variable could be included in the ElmerSolver Manual under the sif structure, keyword syntax, defining parameters depending on field variables. Unless it is already in some tutorial but if it is, I wouldn't know which.